Skip to main content

netlink_bindings/tc/
mod.rs

1#![doc = "Netlink raw family for tc qdisc, chain, class and filter configuration over rtnetlink\\."]
2#![allow(clippy::all)]
3#![allow(unused_imports)]
4#![allow(unused_assignments)]
5#![allow(non_snake_case)]
6#![allow(unused_variables)]
7#![allow(irrefutable_let_patterns)]
8#![allow(unreachable_code)]
9#![allow(unreachable_patterns)]
10#[cfg(test)]
11mod tests;
12use crate::builtin::{BuiltinBitfield32, BuiltinNfgenmsg, Nlmsghdr, PushDummy};
13use crate::{
14    consts,
15    traits::{NetlinkRequest, Protocol},
16    utils::*,
17};
18pub const PROTONAME: &str = "tc";
19pub const PROTONAME_CSTR: &CStr = c"tc";
20pub const PROTONUM: u16 = 0u16;
21#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
22#[derive(Debug, Clone, Copy)]
23pub enum ClsFlags {
24    SkipHw = 1 << 0,
25    SkipSw = 1 << 1,
26    InHw = 1 << 2,
27    NotInNw = 1 << 3,
28    Verbose = 1 << 4,
29}
30impl ClsFlags {
31    pub fn from_value(value: u64) -> Option<Self> {
32        Some(match value {
33            n if n == 1 << 0 => Self::SkipHw,
34            n if n == 1 << 1 => Self::SkipSw,
35            n if n == 1 << 2 => Self::InHw,
36            n if n == 1 << 3 => Self::NotInNw,
37            n if n == 1 << 4 => Self::Verbose,
38            _ => return None,
39        })
40    }
41}
42#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
43#[derive(Debug, Clone, Copy)]
44pub enum FlowerKeyCtrlFlags {
45    Frag = 1 << 0,
46    Firstfrag = 1 << 1,
47    Tuncsum = 1 << 2,
48    Tundf = 1 << 3,
49    Tunoam = 1 << 4,
50    Tuncrit = 1 << 5,
51}
52impl FlowerKeyCtrlFlags {
53    pub fn from_value(value: u64) -> Option<Self> {
54        Some(match value {
55            n if n == 1 << 0 => Self::Frag,
56            n if n == 1 << 1 => Self::Firstfrag,
57            n if n == 1 << 2 => Self::Tuncsum,
58            n if n == 1 << 3 => Self::Tundf,
59            n if n == 1 << 4 => Self::Tunoam,
60            n if n == 1 << 5 => Self::Tuncrit,
61            _ => return None,
62        })
63    }
64}
65#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
66#[derive(Debug, Clone, Copy)]
67pub enum Dualpi2DropOverload {
68    Overflow = 0,
69    Drop = 1,
70}
71impl Dualpi2DropOverload {
72    pub fn from_value(value: u64) -> Option<Self> {
73        Some(match value {
74            0 => Self::Overflow,
75            1 => Self::Drop,
76            _ => return None,
77        })
78    }
79}
80#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
81#[derive(Debug, Clone, Copy)]
82pub enum Dualpi2DropEarly {
83    DropDequeue = 0,
84    DropEnqueue = 1,
85}
86impl Dualpi2DropEarly {
87    pub fn from_value(value: u64) -> Option<Self> {
88        Some(match value {
89            0 => Self::DropDequeue,
90            1 => Self::DropEnqueue,
91            _ => return None,
92        })
93    }
94}
95#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
96#[derive(Debug, Clone, Copy)]
97pub enum Dualpi2EcnMask {
98    L4sEct = 1,
99    ClaEct = 2,
100    AnyEct = 3,
101}
102impl Dualpi2EcnMask {
103    pub fn from_value(value: u64) -> Option<Self> {
104        Some(match value {
105            1 => Self::L4sEct,
106            2 => Self::ClaEct,
107            3 => Self::AnyEct,
108            _ => return None,
109        })
110    }
111}
112#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
113#[derive(Debug, Clone, Copy)]
114pub enum Dualpi2SplitGso {
115    NoSplitGso = 0,
116    SplitGso = 1,
117}
118impl Dualpi2SplitGso {
119    pub fn from_value(value: u64) -> Option<Self> {
120        Some(match value {
121            0 => Self::NoSplitGso,
122            1 => Self::SplitGso,
123            _ => return None,
124        })
125    }
126}
127#[doc = "State transition probabilities for 4 state model"]
128#[doc = "Gilbert\\-Elliot models"]
129#[repr(C, packed(4))]
130pub struct Tcmsg {
131    pub family: u8,
132    pub _pad: [u8; 3usize],
133    pub ifindex: i32,
134    pub handle: u32,
135    pub parent: u32,
136    pub info: u32,
137}
138impl Clone for Tcmsg {
139    fn clone(&self) -> Self {
140        Self::new_from_array(*self.as_array())
141    }
142}
143#[doc = "Create zero-initialized struct"]
144impl Default for Tcmsg {
145    fn default() -> Self {
146        Self::new()
147    }
148}
149impl Tcmsg {
150    #[doc = "Create zero-initialized struct"]
151    pub fn new() -> Self {
152        Self::new_from_array([0u8; Self::len()])
153    }
154    #[doc = "Copy from contents from slice"]
155    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
156        if other.len() != Self::len() {
157            return None;
158        }
159        let mut buf = [0u8; Self::len()];
160        buf.clone_from_slice(other);
161        Some(Self::new_from_array(buf))
162    }
163    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
164    pub fn new_from_zeroed(other: &[u8]) -> Self {
165        let mut buf = [0u8; Self::len()];
166        let len = buf.len().min(other.len());
167        buf[..len].clone_from_slice(&other[..len]);
168        Self::new_from_array(buf)
169    }
170    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
171        unsafe { std::mem::transmute(buf) }
172    }
173    pub fn as_slice(&self) -> &[u8] {
174        unsafe {
175            let ptr: *const u8 = std::mem::transmute(self as *const Self);
176            std::slice::from_raw_parts(ptr, Self::len())
177        }
178    }
179    pub fn from_slice(buf: &[u8]) -> &Self {
180        assert!(buf.len() >= Self::len());
181        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
182        unsafe { std::mem::transmute(buf.as_ptr()) }
183    }
184    pub fn as_array(&self) -> &[u8; 20usize] {
185        unsafe { std::mem::transmute(self) }
186    }
187    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
188        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
189        unsafe { std::mem::transmute(buf) }
190    }
191    pub fn into_array(self) -> [u8; 20usize] {
192        unsafe { std::mem::transmute(self) }
193    }
194    pub const fn len() -> usize {
195        const _: () = assert!(std::mem::size_of::<Tcmsg>() == 20usize);
196        20usize
197    }
198}
199impl std::fmt::Debug for Tcmsg {
200    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
201        fmt.debug_struct("Tcmsg")
202            .field("family", &self.family)
203            .field("ifindex", &self.ifindex)
204            .field("handle", &self.handle)
205            .field("parent", &self.parent)
206            .field("info", &self.info)
207            .finish()
208    }
209}
210#[repr(C, packed(4))]
211pub struct TcStats {
212    #[doc = "Number of enqueued bytes"]
213    pub bytes: u64,
214    #[doc = "Number of enqueued packets"]
215    pub packets: u32,
216    #[doc = "Packets dropped because of lack of resources"]
217    pub drops: u32,
218    #[doc = "Number of throttle events when this flow goes out of allocated\nbandwidth\n"]
219    pub overlimits: u32,
220    #[doc = "Current flow byte rate"]
221    pub bps: u32,
222    #[doc = "Current flow packet rate"]
223    pub pps: u32,
224    pub qlen: u32,
225    pub backlog: u32,
226    pub _pad_36: [u8; 4usize],
227}
228impl Clone for TcStats {
229    fn clone(&self) -> Self {
230        Self::new_from_array(*self.as_array())
231    }
232}
233#[doc = "Create zero-initialized struct"]
234impl Default for TcStats {
235    fn default() -> Self {
236        Self::new()
237    }
238}
239impl TcStats {
240    #[doc = "Create zero-initialized struct"]
241    pub fn new() -> Self {
242        Self::new_from_array([0u8; Self::len()])
243    }
244    #[doc = "Copy from contents from slice"]
245    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
246        if other.len() != Self::len() {
247            return None;
248        }
249        let mut buf = [0u8; Self::len()];
250        buf.clone_from_slice(other);
251        Some(Self::new_from_array(buf))
252    }
253    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
254    pub fn new_from_zeroed(other: &[u8]) -> Self {
255        let mut buf = [0u8; Self::len()];
256        let len = buf.len().min(other.len());
257        buf[..len].clone_from_slice(&other[..len]);
258        Self::new_from_array(buf)
259    }
260    pub fn new_from_array(buf: [u8; 40usize]) -> Self {
261        unsafe { std::mem::transmute(buf) }
262    }
263    pub fn as_slice(&self) -> &[u8] {
264        unsafe {
265            let ptr: *const u8 = std::mem::transmute(self as *const Self);
266            std::slice::from_raw_parts(ptr, Self::len())
267        }
268    }
269    pub fn from_slice(buf: &[u8]) -> &Self {
270        assert!(buf.len() >= Self::len());
271        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
272        unsafe { std::mem::transmute(buf.as_ptr()) }
273    }
274    pub fn as_array(&self) -> &[u8; 40usize] {
275        unsafe { std::mem::transmute(self) }
276    }
277    pub fn from_array(buf: &[u8; 40usize]) -> &Self {
278        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
279        unsafe { std::mem::transmute(buf) }
280    }
281    pub fn into_array(self) -> [u8; 40usize] {
282        unsafe { std::mem::transmute(self) }
283    }
284    pub const fn len() -> usize {
285        const _: () = assert!(std::mem::size_of::<TcStats>() == 40usize);
286        40usize
287    }
288}
289impl std::fmt::Debug for TcStats {
290    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
291        fmt.debug_struct("TcStats")
292            .field("bytes", &{ self.bytes })
293            .field("packets", &self.packets)
294            .field("drops", &self.drops)
295            .field("overlimits", &self.overlimits)
296            .field("bps", &self.bps)
297            .field("pps", &self.pps)
298            .field("qlen", &self.qlen)
299            .field("backlog", &self.backlog)
300            .finish()
301    }
302}
303#[repr(C, packed(4))]
304pub struct TcCbsQopt {
305    pub offload: u8,
306    pub _pad: [u8; 3usize],
307    pub hicredit: i32,
308    pub locredit: i32,
309    pub idleslope: i32,
310    pub sendslope: i32,
311}
312impl Clone for TcCbsQopt {
313    fn clone(&self) -> Self {
314        Self::new_from_array(*self.as_array())
315    }
316}
317#[doc = "Create zero-initialized struct"]
318impl Default for TcCbsQopt {
319    fn default() -> Self {
320        Self::new()
321    }
322}
323impl TcCbsQopt {
324    #[doc = "Create zero-initialized struct"]
325    pub fn new() -> Self {
326        Self::new_from_array([0u8; Self::len()])
327    }
328    #[doc = "Copy from contents from slice"]
329    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
330        if other.len() != Self::len() {
331            return None;
332        }
333        let mut buf = [0u8; Self::len()];
334        buf.clone_from_slice(other);
335        Some(Self::new_from_array(buf))
336    }
337    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
338    pub fn new_from_zeroed(other: &[u8]) -> Self {
339        let mut buf = [0u8; Self::len()];
340        let len = buf.len().min(other.len());
341        buf[..len].clone_from_slice(&other[..len]);
342        Self::new_from_array(buf)
343    }
344    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
345        unsafe { std::mem::transmute(buf) }
346    }
347    pub fn as_slice(&self) -> &[u8] {
348        unsafe {
349            let ptr: *const u8 = std::mem::transmute(self as *const Self);
350            std::slice::from_raw_parts(ptr, Self::len())
351        }
352    }
353    pub fn from_slice(buf: &[u8]) -> &Self {
354        assert!(buf.len() >= Self::len());
355        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
356        unsafe { std::mem::transmute(buf.as_ptr()) }
357    }
358    pub fn as_array(&self) -> &[u8; 20usize] {
359        unsafe { std::mem::transmute(self) }
360    }
361    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
362        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
363        unsafe { std::mem::transmute(buf) }
364    }
365    pub fn into_array(self) -> [u8; 20usize] {
366        unsafe { std::mem::transmute(self) }
367    }
368    pub const fn len() -> usize {
369        const _: () = assert!(std::mem::size_of::<TcCbsQopt>() == 20usize);
370        20usize
371    }
372}
373impl std::fmt::Debug for TcCbsQopt {
374    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
375        fmt.debug_struct("TcCbsQopt")
376            .field("offload", &self.offload)
377            .field("hicredit", &self.hicredit)
378            .field("locredit", &self.locredit)
379            .field("idleslope", &self.idleslope)
380            .field("sendslope", &self.sendslope)
381            .finish()
382    }
383}
384#[derive(Debug)]
385#[repr(C, packed(4))]
386pub struct TcEtfQopt {
387    pub delta: i32,
388    pub clockid: i32,
389    pub flags: i32,
390}
391impl Clone for TcEtfQopt {
392    fn clone(&self) -> Self {
393        Self::new_from_array(*self.as_array())
394    }
395}
396#[doc = "Create zero-initialized struct"]
397impl Default for TcEtfQopt {
398    fn default() -> Self {
399        Self::new()
400    }
401}
402impl TcEtfQopt {
403    #[doc = "Create zero-initialized struct"]
404    pub fn new() -> Self {
405        Self::new_from_array([0u8; Self::len()])
406    }
407    #[doc = "Copy from contents from slice"]
408    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
409        if other.len() != Self::len() {
410            return None;
411        }
412        let mut buf = [0u8; Self::len()];
413        buf.clone_from_slice(other);
414        Some(Self::new_from_array(buf))
415    }
416    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
417    pub fn new_from_zeroed(other: &[u8]) -> Self {
418        let mut buf = [0u8; Self::len()];
419        let len = buf.len().min(other.len());
420        buf[..len].clone_from_slice(&other[..len]);
421        Self::new_from_array(buf)
422    }
423    pub fn new_from_array(buf: [u8; 12usize]) -> Self {
424        unsafe { std::mem::transmute(buf) }
425    }
426    pub fn as_slice(&self) -> &[u8] {
427        unsafe {
428            let ptr: *const u8 = std::mem::transmute(self as *const Self);
429            std::slice::from_raw_parts(ptr, Self::len())
430        }
431    }
432    pub fn from_slice(buf: &[u8]) -> &Self {
433        assert!(buf.len() >= Self::len());
434        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
435        unsafe { std::mem::transmute(buf.as_ptr()) }
436    }
437    pub fn as_array(&self) -> &[u8; 12usize] {
438        unsafe { std::mem::transmute(self) }
439    }
440    pub fn from_array(buf: &[u8; 12usize]) -> &Self {
441        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
442        unsafe { std::mem::transmute(buf) }
443    }
444    pub fn into_array(self) -> [u8; 12usize] {
445        unsafe { std::mem::transmute(self) }
446    }
447    pub const fn len() -> usize {
448        const _: () = assert!(std::mem::size_of::<TcEtfQopt>() == 12usize);
449        12usize
450    }
451}
452#[derive(Debug)]
453#[repr(C, packed(4))]
454pub struct TcFifoQopt {
455    #[doc = "Queue length; bytes for bfifo, packets for pfifo"]
456    pub limit: u32,
457}
458impl Clone for TcFifoQopt {
459    fn clone(&self) -> Self {
460        Self::new_from_array(*self.as_array())
461    }
462}
463#[doc = "Create zero-initialized struct"]
464impl Default for TcFifoQopt {
465    fn default() -> Self {
466        Self::new()
467    }
468}
469impl TcFifoQopt {
470    #[doc = "Create zero-initialized struct"]
471    pub fn new() -> Self {
472        Self::new_from_array([0u8; Self::len()])
473    }
474    #[doc = "Copy from contents from slice"]
475    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
476        if other.len() != Self::len() {
477            return None;
478        }
479        let mut buf = [0u8; Self::len()];
480        buf.clone_from_slice(other);
481        Some(Self::new_from_array(buf))
482    }
483    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
484    pub fn new_from_zeroed(other: &[u8]) -> Self {
485        let mut buf = [0u8; Self::len()];
486        let len = buf.len().min(other.len());
487        buf[..len].clone_from_slice(&other[..len]);
488        Self::new_from_array(buf)
489    }
490    pub fn new_from_array(buf: [u8; 4usize]) -> Self {
491        unsafe { std::mem::transmute(buf) }
492    }
493    pub fn as_slice(&self) -> &[u8] {
494        unsafe {
495            let ptr: *const u8 = std::mem::transmute(self as *const Self);
496            std::slice::from_raw_parts(ptr, Self::len())
497        }
498    }
499    pub fn from_slice(buf: &[u8]) -> &Self {
500        assert!(buf.len() >= Self::len());
501        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
502        unsafe { std::mem::transmute(buf.as_ptr()) }
503    }
504    pub fn as_array(&self) -> &[u8; 4usize] {
505        unsafe { std::mem::transmute(self) }
506    }
507    pub fn from_array(buf: &[u8; 4usize]) -> &Self {
508        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
509        unsafe { std::mem::transmute(buf) }
510    }
511    pub fn into_array(self) -> [u8; 4usize] {
512        unsafe { std::mem::transmute(self) }
513    }
514    pub const fn len() -> usize {
515        const _: () = assert!(std::mem::size_of::<TcFifoQopt>() == 4usize);
516        4usize
517    }
518}
519#[repr(C, packed(4))]
520pub struct TcHtbOpt {
521    pub rate: TcRatespec,
522    pub ceil: TcRatespec,
523    pub buffer: u32,
524    pub cbuffer: u32,
525    pub quantum: u32,
526    pub level: u32,
527    pub prio: u32,
528}
529impl Clone for TcHtbOpt {
530    fn clone(&self) -> Self {
531        Self::new_from_array(*self.as_array())
532    }
533}
534#[doc = "Create zero-initialized struct"]
535impl Default for TcHtbOpt {
536    fn default() -> Self {
537        Self::new()
538    }
539}
540impl TcHtbOpt {
541    #[doc = "Create zero-initialized struct"]
542    pub fn new() -> Self {
543        Self::new_from_array([0u8; Self::len()])
544    }
545    #[doc = "Copy from contents from slice"]
546    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
547        if other.len() != Self::len() {
548            return None;
549        }
550        let mut buf = [0u8; Self::len()];
551        buf.clone_from_slice(other);
552        Some(Self::new_from_array(buf))
553    }
554    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
555    pub fn new_from_zeroed(other: &[u8]) -> Self {
556        let mut buf = [0u8; Self::len()];
557        let len = buf.len().min(other.len());
558        buf[..len].clone_from_slice(&other[..len]);
559        Self::new_from_array(buf)
560    }
561    pub fn new_from_array(buf: [u8; 44usize]) -> Self {
562        unsafe { std::mem::transmute(buf) }
563    }
564    pub fn as_slice(&self) -> &[u8] {
565        unsafe {
566            let ptr: *const u8 = std::mem::transmute(self as *const Self);
567            std::slice::from_raw_parts(ptr, Self::len())
568        }
569    }
570    pub fn from_slice(buf: &[u8]) -> &Self {
571        assert!(buf.len() >= Self::len());
572        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
573        unsafe { std::mem::transmute(buf.as_ptr()) }
574    }
575    pub fn as_array(&self) -> &[u8; 44usize] {
576        unsafe { std::mem::transmute(self) }
577    }
578    pub fn from_array(buf: &[u8; 44usize]) -> &Self {
579        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
580        unsafe { std::mem::transmute(buf) }
581    }
582    pub fn into_array(self) -> [u8; 44usize] {
583        unsafe { std::mem::transmute(self) }
584    }
585    pub const fn len() -> usize {
586        const _: () = assert!(std::mem::size_of::<TcHtbOpt>() == 44usize);
587        44usize
588    }
589}
590impl std::fmt::Debug for TcHtbOpt {
591    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
592        fmt.debug_struct("TcHtbOpt")
593            .field("rate", &self.rate)
594            .field("ceil", &self.ceil)
595            .field("buffer", &self.buffer)
596            .field("cbuffer", &self.cbuffer)
597            .field("quantum", &self.quantum)
598            .field("level", &self.level)
599            .field("prio", &self.prio)
600            .finish()
601    }
602}
603#[derive(Debug)]
604#[repr(C, packed(4))]
605pub struct TcHtbGlob {
606    pub version: u32,
607    #[doc = "bps\\->quantum divisor"]
608    pub rate2quantum: u32,
609    #[doc = "Default class number"]
610    pub defcls: u32,
611    #[doc = "Debug flags"]
612    pub debug: u32,
613    #[doc = "Count of non shaped packets"]
614    pub direct_pkts: u32,
615}
616impl Clone for TcHtbGlob {
617    fn clone(&self) -> Self {
618        Self::new_from_array(*self.as_array())
619    }
620}
621#[doc = "Create zero-initialized struct"]
622impl Default for TcHtbGlob {
623    fn default() -> Self {
624        Self::new()
625    }
626}
627impl TcHtbGlob {
628    #[doc = "Create zero-initialized struct"]
629    pub fn new() -> Self {
630        Self::new_from_array([0u8; Self::len()])
631    }
632    #[doc = "Copy from contents from slice"]
633    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
634        if other.len() != Self::len() {
635            return None;
636        }
637        let mut buf = [0u8; Self::len()];
638        buf.clone_from_slice(other);
639        Some(Self::new_from_array(buf))
640    }
641    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
642    pub fn new_from_zeroed(other: &[u8]) -> Self {
643        let mut buf = [0u8; Self::len()];
644        let len = buf.len().min(other.len());
645        buf[..len].clone_from_slice(&other[..len]);
646        Self::new_from_array(buf)
647    }
648    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
649        unsafe { std::mem::transmute(buf) }
650    }
651    pub fn as_slice(&self) -> &[u8] {
652        unsafe {
653            let ptr: *const u8 = std::mem::transmute(self as *const Self);
654            std::slice::from_raw_parts(ptr, Self::len())
655        }
656    }
657    pub fn from_slice(buf: &[u8]) -> &Self {
658        assert!(buf.len() >= Self::len());
659        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
660        unsafe { std::mem::transmute(buf.as_ptr()) }
661    }
662    pub fn as_array(&self) -> &[u8; 20usize] {
663        unsafe { std::mem::transmute(self) }
664    }
665    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
666        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
667        unsafe { std::mem::transmute(buf) }
668    }
669    pub fn into_array(self) -> [u8; 20usize] {
670        unsafe { std::mem::transmute(self) }
671    }
672    pub const fn len() -> usize {
673        const _: () = assert!(std::mem::size_of::<TcHtbGlob>() == 20usize);
674        20usize
675    }
676}
677#[derive(Debug)]
678#[repr(C, packed(4))]
679pub struct TcGredQopt {
680    #[doc = "HARD maximal queue length in bytes"]
681    pub limit: u32,
682    #[doc = "Min average length threshold in bytes"]
683    pub qth_min: u32,
684    #[doc = "Max average length threshold in bytes"]
685    pub qth_max: u32,
686    #[doc = "Up to 2^32 DPs"]
687    pub DP: u32,
688    pub backlog: u32,
689    pub qave: u32,
690    pub forced: u32,
691    pub early: u32,
692    pub other: u32,
693    pub pdrop: u32,
694    #[doc = "log(W)"]
695    pub Wlog: u8,
696    #[doc = "log(P\\_max / (qth\\-max \\- qth\\-min))"]
697    pub Plog: u8,
698    #[doc = "cell size for idle damping"]
699    pub Scell_log: u8,
700    #[doc = "Priority of this VQ"]
701    pub prio: u8,
702    pub packets: u32,
703    pub bytesin: u32,
704}
705impl Clone for TcGredQopt {
706    fn clone(&self) -> Self {
707        Self::new_from_array(*self.as_array())
708    }
709}
710#[doc = "Create zero-initialized struct"]
711impl Default for TcGredQopt {
712    fn default() -> Self {
713        Self::new()
714    }
715}
716impl TcGredQopt {
717    #[doc = "Create zero-initialized struct"]
718    pub fn new() -> Self {
719        Self::new_from_array([0u8; Self::len()])
720    }
721    #[doc = "Copy from contents from slice"]
722    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
723        if other.len() != Self::len() {
724            return None;
725        }
726        let mut buf = [0u8; Self::len()];
727        buf.clone_from_slice(other);
728        Some(Self::new_from_array(buf))
729    }
730    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
731    pub fn new_from_zeroed(other: &[u8]) -> Self {
732        let mut buf = [0u8; Self::len()];
733        let len = buf.len().min(other.len());
734        buf[..len].clone_from_slice(&other[..len]);
735        Self::new_from_array(buf)
736    }
737    pub fn new_from_array(buf: [u8; 52usize]) -> Self {
738        unsafe { std::mem::transmute(buf) }
739    }
740    pub fn as_slice(&self) -> &[u8] {
741        unsafe {
742            let ptr: *const u8 = std::mem::transmute(self as *const Self);
743            std::slice::from_raw_parts(ptr, Self::len())
744        }
745    }
746    pub fn from_slice(buf: &[u8]) -> &Self {
747        assert!(buf.len() >= Self::len());
748        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
749        unsafe { std::mem::transmute(buf.as_ptr()) }
750    }
751    pub fn as_array(&self) -> &[u8; 52usize] {
752        unsafe { std::mem::transmute(self) }
753    }
754    pub fn from_array(buf: &[u8; 52usize]) -> &Self {
755        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
756        unsafe { std::mem::transmute(buf) }
757    }
758    pub fn into_array(self) -> [u8; 52usize] {
759        unsafe { std::mem::transmute(self) }
760    }
761    pub const fn len() -> usize {
762        const _: () = assert!(std::mem::size_of::<TcGredQopt>() == 52usize);
763        52usize
764    }
765}
766#[repr(C, packed(4))]
767pub struct TcGredSopt {
768    pub DPs: u32,
769    pub def_DP: u32,
770    pub grio: u8,
771    pub flags: u8,
772    pub _pad: [u8; 2usize],
773}
774impl Clone for TcGredSopt {
775    fn clone(&self) -> Self {
776        Self::new_from_array(*self.as_array())
777    }
778}
779#[doc = "Create zero-initialized struct"]
780impl Default for TcGredSopt {
781    fn default() -> Self {
782        Self::new()
783    }
784}
785impl TcGredSopt {
786    #[doc = "Create zero-initialized struct"]
787    pub fn new() -> Self {
788        Self::new_from_array([0u8; Self::len()])
789    }
790    #[doc = "Copy from contents from slice"]
791    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
792        if other.len() != Self::len() {
793            return None;
794        }
795        let mut buf = [0u8; Self::len()];
796        buf.clone_from_slice(other);
797        Some(Self::new_from_array(buf))
798    }
799    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
800    pub fn new_from_zeroed(other: &[u8]) -> Self {
801        let mut buf = [0u8; Self::len()];
802        let len = buf.len().min(other.len());
803        buf[..len].clone_from_slice(&other[..len]);
804        Self::new_from_array(buf)
805    }
806    pub fn new_from_array(buf: [u8; 12usize]) -> Self {
807        unsafe { std::mem::transmute(buf) }
808    }
809    pub fn as_slice(&self) -> &[u8] {
810        unsafe {
811            let ptr: *const u8 = std::mem::transmute(self as *const Self);
812            std::slice::from_raw_parts(ptr, Self::len())
813        }
814    }
815    pub fn from_slice(buf: &[u8]) -> &Self {
816        assert!(buf.len() >= Self::len());
817        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
818        unsafe { std::mem::transmute(buf.as_ptr()) }
819    }
820    pub fn as_array(&self) -> &[u8; 12usize] {
821        unsafe { std::mem::transmute(self) }
822    }
823    pub fn from_array(buf: &[u8; 12usize]) -> &Self {
824        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
825        unsafe { std::mem::transmute(buf) }
826    }
827    pub fn into_array(self) -> [u8; 12usize] {
828        unsafe { std::mem::transmute(self) }
829    }
830    pub const fn len() -> usize {
831        const _: () = assert!(std::mem::size_of::<TcGredSopt>() == 12usize);
832        12usize
833    }
834}
835impl std::fmt::Debug for TcGredSopt {
836    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
837        fmt.debug_struct("TcGredSopt")
838            .field("DPs", &self.DPs)
839            .field("def_DP", &self.def_DP)
840            .field("grio", &self.grio)
841            .field("flags", &self.flags)
842            .finish()
843    }
844}
845#[derive(Debug)]
846#[repr(C, packed(4))]
847pub struct TcHfscQopt {
848    pub defcls: u16,
849}
850impl Clone for TcHfscQopt {
851    fn clone(&self) -> Self {
852        Self::new_from_array(*self.as_array())
853    }
854}
855#[doc = "Create zero-initialized struct"]
856impl Default for TcHfscQopt {
857    fn default() -> Self {
858        Self::new()
859    }
860}
861impl TcHfscQopt {
862    #[doc = "Create zero-initialized struct"]
863    pub fn new() -> Self {
864        Self::new_from_array([0u8; Self::len()])
865    }
866    #[doc = "Copy from contents from slice"]
867    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
868        if other.len() != Self::len() {
869            return None;
870        }
871        let mut buf = [0u8; Self::len()];
872        buf.clone_from_slice(other);
873        Some(Self::new_from_array(buf))
874    }
875    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
876    pub fn new_from_zeroed(other: &[u8]) -> Self {
877        let mut buf = [0u8; Self::len()];
878        let len = buf.len().min(other.len());
879        buf[..len].clone_from_slice(&other[..len]);
880        Self::new_from_array(buf)
881    }
882    pub fn new_from_array(buf: [u8; 2usize]) -> Self {
883        unsafe { std::mem::transmute(buf) }
884    }
885    pub fn as_slice(&self) -> &[u8] {
886        unsafe {
887            let ptr: *const u8 = std::mem::transmute(self as *const Self);
888            std::slice::from_raw_parts(ptr, Self::len())
889        }
890    }
891    pub fn from_slice(buf: &[u8]) -> &Self {
892        assert!(buf.len() >= Self::len());
893        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
894        unsafe { std::mem::transmute(buf.as_ptr()) }
895    }
896    pub fn as_array(&self) -> &[u8; 2usize] {
897        unsafe { std::mem::transmute(self) }
898    }
899    pub fn from_array(buf: &[u8; 2usize]) -> &Self {
900        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
901        unsafe { std::mem::transmute(buf) }
902    }
903    pub fn into_array(self) -> [u8; 2usize] {
904        unsafe { std::mem::transmute(self) }
905    }
906    pub const fn len() -> usize {
907        const _: () = assert!(std::mem::size_of::<TcHfscQopt>() == 2usize);
908        2usize
909    }
910}
911#[derive(Debug)]
912#[repr(C, packed(4))]
913pub struct TcMqprioQopt {
914    pub num_tc: u8,
915    pub prio_tc_map: [u8; 16usize],
916    pub hw: u8,
917    pub count: [u8; 32usize],
918    pub offset: [u8; 32usize],
919}
920impl Clone for TcMqprioQopt {
921    fn clone(&self) -> Self {
922        Self::new_from_array(*self.as_array())
923    }
924}
925#[doc = "Create zero-initialized struct"]
926impl Default for TcMqprioQopt {
927    fn default() -> Self {
928        Self::new()
929    }
930}
931impl TcMqprioQopt {
932    #[doc = "Create zero-initialized struct"]
933    pub fn new() -> Self {
934        Self::new_from_array([0u8; Self::len()])
935    }
936    #[doc = "Copy from contents from slice"]
937    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
938        if other.len() != Self::len() {
939            return None;
940        }
941        let mut buf = [0u8; Self::len()];
942        buf.clone_from_slice(other);
943        Some(Self::new_from_array(buf))
944    }
945    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
946    pub fn new_from_zeroed(other: &[u8]) -> Self {
947        let mut buf = [0u8; Self::len()];
948        let len = buf.len().min(other.len());
949        buf[..len].clone_from_slice(&other[..len]);
950        Self::new_from_array(buf)
951    }
952    pub fn new_from_array(buf: [u8; 82usize]) -> Self {
953        unsafe { std::mem::transmute(buf) }
954    }
955    pub fn as_slice(&self) -> &[u8] {
956        unsafe {
957            let ptr: *const u8 = std::mem::transmute(self as *const Self);
958            std::slice::from_raw_parts(ptr, Self::len())
959        }
960    }
961    pub fn from_slice(buf: &[u8]) -> &Self {
962        assert!(buf.len() >= Self::len());
963        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
964        unsafe { std::mem::transmute(buf.as_ptr()) }
965    }
966    pub fn as_array(&self) -> &[u8; 82usize] {
967        unsafe { std::mem::transmute(self) }
968    }
969    pub fn from_array(buf: &[u8; 82usize]) -> &Self {
970        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
971        unsafe { std::mem::transmute(buf) }
972    }
973    pub fn into_array(self) -> [u8; 82usize] {
974        unsafe { std::mem::transmute(self) }
975    }
976    pub const fn len() -> usize {
977        const _: () = assert!(std::mem::size_of::<TcMqprioQopt>() == 82usize);
978        82usize
979    }
980}
981#[derive(Debug)]
982#[repr(C, packed(4))]
983pub struct TcMultiqQopt {
984    #[doc = "Number of bands"]
985    pub bands: u16,
986    #[doc = "Maximum number of queues"]
987    pub max_bands: u16,
988}
989impl Clone for TcMultiqQopt {
990    fn clone(&self) -> Self {
991        Self::new_from_array(*self.as_array())
992    }
993}
994#[doc = "Create zero-initialized struct"]
995impl Default for TcMultiqQopt {
996    fn default() -> Self {
997        Self::new()
998    }
999}
1000impl TcMultiqQopt {
1001    #[doc = "Create zero-initialized struct"]
1002    pub fn new() -> Self {
1003        Self::new_from_array([0u8; Self::len()])
1004    }
1005    #[doc = "Copy from contents from slice"]
1006    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1007        if other.len() != Self::len() {
1008            return None;
1009        }
1010        let mut buf = [0u8; Self::len()];
1011        buf.clone_from_slice(other);
1012        Some(Self::new_from_array(buf))
1013    }
1014    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1015    pub fn new_from_zeroed(other: &[u8]) -> Self {
1016        let mut buf = [0u8; Self::len()];
1017        let len = buf.len().min(other.len());
1018        buf[..len].clone_from_slice(&other[..len]);
1019        Self::new_from_array(buf)
1020    }
1021    pub fn new_from_array(buf: [u8; 4usize]) -> Self {
1022        unsafe { std::mem::transmute(buf) }
1023    }
1024    pub fn as_slice(&self) -> &[u8] {
1025        unsafe {
1026            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1027            std::slice::from_raw_parts(ptr, Self::len())
1028        }
1029    }
1030    pub fn from_slice(buf: &[u8]) -> &Self {
1031        assert!(buf.len() >= Self::len());
1032        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1033        unsafe { std::mem::transmute(buf.as_ptr()) }
1034    }
1035    pub fn as_array(&self) -> &[u8; 4usize] {
1036        unsafe { std::mem::transmute(self) }
1037    }
1038    pub fn from_array(buf: &[u8; 4usize]) -> &Self {
1039        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1040        unsafe { std::mem::transmute(buf) }
1041    }
1042    pub fn into_array(self) -> [u8; 4usize] {
1043        unsafe { std::mem::transmute(self) }
1044    }
1045    pub const fn len() -> usize {
1046        const _: () = assert!(std::mem::size_of::<TcMultiqQopt>() == 4usize);
1047        4usize
1048    }
1049}
1050#[derive(Debug)]
1051#[repr(C, packed(4))]
1052pub struct TcNetemQopt {
1053    #[doc = "Added delay in microseconds"]
1054    pub latency: u32,
1055    #[doc = "Fifo limit in packets"]
1056    pub limit: u32,
1057    #[doc = "Random packet loss (0=none, \\~0=100%)"]
1058    pub loss: u32,
1059    #[doc = "Re\\-ordering gap (0 for none)"]
1060    pub gap: u32,
1061    #[doc = "Random packet duplication (0=none, \\~0=100%)"]
1062    pub duplicate: u32,
1063    #[doc = "Random jitter latency in microseconds"]
1064    pub jitter: u32,
1065}
1066impl Clone for TcNetemQopt {
1067    fn clone(&self) -> Self {
1068        Self::new_from_array(*self.as_array())
1069    }
1070}
1071#[doc = "Create zero-initialized struct"]
1072impl Default for TcNetemQopt {
1073    fn default() -> Self {
1074        Self::new()
1075    }
1076}
1077impl TcNetemQopt {
1078    #[doc = "Create zero-initialized struct"]
1079    pub fn new() -> Self {
1080        Self::new_from_array([0u8; Self::len()])
1081    }
1082    #[doc = "Copy from contents from slice"]
1083    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1084        if other.len() != Self::len() {
1085            return None;
1086        }
1087        let mut buf = [0u8; Self::len()];
1088        buf.clone_from_slice(other);
1089        Some(Self::new_from_array(buf))
1090    }
1091    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1092    pub fn new_from_zeroed(other: &[u8]) -> Self {
1093        let mut buf = [0u8; Self::len()];
1094        let len = buf.len().min(other.len());
1095        buf[..len].clone_from_slice(&other[..len]);
1096        Self::new_from_array(buf)
1097    }
1098    pub fn new_from_array(buf: [u8; 24usize]) -> Self {
1099        unsafe { std::mem::transmute(buf) }
1100    }
1101    pub fn as_slice(&self) -> &[u8] {
1102        unsafe {
1103            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1104            std::slice::from_raw_parts(ptr, Self::len())
1105        }
1106    }
1107    pub fn from_slice(buf: &[u8]) -> &Self {
1108        assert!(buf.len() >= Self::len());
1109        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1110        unsafe { std::mem::transmute(buf.as_ptr()) }
1111    }
1112    pub fn as_array(&self) -> &[u8; 24usize] {
1113        unsafe { std::mem::transmute(self) }
1114    }
1115    pub fn from_array(buf: &[u8; 24usize]) -> &Self {
1116        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1117        unsafe { std::mem::transmute(buf) }
1118    }
1119    pub fn into_array(self) -> [u8; 24usize] {
1120        unsafe { std::mem::transmute(self) }
1121    }
1122    pub const fn len() -> usize {
1123        const _: () = assert!(std::mem::size_of::<TcNetemQopt>() == 24usize);
1124        24usize
1125    }
1126}
1127#[derive(Debug)]
1128#[repr(C, packed(4))]
1129pub struct TcNetemGimodel {
1130    pub p13: u32,
1131    pub p31: u32,
1132    pub p32: u32,
1133    pub p14: u32,
1134    pub p23: u32,
1135}
1136impl Clone for TcNetemGimodel {
1137    fn clone(&self) -> Self {
1138        Self::new_from_array(*self.as_array())
1139    }
1140}
1141#[doc = "Create zero-initialized struct"]
1142impl Default for TcNetemGimodel {
1143    fn default() -> Self {
1144        Self::new()
1145    }
1146}
1147impl TcNetemGimodel {
1148    #[doc = "Create zero-initialized struct"]
1149    pub fn new() -> Self {
1150        Self::new_from_array([0u8; Self::len()])
1151    }
1152    #[doc = "Copy from contents from slice"]
1153    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1154        if other.len() != Self::len() {
1155            return None;
1156        }
1157        let mut buf = [0u8; Self::len()];
1158        buf.clone_from_slice(other);
1159        Some(Self::new_from_array(buf))
1160    }
1161    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1162    pub fn new_from_zeroed(other: &[u8]) -> Self {
1163        let mut buf = [0u8; Self::len()];
1164        let len = buf.len().min(other.len());
1165        buf[..len].clone_from_slice(&other[..len]);
1166        Self::new_from_array(buf)
1167    }
1168    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
1169        unsafe { std::mem::transmute(buf) }
1170    }
1171    pub fn as_slice(&self) -> &[u8] {
1172        unsafe {
1173            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1174            std::slice::from_raw_parts(ptr, Self::len())
1175        }
1176    }
1177    pub fn from_slice(buf: &[u8]) -> &Self {
1178        assert!(buf.len() >= Self::len());
1179        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1180        unsafe { std::mem::transmute(buf.as_ptr()) }
1181    }
1182    pub fn as_array(&self) -> &[u8; 20usize] {
1183        unsafe { std::mem::transmute(self) }
1184    }
1185    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
1186        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1187        unsafe { std::mem::transmute(buf) }
1188    }
1189    pub fn into_array(self) -> [u8; 20usize] {
1190        unsafe { std::mem::transmute(self) }
1191    }
1192    pub const fn len() -> usize {
1193        const _: () = assert!(std::mem::size_of::<TcNetemGimodel>() == 20usize);
1194        20usize
1195    }
1196}
1197#[derive(Debug)]
1198#[repr(C, packed(4))]
1199pub struct TcNetemGemodel {
1200    pub p: u32,
1201    pub r: u32,
1202    pub h: u32,
1203    pub k1: u32,
1204}
1205impl Clone for TcNetemGemodel {
1206    fn clone(&self) -> Self {
1207        Self::new_from_array(*self.as_array())
1208    }
1209}
1210#[doc = "Create zero-initialized struct"]
1211impl Default for TcNetemGemodel {
1212    fn default() -> Self {
1213        Self::new()
1214    }
1215}
1216impl TcNetemGemodel {
1217    #[doc = "Create zero-initialized struct"]
1218    pub fn new() -> Self {
1219        Self::new_from_array([0u8; Self::len()])
1220    }
1221    #[doc = "Copy from contents from slice"]
1222    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1223        if other.len() != Self::len() {
1224            return None;
1225        }
1226        let mut buf = [0u8; Self::len()];
1227        buf.clone_from_slice(other);
1228        Some(Self::new_from_array(buf))
1229    }
1230    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1231    pub fn new_from_zeroed(other: &[u8]) -> Self {
1232        let mut buf = [0u8; Self::len()];
1233        let len = buf.len().min(other.len());
1234        buf[..len].clone_from_slice(&other[..len]);
1235        Self::new_from_array(buf)
1236    }
1237    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
1238        unsafe { std::mem::transmute(buf) }
1239    }
1240    pub fn as_slice(&self) -> &[u8] {
1241        unsafe {
1242            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1243            std::slice::from_raw_parts(ptr, Self::len())
1244        }
1245    }
1246    pub fn from_slice(buf: &[u8]) -> &Self {
1247        assert!(buf.len() >= Self::len());
1248        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1249        unsafe { std::mem::transmute(buf.as_ptr()) }
1250    }
1251    pub fn as_array(&self) -> &[u8; 16usize] {
1252        unsafe { std::mem::transmute(self) }
1253    }
1254    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
1255        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1256        unsafe { std::mem::transmute(buf) }
1257    }
1258    pub fn into_array(self) -> [u8; 16usize] {
1259        unsafe { std::mem::transmute(self) }
1260    }
1261    pub const fn len() -> usize {
1262        const _: () = assert!(std::mem::size_of::<TcNetemGemodel>() == 16usize);
1263        16usize
1264    }
1265}
1266#[derive(Debug)]
1267#[repr(C, packed(4))]
1268pub struct TcNetemCorr {
1269    #[doc = "Delay correlation"]
1270    pub delay_corr: u32,
1271    #[doc = "Packet loss correlation"]
1272    pub loss_corr: u32,
1273    #[doc = "Duplicate correlation"]
1274    pub dup_corr: u32,
1275}
1276impl Clone for TcNetemCorr {
1277    fn clone(&self) -> Self {
1278        Self::new_from_array(*self.as_array())
1279    }
1280}
1281#[doc = "Create zero-initialized struct"]
1282impl Default for TcNetemCorr {
1283    fn default() -> Self {
1284        Self::new()
1285    }
1286}
1287impl TcNetemCorr {
1288    #[doc = "Create zero-initialized struct"]
1289    pub fn new() -> Self {
1290        Self::new_from_array([0u8; Self::len()])
1291    }
1292    #[doc = "Copy from contents from slice"]
1293    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1294        if other.len() != Self::len() {
1295            return None;
1296        }
1297        let mut buf = [0u8; Self::len()];
1298        buf.clone_from_slice(other);
1299        Some(Self::new_from_array(buf))
1300    }
1301    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1302    pub fn new_from_zeroed(other: &[u8]) -> Self {
1303        let mut buf = [0u8; Self::len()];
1304        let len = buf.len().min(other.len());
1305        buf[..len].clone_from_slice(&other[..len]);
1306        Self::new_from_array(buf)
1307    }
1308    pub fn new_from_array(buf: [u8; 12usize]) -> Self {
1309        unsafe { std::mem::transmute(buf) }
1310    }
1311    pub fn as_slice(&self) -> &[u8] {
1312        unsafe {
1313            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1314            std::slice::from_raw_parts(ptr, Self::len())
1315        }
1316    }
1317    pub fn from_slice(buf: &[u8]) -> &Self {
1318        assert!(buf.len() >= Self::len());
1319        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1320        unsafe { std::mem::transmute(buf.as_ptr()) }
1321    }
1322    pub fn as_array(&self) -> &[u8; 12usize] {
1323        unsafe { std::mem::transmute(self) }
1324    }
1325    pub fn from_array(buf: &[u8; 12usize]) -> &Self {
1326        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1327        unsafe { std::mem::transmute(buf) }
1328    }
1329    pub fn into_array(self) -> [u8; 12usize] {
1330        unsafe { std::mem::transmute(self) }
1331    }
1332    pub const fn len() -> usize {
1333        const _: () = assert!(std::mem::size_of::<TcNetemCorr>() == 12usize);
1334        12usize
1335    }
1336}
1337#[derive(Debug)]
1338#[repr(C, packed(4))]
1339pub struct TcNetemReorder {
1340    pub probability: u32,
1341    pub correlation: u32,
1342}
1343impl Clone for TcNetemReorder {
1344    fn clone(&self) -> Self {
1345        Self::new_from_array(*self.as_array())
1346    }
1347}
1348#[doc = "Create zero-initialized struct"]
1349impl Default for TcNetemReorder {
1350    fn default() -> Self {
1351        Self::new()
1352    }
1353}
1354impl TcNetemReorder {
1355    #[doc = "Create zero-initialized struct"]
1356    pub fn new() -> Self {
1357        Self::new_from_array([0u8; Self::len()])
1358    }
1359    #[doc = "Copy from contents from slice"]
1360    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1361        if other.len() != Self::len() {
1362            return None;
1363        }
1364        let mut buf = [0u8; Self::len()];
1365        buf.clone_from_slice(other);
1366        Some(Self::new_from_array(buf))
1367    }
1368    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1369    pub fn new_from_zeroed(other: &[u8]) -> Self {
1370        let mut buf = [0u8; Self::len()];
1371        let len = buf.len().min(other.len());
1372        buf[..len].clone_from_slice(&other[..len]);
1373        Self::new_from_array(buf)
1374    }
1375    pub fn new_from_array(buf: [u8; 8usize]) -> Self {
1376        unsafe { std::mem::transmute(buf) }
1377    }
1378    pub fn as_slice(&self) -> &[u8] {
1379        unsafe {
1380            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1381            std::slice::from_raw_parts(ptr, Self::len())
1382        }
1383    }
1384    pub fn from_slice(buf: &[u8]) -> &Self {
1385        assert!(buf.len() >= Self::len());
1386        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1387        unsafe { std::mem::transmute(buf.as_ptr()) }
1388    }
1389    pub fn as_array(&self) -> &[u8; 8usize] {
1390        unsafe { std::mem::transmute(self) }
1391    }
1392    pub fn from_array(buf: &[u8; 8usize]) -> &Self {
1393        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1394        unsafe { std::mem::transmute(buf) }
1395    }
1396    pub fn into_array(self) -> [u8; 8usize] {
1397        unsafe { std::mem::transmute(self) }
1398    }
1399    pub const fn len() -> usize {
1400        const _: () = assert!(std::mem::size_of::<TcNetemReorder>() == 8usize);
1401        8usize
1402    }
1403}
1404#[derive(Debug)]
1405#[repr(C, packed(4))]
1406pub struct TcNetemCorrupt {
1407    pub probability: u32,
1408    pub correlation: u32,
1409}
1410impl Clone for TcNetemCorrupt {
1411    fn clone(&self) -> Self {
1412        Self::new_from_array(*self.as_array())
1413    }
1414}
1415#[doc = "Create zero-initialized struct"]
1416impl Default for TcNetemCorrupt {
1417    fn default() -> Self {
1418        Self::new()
1419    }
1420}
1421impl TcNetemCorrupt {
1422    #[doc = "Create zero-initialized struct"]
1423    pub fn new() -> Self {
1424        Self::new_from_array([0u8; Self::len()])
1425    }
1426    #[doc = "Copy from contents from slice"]
1427    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1428        if other.len() != Self::len() {
1429            return None;
1430        }
1431        let mut buf = [0u8; Self::len()];
1432        buf.clone_from_slice(other);
1433        Some(Self::new_from_array(buf))
1434    }
1435    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1436    pub fn new_from_zeroed(other: &[u8]) -> Self {
1437        let mut buf = [0u8; Self::len()];
1438        let len = buf.len().min(other.len());
1439        buf[..len].clone_from_slice(&other[..len]);
1440        Self::new_from_array(buf)
1441    }
1442    pub fn new_from_array(buf: [u8; 8usize]) -> Self {
1443        unsafe { std::mem::transmute(buf) }
1444    }
1445    pub fn as_slice(&self) -> &[u8] {
1446        unsafe {
1447            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1448            std::slice::from_raw_parts(ptr, Self::len())
1449        }
1450    }
1451    pub fn from_slice(buf: &[u8]) -> &Self {
1452        assert!(buf.len() >= Self::len());
1453        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1454        unsafe { std::mem::transmute(buf.as_ptr()) }
1455    }
1456    pub fn as_array(&self) -> &[u8; 8usize] {
1457        unsafe { std::mem::transmute(self) }
1458    }
1459    pub fn from_array(buf: &[u8; 8usize]) -> &Self {
1460        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1461        unsafe { std::mem::transmute(buf) }
1462    }
1463    pub fn into_array(self) -> [u8; 8usize] {
1464        unsafe { std::mem::transmute(self) }
1465    }
1466    pub const fn len() -> usize {
1467        const _: () = assert!(std::mem::size_of::<TcNetemCorrupt>() == 8usize);
1468        8usize
1469    }
1470}
1471#[derive(Debug)]
1472#[repr(C, packed(4))]
1473pub struct TcNetemRate {
1474    pub rate: u32,
1475    pub packet_overhead: i32,
1476    pub cell_size: u32,
1477    pub cell_overhead: i32,
1478}
1479impl Clone for TcNetemRate {
1480    fn clone(&self) -> Self {
1481        Self::new_from_array(*self.as_array())
1482    }
1483}
1484#[doc = "Create zero-initialized struct"]
1485impl Default for TcNetemRate {
1486    fn default() -> Self {
1487        Self::new()
1488    }
1489}
1490impl TcNetemRate {
1491    #[doc = "Create zero-initialized struct"]
1492    pub fn new() -> Self {
1493        Self::new_from_array([0u8; Self::len()])
1494    }
1495    #[doc = "Copy from contents from slice"]
1496    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1497        if other.len() != Self::len() {
1498            return None;
1499        }
1500        let mut buf = [0u8; Self::len()];
1501        buf.clone_from_slice(other);
1502        Some(Self::new_from_array(buf))
1503    }
1504    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1505    pub fn new_from_zeroed(other: &[u8]) -> Self {
1506        let mut buf = [0u8; Self::len()];
1507        let len = buf.len().min(other.len());
1508        buf[..len].clone_from_slice(&other[..len]);
1509        Self::new_from_array(buf)
1510    }
1511    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
1512        unsafe { std::mem::transmute(buf) }
1513    }
1514    pub fn as_slice(&self) -> &[u8] {
1515        unsafe {
1516            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1517            std::slice::from_raw_parts(ptr, Self::len())
1518        }
1519    }
1520    pub fn from_slice(buf: &[u8]) -> &Self {
1521        assert!(buf.len() >= Self::len());
1522        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1523        unsafe { std::mem::transmute(buf.as_ptr()) }
1524    }
1525    pub fn as_array(&self) -> &[u8; 16usize] {
1526        unsafe { std::mem::transmute(self) }
1527    }
1528    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
1529        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1530        unsafe { std::mem::transmute(buf) }
1531    }
1532    pub fn into_array(self) -> [u8; 16usize] {
1533        unsafe { std::mem::transmute(self) }
1534    }
1535    pub const fn len() -> usize {
1536        const _: () = assert!(std::mem::size_of::<TcNetemRate>() == 16usize);
1537        16usize
1538    }
1539}
1540#[repr(C, packed(4))]
1541pub struct TcNetemSlot {
1542    pub min_delay: i64,
1543    pub max_delay: i64,
1544    pub max_packets: i32,
1545    pub max_bytes: i32,
1546    pub dist_delay: i64,
1547    pub dist_jitter: i64,
1548}
1549impl Clone for TcNetemSlot {
1550    fn clone(&self) -> Self {
1551        Self::new_from_array(*self.as_array())
1552    }
1553}
1554#[doc = "Create zero-initialized struct"]
1555impl Default for TcNetemSlot {
1556    fn default() -> Self {
1557        Self::new()
1558    }
1559}
1560impl TcNetemSlot {
1561    #[doc = "Create zero-initialized struct"]
1562    pub fn new() -> Self {
1563        Self::new_from_array([0u8; Self::len()])
1564    }
1565    #[doc = "Copy from contents from slice"]
1566    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1567        if other.len() != Self::len() {
1568            return None;
1569        }
1570        let mut buf = [0u8; Self::len()];
1571        buf.clone_from_slice(other);
1572        Some(Self::new_from_array(buf))
1573    }
1574    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1575    pub fn new_from_zeroed(other: &[u8]) -> Self {
1576        let mut buf = [0u8; Self::len()];
1577        let len = buf.len().min(other.len());
1578        buf[..len].clone_from_slice(&other[..len]);
1579        Self::new_from_array(buf)
1580    }
1581    pub fn new_from_array(buf: [u8; 40usize]) -> Self {
1582        unsafe { std::mem::transmute(buf) }
1583    }
1584    pub fn as_slice(&self) -> &[u8] {
1585        unsafe {
1586            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1587            std::slice::from_raw_parts(ptr, Self::len())
1588        }
1589    }
1590    pub fn from_slice(buf: &[u8]) -> &Self {
1591        assert!(buf.len() >= Self::len());
1592        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1593        unsafe { std::mem::transmute(buf.as_ptr()) }
1594    }
1595    pub fn as_array(&self) -> &[u8; 40usize] {
1596        unsafe { std::mem::transmute(self) }
1597    }
1598    pub fn from_array(buf: &[u8; 40usize]) -> &Self {
1599        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1600        unsafe { std::mem::transmute(buf) }
1601    }
1602    pub fn into_array(self) -> [u8; 40usize] {
1603        unsafe { std::mem::transmute(self) }
1604    }
1605    pub const fn len() -> usize {
1606        const _: () = assert!(std::mem::size_of::<TcNetemSlot>() == 40usize);
1607        40usize
1608    }
1609}
1610impl std::fmt::Debug for TcNetemSlot {
1611    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1612        fmt.debug_struct("TcNetemSlot")
1613            .field("min_delay", &{ self.min_delay })
1614            .field("max_delay", &{ self.max_delay })
1615            .field("max_packets", &self.max_packets)
1616            .field("max_bytes", &self.max_bytes)
1617            .field("dist_delay", &{ self.dist_delay })
1618            .field("dist_jitter", &{ self.dist_jitter })
1619            .finish()
1620    }
1621}
1622#[derive(Debug)]
1623#[repr(C, packed(4))]
1624pub struct TcPlugQopt {
1625    pub action: i32,
1626    pub limit: u32,
1627}
1628impl Clone for TcPlugQopt {
1629    fn clone(&self) -> Self {
1630        Self::new_from_array(*self.as_array())
1631    }
1632}
1633#[doc = "Create zero-initialized struct"]
1634impl Default for TcPlugQopt {
1635    fn default() -> Self {
1636        Self::new()
1637    }
1638}
1639impl TcPlugQopt {
1640    #[doc = "Create zero-initialized struct"]
1641    pub fn new() -> Self {
1642        Self::new_from_array([0u8; Self::len()])
1643    }
1644    #[doc = "Copy from contents from slice"]
1645    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1646        if other.len() != Self::len() {
1647            return None;
1648        }
1649        let mut buf = [0u8; Self::len()];
1650        buf.clone_from_slice(other);
1651        Some(Self::new_from_array(buf))
1652    }
1653    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1654    pub fn new_from_zeroed(other: &[u8]) -> Self {
1655        let mut buf = [0u8; Self::len()];
1656        let len = buf.len().min(other.len());
1657        buf[..len].clone_from_slice(&other[..len]);
1658        Self::new_from_array(buf)
1659    }
1660    pub fn new_from_array(buf: [u8; 8usize]) -> Self {
1661        unsafe { std::mem::transmute(buf) }
1662    }
1663    pub fn as_slice(&self) -> &[u8] {
1664        unsafe {
1665            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1666            std::slice::from_raw_parts(ptr, Self::len())
1667        }
1668    }
1669    pub fn from_slice(buf: &[u8]) -> &Self {
1670        assert!(buf.len() >= Self::len());
1671        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1672        unsafe { std::mem::transmute(buf.as_ptr()) }
1673    }
1674    pub fn as_array(&self) -> &[u8; 8usize] {
1675        unsafe { std::mem::transmute(self) }
1676    }
1677    pub fn from_array(buf: &[u8; 8usize]) -> &Self {
1678        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1679        unsafe { std::mem::transmute(buf) }
1680    }
1681    pub fn into_array(self) -> [u8; 8usize] {
1682        unsafe { std::mem::transmute(self) }
1683    }
1684    pub const fn len() -> usize {
1685        const _: () = assert!(std::mem::size_of::<TcPlugQopt>() == 8usize);
1686        8usize
1687    }
1688}
1689#[derive(Debug)]
1690#[repr(C, packed(4))]
1691pub struct TcPrioQopt {
1692    #[doc = "Number of bands"]
1693    pub bands: u32,
1694    #[doc = "Map of logical priority \\-> PRIO band"]
1695    pub priomap: [u8; 16usize],
1696}
1697impl Clone for TcPrioQopt {
1698    fn clone(&self) -> Self {
1699        Self::new_from_array(*self.as_array())
1700    }
1701}
1702#[doc = "Create zero-initialized struct"]
1703impl Default for TcPrioQopt {
1704    fn default() -> Self {
1705        Self::new()
1706    }
1707}
1708impl TcPrioQopt {
1709    #[doc = "Create zero-initialized struct"]
1710    pub fn new() -> Self {
1711        Self::new_from_array([0u8; Self::len()])
1712    }
1713    #[doc = "Copy from contents from slice"]
1714    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1715        if other.len() != Self::len() {
1716            return None;
1717        }
1718        let mut buf = [0u8; Self::len()];
1719        buf.clone_from_slice(other);
1720        Some(Self::new_from_array(buf))
1721    }
1722    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1723    pub fn new_from_zeroed(other: &[u8]) -> Self {
1724        let mut buf = [0u8; Self::len()];
1725        let len = buf.len().min(other.len());
1726        buf[..len].clone_from_slice(&other[..len]);
1727        Self::new_from_array(buf)
1728    }
1729    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
1730        unsafe { std::mem::transmute(buf) }
1731    }
1732    pub fn as_slice(&self) -> &[u8] {
1733        unsafe {
1734            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1735            std::slice::from_raw_parts(ptr, Self::len())
1736        }
1737    }
1738    pub fn from_slice(buf: &[u8]) -> &Self {
1739        assert!(buf.len() >= Self::len());
1740        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1741        unsafe { std::mem::transmute(buf.as_ptr()) }
1742    }
1743    pub fn as_array(&self) -> &[u8; 20usize] {
1744        unsafe { std::mem::transmute(self) }
1745    }
1746    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
1747        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1748        unsafe { std::mem::transmute(buf) }
1749    }
1750    pub fn into_array(self) -> [u8; 20usize] {
1751        unsafe { std::mem::transmute(self) }
1752    }
1753    pub const fn len() -> usize {
1754        const _: () = assert!(std::mem::size_of::<TcPrioQopt>() == 20usize);
1755        20usize
1756    }
1757}
1758#[derive(Debug)]
1759#[repr(C, packed(4))]
1760pub struct TcRedQopt {
1761    #[doc = "Hard queue length in packets"]
1762    pub limit: u32,
1763    #[doc = "Min average threshold in packets"]
1764    pub qth_min: u32,
1765    #[doc = "Max average threshold in packets"]
1766    pub qth_max: u32,
1767    #[doc = "log(W)"]
1768    pub Wlog: u8,
1769    #[doc = "log(P\\_max / (qth\\-max \\- qth\\-min))"]
1770    pub Plog: u8,
1771    #[doc = "Cell size for idle damping"]
1772    pub Scell_log: u8,
1773    pub flags: u8,
1774}
1775impl Clone for TcRedQopt {
1776    fn clone(&self) -> Self {
1777        Self::new_from_array(*self.as_array())
1778    }
1779}
1780#[doc = "Create zero-initialized struct"]
1781impl Default for TcRedQopt {
1782    fn default() -> Self {
1783        Self::new()
1784    }
1785}
1786impl TcRedQopt {
1787    #[doc = "Create zero-initialized struct"]
1788    pub fn new() -> Self {
1789        Self::new_from_array([0u8; Self::len()])
1790    }
1791    #[doc = "Copy from contents from slice"]
1792    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1793        if other.len() != Self::len() {
1794            return None;
1795        }
1796        let mut buf = [0u8; Self::len()];
1797        buf.clone_from_slice(other);
1798        Some(Self::new_from_array(buf))
1799    }
1800    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1801    pub fn new_from_zeroed(other: &[u8]) -> Self {
1802        let mut buf = [0u8; Self::len()];
1803        let len = buf.len().min(other.len());
1804        buf[..len].clone_from_slice(&other[..len]);
1805        Self::new_from_array(buf)
1806    }
1807    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
1808        unsafe { std::mem::transmute(buf) }
1809    }
1810    pub fn as_slice(&self) -> &[u8] {
1811        unsafe {
1812            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1813            std::slice::from_raw_parts(ptr, Self::len())
1814        }
1815    }
1816    pub fn from_slice(buf: &[u8]) -> &Self {
1817        assert!(buf.len() >= Self::len());
1818        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1819        unsafe { std::mem::transmute(buf.as_ptr()) }
1820    }
1821    pub fn as_array(&self) -> &[u8; 16usize] {
1822        unsafe { std::mem::transmute(self) }
1823    }
1824    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
1825        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1826        unsafe { std::mem::transmute(buf) }
1827    }
1828    pub fn into_array(self) -> [u8; 16usize] {
1829        unsafe { std::mem::transmute(self) }
1830    }
1831    pub const fn len() -> usize {
1832        const _: () = assert!(std::mem::size_of::<TcRedQopt>() == 16usize);
1833        16usize
1834    }
1835}
1836#[derive(Debug)]
1837#[repr(C, packed(4))]
1838pub struct TcSfbQopt {
1839    pub rehash_interval: u32,
1840    pub warmup_time: u32,
1841    pub max: u32,
1842    pub bin_size: u32,
1843    pub increment: u32,
1844    pub decrement: u32,
1845    pub limit: u32,
1846    pub penalty_rate: u32,
1847    pub penalty_burst: u32,
1848}
1849impl Clone for TcSfbQopt {
1850    fn clone(&self) -> Self {
1851        Self::new_from_array(*self.as_array())
1852    }
1853}
1854#[doc = "Create zero-initialized struct"]
1855impl Default for TcSfbQopt {
1856    fn default() -> Self {
1857        Self::new()
1858    }
1859}
1860impl TcSfbQopt {
1861    #[doc = "Create zero-initialized struct"]
1862    pub fn new() -> Self {
1863        Self::new_from_array([0u8; Self::len()])
1864    }
1865    #[doc = "Copy from contents from slice"]
1866    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1867        if other.len() != Self::len() {
1868            return None;
1869        }
1870        let mut buf = [0u8; Self::len()];
1871        buf.clone_from_slice(other);
1872        Some(Self::new_from_array(buf))
1873    }
1874    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1875    pub fn new_from_zeroed(other: &[u8]) -> Self {
1876        let mut buf = [0u8; Self::len()];
1877        let len = buf.len().min(other.len());
1878        buf[..len].clone_from_slice(&other[..len]);
1879        Self::new_from_array(buf)
1880    }
1881    pub fn new_from_array(buf: [u8; 36usize]) -> Self {
1882        unsafe { std::mem::transmute(buf) }
1883    }
1884    pub fn as_slice(&self) -> &[u8] {
1885        unsafe {
1886            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1887            std::slice::from_raw_parts(ptr, Self::len())
1888        }
1889    }
1890    pub fn from_slice(buf: &[u8]) -> &Self {
1891        assert!(buf.len() >= Self::len());
1892        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1893        unsafe { std::mem::transmute(buf.as_ptr()) }
1894    }
1895    pub fn as_array(&self) -> &[u8; 36usize] {
1896        unsafe { std::mem::transmute(self) }
1897    }
1898    pub fn from_array(buf: &[u8; 36usize]) -> &Self {
1899        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1900        unsafe { std::mem::transmute(buf) }
1901    }
1902    pub fn into_array(self) -> [u8; 36usize] {
1903        unsafe { std::mem::transmute(self) }
1904    }
1905    pub const fn len() -> usize {
1906        const _: () = assert!(std::mem::size_of::<TcSfbQopt>() == 36usize);
1907        36usize
1908    }
1909}
1910#[derive(Debug)]
1911#[repr(C, packed(4))]
1912pub struct TcSfqQopt {
1913    #[doc = "Bytes per round allocated to flow"]
1914    pub quantum: u32,
1915    #[doc = "Period of hash perturbation"]
1916    pub perturb_period: i32,
1917    #[doc = "Maximal packets in queue"]
1918    pub limit: u32,
1919    #[doc = "Hash divisor"]
1920    pub divisor: u32,
1921    #[doc = "Maximal number of flows"]
1922    pub flows: u32,
1923}
1924impl Clone for TcSfqQopt {
1925    fn clone(&self) -> Self {
1926        Self::new_from_array(*self.as_array())
1927    }
1928}
1929#[doc = "Create zero-initialized struct"]
1930impl Default for TcSfqQopt {
1931    fn default() -> Self {
1932        Self::new()
1933    }
1934}
1935impl TcSfqQopt {
1936    #[doc = "Create zero-initialized struct"]
1937    pub fn new() -> Self {
1938        Self::new_from_array([0u8; Self::len()])
1939    }
1940    #[doc = "Copy from contents from slice"]
1941    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1942        if other.len() != Self::len() {
1943            return None;
1944        }
1945        let mut buf = [0u8; Self::len()];
1946        buf.clone_from_slice(other);
1947        Some(Self::new_from_array(buf))
1948    }
1949    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1950    pub fn new_from_zeroed(other: &[u8]) -> Self {
1951        let mut buf = [0u8; Self::len()];
1952        let len = buf.len().min(other.len());
1953        buf[..len].clone_from_slice(&other[..len]);
1954        Self::new_from_array(buf)
1955    }
1956    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
1957        unsafe { std::mem::transmute(buf) }
1958    }
1959    pub fn as_slice(&self) -> &[u8] {
1960        unsafe {
1961            let ptr: *const u8 = std::mem::transmute(self as *const Self);
1962            std::slice::from_raw_parts(ptr, Self::len())
1963        }
1964    }
1965    pub fn from_slice(buf: &[u8]) -> &Self {
1966        assert!(buf.len() >= Self::len());
1967        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1968        unsafe { std::mem::transmute(buf.as_ptr()) }
1969    }
1970    pub fn as_array(&self) -> &[u8; 20usize] {
1971        unsafe { std::mem::transmute(self) }
1972    }
1973    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
1974        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
1975        unsafe { std::mem::transmute(buf) }
1976    }
1977    pub fn into_array(self) -> [u8; 20usize] {
1978        unsafe { std::mem::transmute(self) }
1979    }
1980    pub const fn len() -> usize {
1981        const _: () = assert!(std::mem::size_of::<TcSfqQopt>() == 20usize);
1982        20usize
1983    }
1984}
1985#[derive(Debug)]
1986#[repr(C, packed(4))]
1987pub struct TcSfqredStats {
1988    #[doc = "Early drops, below max threshold"]
1989    pub prob_drop: u32,
1990    #[doc = "Early drops, after max threshold"]
1991    pub forced_drop: u32,
1992    #[doc = "Marked packets, below max threshold"]
1993    pub prob_mark: u32,
1994    #[doc = "Marked packets, after max threshold"]
1995    pub forced_mark: u32,
1996    #[doc = "Marked packets, below max threshold"]
1997    pub prob_mark_head: u32,
1998    #[doc = "Marked packets, after max threshold"]
1999    pub forced_mark_head: u32,
2000}
2001impl Clone for TcSfqredStats {
2002    fn clone(&self) -> Self {
2003        Self::new_from_array(*self.as_array())
2004    }
2005}
2006#[doc = "Create zero-initialized struct"]
2007impl Default for TcSfqredStats {
2008    fn default() -> Self {
2009        Self::new()
2010    }
2011}
2012impl TcSfqredStats {
2013    #[doc = "Create zero-initialized struct"]
2014    pub fn new() -> Self {
2015        Self::new_from_array([0u8; Self::len()])
2016    }
2017    #[doc = "Copy from contents from slice"]
2018    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2019        if other.len() != Self::len() {
2020            return None;
2021        }
2022        let mut buf = [0u8; Self::len()];
2023        buf.clone_from_slice(other);
2024        Some(Self::new_from_array(buf))
2025    }
2026    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2027    pub fn new_from_zeroed(other: &[u8]) -> Self {
2028        let mut buf = [0u8; Self::len()];
2029        let len = buf.len().min(other.len());
2030        buf[..len].clone_from_slice(&other[..len]);
2031        Self::new_from_array(buf)
2032    }
2033    pub fn new_from_array(buf: [u8; 24usize]) -> Self {
2034        unsafe { std::mem::transmute(buf) }
2035    }
2036    pub fn as_slice(&self) -> &[u8] {
2037        unsafe {
2038            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2039            std::slice::from_raw_parts(ptr, Self::len())
2040        }
2041    }
2042    pub fn from_slice(buf: &[u8]) -> &Self {
2043        assert!(buf.len() >= Self::len());
2044        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2045        unsafe { std::mem::transmute(buf.as_ptr()) }
2046    }
2047    pub fn as_array(&self) -> &[u8; 24usize] {
2048        unsafe { std::mem::transmute(self) }
2049    }
2050    pub fn from_array(buf: &[u8; 24usize]) -> &Self {
2051        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2052        unsafe { std::mem::transmute(buf) }
2053    }
2054    pub fn into_array(self) -> [u8; 24usize] {
2055        unsafe { std::mem::transmute(self) }
2056    }
2057    pub const fn len() -> usize {
2058        const _: () = assert!(std::mem::size_of::<TcSfqredStats>() == 24usize);
2059        24usize
2060    }
2061}
2062#[repr(C, packed(4))]
2063pub struct TcSfqQoptV1 {
2064    pub v0: TcSfqQopt,
2065    #[doc = "Maximum number of packets per flow"]
2066    pub depth: u32,
2067    pub headdrop: u32,
2068    #[doc = "HARD maximal flow queue length in bytes"]
2069    pub limit: u32,
2070    #[doc = "Min average length threshold in bytes"]
2071    pub qth_min: u32,
2072    #[doc = "Max average length threshold in bytes"]
2073    pub qth_max: u32,
2074    #[doc = "log(W)"]
2075    pub Wlog: u8,
2076    #[doc = "log(P\\_max / (qth\\-max \\- qth\\-min))"]
2077    pub Plog: u8,
2078    #[doc = "Cell size for idle damping"]
2079    pub Scell_log: u8,
2080    pub flags: u8,
2081    #[doc = "probability, high resolution"]
2082    pub max_P: u32,
2083    pub stats: TcSfqredStats,
2084}
2085impl Clone for TcSfqQoptV1 {
2086    fn clone(&self) -> Self {
2087        Self::new_from_array(*self.as_array())
2088    }
2089}
2090#[doc = "Create zero-initialized struct"]
2091impl Default for TcSfqQoptV1 {
2092    fn default() -> Self {
2093        Self::new()
2094    }
2095}
2096impl TcSfqQoptV1 {
2097    #[doc = "Create zero-initialized struct"]
2098    pub fn new() -> Self {
2099        Self::new_from_array([0u8; Self::len()])
2100    }
2101    #[doc = "Copy from contents from slice"]
2102    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2103        if other.len() != Self::len() {
2104            return None;
2105        }
2106        let mut buf = [0u8; Self::len()];
2107        buf.clone_from_slice(other);
2108        Some(Self::new_from_array(buf))
2109    }
2110    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2111    pub fn new_from_zeroed(other: &[u8]) -> Self {
2112        let mut buf = [0u8; Self::len()];
2113        let len = buf.len().min(other.len());
2114        buf[..len].clone_from_slice(&other[..len]);
2115        Self::new_from_array(buf)
2116    }
2117    pub fn new_from_array(buf: [u8; 72usize]) -> Self {
2118        unsafe { std::mem::transmute(buf) }
2119    }
2120    pub fn as_slice(&self) -> &[u8] {
2121        unsafe {
2122            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2123            std::slice::from_raw_parts(ptr, Self::len())
2124        }
2125    }
2126    pub fn from_slice(buf: &[u8]) -> &Self {
2127        assert!(buf.len() >= Self::len());
2128        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2129        unsafe { std::mem::transmute(buf.as_ptr()) }
2130    }
2131    pub fn as_array(&self) -> &[u8; 72usize] {
2132        unsafe { std::mem::transmute(self) }
2133    }
2134    pub fn from_array(buf: &[u8; 72usize]) -> &Self {
2135        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2136        unsafe { std::mem::transmute(buf) }
2137    }
2138    pub fn into_array(self) -> [u8; 72usize] {
2139        unsafe { std::mem::transmute(self) }
2140    }
2141    pub const fn len() -> usize {
2142        const _: () = assert!(std::mem::size_of::<TcSfqQoptV1>() == 72usize);
2143        72usize
2144    }
2145}
2146impl std::fmt::Debug for TcSfqQoptV1 {
2147    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2148        fmt.debug_struct("TcSfqQoptV1")
2149            .field("v0", &self.v0)
2150            .field("depth", &self.depth)
2151            .field("headdrop", &self.headdrop)
2152            .field("limit", &self.limit)
2153            .field("qth_min", &self.qth_min)
2154            .field("qth_max", &self.qth_max)
2155            .field("Wlog", &self.Wlog)
2156            .field("Plog", &self.Plog)
2157            .field("Scell_log", &self.Scell_log)
2158            .field("flags", &self.flags)
2159            .field("max_P", &self.max_P)
2160            .field("stats", &self.stats)
2161            .finish()
2162    }
2163}
2164#[repr(C, packed(4))]
2165pub struct TcRatespec {
2166    pub cell_log: u8,
2167    pub linklayer: u8,
2168    pub overhead: u8,
2169    pub cell_align: u8,
2170    pub mpu: u8,
2171    pub _pad_5: [u8; 3usize],
2172    pub rate: u32,
2173}
2174impl Clone for TcRatespec {
2175    fn clone(&self) -> Self {
2176        Self::new_from_array(*self.as_array())
2177    }
2178}
2179#[doc = "Create zero-initialized struct"]
2180impl Default for TcRatespec {
2181    fn default() -> Self {
2182        Self::new()
2183    }
2184}
2185impl TcRatespec {
2186    #[doc = "Create zero-initialized struct"]
2187    pub fn new() -> Self {
2188        Self::new_from_array([0u8; Self::len()])
2189    }
2190    #[doc = "Copy from contents from slice"]
2191    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2192        if other.len() != Self::len() {
2193            return None;
2194        }
2195        let mut buf = [0u8; Self::len()];
2196        buf.clone_from_slice(other);
2197        Some(Self::new_from_array(buf))
2198    }
2199    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2200    pub fn new_from_zeroed(other: &[u8]) -> Self {
2201        let mut buf = [0u8; Self::len()];
2202        let len = buf.len().min(other.len());
2203        buf[..len].clone_from_slice(&other[..len]);
2204        Self::new_from_array(buf)
2205    }
2206    pub fn new_from_array(buf: [u8; 12usize]) -> Self {
2207        unsafe { std::mem::transmute(buf) }
2208    }
2209    pub fn as_slice(&self) -> &[u8] {
2210        unsafe {
2211            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2212            std::slice::from_raw_parts(ptr, Self::len())
2213        }
2214    }
2215    pub fn from_slice(buf: &[u8]) -> &Self {
2216        assert!(buf.len() >= Self::len());
2217        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2218        unsafe { std::mem::transmute(buf.as_ptr()) }
2219    }
2220    pub fn as_array(&self) -> &[u8; 12usize] {
2221        unsafe { std::mem::transmute(self) }
2222    }
2223    pub fn from_array(buf: &[u8; 12usize]) -> &Self {
2224        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2225        unsafe { std::mem::transmute(buf) }
2226    }
2227    pub fn into_array(self) -> [u8; 12usize] {
2228        unsafe { std::mem::transmute(self) }
2229    }
2230    pub const fn len() -> usize {
2231        const _: () = assert!(std::mem::size_of::<TcRatespec>() == 12usize);
2232        12usize
2233    }
2234}
2235impl std::fmt::Debug for TcRatespec {
2236    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2237        fmt.debug_struct("TcRatespec")
2238            .field("cell_log", &self.cell_log)
2239            .field("linklayer", &self.linklayer)
2240            .field("overhead", &self.overhead)
2241            .field("cell_align", &self.cell_align)
2242            .field("mpu", &self.mpu)
2243            .field("rate", &self.rate)
2244            .finish()
2245    }
2246}
2247#[repr(C, packed(4))]
2248pub struct TcTbfQopt {
2249    pub rate: TcRatespec,
2250    pub peakrate: TcRatespec,
2251    pub limit: u32,
2252    pub buffer: u32,
2253    pub mtu: u32,
2254}
2255impl Clone for TcTbfQopt {
2256    fn clone(&self) -> Self {
2257        Self::new_from_array(*self.as_array())
2258    }
2259}
2260#[doc = "Create zero-initialized struct"]
2261impl Default for TcTbfQopt {
2262    fn default() -> Self {
2263        Self::new()
2264    }
2265}
2266impl TcTbfQopt {
2267    #[doc = "Create zero-initialized struct"]
2268    pub fn new() -> Self {
2269        Self::new_from_array([0u8; Self::len()])
2270    }
2271    #[doc = "Copy from contents from slice"]
2272    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2273        if other.len() != Self::len() {
2274            return None;
2275        }
2276        let mut buf = [0u8; Self::len()];
2277        buf.clone_from_slice(other);
2278        Some(Self::new_from_array(buf))
2279    }
2280    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2281    pub fn new_from_zeroed(other: &[u8]) -> Self {
2282        let mut buf = [0u8; Self::len()];
2283        let len = buf.len().min(other.len());
2284        buf[..len].clone_from_slice(&other[..len]);
2285        Self::new_from_array(buf)
2286    }
2287    pub fn new_from_array(buf: [u8; 36usize]) -> Self {
2288        unsafe { std::mem::transmute(buf) }
2289    }
2290    pub fn as_slice(&self) -> &[u8] {
2291        unsafe {
2292            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2293            std::slice::from_raw_parts(ptr, Self::len())
2294        }
2295    }
2296    pub fn from_slice(buf: &[u8]) -> &Self {
2297        assert!(buf.len() >= Self::len());
2298        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2299        unsafe { std::mem::transmute(buf.as_ptr()) }
2300    }
2301    pub fn as_array(&self) -> &[u8; 36usize] {
2302        unsafe { std::mem::transmute(self) }
2303    }
2304    pub fn from_array(buf: &[u8; 36usize]) -> &Self {
2305        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2306        unsafe { std::mem::transmute(buf) }
2307    }
2308    pub fn into_array(self) -> [u8; 36usize] {
2309        unsafe { std::mem::transmute(self) }
2310    }
2311    pub const fn len() -> usize {
2312        const _: () = assert!(std::mem::size_of::<TcTbfQopt>() == 36usize);
2313        36usize
2314    }
2315}
2316impl std::fmt::Debug for TcTbfQopt {
2317    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2318        fmt.debug_struct("TcTbfQopt")
2319            .field("rate", &self.rate)
2320            .field("peakrate", &self.peakrate)
2321            .field("limit", &self.limit)
2322            .field("buffer", &self.buffer)
2323            .field("mtu", &self.mtu)
2324            .finish()
2325    }
2326}
2327#[derive(Debug)]
2328#[repr(C, packed(4))]
2329pub struct TcSizespec {
2330    pub cell_log: u8,
2331    pub size_log: u8,
2332    pub cell_align: i16,
2333    pub overhead: i32,
2334    pub linklayer: u32,
2335    pub mpu: u32,
2336    pub mtu: u32,
2337    pub tsize: u32,
2338}
2339impl Clone for TcSizespec {
2340    fn clone(&self) -> Self {
2341        Self::new_from_array(*self.as_array())
2342    }
2343}
2344#[doc = "Create zero-initialized struct"]
2345impl Default for TcSizespec {
2346    fn default() -> Self {
2347        Self::new()
2348    }
2349}
2350impl TcSizespec {
2351    #[doc = "Create zero-initialized struct"]
2352    pub fn new() -> Self {
2353        Self::new_from_array([0u8; Self::len()])
2354    }
2355    #[doc = "Copy from contents from slice"]
2356    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2357        if other.len() != Self::len() {
2358            return None;
2359        }
2360        let mut buf = [0u8; Self::len()];
2361        buf.clone_from_slice(other);
2362        Some(Self::new_from_array(buf))
2363    }
2364    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2365    pub fn new_from_zeroed(other: &[u8]) -> Self {
2366        let mut buf = [0u8; Self::len()];
2367        let len = buf.len().min(other.len());
2368        buf[..len].clone_from_slice(&other[..len]);
2369        Self::new_from_array(buf)
2370    }
2371    pub fn new_from_array(buf: [u8; 24usize]) -> Self {
2372        unsafe { std::mem::transmute(buf) }
2373    }
2374    pub fn as_slice(&self) -> &[u8] {
2375        unsafe {
2376            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2377            std::slice::from_raw_parts(ptr, Self::len())
2378        }
2379    }
2380    pub fn from_slice(buf: &[u8]) -> &Self {
2381        assert!(buf.len() >= Self::len());
2382        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2383        unsafe { std::mem::transmute(buf.as_ptr()) }
2384    }
2385    pub fn as_array(&self) -> &[u8; 24usize] {
2386        unsafe { std::mem::transmute(self) }
2387    }
2388    pub fn from_array(buf: &[u8; 24usize]) -> &Self {
2389        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2390        unsafe { std::mem::transmute(buf) }
2391    }
2392    pub fn into_array(self) -> [u8; 24usize] {
2393        unsafe { std::mem::transmute(self) }
2394    }
2395    pub const fn len() -> usize {
2396        const _: () = assert!(std::mem::size_of::<TcSizespec>() == 24usize);
2397        24usize
2398    }
2399}
2400#[derive(Debug)]
2401#[repr(C, packed(4))]
2402pub struct GnetEstimator {
2403    #[doc = "Sampling period"]
2404    pub interval: i8,
2405    #[doc = "The log() of measurement window weight"]
2406    pub ewma_log: u8,
2407}
2408impl Clone for GnetEstimator {
2409    fn clone(&self) -> Self {
2410        Self::new_from_array(*self.as_array())
2411    }
2412}
2413#[doc = "Create zero-initialized struct"]
2414impl Default for GnetEstimator {
2415    fn default() -> Self {
2416        Self::new()
2417    }
2418}
2419impl GnetEstimator {
2420    #[doc = "Create zero-initialized struct"]
2421    pub fn new() -> Self {
2422        Self::new_from_array([0u8; Self::len()])
2423    }
2424    #[doc = "Copy from contents from slice"]
2425    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2426        if other.len() != Self::len() {
2427            return None;
2428        }
2429        let mut buf = [0u8; Self::len()];
2430        buf.clone_from_slice(other);
2431        Some(Self::new_from_array(buf))
2432    }
2433    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2434    pub fn new_from_zeroed(other: &[u8]) -> Self {
2435        let mut buf = [0u8; Self::len()];
2436        let len = buf.len().min(other.len());
2437        buf[..len].clone_from_slice(&other[..len]);
2438        Self::new_from_array(buf)
2439    }
2440    pub fn new_from_array(buf: [u8; 2usize]) -> Self {
2441        unsafe { std::mem::transmute(buf) }
2442    }
2443    pub fn as_slice(&self) -> &[u8] {
2444        unsafe {
2445            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2446            std::slice::from_raw_parts(ptr, Self::len())
2447        }
2448    }
2449    pub fn from_slice(buf: &[u8]) -> &Self {
2450        assert!(buf.len() >= Self::len());
2451        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2452        unsafe { std::mem::transmute(buf.as_ptr()) }
2453    }
2454    pub fn as_array(&self) -> &[u8; 2usize] {
2455        unsafe { std::mem::transmute(self) }
2456    }
2457    pub fn from_array(buf: &[u8; 2usize]) -> &Self {
2458        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2459        unsafe { std::mem::transmute(buf) }
2460    }
2461    pub fn into_array(self) -> [u8; 2usize] {
2462        unsafe { std::mem::transmute(self) }
2463    }
2464    pub const fn len() -> usize {
2465        const _: () = assert!(std::mem::size_of::<GnetEstimator>() == 2usize);
2466        2usize
2467    }
2468}
2469#[derive(Debug)]
2470#[repr(C, packed(4))]
2471pub struct TcChokeXstats {
2472    #[doc = "Early drops"]
2473    pub early: u32,
2474    #[doc = "Drops due to queue limits"]
2475    pub pdrop: u32,
2476    #[doc = "Drops due to drop() calls"]
2477    pub other: u32,
2478    #[doc = "Marked packets"]
2479    pub marked: u32,
2480    #[doc = "Drops due to flow match"]
2481    pub matched: u32,
2482}
2483impl Clone for TcChokeXstats {
2484    fn clone(&self) -> Self {
2485        Self::new_from_array(*self.as_array())
2486    }
2487}
2488#[doc = "Create zero-initialized struct"]
2489impl Default for TcChokeXstats {
2490    fn default() -> Self {
2491        Self::new()
2492    }
2493}
2494impl TcChokeXstats {
2495    #[doc = "Create zero-initialized struct"]
2496    pub fn new() -> Self {
2497        Self::new_from_array([0u8; Self::len()])
2498    }
2499    #[doc = "Copy from contents from slice"]
2500    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2501        if other.len() != Self::len() {
2502            return None;
2503        }
2504        let mut buf = [0u8; Self::len()];
2505        buf.clone_from_slice(other);
2506        Some(Self::new_from_array(buf))
2507    }
2508    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2509    pub fn new_from_zeroed(other: &[u8]) -> Self {
2510        let mut buf = [0u8; Self::len()];
2511        let len = buf.len().min(other.len());
2512        buf[..len].clone_from_slice(&other[..len]);
2513        Self::new_from_array(buf)
2514    }
2515    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
2516        unsafe { std::mem::transmute(buf) }
2517    }
2518    pub fn as_slice(&self) -> &[u8] {
2519        unsafe {
2520            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2521            std::slice::from_raw_parts(ptr, Self::len())
2522        }
2523    }
2524    pub fn from_slice(buf: &[u8]) -> &Self {
2525        assert!(buf.len() >= Self::len());
2526        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2527        unsafe { std::mem::transmute(buf.as_ptr()) }
2528    }
2529    pub fn as_array(&self) -> &[u8; 20usize] {
2530        unsafe { std::mem::transmute(self) }
2531    }
2532    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
2533        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2534        unsafe { std::mem::transmute(buf) }
2535    }
2536    pub fn into_array(self) -> [u8; 20usize] {
2537        unsafe { std::mem::transmute(self) }
2538    }
2539    pub const fn len() -> usize {
2540        const _: () = assert!(std::mem::size_of::<TcChokeXstats>() == 20usize);
2541        20usize
2542    }
2543}
2544#[derive(Debug)]
2545#[repr(C, packed(4))]
2546pub struct TcCodelXstats {
2547    #[doc = "Largest packet we've seen so far"]
2548    pub maxpacket: u32,
2549    #[doc = "How many drops we've done since the last time we entered dropping\nstate\n"]
2550    pub count: u32,
2551    #[doc = "Count at entry to dropping state"]
2552    pub lastcount: u32,
2553    #[doc = "in\\-queue delay seen by most recently dequeued packet"]
2554    pub ldelay: u32,
2555    #[doc = "Time to drop next packet"]
2556    pub drop_next: i32,
2557    #[doc = "Number of times max qdisc packet limit was hit"]
2558    pub drop_overlimit: u32,
2559    #[doc = "Number of packets we've ECN marked instead of dropped"]
2560    pub ecn_mark: u32,
2561    #[doc = "Are we in a dropping state?"]
2562    pub dropping: u32,
2563    #[doc = "Number of CE marked packets because of ce\\-threshold"]
2564    pub ce_mark: u32,
2565}
2566impl Clone for TcCodelXstats {
2567    fn clone(&self) -> Self {
2568        Self::new_from_array(*self.as_array())
2569    }
2570}
2571#[doc = "Create zero-initialized struct"]
2572impl Default for TcCodelXstats {
2573    fn default() -> Self {
2574        Self::new()
2575    }
2576}
2577impl TcCodelXstats {
2578    #[doc = "Create zero-initialized struct"]
2579    pub fn new() -> Self {
2580        Self::new_from_array([0u8; Self::len()])
2581    }
2582    #[doc = "Copy from contents from slice"]
2583    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2584        if other.len() != Self::len() {
2585            return None;
2586        }
2587        let mut buf = [0u8; Self::len()];
2588        buf.clone_from_slice(other);
2589        Some(Self::new_from_array(buf))
2590    }
2591    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2592    pub fn new_from_zeroed(other: &[u8]) -> Self {
2593        let mut buf = [0u8; Self::len()];
2594        let len = buf.len().min(other.len());
2595        buf[..len].clone_from_slice(&other[..len]);
2596        Self::new_from_array(buf)
2597    }
2598    pub fn new_from_array(buf: [u8; 36usize]) -> Self {
2599        unsafe { std::mem::transmute(buf) }
2600    }
2601    pub fn as_slice(&self) -> &[u8] {
2602        unsafe {
2603            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2604            std::slice::from_raw_parts(ptr, Self::len())
2605        }
2606    }
2607    pub fn from_slice(buf: &[u8]) -> &Self {
2608        assert!(buf.len() >= Self::len());
2609        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2610        unsafe { std::mem::transmute(buf.as_ptr()) }
2611    }
2612    pub fn as_array(&self) -> &[u8; 36usize] {
2613        unsafe { std::mem::transmute(self) }
2614    }
2615    pub fn from_array(buf: &[u8; 36usize]) -> &Self {
2616        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2617        unsafe { std::mem::transmute(buf) }
2618    }
2619    pub fn into_array(self) -> [u8; 36usize] {
2620        unsafe { std::mem::transmute(self) }
2621    }
2622    pub const fn len() -> usize {
2623        const _: () = assert!(std::mem::size_of::<TcCodelXstats>() == 36usize);
2624        36usize
2625    }
2626}
2627#[derive(Debug)]
2628#[repr(C, packed(4))]
2629pub struct TcFqCodelXstats {
2630    pub r#type: u32,
2631    #[doc = "Largest packet we've seen so far"]
2632    pub maxpacket: u32,
2633    #[doc = "Number of times max qdisc packet limit was hit"]
2634    pub drop_overlimit: u32,
2635    #[doc = "Number of packets we ECN marked instead of being dropped"]
2636    pub ecn_mark: u32,
2637    #[doc = "Number of times packets created a new flow"]
2638    pub new_flow_count: u32,
2639    #[doc = "Count of flows in new list"]
2640    pub new_flows_len: u32,
2641    #[doc = "Count of flows in old list"]
2642    pub old_flows_len: u32,
2643    #[doc = "Packets above ce\\-threshold"]
2644    pub ce_mark: u32,
2645    #[doc = "Memory usage in bytes"]
2646    pub memory_usage: u32,
2647    pub drop_overmemory: u32,
2648}
2649impl Clone for TcFqCodelXstats {
2650    fn clone(&self) -> Self {
2651        Self::new_from_array(*self.as_array())
2652    }
2653}
2654#[doc = "Create zero-initialized struct"]
2655impl Default for TcFqCodelXstats {
2656    fn default() -> Self {
2657        Self::new()
2658    }
2659}
2660impl TcFqCodelXstats {
2661    #[doc = "Create zero-initialized struct"]
2662    pub fn new() -> Self {
2663        Self::new_from_array([0u8; Self::len()])
2664    }
2665    #[doc = "Copy from contents from slice"]
2666    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2667        if other.len() != Self::len() {
2668            return None;
2669        }
2670        let mut buf = [0u8; Self::len()];
2671        buf.clone_from_slice(other);
2672        Some(Self::new_from_array(buf))
2673    }
2674    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2675    pub fn new_from_zeroed(other: &[u8]) -> Self {
2676        let mut buf = [0u8; Self::len()];
2677        let len = buf.len().min(other.len());
2678        buf[..len].clone_from_slice(&other[..len]);
2679        Self::new_from_array(buf)
2680    }
2681    pub fn new_from_array(buf: [u8; 40usize]) -> Self {
2682        unsafe { std::mem::transmute(buf) }
2683    }
2684    pub fn as_slice(&self) -> &[u8] {
2685        unsafe {
2686            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2687            std::slice::from_raw_parts(ptr, Self::len())
2688        }
2689    }
2690    pub fn from_slice(buf: &[u8]) -> &Self {
2691        assert!(buf.len() >= Self::len());
2692        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2693        unsafe { std::mem::transmute(buf.as_ptr()) }
2694    }
2695    pub fn as_array(&self) -> &[u8; 40usize] {
2696        unsafe { std::mem::transmute(self) }
2697    }
2698    pub fn from_array(buf: &[u8; 40usize]) -> &Self {
2699        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2700        unsafe { std::mem::transmute(buf) }
2701    }
2702    pub fn into_array(self) -> [u8; 40usize] {
2703        unsafe { std::mem::transmute(self) }
2704    }
2705    pub const fn len() -> usize {
2706        const _: () = assert!(std::mem::size_of::<TcFqCodelXstats>() == 40usize);
2707        40usize
2708    }
2709}
2710#[derive(Debug)]
2711#[repr(C, packed(4))]
2712pub struct TcDualpi2Xstats {
2713    #[doc = "Current base PI probability"]
2714    pub prob: u32,
2715    #[doc = "Current C\\-queue delay in microseconds"]
2716    pub delay_c: u32,
2717    #[doc = "Current L\\-queue delay in microseconds"]
2718    pub delay_l: u32,
2719    #[doc = "Number of packets enqueued in the C\\-queue"]
2720    pub pkts_in_c: u32,
2721    #[doc = "Number of packets enqueued in the L\\-queue"]
2722    pub pkts_in_l: u32,
2723    #[doc = "Maximum number of packets seen by the DualPI2"]
2724    pub maxq: u32,
2725    #[doc = "All packets marked with ECN"]
2726    pub ecn_mark: u32,
2727    #[doc = "Only packets marked with ECN due to L\\-queue step AQM"]
2728    pub step_mark: u32,
2729    #[doc = "Current credit value for WRR"]
2730    pub credit: i32,
2731    #[doc = "Memory used in bytes by the DualPI2"]
2732    pub memory_used: u32,
2733    #[doc = "Maximum memory used in bytes by the DualPI2"]
2734    pub max_memory_used: u32,
2735    #[doc = "Memory limit in bytes"]
2736    pub memory_limit: u32,
2737}
2738impl Clone for TcDualpi2Xstats {
2739    fn clone(&self) -> Self {
2740        Self::new_from_array(*self.as_array())
2741    }
2742}
2743#[doc = "Create zero-initialized struct"]
2744impl Default for TcDualpi2Xstats {
2745    fn default() -> Self {
2746        Self::new()
2747    }
2748}
2749impl TcDualpi2Xstats {
2750    #[doc = "Create zero-initialized struct"]
2751    pub fn new() -> Self {
2752        Self::new_from_array([0u8; Self::len()])
2753    }
2754    #[doc = "Copy from contents from slice"]
2755    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2756        if other.len() != Self::len() {
2757            return None;
2758        }
2759        let mut buf = [0u8; Self::len()];
2760        buf.clone_from_slice(other);
2761        Some(Self::new_from_array(buf))
2762    }
2763    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2764    pub fn new_from_zeroed(other: &[u8]) -> Self {
2765        let mut buf = [0u8; Self::len()];
2766        let len = buf.len().min(other.len());
2767        buf[..len].clone_from_slice(&other[..len]);
2768        Self::new_from_array(buf)
2769    }
2770    pub fn new_from_array(buf: [u8; 48usize]) -> Self {
2771        unsafe { std::mem::transmute(buf) }
2772    }
2773    pub fn as_slice(&self) -> &[u8] {
2774        unsafe {
2775            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2776            std::slice::from_raw_parts(ptr, Self::len())
2777        }
2778    }
2779    pub fn from_slice(buf: &[u8]) -> &Self {
2780        assert!(buf.len() >= Self::len());
2781        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2782        unsafe { std::mem::transmute(buf.as_ptr()) }
2783    }
2784    pub fn as_array(&self) -> &[u8; 48usize] {
2785        unsafe { std::mem::transmute(self) }
2786    }
2787    pub fn from_array(buf: &[u8; 48usize]) -> &Self {
2788        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2789        unsafe { std::mem::transmute(buf) }
2790    }
2791    pub fn into_array(self) -> [u8; 48usize] {
2792        unsafe { std::mem::transmute(self) }
2793    }
2794    pub const fn len() -> usize {
2795        const _: () = assert!(std::mem::size_of::<TcDualpi2Xstats>() == 48usize);
2796        48usize
2797    }
2798}
2799#[derive(Debug)]
2800#[repr(C, packed(4))]
2801pub struct TcFqPieXstats {
2802    #[doc = "Total number of packets enqueued"]
2803    pub packets_in: u32,
2804    #[doc = "Packets dropped due to fq\\_pie\\_action"]
2805    pub dropped: u32,
2806    #[doc = "Dropped due to lack of space in queue"]
2807    pub overlimit: u32,
2808    #[doc = "Dropped due to lack of memory in queue"]
2809    pub overmemory: u32,
2810    #[doc = "Packets marked with ECN"]
2811    pub ecn_mark: u32,
2812    #[doc = "Count of new flows created by packets"]
2813    pub new_flow_count: u32,
2814    #[doc = "Count of flows in new list"]
2815    pub new_flows_len: u32,
2816    #[doc = "Count of flows in old list"]
2817    pub old_flows_len: u32,
2818    #[doc = "Total memory across all queues"]
2819    pub memory_usage: u32,
2820}
2821impl Clone for TcFqPieXstats {
2822    fn clone(&self) -> Self {
2823        Self::new_from_array(*self.as_array())
2824    }
2825}
2826#[doc = "Create zero-initialized struct"]
2827impl Default for TcFqPieXstats {
2828    fn default() -> Self {
2829        Self::new()
2830    }
2831}
2832impl TcFqPieXstats {
2833    #[doc = "Create zero-initialized struct"]
2834    pub fn new() -> Self {
2835        Self::new_from_array([0u8; Self::len()])
2836    }
2837    #[doc = "Copy from contents from slice"]
2838    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2839        if other.len() != Self::len() {
2840            return None;
2841        }
2842        let mut buf = [0u8; Self::len()];
2843        buf.clone_from_slice(other);
2844        Some(Self::new_from_array(buf))
2845    }
2846    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2847    pub fn new_from_zeroed(other: &[u8]) -> Self {
2848        let mut buf = [0u8; Self::len()];
2849        let len = buf.len().min(other.len());
2850        buf[..len].clone_from_slice(&other[..len]);
2851        Self::new_from_array(buf)
2852    }
2853    pub fn new_from_array(buf: [u8; 36usize]) -> Self {
2854        unsafe { std::mem::transmute(buf) }
2855    }
2856    pub fn as_slice(&self) -> &[u8] {
2857        unsafe {
2858            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2859            std::slice::from_raw_parts(ptr, Self::len())
2860        }
2861    }
2862    pub fn from_slice(buf: &[u8]) -> &Self {
2863        assert!(buf.len() >= Self::len());
2864        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2865        unsafe { std::mem::transmute(buf.as_ptr()) }
2866    }
2867    pub fn as_array(&self) -> &[u8; 36usize] {
2868        unsafe { std::mem::transmute(self) }
2869    }
2870    pub fn from_array(buf: &[u8; 36usize]) -> &Self {
2871        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2872        unsafe { std::mem::transmute(buf) }
2873    }
2874    pub fn into_array(self) -> [u8; 36usize] {
2875        unsafe { std::mem::transmute(self) }
2876    }
2877    pub const fn len() -> usize {
2878        const _: () = assert!(std::mem::size_of::<TcFqPieXstats>() == 36usize);
2879        36usize
2880    }
2881}
2882#[repr(C, packed(4))]
2883pub struct TcFqQdStats {
2884    pub gc_flows: u64,
2885    #[doc = "obsolete"]
2886    pub highprio_packets: u64,
2887    #[doc = "obsolete"]
2888    pub tcp_retrans: u64,
2889    pub throttled: u64,
2890    pub flows_plimit: u64,
2891    pub pkts_too_long: u64,
2892    pub allocation_errors: u64,
2893    pub time_next_delayed_flow: i64,
2894    pub flows: u32,
2895    pub inactive_flows: u32,
2896    pub throttled_flows: u32,
2897    pub unthrottle_latency_ns: u32,
2898    #[doc = "Packets above ce\\-threshold"]
2899    pub ce_mark: u64,
2900    pub horizon_drops: u64,
2901    pub horizon_caps: u64,
2902    pub fastpath_packets: u64,
2903    pub band_drops: [u8; 24usize],
2904    pub band_pkt_count: [u8; 12usize],
2905    pub _pad: [u8; 4usize],
2906}
2907impl Clone for TcFqQdStats {
2908    fn clone(&self) -> Self {
2909        Self::new_from_array(*self.as_array())
2910    }
2911}
2912#[doc = "Create zero-initialized struct"]
2913impl Default for TcFqQdStats {
2914    fn default() -> Self {
2915        Self::new()
2916    }
2917}
2918impl TcFqQdStats {
2919    #[doc = "Create zero-initialized struct"]
2920    pub fn new() -> Self {
2921        Self::new_from_array([0u8; Self::len()])
2922    }
2923    #[doc = "Copy from contents from slice"]
2924    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
2925        if other.len() != Self::len() {
2926            return None;
2927        }
2928        let mut buf = [0u8; Self::len()];
2929        buf.clone_from_slice(other);
2930        Some(Self::new_from_array(buf))
2931    }
2932    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
2933    pub fn new_from_zeroed(other: &[u8]) -> Self {
2934        let mut buf = [0u8; Self::len()];
2935        let len = buf.len().min(other.len());
2936        buf[..len].clone_from_slice(&other[..len]);
2937        Self::new_from_array(buf)
2938    }
2939    pub fn new_from_array(buf: [u8; 152usize]) -> Self {
2940        unsafe { std::mem::transmute(buf) }
2941    }
2942    pub fn as_slice(&self) -> &[u8] {
2943        unsafe {
2944            let ptr: *const u8 = std::mem::transmute(self as *const Self);
2945            std::slice::from_raw_parts(ptr, Self::len())
2946        }
2947    }
2948    pub fn from_slice(buf: &[u8]) -> &Self {
2949        assert!(buf.len() >= Self::len());
2950        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2951        unsafe { std::mem::transmute(buf.as_ptr()) }
2952    }
2953    pub fn as_array(&self) -> &[u8; 152usize] {
2954        unsafe { std::mem::transmute(self) }
2955    }
2956    pub fn from_array(buf: &[u8; 152usize]) -> &Self {
2957        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
2958        unsafe { std::mem::transmute(buf) }
2959    }
2960    pub fn into_array(self) -> [u8; 152usize] {
2961        unsafe { std::mem::transmute(self) }
2962    }
2963    pub const fn len() -> usize {
2964        const _: () = assert!(std::mem::size_of::<TcFqQdStats>() == 152usize);
2965        152usize
2966    }
2967}
2968impl std::fmt::Debug for TcFqQdStats {
2969    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2970        fmt.debug_struct("TcFqQdStats")
2971            .field("gc_flows", &{ self.gc_flows })
2972            .field("highprio_packets", &{ self.highprio_packets })
2973            .field("tcp_retrans", &{ self.tcp_retrans })
2974            .field("throttled", &{ self.throttled })
2975            .field("flows_plimit", &{ self.flows_plimit })
2976            .field("pkts_too_long", &{ self.pkts_too_long })
2977            .field("allocation_errors", &{ self.allocation_errors })
2978            .field("time_next_delayed_flow", &{ self.time_next_delayed_flow })
2979            .field("flows", &self.flows)
2980            .field("inactive_flows", &self.inactive_flows)
2981            .field("throttled_flows", &self.throttled_flows)
2982            .field("unthrottle_latency_ns", &self.unthrottle_latency_ns)
2983            .field("ce_mark", &{ self.ce_mark })
2984            .field("horizon_drops", &{ self.horizon_drops })
2985            .field("horizon_caps", &{ self.horizon_caps })
2986            .field("fastpath_packets", &{ self.fastpath_packets })
2987            .field("band_drops", &self.band_drops)
2988            .field("band_pkt_count", &self.band_pkt_count)
2989            .finish()
2990    }
2991}
2992#[derive(Debug)]
2993#[repr(C, packed(4))]
2994pub struct TcHhfXstats {
2995    #[doc = "Number of times max qdisc packet limit was hit"]
2996    pub drop_overlimit: u32,
2997    #[doc = "Number of times max heavy\\-hitters was hit"]
2998    pub hh_overlimit: u32,
2999    #[doc = "Number of captured heavy\\-hitters so far"]
3000    pub hh_tot_count: u32,
3001    #[doc = "Number of current heavy\\-hitters"]
3002    pub hh_cur_count: u32,
3003}
3004impl Clone for TcHhfXstats {
3005    fn clone(&self) -> Self {
3006        Self::new_from_array(*self.as_array())
3007    }
3008}
3009#[doc = "Create zero-initialized struct"]
3010impl Default for TcHhfXstats {
3011    fn default() -> Self {
3012        Self::new()
3013    }
3014}
3015impl TcHhfXstats {
3016    #[doc = "Create zero-initialized struct"]
3017    pub fn new() -> Self {
3018        Self::new_from_array([0u8; Self::len()])
3019    }
3020    #[doc = "Copy from contents from slice"]
3021    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3022        if other.len() != Self::len() {
3023            return None;
3024        }
3025        let mut buf = [0u8; Self::len()];
3026        buf.clone_from_slice(other);
3027        Some(Self::new_from_array(buf))
3028    }
3029    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3030    pub fn new_from_zeroed(other: &[u8]) -> Self {
3031        let mut buf = [0u8; Self::len()];
3032        let len = buf.len().min(other.len());
3033        buf[..len].clone_from_slice(&other[..len]);
3034        Self::new_from_array(buf)
3035    }
3036    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
3037        unsafe { std::mem::transmute(buf) }
3038    }
3039    pub fn as_slice(&self) -> &[u8] {
3040        unsafe {
3041            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3042            std::slice::from_raw_parts(ptr, Self::len())
3043        }
3044    }
3045    pub fn from_slice(buf: &[u8]) -> &Self {
3046        assert!(buf.len() >= Self::len());
3047        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3048        unsafe { std::mem::transmute(buf.as_ptr()) }
3049    }
3050    pub fn as_array(&self) -> &[u8; 16usize] {
3051        unsafe { std::mem::transmute(self) }
3052    }
3053    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
3054        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3055        unsafe { std::mem::transmute(buf) }
3056    }
3057    pub fn into_array(self) -> [u8; 16usize] {
3058        unsafe { std::mem::transmute(self) }
3059    }
3060    pub const fn len() -> usize {
3061        const _: () = assert!(std::mem::size_of::<TcHhfXstats>() == 16usize);
3062        16usize
3063    }
3064}
3065#[repr(C, packed(4))]
3066pub struct TcPieXstats {
3067    #[doc = "Current probability"]
3068    pub prob: u64,
3069    #[doc = "Current delay in ms"]
3070    pub delay: u32,
3071    #[doc = "Current average dq rate in bits/pie\\-time"]
3072    pub avg_dq_rate: u32,
3073    #[doc = "Is avg\\-dq\\-rate being calculated?"]
3074    pub dq_rate_estimating: u32,
3075    #[doc = "Total number of packets enqueued"]
3076    pub packets_in: u32,
3077    #[doc = "Packets dropped due to pie action"]
3078    pub dropped: u32,
3079    #[doc = "Dropped due to lack of space in queue"]
3080    pub overlimit: u32,
3081    #[doc = "Maximum queue size"]
3082    pub maxq: u32,
3083    #[doc = "Packets marked with ECN"]
3084    pub ecn_mark: u32,
3085}
3086impl Clone for TcPieXstats {
3087    fn clone(&self) -> Self {
3088        Self::new_from_array(*self.as_array())
3089    }
3090}
3091#[doc = "Create zero-initialized struct"]
3092impl Default for TcPieXstats {
3093    fn default() -> Self {
3094        Self::new()
3095    }
3096}
3097impl TcPieXstats {
3098    #[doc = "Create zero-initialized struct"]
3099    pub fn new() -> Self {
3100        Self::new_from_array([0u8; Self::len()])
3101    }
3102    #[doc = "Copy from contents from slice"]
3103    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3104        if other.len() != Self::len() {
3105            return None;
3106        }
3107        let mut buf = [0u8; Self::len()];
3108        buf.clone_from_slice(other);
3109        Some(Self::new_from_array(buf))
3110    }
3111    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3112    pub fn new_from_zeroed(other: &[u8]) -> Self {
3113        let mut buf = [0u8; Self::len()];
3114        let len = buf.len().min(other.len());
3115        buf[..len].clone_from_slice(&other[..len]);
3116        Self::new_from_array(buf)
3117    }
3118    pub fn new_from_array(buf: [u8; 40usize]) -> Self {
3119        unsafe { std::mem::transmute(buf) }
3120    }
3121    pub fn as_slice(&self) -> &[u8] {
3122        unsafe {
3123            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3124            std::slice::from_raw_parts(ptr, Self::len())
3125        }
3126    }
3127    pub fn from_slice(buf: &[u8]) -> &Self {
3128        assert!(buf.len() >= Self::len());
3129        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3130        unsafe { std::mem::transmute(buf.as_ptr()) }
3131    }
3132    pub fn as_array(&self) -> &[u8; 40usize] {
3133        unsafe { std::mem::transmute(self) }
3134    }
3135    pub fn from_array(buf: &[u8; 40usize]) -> &Self {
3136        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3137        unsafe { std::mem::transmute(buf) }
3138    }
3139    pub fn into_array(self) -> [u8; 40usize] {
3140        unsafe { std::mem::transmute(self) }
3141    }
3142    pub const fn len() -> usize {
3143        const _: () = assert!(std::mem::size_of::<TcPieXstats>() == 40usize);
3144        40usize
3145    }
3146}
3147impl std::fmt::Debug for TcPieXstats {
3148    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3149        fmt.debug_struct("TcPieXstats")
3150            .field("prob", &{ self.prob })
3151            .field("delay", &self.delay)
3152            .field("avg_dq_rate", &self.avg_dq_rate)
3153            .field("dq_rate_estimating", &self.dq_rate_estimating)
3154            .field("packets_in", &self.packets_in)
3155            .field("dropped", &self.dropped)
3156            .field("overlimit", &self.overlimit)
3157            .field("maxq", &self.maxq)
3158            .field("ecn_mark", &self.ecn_mark)
3159            .finish()
3160    }
3161}
3162#[derive(Debug)]
3163#[repr(C, packed(4))]
3164pub struct TcRedXstats {
3165    #[doc = "Early drops"]
3166    pub early: u32,
3167    #[doc = "Drops due to queue limits"]
3168    pub pdrop: u32,
3169    #[doc = "Drops due to drop() calls"]
3170    pub other: u32,
3171    #[doc = "Marked packets"]
3172    pub marked: u32,
3173}
3174impl Clone for TcRedXstats {
3175    fn clone(&self) -> Self {
3176        Self::new_from_array(*self.as_array())
3177    }
3178}
3179#[doc = "Create zero-initialized struct"]
3180impl Default for TcRedXstats {
3181    fn default() -> Self {
3182        Self::new()
3183    }
3184}
3185impl TcRedXstats {
3186    #[doc = "Create zero-initialized struct"]
3187    pub fn new() -> Self {
3188        Self::new_from_array([0u8; Self::len()])
3189    }
3190    #[doc = "Copy from contents from slice"]
3191    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3192        if other.len() != Self::len() {
3193            return None;
3194        }
3195        let mut buf = [0u8; Self::len()];
3196        buf.clone_from_slice(other);
3197        Some(Self::new_from_array(buf))
3198    }
3199    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3200    pub fn new_from_zeroed(other: &[u8]) -> Self {
3201        let mut buf = [0u8; Self::len()];
3202        let len = buf.len().min(other.len());
3203        buf[..len].clone_from_slice(&other[..len]);
3204        Self::new_from_array(buf)
3205    }
3206    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
3207        unsafe { std::mem::transmute(buf) }
3208    }
3209    pub fn as_slice(&self) -> &[u8] {
3210        unsafe {
3211            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3212            std::slice::from_raw_parts(ptr, Self::len())
3213        }
3214    }
3215    pub fn from_slice(buf: &[u8]) -> &Self {
3216        assert!(buf.len() >= Self::len());
3217        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3218        unsafe { std::mem::transmute(buf.as_ptr()) }
3219    }
3220    pub fn as_array(&self) -> &[u8; 16usize] {
3221        unsafe { std::mem::transmute(self) }
3222    }
3223    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
3224        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3225        unsafe { std::mem::transmute(buf) }
3226    }
3227    pub fn into_array(self) -> [u8; 16usize] {
3228        unsafe { std::mem::transmute(self) }
3229    }
3230    pub const fn len() -> usize {
3231        const _: () = assert!(std::mem::size_of::<TcRedXstats>() == 16usize);
3232        16usize
3233    }
3234}
3235#[derive(Debug)]
3236#[repr(C, packed(4))]
3237pub struct TcSfbXstats {
3238    pub earlydrop: u32,
3239    pub penaltydrop: u32,
3240    pub bucketdrop: u32,
3241    pub queuedrop: u32,
3242    #[doc = "drops in child qdisc"]
3243    pub childdrop: u32,
3244    pub marked: u32,
3245    pub maxqlen: u32,
3246    pub maxprob: u32,
3247    pub avgprob: u32,
3248}
3249impl Clone for TcSfbXstats {
3250    fn clone(&self) -> Self {
3251        Self::new_from_array(*self.as_array())
3252    }
3253}
3254#[doc = "Create zero-initialized struct"]
3255impl Default for TcSfbXstats {
3256    fn default() -> Self {
3257        Self::new()
3258    }
3259}
3260impl TcSfbXstats {
3261    #[doc = "Create zero-initialized struct"]
3262    pub fn new() -> Self {
3263        Self::new_from_array([0u8; Self::len()])
3264    }
3265    #[doc = "Copy from contents from slice"]
3266    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3267        if other.len() != Self::len() {
3268            return None;
3269        }
3270        let mut buf = [0u8; Self::len()];
3271        buf.clone_from_slice(other);
3272        Some(Self::new_from_array(buf))
3273    }
3274    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3275    pub fn new_from_zeroed(other: &[u8]) -> Self {
3276        let mut buf = [0u8; Self::len()];
3277        let len = buf.len().min(other.len());
3278        buf[..len].clone_from_slice(&other[..len]);
3279        Self::new_from_array(buf)
3280    }
3281    pub fn new_from_array(buf: [u8; 36usize]) -> Self {
3282        unsafe { std::mem::transmute(buf) }
3283    }
3284    pub fn as_slice(&self) -> &[u8] {
3285        unsafe {
3286            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3287            std::slice::from_raw_parts(ptr, Self::len())
3288        }
3289    }
3290    pub fn from_slice(buf: &[u8]) -> &Self {
3291        assert!(buf.len() >= Self::len());
3292        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3293        unsafe { std::mem::transmute(buf.as_ptr()) }
3294    }
3295    pub fn as_array(&self) -> &[u8; 36usize] {
3296        unsafe { std::mem::transmute(self) }
3297    }
3298    pub fn from_array(buf: &[u8; 36usize]) -> &Self {
3299        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3300        unsafe { std::mem::transmute(buf) }
3301    }
3302    pub fn into_array(self) -> [u8; 36usize] {
3303        unsafe { std::mem::transmute(self) }
3304    }
3305    pub const fn len() -> usize {
3306        const _: () = assert!(std::mem::size_of::<TcSfbXstats>() == 36usize);
3307        36usize
3308    }
3309}
3310#[derive(Debug)]
3311#[repr(C, packed(4))]
3312pub struct TcSfqXstats {
3313    pub allot: i32,
3314}
3315impl Clone for TcSfqXstats {
3316    fn clone(&self) -> Self {
3317        Self::new_from_array(*self.as_array())
3318    }
3319}
3320#[doc = "Create zero-initialized struct"]
3321impl Default for TcSfqXstats {
3322    fn default() -> Self {
3323        Self::new()
3324    }
3325}
3326impl TcSfqXstats {
3327    #[doc = "Create zero-initialized struct"]
3328    pub fn new() -> Self {
3329        Self::new_from_array([0u8; Self::len()])
3330    }
3331    #[doc = "Copy from contents from slice"]
3332    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3333        if other.len() != Self::len() {
3334            return None;
3335        }
3336        let mut buf = [0u8; Self::len()];
3337        buf.clone_from_slice(other);
3338        Some(Self::new_from_array(buf))
3339    }
3340    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3341    pub fn new_from_zeroed(other: &[u8]) -> Self {
3342        let mut buf = [0u8; Self::len()];
3343        let len = buf.len().min(other.len());
3344        buf[..len].clone_from_slice(&other[..len]);
3345        Self::new_from_array(buf)
3346    }
3347    pub fn new_from_array(buf: [u8; 4usize]) -> Self {
3348        unsafe { std::mem::transmute(buf) }
3349    }
3350    pub fn as_slice(&self) -> &[u8] {
3351        unsafe {
3352            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3353            std::slice::from_raw_parts(ptr, Self::len())
3354        }
3355    }
3356    pub fn from_slice(buf: &[u8]) -> &Self {
3357        assert!(buf.len() >= Self::len());
3358        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3359        unsafe { std::mem::transmute(buf.as_ptr()) }
3360    }
3361    pub fn as_array(&self) -> &[u8; 4usize] {
3362        unsafe { std::mem::transmute(self) }
3363    }
3364    pub fn from_array(buf: &[u8; 4usize]) -> &Self {
3365        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3366        unsafe { std::mem::transmute(buf) }
3367    }
3368    pub fn into_array(self) -> [u8; 4usize] {
3369        unsafe { std::mem::transmute(self) }
3370    }
3371    pub const fn len() -> usize {
3372        const _: () = assert!(std::mem::size_of::<TcSfqXstats>() == 4usize);
3373        4usize
3374    }
3375}
3376#[repr(C, packed(4))]
3377pub struct GnetStatsBasic {
3378    pub bytes: u64,
3379    pub packets: u32,
3380    pub _pad_12: [u8; 4usize],
3381}
3382impl Clone for GnetStatsBasic {
3383    fn clone(&self) -> Self {
3384        Self::new_from_array(*self.as_array())
3385    }
3386}
3387#[doc = "Create zero-initialized struct"]
3388impl Default for GnetStatsBasic {
3389    fn default() -> Self {
3390        Self::new()
3391    }
3392}
3393impl GnetStatsBasic {
3394    #[doc = "Create zero-initialized struct"]
3395    pub fn new() -> Self {
3396        Self::new_from_array([0u8; Self::len()])
3397    }
3398    #[doc = "Copy from contents from slice"]
3399    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3400        if other.len() != Self::len() {
3401            return None;
3402        }
3403        let mut buf = [0u8; Self::len()];
3404        buf.clone_from_slice(other);
3405        Some(Self::new_from_array(buf))
3406    }
3407    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3408    pub fn new_from_zeroed(other: &[u8]) -> Self {
3409        let mut buf = [0u8; Self::len()];
3410        let len = buf.len().min(other.len());
3411        buf[..len].clone_from_slice(&other[..len]);
3412        Self::new_from_array(buf)
3413    }
3414    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
3415        unsafe { std::mem::transmute(buf) }
3416    }
3417    pub fn as_slice(&self) -> &[u8] {
3418        unsafe {
3419            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3420            std::slice::from_raw_parts(ptr, Self::len())
3421        }
3422    }
3423    pub fn from_slice(buf: &[u8]) -> &Self {
3424        assert!(buf.len() >= Self::len());
3425        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3426        unsafe { std::mem::transmute(buf.as_ptr()) }
3427    }
3428    pub fn as_array(&self) -> &[u8; 16usize] {
3429        unsafe { std::mem::transmute(self) }
3430    }
3431    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
3432        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3433        unsafe { std::mem::transmute(buf) }
3434    }
3435    pub fn into_array(self) -> [u8; 16usize] {
3436        unsafe { std::mem::transmute(self) }
3437    }
3438    pub const fn len() -> usize {
3439        const _: () = assert!(std::mem::size_of::<GnetStatsBasic>() == 16usize);
3440        16usize
3441    }
3442}
3443impl std::fmt::Debug for GnetStatsBasic {
3444    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3445        fmt.debug_struct("GnetStatsBasic")
3446            .field("bytes", &{ self.bytes })
3447            .field("packets", &self.packets)
3448            .finish()
3449    }
3450}
3451#[derive(Debug)]
3452#[repr(C, packed(4))]
3453pub struct GnetStatsRateEst {
3454    pub bps: u32,
3455    pub pps: u32,
3456}
3457impl Clone for GnetStatsRateEst {
3458    fn clone(&self) -> Self {
3459        Self::new_from_array(*self.as_array())
3460    }
3461}
3462#[doc = "Create zero-initialized struct"]
3463impl Default for GnetStatsRateEst {
3464    fn default() -> Self {
3465        Self::new()
3466    }
3467}
3468impl GnetStatsRateEst {
3469    #[doc = "Create zero-initialized struct"]
3470    pub fn new() -> Self {
3471        Self::new_from_array([0u8; Self::len()])
3472    }
3473    #[doc = "Copy from contents from slice"]
3474    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3475        if other.len() != Self::len() {
3476            return None;
3477        }
3478        let mut buf = [0u8; Self::len()];
3479        buf.clone_from_slice(other);
3480        Some(Self::new_from_array(buf))
3481    }
3482    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3483    pub fn new_from_zeroed(other: &[u8]) -> Self {
3484        let mut buf = [0u8; Self::len()];
3485        let len = buf.len().min(other.len());
3486        buf[..len].clone_from_slice(&other[..len]);
3487        Self::new_from_array(buf)
3488    }
3489    pub fn new_from_array(buf: [u8; 8usize]) -> Self {
3490        unsafe { std::mem::transmute(buf) }
3491    }
3492    pub fn as_slice(&self) -> &[u8] {
3493        unsafe {
3494            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3495            std::slice::from_raw_parts(ptr, Self::len())
3496        }
3497    }
3498    pub fn from_slice(buf: &[u8]) -> &Self {
3499        assert!(buf.len() >= Self::len());
3500        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3501        unsafe { std::mem::transmute(buf.as_ptr()) }
3502    }
3503    pub fn as_array(&self) -> &[u8; 8usize] {
3504        unsafe { std::mem::transmute(self) }
3505    }
3506    pub fn from_array(buf: &[u8; 8usize]) -> &Self {
3507        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3508        unsafe { std::mem::transmute(buf) }
3509    }
3510    pub fn into_array(self) -> [u8; 8usize] {
3511        unsafe { std::mem::transmute(self) }
3512    }
3513    pub const fn len() -> usize {
3514        const _: () = assert!(std::mem::size_of::<GnetStatsRateEst>() == 8usize);
3515        8usize
3516    }
3517}
3518#[repr(C, packed(4))]
3519pub struct GnetStatsRateEst64 {
3520    pub bps: u64,
3521    pub pps: u64,
3522}
3523impl Clone for GnetStatsRateEst64 {
3524    fn clone(&self) -> Self {
3525        Self::new_from_array(*self.as_array())
3526    }
3527}
3528#[doc = "Create zero-initialized struct"]
3529impl Default for GnetStatsRateEst64 {
3530    fn default() -> Self {
3531        Self::new()
3532    }
3533}
3534impl GnetStatsRateEst64 {
3535    #[doc = "Create zero-initialized struct"]
3536    pub fn new() -> Self {
3537        Self::new_from_array([0u8; Self::len()])
3538    }
3539    #[doc = "Copy from contents from slice"]
3540    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3541        if other.len() != Self::len() {
3542            return None;
3543        }
3544        let mut buf = [0u8; Self::len()];
3545        buf.clone_from_slice(other);
3546        Some(Self::new_from_array(buf))
3547    }
3548    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3549    pub fn new_from_zeroed(other: &[u8]) -> Self {
3550        let mut buf = [0u8; Self::len()];
3551        let len = buf.len().min(other.len());
3552        buf[..len].clone_from_slice(&other[..len]);
3553        Self::new_from_array(buf)
3554    }
3555    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
3556        unsafe { std::mem::transmute(buf) }
3557    }
3558    pub fn as_slice(&self) -> &[u8] {
3559        unsafe {
3560            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3561            std::slice::from_raw_parts(ptr, Self::len())
3562        }
3563    }
3564    pub fn from_slice(buf: &[u8]) -> &Self {
3565        assert!(buf.len() >= Self::len());
3566        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3567        unsafe { std::mem::transmute(buf.as_ptr()) }
3568    }
3569    pub fn as_array(&self) -> &[u8; 16usize] {
3570        unsafe { std::mem::transmute(self) }
3571    }
3572    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
3573        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3574        unsafe { std::mem::transmute(buf) }
3575    }
3576    pub fn into_array(self) -> [u8; 16usize] {
3577        unsafe { std::mem::transmute(self) }
3578    }
3579    pub const fn len() -> usize {
3580        const _: () = assert!(std::mem::size_of::<GnetStatsRateEst64>() == 16usize);
3581        16usize
3582    }
3583}
3584impl std::fmt::Debug for GnetStatsRateEst64 {
3585    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3586        fmt.debug_struct("GnetStatsRateEst64")
3587            .field("bps", &{ self.bps })
3588            .field("pps", &{ self.pps })
3589            .finish()
3590    }
3591}
3592#[derive(Debug)]
3593#[repr(C, packed(4))]
3594pub struct GnetStatsQueue {
3595    pub qlen: u32,
3596    pub backlog: u32,
3597    pub drops: u32,
3598    pub requeues: u32,
3599    pub overlimits: u32,
3600}
3601impl Clone for GnetStatsQueue {
3602    fn clone(&self) -> Self {
3603        Self::new_from_array(*self.as_array())
3604    }
3605}
3606#[doc = "Create zero-initialized struct"]
3607impl Default for GnetStatsQueue {
3608    fn default() -> Self {
3609        Self::new()
3610    }
3611}
3612impl GnetStatsQueue {
3613    #[doc = "Create zero-initialized struct"]
3614    pub fn new() -> Self {
3615        Self::new_from_array([0u8; Self::len()])
3616    }
3617    #[doc = "Copy from contents from slice"]
3618    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3619        if other.len() != Self::len() {
3620            return None;
3621        }
3622        let mut buf = [0u8; Self::len()];
3623        buf.clone_from_slice(other);
3624        Some(Self::new_from_array(buf))
3625    }
3626    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3627    pub fn new_from_zeroed(other: &[u8]) -> Self {
3628        let mut buf = [0u8; Self::len()];
3629        let len = buf.len().min(other.len());
3630        buf[..len].clone_from_slice(&other[..len]);
3631        Self::new_from_array(buf)
3632    }
3633    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
3634        unsafe { std::mem::transmute(buf) }
3635    }
3636    pub fn as_slice(&self) -> &[u8] {
3637        unsafe {
3638            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3639            std::slice::from_raw_parts(ptr, Self::len())
3640        }
3641    }
3642    pub fn from_slice(buf: &[u8]) -> &Self {
3643        assert!(buf.len() >= Self::len());
3644        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3645        unsafe { std::mem::transmute(buf.as_ptr()) }
3646    }
3647    pub fn as_array(&self) -> &[u8; 20usize] {
3648        unsafe { std::mem::transmute(self) }
3649    }
3650    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
3651        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3652        unsafe { std::mem::transmute(buf) }
3653    }
3654    pub fn into_array(self) -> [u8; 20usize] {
3655        unsafe { std::mem::transmute(self) }
3656    }
3657    pub const fn len() -> usize {
3658        const _: () = assert!(std::mem::size_of::<GnetStatsQueue>() == 20usize);
3659        20usize
3660    }
3661}
3662#[repr(C, packed(4))]
3663pub struct TcU32Key {
3664    pub _mask_be: u32,
3665    pub _val_be: u32,
3666    pub off: i32,
3667    pub offmask: i32,
3668}
3669impl Clone for TcU32Key {
3670    fn clone(&self) -> Self {
3671        Self::new_from_array(*self.as_array())
3672    }
3673}
3674#[doc = "Create zero-initialized struct"]
3675impl Default for TcU32Key {
3676    fn default() -> Self {
3677        Self::new()
3678    }
3679}
3680impl TcU32Key {
3681    #[doc = "Create zero-initialized struct"]
3682    pub fn new() -> Self {
3683        Self::new_from_array([0u8; Self::len()])
3684    }
3685    #[doc = "Copy from contents from slice"]
3686    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3687        if other.len() != Self::len() {
3688            return None;
3689        }
3690        let mut buf = [0u8; Self::len()];
3691        buf.clone_from_slice(other);
3692        Some(Self::new_from_array(buf))
3693    }
3694    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3695    pub fn new_from_zeroed(other: &[u8]) -> Self {
3696        let mut buf = [0u8; Self::len()];
3697        let len = buf.len().min(other.len());
3698        buf[..len].clone_from_slice(&other[..len]);
3699        Self::new_from_array(buf)
3700    }
3701    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
3702        unsafe { std::mem::transmute(buf) }
3703    }
3704    pub fn as_slice(&self) -> &[u8] {
3705        unsafe {
3706            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3707            std::slice::from_raw_parts(ptr, Self::len())
3708        }
3709    }
3710    pub fn from_slice(buf: &[u8]) -> &Self {
3711        assert!(buf.len() >= Self::len());
3712        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3713        unsafe { std::mem::transmute(buf.as_ptr()) }
3714    }
3715    pub fn as_array(&self) -> &[u8; 16usize] {
3716        unsafe { std::mem::transmute(self) }
3717    }
3718    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
3719        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3720        unsafe { std::mem::transmute(buf) }
3721    }
3722    pub fn into_array(self) -> [u8; 16usize] {
3723        unsafe { std::mem::transmute(self) }
3724    }
3725    pub const fn len() -> usize {
3726        const _: () = assert!(std::mem::size_of::<TcU32Key>() == 16usize);
3727        16usize
3728    }
3729    pub fn mask(&self) -> u32 {
3730        u32::from_be(self._mask_be)
3731    }
3732    pub fn set_mask(&mut self, value: u32) {
3733        self._mask_be = value.to_be();
3734    }
3735    pub fn val(&self) -> u32 {
3736        u32::from_be(self._val_be)
3737    }
3738    pub fn set_val(&mut self, value: u32) {
3739        self._val_be = value.to_be();
3740    }
3741}
3742impl std::fmt::Debug for TcU32Key {
3743    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3744        fmt.debug_struct("TcU32Key")
3745            .field("mask", &self.mask())
3746            .field("val", &self.val())
3747            .field("off", &self.off)
3748            .field("offmask", &self.offmask)
3749            .finish()
3750    }
3751}
3752#[derive(Debug)]
3753#[repr(C, packed(4))]
3754pub struct TcU32Mark {
3755    pub val: u32,
3756    pub mask: u32,
3757    pub success: u32,
3758}
3759impl Clone for TcU32Mark {
3760    fn clone(&self) -> Self {
3761        Self::new_from_array(*self.as_array())
3762    }
3763}
3764#[doc = "Create zero-initialized struct"]
3765impl Default for TcU32Mark {
3766    fn default() -> Self {
3767        Self::new()
3768    }
3769}
3770impl TcU32Mark {
3771    #[doc = "Create zero-initialized struct"]
3772    pub fn new() -> Self {
3773        Self::new_from_array([0u8; Self::len()])
3774    }
3775    #[doc = "Copy from contents from slice"]
3776    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3777        if other.len() != Self::len() {
3778            return None;
3779        }
3780        let mut buf = [0u8; Self::len()];
3781        buf.clone_from_slice(other);
3782        Some(Self::new_from_array(buf))
3783    }
3784    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3785    pub fn new_from_zeroed(other: &[u8]) -> Self {
3786        let mut buf = [0u8; Self::len()];
3787        let len = buf.len().min(other.len());
3788        buf[..len].clone_from_slice(&other[..len]);
3789        Self::new_from_array(buf)
3790    }
3791    pub fn new_from_array(buf: [u8; 12usize]) -> Self {
3792        unsafe { std::mem::transmute(buf) }
3793    }
3794    pub fn as_slice(&self) -> &[u8] {
3795        unsafe {
3796            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3797            std::slice::from_raw_parts(ptr, Self::len())
3798        }
3799    }
3800    pub fn from_slice(buf: &[u8]) -> &Self {
3801        assert!(buf.len() >= Self::len());
3802        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3803        unsafe { std::mem::transmute(buf.as_ptr()) }
3804    }
3805    pub fn as_array(&self) -> &[u8; 12usize] {
3806        unsafe { std::mem::transmute(self) }
3807    }
3808    pub fn from_array(buf: &[u8; 12usize]) -> &Self {
3809        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3810        unsafe { std::mem::transmute(buf) }
3811    }
3812    pub fn into_array(self) -> [u8; 12usize] {
3813        unsafe { std::mem::transmute(self) }
3814    }
3815    pub const fn len() -> usize {
3816        const _: () = assert!(std::mem::size_of::<TcU32Mark>() == 12usize);
3817        12usize
3818    }
3819}
3820#[repr(C, packed(4))]
3821pub struct TcU32Sel {
3822    pub flags: u8,
3823    pub offshift: u8,
3824    pub nkeys: u8,
3825    pub _pad_3: [u8; 1usize],
3826    pub _offmask_be: u16,
3827    pub off: u16,
3828    pub offoff: i16,
3829    pub hoff: i16,
3830    pub _hmask_be: u32,
3831    pub keys: TcU32Key,
3832}
3833impl Clone for TcU32Sel {
3834    fn clone(&self) -> Self {
3835        Self::new_from_array(*self.as_array())
3836    }
3837}
3838#[doc = "Create zero-initialized struct"]
3839impl Default for TcU32Sel {
3840    fn default() -> Self {
3841        Self::new()
3842    }
3843}
3844impl TcU32Sel {
3845    #[doc = "Create zero-initialized struct"]
3846    pub fn new() -> Self {
3847        Self::new_from_array([0u8; Self::len()])
3848    }
3849    #[doc = "Copy from contents from slice"]
3850    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3851        if other.len() != Self::len() {
3852            return None;
3853        }
3854        let mut buf = [0u8; Self::len()];
3855        buf.clone_from_slice(other);
3856        Some(Self::new_from_array(buf))
3857    }
3858    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3859    pub fn new_from_zeroed(other: &[u8]) -> Self {
3860        let mut buf = [0u8; Self::len()];
3861        let len = buf.len().min(other.len());
3862        buf[..len].clone_from_slice(&other[..len]);
3863        Self::new_from_array(buf)
3864    }
3865    pub fn new_from_array(buf: [u8; 32usize]) -> Self {
3866        unsafe { std::mem::transmute(buf) }
3867    }
3868    pub fn as_slice(&self) -> &[u8] {
3869        unsafe {
3870            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3871            std::slice::from_raw_parts(ptr, Self::len())
3872        }
3873    }
3874    pub fn from_slice(buf: &[u8]) -> &Self {
3875        assert!(buf.len() >= Self::len());
3876        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3877        unsafe { std::mem::transmute(buf.as_ptr()) }
3878    }
3879    pub fn as_array(&self) -> &[u8; 32usize] {
3880        unsafe { std::mem::transmute(self) }
3881    }
3882    pub fn from_array(buf: &[u8; 32usize]) -> &Self {
3883        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3884        unsafe { std::mem::transmute(buf) }
3885    }
3886    pub fn into_array(self) -> [u8; 32usize] {
3887        unsafe { std::mem::transmute(self) }
3888    }
3889    pub const fn len() -> usize {
3890        const _: () = assert!(std::mem::size_of::<TcU32Sel>() == 32usize);
3891        32usize
3892    }
3893    pub fn offmask(&self) -> u16 {
3894        u16::from_be(self._offmask_be)
3895    }
3896    pub fn set_offmask(&mut self, value: u16) {
3897        self._offmask_be = value.to_be();
3898    }
3899    pub fn hmask(&self) -> u32 {
3900        u32::from_be(self._hmask_be)
3901    }
3902    pub fn set_hmask(&mut self, value: u32) {
3903        self._hmask_be = value.to_be();
3904    }
3905}
3906impl std::fmt::Debug for TcU32Sel {
3907    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3908        fmt.debug_struct("TcU32Sel")
3909            .field("flags", &self.flags)
3910            .field("offshift", &self.offshift)
3911            .field("nkeys", &self.nkeys)
3912            .field("offmask", &self.offmask())
3913            .field("off", &self.off)
3914            .field("offoff", &self.offoff)
3915            .field("hoff", &self.hoff)
3916            .field("hmask", &self.hmask())
3917            .field("keys", &self.keys)
3918            .finish()
3919    }
3920}
3921#[repr(C, packed(4))]
3922pub struct TcU32Pcnt {
3923    pub rcnt: u64,
3924    pub rhit: u64,
3925    pub kcnts: u64,
3926}
3927impl Clone for TcU32Pcnt {
3928    fn clone(&self) -> Self {
3929        Self::new_from_array(*self.as_array())
3930    }
3931}
3932#[doc = "Create zero-initialized struct"]
3933impl Default for TcU32Pcnt {
3934    fn default() -> Self {
3935        Self::new()
3936    }
3937}
3938impl TcU32Pcnt {
3939    #[doc = "Create zero-initialized struct"]
3940    pub fn new() -> Self {
3941        Self::new_from_array([0u8; Self::len()])
3942    }
3943    #[doc = "Copy from contents from slice"]
3944    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
3945        if other.len() != Self::len() {
3946            return None;
3947        }
3948        let mut buf = [0u8; Self::len()];
3949        buf.clone_from_slice(other);
3950        Some(Self::new_from_array(buf))
3951    }
3952    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
3953    pub fn new_from_zeroed(other: &[u8]) -> Self {
3954        let mut buf = [0u8; Self::len()];
3955        let len = buf.len().min(other.len());
3956        buf[..len].clone_from_slice(&other[..len]);
3957        Self::new_from_array(buf)
3958    }
3959    pub fn new_from_array(buf: [u8; 24usize]) -> Self {
3960        unsafe { std::mem::transmute(buf) }
3961    }
3962    pub fn as_slice(&self) -> &[u8] {
3963        unsafe {
3964            let ptr: *const u8 = std::mem::transmute(self as *const Self);
3965            std::slice::from_raw_parts(ptr, Self::len())
3966        }
3967    }
3968    pub fn from_slice(buf: &[u8]) -> &Self {
3969        assert!(buf.len() >= Self::len());
3970        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3971        unsafe { std::mem::transmute(buf.as_ptr()) }
3972    }
3973    pub fn as_array(&self) -> &[u8; 24usize] {
3974        unsafe { std::mem::transmute(self) }
3975    }
3976    pub fn from_array(buf: &[u8; 24usize]) -> &Self {
3977        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
3978        unsafe { std::mem::transmute(buf) }
3979    }
3980    pub fn into_array(self) -> [u8; 24usize] {
3981        unsafe { std::mem::transmute(self) }
3982    }
3983    pub const fn len() -> usize {
3984        const _: () = assert!(std::mem::size_of::<TcU32Pcnt>() == 24usize);
3985        24usize
3986    }
3987}
3988impl std::fmt::Debug for TcU32Pcnt {
3989    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3990        fmt.debug_struct("TcU32Pcnt")
3991            .field("rcnt", &{ self.rcnt })
3992            .field("rhit", &{ self.rhit })
3993            .field("kcnts", &{ self.kcnts })
3994            .finish()
3995    }
3996}
3997#[repr(C, packed(4))]
3998pub struct TcfT {
3999    pub install: u64,
4000    pub lastuse: u64,
4001    pub expires: u64,
4002    pub firstuse: u64,
4003}
4004impl Clone for TcfT {
4005    fn clone(&self) -> Self {
4006        Self::new_from_array(*self.as_array())
4007    }
4008}
4009#[doc = "Create zero-initialized struct"]
4010impl Default for TcfT {
4011    fn default() -> Self {
4012        Self::new()
4013    }
4014}
4015impl TcfT {
4016    #[doc = "Create zero-initialized struct"]
4017    pub fn new() -> Self {
4018        Self::new_from_array([0u8; Self::len()])
4019    }
4020    #[doc = "Copy from contents from slice"]
4021    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4022        if other.len() != Self::len() {
4023            return None;
4024        }
4025        let mut buf = [0u8; Self::len()];
4026        buf.clone_from_slice(other);
4027        Some(Self::new_from_array(buf))
4028    }
4029    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4030    pub fn new_from_zeroed(other: &[u8]) -> Self {
4031        let mut buf = [0u8; Self::len()];
4032        let len = buf.len().min(other.len());
4033        buf[..len].clone_from_slice(&other[..len]);
4034        Self::new_from_array(buf)
4035    }
4036    pub fn new_from_array(buf: [u8; 32usize]) -> Self {
4037        unsafe { std::mem::transmute(buf) }
4038    }
4039    pub fn as_slice(&self) -> &[u8] {
4040        unsafe {
4041            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4042            std::slice::from_raw_parts(ptr, Self::len())
4043        }
4044    }
4045    pub fn from_slice(buf: &[u8]) -> &Self {
4046        assert!(buf.len() >= Self::len());
4047        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4048        unsafe { std::mem::transmute(buf.as_ptr()) }
4049    }
4050    pub fn as_array(&self) -> &[u8; 32usize] {
4051        unsafe { std::mem::transmute(self) }
4052    }
4053    pub fn from_array(buf: &[u8; 32usize]) -> &Self {
4054        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4055        unsafe { std::mem::transmute(buf) }
4056    }
4057    pub fn into_array(self) -> [u8; 32usize] {
4058        unsafe { std::mem::transmute(self) }
4059    }
4060    pub const fn len() -> usize {
4061        const _: () = assert!(std::mem::size_of::<TcfT>() == 32usize);
4062        32usize
4063    }
4064}
4065impl std::fmt::Debug for TcfT {
4066    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4067        fmt.debug_struct("TcfT")
4068            .field("install", &{ self.install })
4069            .field("lastuse", &{ self.lastuse })
4070            .field("expires", &{ self.expires })
4071            .field("firstuse", &{ self.firstuse })
4072            .finish()
4073    }
4074}
4075#[derive(Debug)]
4076#[repr(C, packed(4))]
4077pub struct TcGact {
4078    pub index: u32,
4079    pub capab: u32,
4080    pub action: i32,
4081    pub refcnt: i32,
4082    pub bindcnt: i32,
4083}
4084impl Clone for TcGact {
4085    fn clone(&self) -> Self {
4086        Self::new_from_array(*self.as_array())
4087    }
4088}
4089#[doc = "Create zero-initialized struct"]
4090impl Default for TcGact {
4091    fn default() -> Self {
4092        Self::new()
4093    }
4094}
4095impl TcGact {
4096    #[doc = "Create zero-initialized struct"]
4097    pub fn new() -> Self {
4098        Self::new_from_array([0u8; Self::len()])
4099    }
4100    #[doc = "Copy from contents from slice"]
4101    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4102        if other.len() != Self::len() {
4103            return None;
4104        }
4105        let mut buf = [0u8; Self::len()];
4106        buf.clone_from_slice(other);
4107        Some(Self::new_from_array(buf))
4108    }
4109    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4110    pub fn new_from_zeroed(other: &[u8]) -> Self {
4111        let mut buf = [0u8; Self::len()];
4112        let len = buf.len().min(other.len());
4113        buf[..len].clone_from_slice(&other[..len]);
4114        Self::new_from_array(buf)
4115    }
4116    pub fn new_from_array(buf: [u8; 20usize]) -> Self {
4117        unsafe { std::mem::transmute(buf) }
4118    }
4119    pub fn as_slice(&self) -> &[u8] {
4120        unsafe {
4121            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4122            std::slice::from_raw_parts(ptr, Self::len())
4123        }
4124    }
4125    pub fn from_slice(buf: &[u8]) -> &Self {
4126        assert!(buf.len() >= Self::len());
4127        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4128        unsafe { std::mem::transmute(buf.as_ptr()) }
4129    }
4130    pub fn as_array(&self) -> &[u8; 20usize] {
4131        unsafe { std::mem::transmute(self) }
4132    }
4133    pub fn from_array(buf: &[u8; 20usize]) -> &Self {
4134        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4135        unsafe { std::mem::transmute(buf) }
4136    }
4137    pub fn into_array(self) -> [u8; 20usize] {
4138        unsafe { std::mem::transmute(self) }
4139    }
4140    pub const fn len() -> usize {
4141        const _: () = assert!(std::mem::size_of::<TcGact>() == 20usize);
4142        20usize
4143    }
4144}
4145#[derive(Debug)]
4146#[repr(C, packed(4))]
4147pub struct TcGactP {
4148    pub ptype: u16,
4149    pub pval: u16,
4150    pub paction: i32,
4151}
4152impl Clone for TcGactP {
4153    fn clone(&self) -> Self {
4154        Self::new_from_array(*self.as_array())
4155    }
4156}
4157#[doc = "Create zero-initialized struct"]
4158impl Default for TcGactP {
4159    fn default() -> Self {
4160        Self::new()
4161    }
4162}
4163impl TcGactP {
4164    #[doc = "Create zero-initialized struct"]
4165    pub fn new() -> Self {
4166        Self::new_from_array([0u8; Self::len()])
4167    }
4168    #[doc = "Copy from contents from slice"]
4169    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4170        if other.len() != Self::len() {
4171            return None;
4172        }
4173        let mut buf = [0u8; Self::len()];
4174        buf.clone_from_slice(other);
4175        Some(Self::new_from_array(buf))
4176    }
4177    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4178    pub fn new_from_zeroed(other: &[u8]) -> Self {
4179        let mut buf = [0u8; Self::len()];
4180        let len = buf.len().min(other.len());
4181        buf[..len].clone_from_slice(&other[..len]);
4182        Self::new_from_array(buf)
4183    }
4184    pub fn new_from_array(buf: [u8; 8usize]) -> Self {
4185        unsafe { std::mem::transmute(buf) }
4186    }
4187    pub fn as_slice(&self) -> &[u8] {
4188        unsafe {
4189            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4190            std::slice::from_raw_parts(ptr, Self::len())
4191        }
4192    }
4193    pub fn from_slice(buf: &[u8]) -> &Self {
4194        assert!(buf.len() >= Self::len());
4195        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4196        unsafe { std::mem::transmute(buf.as_ptr()) }
4197    }
4198    pub fn as_array(&self) -> &[u8; 8usize] {
4199        unsafe { std::mem::transmute(self) }
4200    }
4201    pub fn from_array(buf: &[u8; 8usize]) -> &Self {
4202        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4203        unsafe { std::mem::transmute(buf) }
4204    }
4205    pub fn into_array(self) -> [u8; 8usize] {
4206        unsafe { std::mem::transmute(self) }
4207    }
4208    pub const fn len() -> usize {
4209        const _: () = assert!(std::mem::size_of::<TcGactP>() == 8usize);
4210        8usize
4211    }
4212}
4213#[derive(Debug)]
4214#[repr(C, packed(4))]
4215pub struct TcfEmatchTreeHdr {
4216    pub nmatches: u16,
4217    pub progid: u16,
4218}
4219impl Clone for TcfEmatchTreeHdr {
4220    fn clone(&self) -> Self {
4221        Self::new_from_array(*self.as_array())
4222    }
4223}
4224#[doc = "Create zero-initialized struct"]
4225impl Default for TcfEmatchTreeHdr {
4226    fn default() -> Self {
4227        Self::new()
4228    }
4229}
4230impl TcfEmatchTreeHdr {
4231    #[doc = "Create zero-initialized struct"]
4232    pub fn new() -> Self {
4233        Self::new_from_array([0u8; Self::len()])
4234    }
4235    #[doc = "Copy from contents from slice"]
4236    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4237        if other.len() != Self::len() {
4238            return None;
4239        }
4240        let mut buf = [0u8; Self::len()];
4241        buf.clone_from_slice(other);
4242        Some(Self::new_from_array(buf))
4243    }
4244    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4245    pub fn new_from_zeroed(other: &[u8]) -> Self {
4246        let mut buf = [0u8; Self::len()];
4247        let len = buf.len().min(other.len());
4248        buf[..len].clone_from_slice(&other[..len]);
4249        Self::new_from_array(buf)
4250    }
4251    pub fn new_from_array(buf: [u8; 4usize]) -> Self {
4252        unsafe { std::mem::transmute(buf) }
4253    }
4254    pub fn as_slice(&self) -> &[u8] {
4255        unsafe {
4256            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4257            std::slice::from_raw_parts(ptr, Self::len())
4258        }
4259    }
4260    pub fn from_slice(buf: &[u8]) -> &Self {
4261        assert!(buf.len() >= Self::len());
4262        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4263        unsafe { std::mem::transmute(buf.as_ptr()) }
4264    }
4265    pub fn as_array(&self) -> &[u8; 4usize] {
4266        unsafe { std::mem::transmute(self) }
4267    }
4268    pub fn from_array(buf: &[u8; 4usize]) -> &Self {
4269        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4270        unsafe { std::mem::transmute(buf) }
4271    }
4272    pub fn into_array(self) -> [u8; 4usize] {
4273        unsafe { std::mem::transmute(self) }
4274    }
4275    pub const fn len() -> usize {
4276        const _: () = assert!(std::mem::size_of::<TcfEmatchTreeHdr>() == 4usize);
4277        4usize
4278    }
4279}
4280#[repr(C, packed(4))]
4281pub struct TcBasicPcnt {
4282    pub rcnt: u64,
4283    pub rhit: u64,
4284}
4285impl Clone for TcBasicPcnt {
4286    fn clone(&self) -> Self {
4287        Self::new_from_array(*self.as_array())
4288    }
4289}
4290#[doc = "Create zero-initialized struct"]
4291impl Default for TcBasicPcnt {
4292    fn default() -> Self {
4293        Self::new()
4294    }
4295}
4296impl TcBasicPcnt {
4297    #[doc = "Create zero-initialized struct"]
4298    pub fn new() -> Self {
4299        Self::new_from_array([0u8; Self::len()])
4300    }
4301    #[doc = "Copy from contents from slice"]
4302    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4303        if other.len() != Self::len() {
4304            return None;
4305        }
4306        let mut buf = [0u8; Self::len()];
4307        buf.clone_from_slice(other);
4308        Some(Self::new_from_array(buf))
4309    }
4310    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4311    pub fn new_from_zeroed(other: &[u8]) -> Self {
4312        let mut buf = [0u8; Self::len()];
4313        let len = buf.len().min(other.len());
4314        buf[..len].clone_from_slice(&other[..len]);
4315        Self::new_from_array(buf)
4316    }
4317    pub fn new_from_array(buf: [u8; 16usize]) -> Self {
4318        unsafe { std::mem::transmute(buf) }
4319    }
4320    pub fn as_slice(&self) -> &[u8] {
4321        unsafe {
4322            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4323            std::slice::from_raw_parts(ptr, Self::len())
4324        }
4325    }
4326    pub fn from_slice(buf: &[u8]) -> &Self {
4327        assert!(buf.len() >= Self::len());
4328        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4329        unsafe { std::mem::transmute(buf.as_ptr()) }
4330    }
4331    pub fn as_array(&self) -> &[u8; 16usize] {
4332        unsafe { std::mem::transmute(self) }
4333    }
4334    pub fn from_array(buf: &[u8; 16usize]) -> &Self {
4335        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4336        unsafe { std::mem::transmute(buf) }
4337    }
4338    pub fn into_array(self) -> [u8; 16usize] {
4339        unsafe { std::mem::transmute(self) }
4340    }
4341    pub const fn len() -> usize {
4342        const _: () = assert!(std::mem::size_of::<TcBasicPcnt>() == 16usize);
4343        16usize
4344    }
4345}
4346impl std::fmt::Debug for TcBasicPcnt {
4347    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4348        fmt.debug_struct("TcBasicPcnt")
4349            .field("rcnt", &{ self.rcnt })
4350            .field("rhit", &{ self.rhit })
4351            .finish()
4352    }
4353}
4354#[repr(C, packed(4))]
4355pub struct TcMatchallPcnt {
4356    pub rhit: u64,
4357}
4358impl Clone for TcMatchallPcnt {
4359    fn clone(&self) -> Self {
4360        Self::new_from_array(*self.as_array())
4361    }
4362}
4363#[doc = "Create zero-initialized struct"]
4364impl Default for TcMatchallPcnt {
4365    fn default() -> Self {
4366        Self::new()
4367    }
4368}
4369impl TcMatchallPcnt {
4370    #[doc = "Create zero-initialized struct"]
4371    pub fn new() -> Self {
4372        Self::new_from_array([0u8; Self::len()])
4373    }
4374    #[doc = "Copy from contents from slice"]
4375    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4376        if other.len() != Self::len() {
4377            return None;
4378        }
4379        let mut buf = [0u8; Self::len()];
4380        buf.clone_from_slice(other);
4381        Some(Self::new_from_array(buf))
4382    }
4383    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4384    pub fn new_from_zeroed(other: &[u8]) -> Self {
4385        let mut buf = [0u8; Self::len()];
4386        let len = buf.len().min(other.len());
4387        buf[..len].clone_from_slice(&other[..len]);
4388        Self::new_from_array(buf)
4389    }
4390    pub fn new_from_array(buf: [u8; 8usize]) -> Self {
4391        unsafe { std::mem::transmute(buf) }
4392    }
4393    pub fn as_slice(&self) -> &[u8] {
4394        unsafe {
4395            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4396            std::slice::from_raw_parts(ptr, Self::len())
4397        }
4398    }
4399    pub fn from_slice(buf: &[u8]) -> &Self {
4400        assert!(buf.len() >= Self::len());
4401        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4402        unsafe { std::mem::transmute(buf.as_ptr()) }
4403    }
4404    pub fn as_array(&self) -> &[u8; 8usize] {
4405        unsafe { std::mem::transmute(self) }
4406    }
4407    pub fn from_array(buf: &[u8; 8usize]) -> &Self {
4408        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4409        unsafe { std::mem::transmute(buf) }
4410    }
4411    pub fn into_array(self) -> [u8; 8usize] {
4412        unsafe { std::mem::transmute(self) }
4413    }
4414    pub const fn len() -> usize {
4415        const _: () = assert!(std::mem::size_of::<TcMatchallPcnt>() == 8usize);
4416        8usize
4417    }
4418}
4419impl std::fmt::Debug for TcMatchallPcnt {
4420    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4421        fmt.debug_struct("TcMatchallPcnt")
4422            .field("rhit", &{ self.rhit })
4423            .finish()
4424    }
4425}
4426#[derive(Debug)]
4427#[repr(C, packed(4))]
4428pub struct TcMpls {
4429    pub index: u32,
4430    pub capab: u32,
4431    pub action: i32,
4432    pub refcnt: i32,
4433    pub bindcnt: i32,
4434    pub m_action: i32,
4435}
4436impl Clone for TcMpls {
4437    fn clone(&self) -> Self {
4438        Self::new_from_array(*self.as_array())
4439    }
4440}
4441#[doc = "Create zero-initialized struct"]
4442impl Default for TcMpls {
4443    fn default() -> Self {
4444        Self::new()
4445    }
4446}
4447impl TcMpls {
4448    #[doc = "Create zero-initialized struct"]
4449    pub fn new() -> Self {
4450        Self::new_from_array([0u8; Self::len()])
4451    }
4452    #[doc = "Copy from contents from slice"]
4453    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4454        if other.len() != Self::len() {
4455            return None;
4456        }
4457        let mut buf = [0u8; Self::len()];
4458        buf.clone_from_slice(other);
4459        Some(Self::new_from_array(buf))
4460    }
4461    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4462    pub fn new_from_zeroed(other: &[u8]) -> Self {
4463        let mut buf = [0u8; Self::len()];
4464        let len = buf.len().min(other.len());
4465        buf[..len].clone_from_slice(&other[..len]);
4466        Self::new_from_array(buf)
4467    }
4468    pub fn new_from_array(buf: [u8; 24usize]) -> Self {
4469        unsafe { std::mem::transmute(buf) }
4470    }
4471    pub fn as_slice(&self) -> &[u8] {
4472        unsafe {
4473            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4474            std::slice::from_raw_parts(ptr, Self::len())
4475        }
4476    }
4477    pub fn from_slice(buf: &[u8]) -> &Self {
4478        assert!(buf.len() >= Self::len());
4479        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4480        unsafe { std::mem::transmute(buf.as_ptr()) }
4481    }
4482    pub fn as_array(&self) -> &[u8; 24usize] {
4483        unsafe { std::mem::transmute(self) }
4484    }
4485    pub fn from_array(buf: &[u8; 24usize]) -> &Self {
4486        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4487        unsafe { std::mem::transmute(buf) }
4488    }
4489    pub fn into_array(self) -> [u8; 24usize] {
4490        unsafe { std::mem::transmute(self) }
4491    }
4492    pub const fn len() -> usize {
4493        const _: () = assert!(std::mem::size_of::<TcMpls>() == 24usize);
4494        24usize
4495    }
4496}
4497#[repr(C, packed(4))]
4498pub struct TcPolice {
4499    pub index: u32,
4500    pub action: i32,
4501    pub limit: u32,
4502    pub burst: u32,
4503    pub mtu: u32,
4504    pub rate: TcRatespec,
4505    pub peakrate: TcRatespec,
4506    pub refcnt: i32,
4507    pub bindcnt: i32,
4508    pub capab: u32,
4509}
4510impl Clone for TcPolice {
4511    fn clone(&self) -> Self {
4512        Self::new_from_array(*self.as_array())
4513    }
4514}
4515#[doc = "Create zero-initialized struct"]
4516impl Default for TcPolice {
4517    fn default() -> Self {
4518        Self::new()
4519    }
4520}
4521impl TcPolice {
4522    #[doc = "Create zero-initialized struct"]
4523    pub fn new() -> Self {
4524        Self::new_from_array([0u8; Self::len()])
4525    }
4526    #[doc = "Copy from contents from slice"]
4527    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4528        if other.len() != Self::len() {
4529            return None;
4530        }
4531        let mut buf = [0u8; Self::len()];
4532        buf.clone_from_slice(other);
4533        Some(Self::new_from_array(buf))
4534    }
4535    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4536    pub fn new_from_zeroed(other: &[u8]) -> Self {
4537        let mut buf = [0u8; Self::len()];
4538        let len = buf.len().min(other.len());
4539        buf[..len].clone_from_slice(&other[..len]);
4540        Self::new_from_array(buf)
4541    }
4542    pub fn new_from_array(buf: [u8; 56usize]) -> Self {
4543        unsafe { std::mem::transmute(buf) }
4544    }
4545    pub fn as_slice(&self) -> &[u8] {
4546        unsafe {
4547            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4548            std::slice::from_raw_parts(ptr, Self::len())
4549        }
4550    }
4551    pub fn from_slice(buf: &[u8]) -> &Self {
4552        assert!(buf.len() >= Self::len());
4553        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4554        unsafe { std::mem::transmute(buf.as_ptr()) }
4555    }
4556    pub fn as_array(&self) -> &[u8; 56usize] {
4557        unsafe { std::mem::transmute(self) }
4558    }
4559    pub fn from_array(buf: &[u8; 56usize]) -> &Self {
4560        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4561        unsafe { std::mem::transmute(buf) }
4562    }
4563    pub fn into_array(self) -> [u8; 56usize] {
4564        unsafe { std::mem::transmute(self) }
4565    }
4566    pub const fn len() -> usize {
4567        const _: () = assert!(std::mem::size_of::<TcPolice>() == 56usize);
4568        56usize
4569    }
4570}
4571impl std::fmt::Debug for TcPolice {
4572    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4573        fmt.debug_struct("TcPolice")
4574            .field("index", &self.index)
4575            .field("action", &self.action)
4576            .field("limit", &self.limit)
4577            .field("burst", &self.burst)
4578            .field("mtu", &self.mtu)
4579            .field("rate", &self.rate)
4580            .field("peakrate", &self.peakrate)
4581            .field("refcnt", &self.refcnt)
4582            .field("bindcnt", &self.bindcnt)
4583            .field("capab", &self.capab)
4584            .finish()
4585    }
4586}
4587#[repr(C, packed(4))]
4588pub struct TcPeditSel {
4589    pub index: u32,
4590    pub capab: u32,
4591    pub action: i32,
4592    pub refcnt: i32,
4593    pub bindcnt: i32,
4594    pub nkeys: u8,
4595    pub flags: u8,
4596    pub _pad_22: [u8; 2usize],
4597    pub keys: TcPeditKey,
4598}
4599impl Clone for TcPeditSel {
4600    fn clone(&self) -> Self {
4601        Self::new_from_array(*self.as_array())
4602    }
4603}
4604#[doc = "Create zero-initialized struct"]
4605impl Default for TcPeditSel {
4606    fn default() -> Self {
4607        Self::new()
4608    }
4609}
4610impl TcPeditSel {
4611    #[doc = "Create zero-initialized struct"]
4612    pub fn new() -> Self {
4613        Self::new_from_array([0u8; Self::len()])
4614    }
4615    #[doc = "Copy from contents from slice"]
4616    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4617        if other.len() != Self::len() {
4618            return None;
4619        }
4620        let mut buf = [0u8; Self::len()];
4621        buf.clone_from_slice(other);
4622        Some(Self::new_from_array(buf))
4623    }
4624    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4625    pub fn new_from_zeroed(other: &[u8]) -> Self {
4626        let mut buf = [0u8; Self::len()];
4627        let len = buf.len().min(other.len());
4628        buf[..len].clone_from_slice(&other[..len]);
4629        Self::new_from_array(buf)
4630    }
4631    pub fn new_from_array(buf: [u8; 48usize]) -> Self {
4632        unsafe { std::mem::transmute(buf) }
4633    }
4634    pub fn as_slice(&self) -> &[u8] {
4635        unsafe {
4636            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4637            std::slice::from_raw_parts(ptr, Self::len())
4638        }
4639    }
4640    pub fn from_slice(buf: &[u8]) -> &Self {
4641        assert!(buf.len() >= Self::len());
4642        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4643        unsafe { std::mem::transmute(buf.as_ptr()) }
4644    }
4645    pub fn as_array(&self) -> &[u8; 48usize] {
4646        unsafe { std::mem::transmute(self) }
4647    }
4648    pub fn from_array(buf: &[u8; 48usize]) -> &Self {
4649        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4650        unsafe { std::mem::transmute(buf) }
4651    }
4652    pub fn into_array(self) -> [u8; 48usize] {
4653        unsafe { std::mem::transmute(self) }
4654    }
4655    pub const fn len() -> usize {
4656        const _: () = assert!(std::mem::size_of::<TcPeditSel>() == 48usize);
4657        48usize
4658    }
4659}
4660impl std::fmt::Debug for TcPeditSel {
4661    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4662        fmt.debug_struct("TcPeditSel")
4663            .field("index", &self.index)
4664            .field("capab", &self.capab)
4665            .field("action", &self.action)
4666            .field("refcnt", &self.refcnt)
4667            .field("bindcnt", &self.bindcnt)
4668            .field("nkeys", &self.nkeys)
4669            .field("flags", &self.flags)
4670            .field("keys", &self.keys)
4671            .finish()
4672    }
4673}
4674#[derive(Debug)]
4675#[repr(C, packed(4))]
4676pub struct TcPeditKey {
4677    pub mask: u32,
4678    pub val: u32,
4679    pub off: u32,
4680    pub at: u32,
4681    pub offmask: u32,
4682    pub shift: u32,
4683}
4684impl Clone for TcPeditKey {
4685    fn clone(&self) -> Self {
4686        Self::new_from_array(*self.as_array())
4687    }
4688}
4689#[doc = "Create zero-initialized struct"]
4690impl Default for TcPeditKey {
4691    fn default() -> Self {
4692        Self::new()
4693    }
4694}
4695impl TcPeditKey {
4696    #[doc = "Create zero-initialized struct"]
4697    pub fn new() -> Self {
4698        Self::new_from_array([0u8; Self::len()])
4699    }
4700    #[doc = "Copy from contents from slice"]
4701    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4702        if other.len() != Self::len() {
4703            return None;
4704        }
4705        let mut buf = [0u8; Self::len()];
4706        buf.clone_from_slice(other);
4707        Some(Self::new_from_array(buf))
4708    }
4709    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4710    pub fn new_from_zeroed(other: &[u8]) -> Self {
4711        let mut buf = [0u8; Self::len()];
4712        let len = buf.len().min(other.len());
4713        buf[..len].clone_from_slice(&other[..len]);
4714        Self::new_from_array(buf)
4715    }
4716    pub fn new_from_array(buf: [u8; 24usize]) -> Self {
4717        unsafe { std::mem::transmute(buf) }
4718    }
4719    pub fn as_slice(&self) -> &[u8] {
4720        unsafe {
4721            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4722            std::slice::from_raw_parts(ptr, Self::len())
4723        }
4724    }
4725    pub fn from_slice(buf: &[u8]) -> &Self {
4726        assert!(buf.len() >= Self::len());
4727        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4728        unsafe { std::mem::transmute(buf.as_ptr()) }
4729    }
4730    pub fn as_array(&self) -> &[u8; 24usize] {
4731        unsafe { std::mem::transmute(self) }
4732    }
4733    pub fn from_array(buf: &[u8; 24usize]) -> &Self {
4734        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4735        unsafe { std::mem::transmute(buf) }
4736    }
4737    pub fn into_array(self) -> [u8; 24usize] {
4738        unsafe { std::mem::transmute(self) }
4739    }
4740    pub const fn len() -> usize {
4741        const _: () = assert!(std::mem::size_of::<TcPeditKey>() == 24usize);
4742        24usize
4743    }
4744}
4745#[derive(Debug)]
4746#[repr(C, packed(4))]
4747pub struct TcVlan {
4748    pub index: u32,
4749    pub capab: u32,
4750    pub action: i32,
4751    pub refcnt: i32,
4752    pub bindcnt: i32,
4753    pub v_action: i32,
4754}
4755impl Clone for TcVlan {
4756    fn clone(&self) -> Self {
4757        Self::new_from_array(*self.as_array())
4758    }
4759}
4760#[doc = "Create zero-initialized struct"]
4761impl Default for TcVlan {
4762    fn default() -> Self {
4763        Self::new()
4764    }
4765}
4766impl TcVlan {
4767    #[doc = "Create zero-initialized struct"]
4768    pub fn new() -> Self {
4769        Self::new_from_array([0u8; Self::len()])
4770    }
4771    #[doc = "Copy from contents from slice"]
4772    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
4773        if other.len() != Self::len() {
4774            return None;
4775        }
4776        let mut buf = [0u8; Self::len()];
4777        buf.clone_from_slice(other);
4778        Some(Self::new_from_array(buf))
4779    }
4780    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
4781    pub fn new_from_zeroed(other: &[u8]) -> Self {
4782        let mut buf = [0u8; Self::len()];
4783        let len = buf.len().min(other.len());
4784        buf[..len].clone_from_slice(&other[..len]);
4785        Self::new_from_array(buf)
4786    }
4787    pub fn new_from_array(buf: [u8; 24usize]) -> Self {
4788        unsafe { std::mem::transmute(buf) }
4789    }
4790    pub fn as_slice(&self) -> &[u8] {
4791        unsafe {
4792            let ptr: *const u8 = std::mem::transmute(self as *const Self);
4793            std::slice::from_raw_parts(ptr, Self::len())
4794        }
4795    }
4796    pub fn from_slice(buf: &[u8]) -> &Self {
4797        assert!(buf.len() >= Self::len());
4798        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4799        unsafe { std::mem::transmute(buf.as_ptr()) }
4800    }
4801    pub fn as_array(&self) -> &[u8; 24usize] {
4802        unsafe { std::mem::transmute(self) }
4803    }
4804    pub fn from_array(buf: &[u8; 24usize]) -> &Self {
4805        assert!(buf.as_ptr() as usize % std::mem::align_of::<Self>() == 0);
4806        unsafe { std::mem::transmute(buf) }
4807    }
4808    pub fn into_array(self) -> [u8; 24usize] {
4809        unsafe { std::mem::transmute(self) }
4810    }
4811    pub const fn len() -> usize {
4812        const _: () = assert!(std::mem::size_of::<TcVlan>() == 24usize);
4813        24usize
4814    }
4815}
4816#[derive(Clone)]
4817pub enum Attrs<'a> {
4818    Kind(&'a CStr),
4819    Options(OptionsMsg<'a>),
4820    Stats(TcStats),
4821    Xstats(TcaStatsAppMsg<'a>),
4822    Rate(GnetEstimator),
4823    Fcnt(u32),
4824    Stats2(IterableTcaStatsAttrs<'a>),
4825    Stab(IterableTcaStabAttrs<'a>),
4826    Pad(&'a [u8]),
4827    DumpInvisible(()),
4828    Chain(u32),
4829    HwOffload(u8),
4830    IngressBlock(u32),
4831    EgressBlock(u32),
4832    DumpFlags(BuiltinBitfield32),
4833    ExtWarnMsg(&'a CStr),
4834}
4835impl<'a> IterableAttrs<'a> {
4836    pub fn get_kind(&self) -> Result<&'a CStr, ErrorContext> {
4837        let mut iter = self.clone();
4838        iter.pos = 0;
4839        for attr in iter {
4840            if let Attrs::Kind(val) = attr? {
4841                return Ok(val);
4842            }
4843        }
4844        Err(ErrorContext::new_missing(
4845            "Attrs",
4846            "Kind",
4847            self.orig_loc,
4848            self.buf.as_ptr() as usize,
4849        ))
4850    }
4851    pub fn get_options(&self) -> Result<OptionsMsg<'a>, ErrorContext> {
4852        let mut iter = self.clone();
4853        iter.pos = 0;
4854        for attr in iter {
4855            if let Attrs::Options(val) = attr? {
4856                return Ok(val);
4857            }
4858        }
4859        Err(ErrorContext::new_missing(
4860            "Attrs",
4861            "Options",
4862            self.orig_loc,
4863            self.buf.as_ptr() as usize,
4864        ))
4865    }
4866    pub fn get_stats(&self) -> Result<TcStats, ErrorContext> {
4867        let mut iter = self.clone();
4868        iter.pos = 0;
4869        for attr in iter {
4870            if let Attrs::Stats(val) = attr? {
4871                return Ok(val);
4872            }
4873        }
4874        Err(ErrorContext::new_missing(
4875            "Attrs",
4876            "Stats",
4877            self.orig_loc,
4878            self.buf.as_ptr() as usize,
4879        ))
4880    }
4881    pub fn get_xstats(&self) -> Result<TcaStatsAppMsg<'a>, ErrorContext> {
4882        let mut iter = self.clone();
4883        iter.pos = 0;
4884        for attr in iter {
4885            if let Attrs::Xstats(val) = attr? {
4886                return Ok(val);
4887            }
4888        }
4889        Err(ErrorContext::new_missing(
4890            "Attrs",
4891            "Xstats",
4892            self.orig_loc,
4893            self.buf.as_ptr() as usize,
4894        ))
4895    }
4896    pub fn get_rate(&self) -> Result<GnetEstimator, ErrorContext> {
4897        let mut iter = self.clone();
4898        iter.pos = 0;
4899        for attr in iter {
4900            if let Attrs::Rate(val) = attr? {
4901                return Ok(val);
4902            }
4903        }
4904        Err(ErrorContext::new_missing(
4905            "Attrs",
4906            "Rate",
4907            self.orig_loc,
4908            self.buf.as_ptr() as usize,
4909        ))
4910    }
4911    pub fn get_fcnt(&self) -> Result<u32, ErrorContext> {
4912        let mut iter = self.clone();
4913        iter.pos = 0;
4914        for attr in iter {
4915            if let Attrs::Fcnt(val) = attr? {
4916                return Ok(val);
4917            }
4918        }
4919        Err(ErrorContext::new_missing(
4920            "Attrs",
4921            "Fcnt",
4922            self.orig_loc,
4923            self.buf.as_ptr() as usize,
4924        ))
4925    }
4926    pub fn get_stats2(&self) -> Result<IterableTcaStatsAttrs<'a>, ErrorContext> {
4927        let mut iter = self.clone();
4928        iter.pos = 0;
4929        for attr in iter {
4930            if let Attrs::Stats2(val) = attr? {
4931                return Ok(val);
4932            }
4933        }
4934        Err(ErrorContext::new_missing(
4935            "Attrs",
4936            "Stats2",
4937            self.orig_loc,
4938            self.buf.as_ptr() as usize,
4939        ))
4940    }
4941    pub fn get_stab(&self) -> Result<IterableTcaStabAttrs<'a>, ErrorContext> {
4942        let mut iter = self.clone();
4943        iter.pos = 0;
4944        for attr in iter {
4945            if let Attrs::Stab(val) = attr? {
4946                return Ok(val);
4947            }
4948        }
4949        Err(ErrorContext::new_missing(
4950            "Attrs",
4951            "Stab",
4952            self.orig_loc,
4953            self.buf.as_ptr() as usize,
4954        ))
4955    }
4956    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
4957        let mut iter = self.clone();
4958        iter.pos = 0;
4959        for attr in iter {
4960            if let Attrs::Pad(val) = attr? {
4961                return Ok(val);
4962            }
4963        }
4964        Err(ErrorContext::new_missing(
4965            "Attrs",
4966            "Pad",
4967            self.orig_loc,
4968            self.buf.as_ptr() as usize,
4969        ))
4970    }
4971    pub fn get_dump_invisible(&self) -> Result<(), ErrorContext> {
4972        let mut iter = self.clone();
4973        iter.pos = 0;
4974        for attr in iter {
4975            if let Attrs::DumpInvisible(val) = attr? {
4976                return Ok(val);
4977            }
4978        }
4979        Err(ErrorContext::new_missing(
4980            "Attrs",
4981            "DumpInvisible",
4982            self.orig_loc,
4983            self.buf.as_ptr() as usize,
4984        ))
4985    }
4986    pub fn get_chain(&self) -> Result<u32, ErrorContext> {
4987        let mut iter = self.clone();
4988        iter.pos = 0;
4989        for attr in iter {
4990            if let Attrs::Chain(val) = attr? {
4991                return Ok(val);
4992            }
4993        }
4994        Err(ErrorContext::new_missing(
4995            "Attrs",
4996            "Chain",
4997            self.orig_loc,
4998            self.buf.as_ptr() as usize,
4999        ))
5000    }
5001    pub fn get_hw_offload(&self) -> Result<u8, ErrorContext> {
5002        let mut iter = self.clone();
5003        iter.pos = 0;
5004        for attr in iter {
5005            if let Attrs::HwOffload(val) = attr? {
5006                return Ok(val);
5007            }
5008        }
5009        Err(ErrorContext::new_missing(
5010            "Attrs",
5011            "HwOffload",
5012            self.orig_loc,
5013            self.buf.as_ptr() as usize,
5014        ))
5015    }
5016    pub fn get_ingress_block(&self) -> Result<u32, ErrorContext> {
5017        let mut iter = self.clone();
5018        iter.pos = 0;
5019        for attr in iter {
5020            if let Attrs::IngressBlock(val) = attr? {
5021                return Ok(val);
5022            }
5023        }
5024        Err(ErrorContext::new_missing(
5025            "Attrs",
5026            "IngressBlock",
5027            self.orig_loc,
5028            self.buf.as_ptr() as usize,
5029        ))
5030    }
5031    pub fn get_egress_block(&self) -> Result<u32, ErrorContext> {
5032        let mut iter = self.clone();
5033        iter.pos = 0;
5034        for attr in iter {
5035            if let Attrs::EgressBlock(val) = attr? {
5036                return Ok(val);
5037            }
5038        }
5039        Err(ErrorContext::new_missing(
5040            "Attrs",
5041            "EgressBlock",
5042            self.orig_loc,
5043            self.buf.as_ptr() as usize,
5044        ))
5045    }
5046    pub fn get_dump_flags(&self) -> Result<BuiltinBitfield32, ErrorContext> {
5047        let mut iter = self.clone();
5048        iter.pos = 0;
5049        for attr in iter {
5050            if let Attrs::DumpFlags(val) = attr? {
5051                return Ok(val);
5052            }
5053        }
5054        Err(ErrorContext::new_missing(
5055            "Attrs",
5056            "DumpFlags",
5057            self.orig_loc,
5058            self.buf.as_ptr() as usize,
5059        ))
5060    }
5061    pub fn get_ext_warn_msg(&self) -> Result<&'a CStr, ErrorContext> {
5062        let mut iter = self.clone();
5063        iter.pos = 0;
5064        for attr in iter {
5065            if let Attrs::ExtWarnMsg(val) = attr? {
5066                return Ok(val);
5067            }
5068        }
5069        Err(ErrorContext::new_missing(
5070            "Attrs",
5071            "ExtWarnMsg",
5072            self.orig_loc,
5073            self.buf.as_ptr() as usize,
5074        ))
5075    }
5076}
5077#[derive(Debug, Clone)]
5078pub enum OptionsMsg<'a> {
5079    Basic(IterableBasicAttrs<'a>),
5080    Bpf(IterableBpfAttrs<'a>),
5081    Bfifo(TcFifoQopt),
5082    Cake(IterableCakeAttrs<'a>),
5083    Cbs(IterableCbsAttrs<'a>),
5084    Cgroup(IterableCgroupAttrs<'a>),
5085    Choke(IterableChokeAttrs<'a>),
5086    Clsact,
5087    Codel(IterableCodelAttrs<'a>),
5088    Drr(IterableDrrAttrs<'a>),
5089    Dualpi2(IterableDualpi2Attrs<'a>),
5090    Etf(IterableEtfAttrs<'a>),
5091    Ets(IterableEtsAttrs<'a>),
5092    Flow(IterableFlowAttrs<'a>),
5093    Flower(IterableFlowerAttrs<'a>),
5094    Fq(IterableFqAttrs<'a>),
5095    FqCodel(IterableFqCodelAttrs<'a>),
5096    FqPie(IterableFqPieAttrs<'a>),
5097    Fw(IterableFwAttrs<'a>),
5098    Gred(IterableGredAttrs<'a>),
5099    Hfsc(TcHfscQopt),
5100    Hhf(IterableHhfAttrs<'a>),
5101    Htb(IterableHtbAttrs<'a>),
5102    Ingress,
5103    Matchall(IterableMatchallAttrs<'a>),
5104    Mq,
5105    Mqprio(TcMqprioQopt),
5106    Multiq(TcMultiqQopt),
5107    Netem(TcNetemQopt, IterableNetemAttrs<'a>),
5108    Pfifo(TcFifoQopt),
5109    PfifoFast(TcPrioQopt),
5110    PfifoHeadDrop(TcFifoQopt),
5111    Pie(IterablePieAttrs<'a>),
5112    Plug(TcPlugQopt),
5113    Prio(TcPrioQopt),
5114    Qfq(IterableQfqAttrs<'a>),
5115    Red(IterableRedAttrs<'a>),
5116    Route(IterableRouteAttrs<'a>),
5117    Sfb(TcSfbQopt),
5118    Sfq(TcSfqQoptV1),
5119    Taprio(IterableTaprioAttrs<'a>),
5120    Tbf(IterableTbfAttrs<'a>),
5121    U32(IterableU32Attrs<'a>),
5122}
5123impl<'a> OptionsMsg<'a> {
5124    fn select_with_loc(selector: &'a CStr, buf: &'a [u8], loc: usize) -> Option<Self> {
5125        match selector.to_bytes() {
5126            b"basic" => Some(OptionsMsg::Basic(IterableBasicAttrs::with_loc(buf, loc))),
5127            b"bpf" => Some(OptionsMsg::Bpf(IterableBpfAttrs::with_loc(buf, loc))),
5128            b"bfifo" => Some(OptionsMsg::Bfifo(TcFifoQopt::new_from_zeroed(buf))),
5129            b"cake" => Some(OptionsMsg::Cake(IterableCakeAttrs::with_loc(buf, loc))),
5130            b"cbs" => Some(OptionsMsg::Cbs(IterableCbsAttrs::with_loc(buf, loc))),
5131            b"cgroup" => Some(OptionsMsg::Cgroup(IterableCgroupAttrs::with_loc(buf, loc))),
5132            b"choke" => Some(OptionsMsg::Choke(IterableChokeAttrs::with_loc(buf, loc))),
5133            b"clsact" => Some(OptionsMsg::Clsact),
5134            b"codel" => Some(OptionsMsg::Codel(IterableCodelAttrs::with_loc(buf, loc))),
5135            b"drr" => Some(OptionsMsg::Drr(IterableDrrAttrs::with_loc(buf, loc))),
5136            b"dualpi2" => Some(OptionsMsg::Dualpi2(IterableDualpi2Attrs::with_loc(
5137                buf, loc,
5138            ))),
5139            b"etf" => Some(OptionsMsg::Etf(IterableEtfAttrs::with_loc(buf, loc))),
5140            b"ets" => Some(OptionsMsg::Ets(IterableEtsAttrs::with_loc(buf, loc))),
5141            b"flow" => Some(OptionsMsg::Flow(IterableFlowAttrs::with_loc(buf, loc))),
5142            b"flower" => Some(OptionsMsg::Flower(IterableFlowerAttrs::with_loc(buf, loc))),
5143            b"fq" => Some(OptionsMsg::Fq(IterableFqAttrs::with_loc(buf, loc))),
5144            b"fq_codel" => Some(OptionsMsg::FqCodel(IterableFqCodelAttrs::with_loc(
5145                buf, loc,
5146            ))),
5147            b"fq_pie" => Some(OptionsMsg::FqPie(IterableFqPieAttrs::with_loc(buf, loc))),
5148            b"fw" => Some(OptionsMsg::Fw(IterableFwAttrs::with_loc(buf, loc))),
5149            b"gred" => Some(OptionsMsg::Gred(IterableGredAttrs::with_loc(buf, loc))),
5150            b"hfsc" => Some(OptionsMsg::Hfsc(TcHfscQopt::new_from_zeroed(buf))),
5151            b"hhf" => Some(OptionsMsg::Hhf(IterableHhfAttrs::with_loc(buf, loc))),
5152            b"htb" => Some(OptionsMsg::Htb(IterableHtbAttrs::with_loc(buf, loc))),
5153            b"ingress" => Some(OptionsMsg::Ingress),
5154            b"matchall" => Some(OptionsMsg::Matchall(IterableMatchallAttrs::with_loc(
5155                buf, loc,
5156            ))),
5157            b"mq" => Some(OptionsMsg::Mq),
5158            b"mqprio" => Some(OptionsMsg::Mqprio(TcMqprioQopt::new_from_zeroed(buf))),
5159            b"multiq" => Some(OptionsMsg::Multiq(TcMultiqQopt::new_from_zeroed(buf))),
5160            b"netem" => {
5161                let (header, attrs) = buf.split_at(buf.len().min(TcNetemQopt::len()));
5162                Some(OptionsMsg::Netem(
5163                    TcNetemQopt::new_from_slice(header)?,
5164                    IterableNetemAttrs::with_loc(attrs, loc),
5165                ))
5166            }
5167            b"pfifo" => Some(OptionsMsg::Pfifo(TcFifoQopt::new_from_zeroed(buf))),
5168            b"pfifo_fast" => Some(OptionsMsg::PfifoFast(TcPrioQopt::new_from_zeroed(buf))),
5169            b"pfifo_head_drop" => Some(OptionsMsg::PfifoHeadDrop(TcFifoQopt::new_from_zeroed(buf))),
5170            b"pie" => Some(OptionsMsg::Pie(IterablePieAttrs::with_loc(buf, loc))),
5171            b"plug" => Some(OptionsMsg::Plug(TcPlugQopt::new_from_zeroed(buf))),
5172            b"prio" => Some(OptionsMsg::Prio(TcPrioQopt::new_from_zeroed(buf))),
5173            b"qfq" => Some(OptionsMsg::Qfq(IterableQfqAttrs::with_loc(buf, loc))),
5174            b"red" => Some(OptionsMsg::Red(IterableRedAttrs::with_loc(buf, loc))),
5175            b"route" => Some(OptionsMsg::Route(IterableRouteAttrs::with_loc(buf, loc))),
5176            b"sfb" => Some(OptionsMsg::Sfb(TcSfbQopt::new_from_zeroed(buf))),
5177            b"sfq" => Some(OptionsMsg::Sfq(TcSfqQoptV1::new_from_zeroed(buf))),
5178            b"taprio" => Some(OptionsMsg::Taprio(IterableTaprioAttrs::with_loc(buf, loc))),
5179            b"tbf" => Some(OptionsMsg::Tbf(IterableTbfAttrs::with_loc(buf, loc))),
5180            b"u32" => Some(OptionsMsg::U32(IterableU32Attrs::with_loc(buf, loc))),
5181            _ => None,
5182        }
5183    }
5184}
5185#[derive(Debug, Clone)]
5186pub enum TcaStatsAppMsg<'a> {
5187    Cake(IterableCakeStatsAttrs<'a>),
5188    Choke(TcChokeXstats),
5189    Codel(TcCodelXstats),
5190    Dualpi2(TcDualpi2Xstats),
5191    Fq(TcFqQdStats),
5192    FqCodel(TcFqCodelXstats),
5193    FqPie(TcFqPieXstats),
5194    Hhf(TcHhfXstats),
5195    Pie(TcPieXstats),
5196    Red(TcRedXstats),
5197    Sfb(TcSfbXstats),
5198    Sfq(TcSfqXstats),
5199}
5200impl<'a> TcaStatsAppMsg<'a> {
5201    fn select_with_loc(selector: &'a CStr, buf: &'a [u8], loc: usize) -> Option<Self> {
5202        match selector.to_bytes() {
5203            b"cake" => Some(TcaStatsAppMsg::Cake(IterableCakeStatsAttrs::with_loc(
5204                buf, loc,
5205            ))),
5206            b"choke" => Some(TcaStatsAppMsg::Choke(TcChokeXstats::new_from_zeroed(buf))),
5207            b"codel" => Some(TcaStatsAppMsg::Codel(TcCodelXstats::new_from_zeroed(buf))),
5208            b"dualpi2" => Some(TcaStatsAppMsg::Dualpi2(TcDualpi2Xstats::new_from_zeroed(
5209                buf,
5210            ))),
5211            b"fq" => Some(TcaStatsAppMsg::Fq(TcFqQdStats::new_from_zeroed(buf))),
5212            b"fq_codel" => Some(TcaStatsAppMsg::FqCodel(TcFqCodelXstats::new_from_zeroed(
5213                buf,
5214            ))),
5215            b"fq_pie" => Some(TcaStatsAppMsg::FqPie(TcFqPieXstats::new_from_zeroed(buf))),
5216            b"hhf" => Some(TcaStatsAppMsg::Hhf(TcHhfXstats::new_from_zeroed(buf))),
5217            b"pie" => Some(TcaStatsAppMsg::Pie(TcPieXstats::new_from_zeroed(buf))),
5218            b"red" => Some(TcaStatsAppMsg::Red(TcRedXstats::new_from_zeroed(buf))),
5219            b"sfb" => Some(TcaStatsAppMsg::Sfb(TcSfbXstats::new_from_zeroed(buf))),
5220            b"sfq" => Some(TcaStatsAppMsg::Sfq(TcSfqXstats::new_from_zeroed(buf))),
5221            _ => None,
5222        }
5223    }
5224}
5225impl Attrs<'_> {
5226    pub fn new<'a>(buf: &'a [u8]) -> IterableAttrs<'a> {
5227        IterableAttrs::with_loc(buf, buf.as_ptr() as usize)
5228    }
5229    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5230        let res = match r#type {
5231            1u16 => "Kind",
5232            2u16 => "Options",
5233            3u16 => "Stats",
5234            4u16 => "Xstats",
5235            5u16 => "Rate",
5236            6u16 => "Fcnt",
5237            7u16 => "Stats2",
5238            8u16 => "Stab",
5239            9u16 => "Pad",
5240            10u16 => "DumpInvisible",
5241            11u16 => "Chain",
5242            12u16 => "HwOffload",
5243            13u16 => "IngressBlock",
5244            14u16 => "EgressBlock",
5245            15u16 => "DumpFlags",
5246            16u16 => "ExtWarnMsg",
5247            _ => return None,
5248        };
5249        Some(res)
5250    }
5251}
5252#[derive(Clone, Copy, Default)]
5253pub struct IterableAttrs<'a> {
5254    buf: &'a [u8],
5255    pos: usize,
5256    orig_loc: usize,
5257}
5258impl<'a> IterableAttrs<'a> {
5259    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5260        Self {
5261            buf,
5262            pos: 0,
5263            orig_loc,
5264        }
5265    }
5266    pub fn get_buf(&self) -> &'a [u8] {
5267        self.buf
5268    }
5269}
5270impl<'a> Iterator for IterableAttrs<'a> {
5271    type Item = Result<Attrs<'a>, ErrorContext>;
5272    fn next(&mut self) -> Option<Self::Item> {
5273        let pos = self.pos;
5274        let mut r#type;
5275        loop {
5276            r#type = None;
5277            if self.buf.len() == self.pos {
5278                return None;
5279            }
5280            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5281                break;
5282            };
5283            r#type = Some(header.r#type);
5284            let res = match header.r#type {
5285                1u16 => Attrs::Kind({
5286                    let res = CStr::from_bytes_with_nul(next).ok();
5287                    let Some(val) = res else { break };
5288                    val
5289                }),
5290                2u16 => Attrs::Options({
5291                    let res = {
5292                        let Ok(selector) = self.get_kind() else { break };
5293                        match OptionsMsg::select_with_loc(selector, next, self.orig_loc) {
5294                            Some(sub) => Some(sub),
5295                            None if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5296                            None => continue,
5297                        }
5298                    };
5299                    let Some(val) = res else { break };
5300                    val
5301                }),
5302                3u16 => Attrs::Stats({
5303                    let res = Some(TcStats::new_from_zeroed(next));
5304                    let Some(val) = res else { break };
5305                    val
5306                }),
5307                4u16 => Attrs::Xstats({
5308                    let res = {
5309                        let Ok(selector) = self.get_kind() else { break };
5310                        match TcaStatsAppMsg::select_with_loc(selector, next, self.orig_loc) {
5311                            Some(sub) => Some(sub),
5312                            None if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5313                            None => continue,
5314                        }
5315                    };
5316                    let Some(val) = res else { break };
5317                    val
5318                }),
5319                5u16 => Attrs::Rate({
5320                    let res = Some(GnetEstimator::new_from_zeroed(next));
5321                    let Some(val) = res else { break };
5322                    val
5323                }),
5324                6u16 => Attrs::Fcnt({
5325                    let res = parse_u32(next);
5326                    let Some(val) = res else { break };
5327                    val
5328                }),
5329                7u16 => Attrs::Stats2({
5330                    let res = Some(IterableTcaStatsAttrs::with_loc(next, self.orig_loc));
5331                    let Some(val) = res else { break };
5332                    val
5333                }),
5334                8u16 => Attrs::Stab({
5335                    let res = Some(IterableTcaStabAttrs::with_loc(next, self.orig_loc));
5336                    let Some(val) = res else { break };
5337                    val
5338                }),
5339                9u16 => Attrs::Pad({
5340                    let res = Some(next);
5341                    let Some(val) = res else { break };
5342                    val
5343                }),
5344                10u16 => Attrs::DumpInvisible(()),
5345                11u16 => Attrs::Chain({
5346                    let res = parse_u32(next);
5347                    let Some(val) = res else { break };
5348                    val
5349                }),
5350                12u16 => Attrs::HwOffload({
5351                    let res = parse_u8(next);
5352                    let Some(val) = res else { break };
5353                    val
5354                }),
5355                13u16 => Attrs::IngressBlock({
5356                    let res = parse_u32(next);
5357                    let Some(val) = res else { break };
5358                    val
5359                }),
5360                14u16 => Attrs::EgressBlock({
5361                    let res = parse_u32(next);
5362                    let Some(val) = res else { break };
5363                    val
5364                }),
5365                15u16 => Attrs::DumpFlags({
5366                    let res = BuiltinBitfield32::new_from_slice(next);
5367                    let Some(val) = res else { break };
5368                    val
5369                }),
5370                16u16 => Attrs::ExtWarnMsg({
5371                    let res = CStr::from_bytes_with_nul(next).ok();
5372                    let Some(val) = res else { break };
5373                    val
5374                }),
5375                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5376                n => continue,
5377            };
5378            return Some(Ok(res));
5379        }
5380        Some(Err(ErrorContext::new(
5381            "Attrs",
5382            r#type.and_then(|t| Attrs::attr_from_type(t)),
5383            self.orig_loc,
5384            self.buf.as_ptr().wrapping_add(pos) as usize,
5385        )))
5386    }
5387}
5388impl<'a> std::fmt::Debug for IterableAttrs<'_> {
5389    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5390        let mut fmt = f.debug_struct("Attrs");
5391        for attr in self.clone() {
5392            let attr = match attr {
5393                Ok(a) => a,
5394                Err(err) => {
5395                    fmt.finish()?;
5396                    f.write_str("Err(")?;
5397                    err.fmt(f)?;
5398                    return f.write_str(")");
5399                }
5400            };
5401            match attr {
5402                Attrs::Kind(val) => fmt.field("Kind", &val),
5403                Attrs::Options(val) => fmt.field("Options", &val),
5404                Attrs::Stats(val) => fmt.field("Stats", &val),
5405                Attrs::Xstats(val) => fmt.field("Xstats", &val),
5406                Attrs::Rate(val) => fmt.field("Rate", &val),
5407                Attrs::Fcnt(val) => fmt.field("Fcnt", &val),
5408                Attrs::Stats2(val) => fmt.field("Stats2", &val),
5409                Attrs::Stab(val) => fmt.field("Stab", &val),
5410                Attrs::Pad(val) => fmt.field("Pad", &val),
5411                Attrs::DumpInvisible(val) => fmt.field("DumpInvisible", &val),
5412                Attrs::Chain(val) => fmt.field("Chain", &val),
5413                Attrs::HwOffload(val) => fmt.field("HwOffload", &val),
5414                Attrs::IngressBlock(val) => fmt.field("IngressBlock", &val),
5415                Attrs::EgressBlock(val) => fmt.field("EgressBlock", &val),
5416                Attrs::DumpFlags(val) => fmt.field("DumpFlags", &val),
5417                Attrs::ExtWarnMsg(val) => fmt.field("ExtWarnMsg", &val),
5418            };
5419        }
5420        fmt.finish()
5421    }
5422}
5423impl IterableAttrs<'_> {
5424    pub fn lookup_attr(
5425        &self,
5426        offset: usize,
5427        missing_type: Option<u16>,
5428    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5429        let mut stack = Vec::new();
5430        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5431        if missing_type.is_some() && cur == offset {
5432            stack.push(("Attrs", offset));
5433            return (stack, missing_type.and_then(|t| Attrs::attr_from_type(t)));
5434        }
5435        if cur > offset || cur + self.buf.len() < offset {
5436            return (stack, None);
5437        }
5438        let mut attrs = self.clone();
5439        let mut last_off = cur + attrs.pos;
5440        let mut missing = None;
5441        while let Some(attr) = attrs.next() {
5442            let Ok(attr) = attr else { break };
5443            match attr {
5444                Attrs::Kind(val) => {
5445                    if last_off == offset {
5446                        stack.push(("Kind", last_off));
5447                        break;
5448                    }
5449                }
5450                Attrs::Options(val) => {
5451                    if last_off == offset {
5452                        stack.push(("Options", last_off));
5453                        break;
5454                    }
5455                }
5456                Attrs::Stats(val) => {
5457                    if last_off == offset {
5458                        stack.push(("Stats", last_off));
5459                        break;
5460                    }
5461                }
5462                Attrs::Xstats(val) => {
5463                    if last_off == offset {
5464                        stack.push(("Xstats", last_off));
5465                        break;
5466                    }
5467                }
5468                Attrs::Rate(val) => {
5469                    if last_off == offset {
5470                        stack.push(("Rate", last_off));
5471                        break;
5472                    }
5473                }
5474                Attrs::Fcnt(val) => {
5475                    if last_off == offset {
5476                        stack.push(("Fcnt", last_off));
5477                        break;
5478                    }
5479                }
5480                Attrs::Stats2(val) => {
5481                    (stack, missing) = val.lookup_attr(offset, missing_type);
5482                    if !stack.is_empty() {
5483                        break;
5484                    }
5485                }
5486                Attrs::Stab(val) => {
5487                    (stack, missing) = val.lookup_attr(offset, missing_type);
5488                    if !stack.is_empty() {
5489                        break;
5490                    }
5491                }
5492                Attrs::Pad(val) => {
5493                    if last_off == offset {
5494                        stack.push(("Pad", last_off));
5495                        break;
5496                    }
5497                }
5498                Attrs::DumpInvisible(val) => {
5499                    if last_off == offset {
5500                        stack.push(("DumpInvisible", last_off));
5501                        break;
5502                    }
5503                }
5504                Attrs::Chain(val) => {
5505                    if last_off == offset {
5506                        stack.push(("Chain", last_off));
5507                        break;
5508                    }
5509                }
5510                Attrs::HwOffload(val) => {
5511                    if last_off == offset {
5512                        stack.push(("HwOffload", last_off));
5513                        break;
5514                    }
5515                }
5516                Attrs::IngressBlock(val) => {
5517                    if last_off == offset {
5518                        stack.push(("IngressBlock", last_off));
5519                        break;
5520                    }
5521                }
5522                Attrs::EgressBlock(val) => {
5523                    if last_off == offset {
5524                        stack.push(("EgressBlock", last_off));
5525                        break;
5526                    }
5527                }
5528                Attrs::DumpFlags(val) => {
5529                    if last_off == offset {
5530                        stack.push(("DumpFlags", last_off));
5531                        break;
5532                    }
5533                }
5534                Attrs::ExtWarnMsg(val) => {
5535                    if last_off == offset {
5536                        stack.push(("ExtWarnMsg", last_off));
5537                        break;
5538                    }
5539                }
5540                _ => {}
5541            };
5542            last_off = cur + attrs.pos;
5543        }
5544        if !stack.is_empty() {
5545            stack.push(("Attrs", cur));
5546        }
5547        (stack, missing)
5548    }
5549}
5550#[derive(Clone)]
5551pub enum ActAttrs<'a> {
5552    Kind(&'a CStr),
5553    Options(ActOptionsMsg<'a>),
5554    Index(u32),
5555    Stats(IterableTcaStatsAttrs<'a>),
5556    Pad(&'a [u8]),
5557    Cookie(&'a [u8]),
5558    Flags(BuiltinBitfield32),
5559    HwStats(BuiltinBitfield32),
5560    UsedHwStats(BuiltinBitfield32),
5561    InHwCount(u32),
5562}
5563impl<'a> IterableActAttrs<'a> {
5564    pub fn get_kind(&self) -> Result<&'a CStr, ErrorContext> {
5565        let mut iter = self.clone();
5566        iter.pos = 0;
5567        for attr in iter {
5568            if let ActAttrs::Kind(val) = attr? {
5569                return Ok(val);
5570            }
5571        }
5572        Err(ErrorContext::new_missing(
5573            "ActAttrs",
5574            "Kind",
5575            self.orig_loc,
5576            self.buf.as_ptr() as usize,
5577        ))
5578    }
5579    pub fn get_options(&self) -> Result<ActOptionsMsg<'a>, ErrorContext> {
5580        let mut iter = self.clone();
5581        iter.pos = 0;
5582        for attr in iter {
5583            if let ActAttrs::Options(val) = attr? {
5584                return Ok(val);
5585            }
5586        }
5587        Err(ErrorContext::new_missing(
5588            "ActAttrs",
5589            "Options",
5590            self.orig_loc,
5591            self.buf.as_ptr() as usize,
5592        ))
5593    }
5594    pub fn get_index(&self) -> Result<u32, ErrorContext> {
5595        let mut iter = self.clone();
5596        iter.pos = 0;
5597        for attr in iter {
5598            if let ActAttrs::Index(val) = attr? {
5599                return Ok(val);
5600            }
5601        }
5602        Err(ErrorContext::new_missing(
5603            "ActAttrs",
5604            "Index",
5605            self.orig_loc,
5606            self.buf.as_ptr() as usize,
5607        ))
5608    }
5609    pub fn get_stats(&self) -> Result<IterableTcaStatsAttrs<'a>, ErrorContext> {
5610        let mut iter = self.clone();
5611        iter.pos = 0;
5612        for attr in iter {
5613            if let ActAttrs::Stats(val) = attr? {
5614                return Ok(val);
5615            }
5616        }
5617        Err(ErrorContext::new_missing(
5618            "ActAttrs",
5619            "Stats",
5620            self.orig_loc,
5621            self.buf.as_ptr() as usize,
5622        ))
5623    }
5624    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
5625        let mut iter = self.clone();
5626        iter.pos = 0;
5627        for attr in iter {
5628            if let ActAttrs::Pad(val) = attr? {
5629                return Ok(val);
5630            }
5631        }
5632        Err(ErrorContext::new_missing(
5633            "ActAttrs",
5634            "Pad",
5635            self.orig_loc,
5636            self.buf.as_ptr() as usize,
5637        ))
5638    }
5639    pub fn get_cookie(&self) -> Result<&'a [u8], ErrorContext> {
5640        let mut iter = self.clone();
5641        iter.pos = 0;
5642        for attr in iter {
5643            if let ActAttrs::Cookie(val) = attr? {
5644                return Ok(val);
5645            }
5646        }
5647        Err(ErrorContext::new_missing(
5648            "ActAttrs",
5649            "Cookie",
5650            self.orig_loc,
5651            self.buf.as_ptr() as usize,
5652        ))
5653    }
5654    pub fn get_flags(&self) -> Result<BuiltinBitfield32, ErrorContext> {
5655        let mut iter = self.clone();
5656        iter.pos = 0;
5657        for attr in iter {
5658            if let ActAttrs::Flags(val) = attr? {
5659                return Ok(val);
5660            }
5661        }
5662        Err(ErrorContext::new_missing(
5663            "ActAttrs",
5664            "Flags",
5665            self.orig_loc,
5666            self.buf.as_ptr() as usize,
5667        ))
5668    }
5669    pub fn get_hw_stats(&self) -> Result<BuiltinBitfield32, ErrorContext> {
5670        let mut iter = self.clone();
5671        iter.pos = 0;
5672        for attr in iter {
5673            if let ActAttrs::HwStats(val) = attr? {
5674                return Ok(val);
5675            }
5676        }
5677        Err(ErrorContext::new_missing(
5678            "ActAttrs",
5679            "HwStats",
5680            self.orig_loc,
5681            self.buf.as_ptr() as usize,
5682        ))
5683    }
5684    pub fn get_used_hw_stats(&self) -> Result<BuiltinBitfield32, ErrorContext> {
5685        let mut iter = self.clone();
5686        iter.pos = 0;
5687        for attr in iter {
5688            if let ActAttrs::UsedHwStats(val) = attr? {
5689                return Ok(val);
5690            }
5691        }
5692        Err(ErrorContext::new_missing(
5693            "ActAttrs",
5694            "UsedHwStats",
5695            self.orig_loc,
5696            self.buf.as_ptr() as usize,
5697        ))
5698    }
5699    pub fn get_in_hw_count(&self) -> Result<u32, ErrorContext> {
5700        let mut iter = self.clone();
5701        iter.pos = 0;
5702        for attr in iter {
5703            if let ActAttrs::InHwCount(val) = attr? {
5704                return Ok(val);
5705            }
5706        }
5707        Err(ErrorContext::new_missing(
5708            "ActAttrs",
5709            "InHwCount",
5710            self.orig_loc,
5711            self.buf.as_ptr() as usize,
5712        ))
5713    }
5714}
5715#[derive(Debug, Clone)]
5716pub enum ActOptionsMsg<'a> {
5717    Bpf(IterableActBpfAttrs<'a>),
5718    Connmark(IterableActConnmarkAttrs<'a>),
5719    Csum(IterableActCsumAttrs<'a>),
5720    Ct(IterableActCtAttrs<'a>),
5721    Ctinfo(IterableActCtinfoAttrs<'a>),
5722    Gact(IterableActGactAttrs<'a>),
5723    Gate(IterableActGateAttrs<'a>),
5724    Ife(IterableActIfeAttrs<'a>),
5725    Mirred(IterableActMirredAttrs<'a>),
5726    Mpls(IterableActMplsAttrs<'a>),
5727    Nat(IterableActNatAttrs<'a>),
5728    Pedit(IterableActPeditAttrs<'a>),
5729    Police(IterablePoliceAttrs<'a>),
5730    Sample(IterableActSampleAttrs<'a>),
5731    Simple(IterableActSimpleAttrs<'a>),
5732    Skbedit(IterableActSkbeditAttrs<'a>),
5733    Skbmod(IterableActSkbmodAttrs<'a>),
5734    TunnelKey(IterableActTunnelKeyAttrs<'a>),
5735    Vlan(IterableActVlanAttrs<'a>),
5736}
5737impl<'a> ActOptionsMsg<'a> {
5738    fn select_with_loc(selector: &'a CStr, buf: &'a [u8], loc: usize) -> Option<Self> {
5739        match selector.to_bytes() {
5740            b"bpf" => Some(ActOptionsMsg::Bpf(IterableActBpfAttrs::with_loc(buf, loc))),
5741            b"connmark" => Some(ActOptionsMsg::Connmark(IterableActConnmarkAttrs::with_loc(
5742                buf, loc,
5743            ))),
5744            b"csum" => Some(ActOptionsMsg::Csum(IterableActCsumAttrs::with_loc(
5745                buf, loc,
5746            ))),
5747            b"ct" => Some(ActOptionsMsg::Ct(IterableActCtAttrs::with_loc(buf, loc))),
5748            b"ctinfo" => Some(ActOptionsMsg::Ctinfo(IterableActCtinfoAttrs::with_loc(
5749                buf, loc,
5750            ))),
5751            b"gact" => Some(ActOptionsMsg::Gact(IterableActGactAttrs::with_loc(
5752                buf, loc,
5753            ))),
5754            b"gate" => Some(ActOptionsMsg::Gate(IterableActGateAttrs::with_loc(
5755                buf, loc,
5756            ))),
5757            b"ife" => Some(ActOptionsMsg::Ife(IterableActIfeAttrs::with_loc(buf, loc))),
5758            b"mirred" => Some(ActOptionsMsg::Mirred(IterableActMirredAttrs::with_loc(
5759                buf, loc,
5760            ))),
5761            b"mpls" => Some(ActOptionsMsg::Mpls(IterableActMplsAttrs::with_loc(
5762                buf, loc,
5763            ))),
5764            b"nat" => Some(ActOptionsMsg::Nat(IterableActNatAttrs::with_loc(buf, loc))),
5765            b"pedit" => Some(ActOptionsMsg::Pedit(IterableActPeditAttrs::with_loc(
5766                buf, loc,
5767            ))),
5768            b"police" => Some(ActOptionsMsg::Police(IterablePoliceAttrs::with_loc(
5769                buf, loc,
5770            ))),
5771            b"sample" => Some(ActOptionsMsg::Sample(IterableActSampleAttrs::with_loc(
5772                buf, loc,
5773            ))),
5774            b"simple" => Some(ActOptionsMsg::Simple(IterableActSimpleAttrs::with_loc(
5775                buf, loc,
5776            ))),
5777            b"skbedit" => Some(ActOptionsMsg::Skbedit(IterableActSkbeditAttrs::with_loc(
5778                buf, loc,
5779            ))),
5780            b"skbmod" => Some(ActOptionsMsg::Skbmod(IterableActSkbmodAttrs::with_loc(
5781                buf, loc,
5782            ))),
5783            b"tunnel_key" => Some(ActOptionsMsg::TunnelKey(
5784                IterableActTunnelKeyAttrs::with_loc(buf, loc),
5785            )),
5786            b"vlan" => Some(ActOptionsMsg::Vlan(IterableActVlanAttrs::with_loc(
5787                buf, loc,
5788            ))),
5789            _ => None,
5790        }
5791    }
5792}
5793impl ActAttrs<'_> {
5794    pub fn new<'a>(buf: &'a [u8]) -> IterableActAttrs<'a> {
5795        IterableActAttrs::with_loc(buf, buf.as_ptr() as usize)
5796    }
5797    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5798        let res = match r#type {
5799            1u16 => "Kind",
5800            2u16 => "Options",
5801            3u16 => "Index",
5802            4u16 => "Stats",
5803            5u16 => "Pad",
5804            6u16 => "Cookie",
5805            7u16 => "Flags",
5806            8u16 => "HwStats",
5807            9u16 => "UsedHwStats",
5808            10u16 => "InHwCount",
5809            _ => return None,
5810        };
5811        Some(res)
5812    }
5813}
5814#[derive(Clone, Copy, Default)]
5815pub struct IterableActAttrs<'a> {
5816    buf: &'a [u8],
5817    pos: usize,
5818    orig_loc: usize,
5819}
5820impl<'a> IterableActAttrs<'a> {
5821    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5822        Self {
5823            buf,
5824            pos: 0,
5825            orig_loc,
5826        }
5827    }
5828    pub fn get_buf(&self) -> &'a [u8] {
5829        self.buf
5830    }
5831}
5832impl<'a> Iterator for IterableActAttrs<'a> {
5833    type Item = Result<ActAttrs<'a>, ErrorContext>;
5834    fn next(&mut self) -> Option<Self::Item> {
5835        let pos = self.pos;
5836        let mut r#type;
5837        loop {
5838            r#type = None;
5839            if self.buf.len() == self.pos {
5840                return None;
5841            }
5842            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5843                break;
5844            };
5845            r#type = Some(header.r#type);
5846            let res = match header.r#type {
5847                1u16 => ActAttrs::Kind({
5848                    let res = CStr::from_bytes_with_nul(next).ok();
5849                    let Some(val) = res else { break };
5850                    val
5851                }),
5852                2u16 => ActAttrs::Options({
5853                    let res = {
5854                        let Ok(selector) = self.get_kind() else { break };
5855                        match ActOptionsMsg::select_with_loc(selector, next, self.orig_loc) {
5856                            Some(sub) => Some(sub),
5857                            None if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5858                            None => continue,
5859                        }
5860                    };
5861                    let Some(val) = res else { break };
5862                    val
5863                }),
5864                3u16 => ActAttrs::Index({
5865                    let res = parse_u32(next);
5866                    let Some(val) = res else { break };
5867                    val
5868                }),
5869                4u16 => ActAttrs::Stats({
5870                    let res = Some(IterableTcaStatsAttrs::with_loc(next, self.orig_loc));
5871                    let Some(val) = res else { break };
5872                    val
5873                }),
5874                5u16 => ActAttrs::Pad({
5875                    let res = Some(next);
5876                    let Some(val) = res else { break };
5877                    val
5878                }),
5879                6u16 => ActAttrs::Cookie({
5880                    let res = Some(next);
5881                    let Some(val) = res else { break };
5882                    val
5883                }),
5884                7u16 => ActAttrs::Flags({
5885                    let res = BuiltinBitfield32::new_from_slice(next);
5886                    let Some(val) = res else { break };
5887                    val
5888                }),
5889                8u16 => ActAttrs::HwStats({
5890                    let res = BuiltinBitfield32::new_from_slice(next);
5891                    let Some(val) = res else { break };
5892                    val
5893                }),
5894                9u16 => ActAttrs::UsedHwStats({
5895                    let res = BuiltinBitfield32::new_from_slice(next);
5896                    let Some(val) = res else { break };
5897                    val
5898                }),
5899                10u16 => ActAttrs::InHwCount({
5900                    let res = parse_u32(next);
5901                    let Some(val) = res else { break };
5902                    val
5903                }),
5904                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5905                n => continue,
5906            };
5907            return Some(Ok(res));
5908        }
5909        Some(Err(ErrorContext::new(
5910            "ActAttrs",
5911            r#type.and_then(|t| ActAttrs::attr_from_type(t)),
5912            self.orig_loc,
5913            self.buf.as_ptr().wrapping_add(pos) as usize,
5914        )))
5915    }
5916}
5917impl<'a> std::fmt::Debug for IterableActAttrs<'_> {
5918    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5919        let mut fmt = f.debug_struct("ActAttrs");
5920        for attr in self.clone() {
5921            let attr = match attr {
5922                Ok(a) => a,
5923                Err(err) => {
5924                    fmt.finish()?;
5925                    f.write_str("Err(")?;
5926                    err.fmt(f)?;
5927                    return f.write_str(")");
5928                }
5929            };
5930            match attr {
5931                ActAttrs::Kind(val) => fmt.field("Kind", &val),
5932                ActAttrs::Options(val) => fmt.field("Options", &val),
5933                ActAttrs::Index(val) => fmt.field("Index", &val),
5934                ActAttrs::Stats(val) => fmt.field("Stats", &val),
5935                ActAttrs::Pad(val) => fmt.field("Pad", &val),
5936                ActAttrs::Cookie(val) => fmt.field("Cookie", &val),
5937                ActAttrs::Flags(val) => fmt.field("Flags", &val),
5938                ActAttrs::HwStats(val) => fmt.field("HwStats", &val),
5939                ActAttrs::UsedHwStats(val) => fmt.field("UsedHwStats", &val),
5940                ActAttrs::InHwCount(val) => fmt.field("InHwCount", &val),
5941            };
5942        }
5943        fmt.finish()
5944    }
5945}
5946impl IterableActAttrs<'_> {
5947    pub fn lookup_attr(
5948        &self,
5949        offset: usize,
5950        missing_type: Option<u16>,
5951    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5952        let mut stack = Vec::new();
5953        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5954        if missing_type.is_some() && cur == offset {
5955            stack.push(("ActAttrs", offset));
5956            return (
5957                stack,
5958                missing_type.and_then(|t| ActAttrs::attr_from_type(t)),
5959            );
5960        }
5961        if cur > offset || cur + self.buf.len() < offset {
5962            return (stack, None);
5963        }
5964        let mut attrs = self.clone();
5965        let mut last_off = cur + attrs.pos;
5966        let mut missing = None;
5967        while let Some(attr) = attrs.next() {
5968            let Ok(attr) = attr else { break };
5969            match attr {
5970                ActAttrs::Kind(val) => {
5971                    if last_off == offset {
5972                        stack.push(("Kind", last_off));
5973                        break;
5974                    }
5975                }
5976                ActAttrs::Options(val) => {
5977                    if last_off == offset {
5978                        stack.push(("Options", last_off));
5979                        break;
5980                    }
5981                }
5982                ActAttrs::Index(val) => {
5983                    if last_off == offset {
5984                        stack.push(("Index", last_off));
5985                        break;
5986                    }
5987                }
5988                ActAttrs::Stats(val) => {
5989                    (stack, missing) = val.lookup_attr(offset, missing_type);
5990                    if !stack.is_empty() {
5991                        break;
5992                    }
5993                }
5994                ActAttrs::Pad(val) => {
5995                    if last_off == offset {
5996                        stack.push(("Pad", last_off));
5997                        break;
5998                    }
5999                }
6000                ActAttrs::Cookie(val) => {
6001                    if last_off == offset {
6002                        stack.push(("Cookie", last_off));
6003                        break;
6004                    }
6005                }
6006                ActAttrs::Flags(val) => {
6007                    if last_off == offset {
6008                        stack.push(("Flags", last_off));
6009                        break;
6010                    }
6011                }
6012                ActAttrs::HwStats(val) => {
6013                    if last_off == offset {
6014                        stack.push(("HwStats", last_off));
6015                        break;
6016                    }
6017                }
6018                ActAttrs::UsedHwStats(val) => {
6019                    if last_off == offset {
6020                        stack.push(("UsedHwStats", last_off));
6021                        break;
6022                    }
6023                }
6024                ActAttrs::InHwCount(val) => {
6025                    if last_off == offset {
6026                        stack.push(("InHwCount", last_off));
6027                        break;
6028                    }
6029                }
6030                _ => {}
6031            };
6032            last_off = cur + attrs.pos;
6033        }
6034        if !stack.is_empty() {
6035            stack.push(("ActAttrs", cur));
6036        }
6037        (stack, missing)
6038    }
6039}
6040#[derive(Clone)]
6041pub enum ActBpfAttrs<'a> {
6042    Tm(TcfT),
6043    Parms(&'a [u8]),
6044    OpsLen(u16),
6045    Ops(&'a [u8]),
6046    Fd(u32),
6047    Name(&'a CStr),
6048    Pad(&'a [u8]),
6049    Tag(&'a [u8]),
6050    Id(&'a [u8]),
6051}
6052impl<'a> IterableActBpfAttrs<'a> {
6053    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
6054        let mut iter = self.clone();
6055        iter.pos = 0;
6056        for attr in iter {
6057            if let ActBpfAttrs::Tm(val) = attr? {
6058                return Ok(val);
6059            }
6060        }
6061        Err(ErrorContext::new_missing(
6062            "ActBpfAttrs",
6063            "Tm",
6064            self.orig_loc,
6065            self.buf.as_ptr() as usize,
6066        ))
6067    }
6068    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
6069        let mut iter = self.clone();
6070        iter.pos = 0;
6071        for attr in iter {
6072            if let ActBpfAttrs::Parms(val) = attr? {
6073                return Ok(val);
6074            }
6075        }
6076        Err(ErrorContext::new_missing(
6077            "ActBpfAttrs",
6078            "Parms",
6079            self.orig_loc,
6080            self.buf.as_ptr() as usize,
6081        ))
6082    }
6083    pub fn get_ops_len(&self) -> Result<u16, ErrorContext> {
6084        let mut iter = self.clone();
6085        iter.pos = 0;
6086        for attr in iter {
6087            if let ActBpfAttrs::OpsLen(val) = attr? {
6088                return Ok(val);
6089            }
6090        }
6091        Err(ErrorContext::new_missing(
6092            "ActBpfAttrs",
6093            "OpsLen",
6094            self.orig_loc,
6095            self.buf.as_ptr() as usize,
6096        ))
6097    }
6098    pub fn get_ops(&self) -> Result<&'a [u8], ErrorContext> {
6099        let mut iter = self.clone();
6100        iter.pos = 0;
6101        for attr in iter {
6102            if let ActBpfAttrs::Ops(val) = attr? {
6103                return Ok(val);
6104            }
6105        }
6106        Err(ErrorContext::new_missing(
6107            "ActBpfAttrs",
6108            "Ops",
6109            self.orig_loc,
6110            self.buf.as_ptr() as usize,
6111        ))
6112    }
6113    pub fn get_fd(&self) -> Result<u32, ErrorContext> {
6114        let mut iter = self.clone();
6115        iter.pos = 0;
6116        for attr in iter {
6117            if let ActBpfAttrs::Fd(val) = attr? {
6118                return Ok(val);
6119            }
6120        }
6121        Err(ErrorContext::new_missing(
6122            "ActBpfAttrs",
6123            "Fd",
6124            self.orig_loc,
6125            self.buf.as_ptr() as usize,
6126        ))
6127    }
6128    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
6129        let mut iter = self.clone();
6130        iter.pos = 0;
6131        for attr in iter {
6132            if let ActBpfAttrs::Name(val) = attr? {
6133                return Ok(val);
6134            }
6135        }
6136        Err(ErrorContext::new_missing(
6137            "ActBpfAttrs",
6138            "Name",
6139            self.orig_loc,
6140            self.buf.as_ptr() as usize,
6141        ))
6142    }
6143    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
6144        let mut iter = self.clone();
6145        iter.pos = 0;
6146        for attr in iter {
6147            if let ActBpfAttrs::Pad(val) = attr? {
6148                return Ok(val);
6149            }
6150        }
6151        Err(ErrorContext::new_missing(
6152            "ActBpfAttrs",
6153            "Pad",
6154            self.orig_loc,
6155            self.buf.as_ptr() as usize,
6156        ))
6157    }
6158    pub fn get_tag(&self) -> Result<&'a [u8], ErrorContext> {
6159        let mut iter = self.clone();
6160        iter.pos = 0;
6161        for attr in iter {
6162            if let ActBpfAttrs::Tag(val) = attr? {
6163                return Ok(val);
6164            }
6165        }
6166        Err(ErrorContext::new_missing(
6167            "ActBpfAttrs",
6168            "Tag",
6169            self.orig_loc,
6170            self.buf.as_ptr() as usize,
6171        ))
6172    }
6173    pub fn get_id(&self) -> Result<&'a [u8], ErrorContext> {
6174        let mut iter = self.clone();
6175        iter.pos = 0;
6176        for attr in iter {
6177            if let ActBpfAttrs::Id(val) = attr? {
6178                return Ok(val);
6179            }
6180        }
6181        Err(ErrorContext::new_missing(
6182            "ActBpfAttrs",
6183            "Id",
6184            self.orig_loc,
6185            self.buf.as_ptr() as usize,
6186        ))
6187    }
6188}
6189impl ActBpfAttrs<'_> {
6190    pub fn new<'a>(buf: &'a [u8]) -> IterableActBpfAttrs<'a> {
6191        IterableActBpfAttrs::with_loc(buf, buf.as_ptr() as usize)
6192    }
6193    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6194        let res = match r#type {
6195            1u16 => "Tm",
6196            2u16 => "Parms",
6197            3u16 => "OpsLen",
6198            4u16 => "Ops",
6199            5u16 => "Fd",
6200            6u16 => "Name",
6201            7u16 => "Pad",
6202            8u16 => "Tag",
6203            9u16 => "Id",
6204            _ => return None,
6205        };
6206        Some(res)
6207    }
6208}
6209#[derive(Clone, Copy, Default)]
6210pub struct IterableActBpfAttrs<'a> {
6211    buf: &'a [u8],
6212    pos: usize,
6213    orig_loc: usize,
6214}
6215impl<'a> IterableActBpfAttrs<'a> {
6216    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
6217        Self {
6218            buf,
6219            pos: 0,
6220            orig_loc,
6221        }
6222    }
6223    pub fn get_buf(&self) -> &'a [u8] {
6224        self.buf
6225    }
6226}
6227impl<'a> Iterator for IterableActBpfAttrs<'a> {
6228    type Item = Result<ActBpfAttrs<'a>, ErrorContext>;
6229    fn next(&mut self) -> Option<Self::Item> {
6230        let pos = self.pos;
6231        let mut r#type;
6232        loop {
6233            r#type = None;
6234            if self.buf.len() == self.pos {
6235                return None;
6236            }
6237            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
6238                break;
6239            };
6240            r#type = Some(header.r#type);
6241            let res = match header.r#type {
6242                1u16 => ActBpfAttrs::Tm({
6243                    let res = Some(TcfT::new_from_zeroed(next));
6244                    let Some(val) = res else { break };
6245                    val
6246                }),
6247                2u16 => ActBpfAttrs::Parms({
6248                    let res = Some(next);
6249                    let Some(val) = res else { break };
6250                    val
6251                }),
6252                3u16 => ActBpfAttrs::OpsLen({
6253                    let res = parse_u16(next);
6254                    let Some(val) = res else { break };
6255                    val
6256                }),
6257                4u16 => ActBpfAttrs::Ops({
6258                    let res = Some(next);
6259                    let Some(val) = res else { break };
6260                    val
6261                }),
6262                5u16 => ActBpfAttrs::Fd({
6263                    let res = parse_u32(next);
6264                    let Some(val) = res else { break };
6265                    val
6266                }),
6267                6u16 => ActBpfAttrs::Name({
6268                    let res = CStr::from_bytes_with_nul(next).ok();
6269                    let Some(val) = res else { break };
6270                    val
6271                }),
6272                7u16 => ActBpfAttrs::Pad({
6273                    let res = Some(next);
6274                    let Some(val) = res else { break };
6275                    val
6276                }),
6277                8u16 => ActBpfAttrs::Tag({
6278                    let res = Some(next);
6279                    let Some(val) = res else { break };
6280                    val
6281                }),
6282                9u16 => ActBpfAttrs::Id({
6283                    let res = Some(next);
6284                    let Some(val) = res else { break };
6285                    val
6286                }),
6287                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6288                n => continue,
6289            };
6290            return Some(Ok(res));
6291        }
6292        Some(Err(ErrorContext::new(
6293            "ActBpfAttrs",
6294            r#type.and_then(|t| ActBpfAttrs::attr_from_type(t)),
6295            self.orig_loc,
6296            self.buf.as_ptr().wrapping_add(pos) as usize,
6297        )))
6298    }
6299}
6300impl<'a> std::fmt::Debug for IterableActBpfAttrs<'_> {
6301    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6302        let mut fmt = f.debug_struct("ActBpfAttrs");
6303        for attr in self.clone() {
6304            let attr = match attr {
6305                Ok(a) => a,
6306                Err(err) => {
6307                    fmt.finish()?;
6308                    f.write_str("Err(")?;
6309                    err.fmt(f)?;
6310                    return f.write_str(")");
6311                }
6312            };
6313            match attr {
6314                ActBpfAttrs::Tm(val) => fmt.field("Tm", &val),
6315                ActBpfAttrs::Parms(val) => fmt.field("Parms", &val),
6316                ActBpfAttrs::OpsLen(val) => fmt.field("OpsLen", &val),
6317                ActBpfAttrs::Ops(val) => fmt.field("Ops", &val),
6318                ActBpfAttrs::Fd(val) => fmt.field("Fd", &val),
6319                ActBpfAttrs::Name(val) => fmt.field("Name", &val),
6320                ActBpfAttrs::Pad(val) => fmt.field("Pad", &val),
6321                ActBpfAttrs::Tag(val) => fmt.field("Tag", &val),
6322                ActBpfAttrs::Id(val) => fmt.field("Id", &val),
6323            };
6324        }
6325        fmt.finish()
6326    }
6327}
6328impl IterableActBpfAttrs<'_> {
6329    pub fn lookup_attr(
6330        &self,
6331        offset: usize,
6332        missing_type: Option<u16>,
6333    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6334        let mut stack = Vec::new();
6335        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6336        if missing_type.is_some() && cur == offset {
6337            stack.push(("ActBpfAttrs", offset));
6338            return (
6339                stack,
6340                missing_type.and_then(|t| ActBpfAttrs::attr_from_type(t)),
6341            );
6342        }
6343        if cur > offset || cur + self.buf.len() < offset {
6344            return (stack, None);
6345        }
6346        let mut attrs = self.clone();
6347        let mut last_off = cur + attrs.pos;
6348        while let Some(attr) = attrs.next() {
6349            let Ok(attr) = attr else { break };
6350            match attr {
6351                ActBpfAttrs::Tm(val) => {
6352                    if last_off == offset {
6353                        stack.push(("Tm", last_off));
6354                        break;
6355                    }
6356                }
6357                ActBpfAttrs::Parms(val) => {
6358                    if last_off == offset {
6359                        stack.push(("Parms", last_off));
6360                        break;
6361                    }
6362                }
6363                ActBpfAttrs::OpsLen(val) => {
6364                    if last_off == offset {
6365                        stack.push(("OpsLen", last_off));
6366                        break;
6367                    }
6368                }
6369                ActBpfAttrs::Ops(val) => {
6370                    if last_off == offset {
6371                        stack.push(("Ops", last_off));
6372                        break;
6373                    }
6374                }
6375                ActBpfAttrs::Fd(val) => {
6376                    if last_off == offset {
6377                        stack.push(("Fd", last_off));
6378                        break;
6379                    }
6380                }
6381                ActBpfAttrs::Name(val) => {
6382                    if last_off == offset {
6383                        stack.push(("Name", last_off));
6384                        break;
6385                    }
6386                }
6387                ActBpfAttrs::Pad(val) => {
6388                    if last_off == offset {
6389                        stack.push(("Pad", last_off));
6390                        break;
6391                    }
6392                }
6393                ActBpfAttrs::Tag(val) => {
6394                    if last_off == offset {
6395                        stack.push(("Tag", last_off));
6396                        break;
6397                    }
6398                }
6399                ActBpfAttrs::Id(val) => {
6400                    if last_off == offset {
6401                        stack.push(("Id", last_off));
6402                        break;
6403                    }
6404                }
6405                _ => {}
6406            };
6407            last_off = cur + attrs.pos;
6408        }
6409        if !stack.is_empty() {
6410            stack.push(("ActBpfAttrs", cur));
6411        }
6412        (stack, None)
6413    }
6414}
6415#[derive(Clone)]
6416pub enum ActConnmarkAttrs<'a> {
6417    Parms(&'a [u8]),
6418    Tm(TcfT),
6419    Pad(&'a [u8]),
6420}
6421impl<'a> IterableActConnmarkAttrs<'a> {
6422    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
6423        let mut iter = self.clone();
6424        iter.pos = 0;
6425        for attr in iter {
6426            if let ActConnmarkAttrs::Parms(val) = attr? {
6427                return Ok(val);
6428            }
6429        }
6430        Err(ErrorContext::new_missing(
6431            "ActConnmarkAttrs",
6432            "Parms",
6433            self.orig_loc,
6434            self.buf.as_ptr() as usize,
6435        ))
6436    }
6437    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
6438        let mut iter = self.clone();
6439        iter.pos = 0;
6440        for attr in iter {
6441            if let ActConnmarkAttrs::Tm(val) = attr? {
6442                return Ok(val);
6443            }
6444        }
6445        Err(ErrorContext::new_missing(
6446            "ActConnmarkAttrs",
6447            "Tm",
6448            self.orig_loc,
6449            self.buf.as_ptr() as usize,
6450        ))
6451    }
6452    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
6453        let mut iter = self.clone();
6454        iter.pos = 0;
6455        for attr in iter {
6456            if let ActConnmarkAttrs::Pad(val) = attr? {
6457                return Ok(val);
6458            }
6459        }
6460        Err(ErrorContext::new_missing(
6461            "ActConnmarkAttrs",
6462            "Pad",
6463            self.orig_loc,
6464            self.buf.as_ptr() as usize,
6465        ))
6466    }
6467}
6468impl ActConnmarkAttrs<'_> {
6469    pub fn new<'a>(buf: &'a [u8]) -> IterableActConnmarkAttrs<'a> {
6470        IterableActConnmarkAttrs::with_loc(buf, buf.as_ptr() as usize)
6471    }
6472    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6473        let res = match r#type {
6474            1u16 => "Parms",
6475            2u16 => "Tm",
6476            3u16 => "Pad",
6477            _ => return None,
6478        };
6479        Some(res)
6480    }
6481}
6482#[derive(Clone, Copy, Default)]
6483pub struct IterableActConnmarkAttrs<'a> {
6484    buf: &'a [u8],
6485    pos: usize,
6486    orig_loc: usize,
6487}
6488impl<'a> IterableActConnmarkAttrs<'a> {
6489    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
6490        Self {
6491            buf,
6492            pos: 0,
6493            orig_loc,
6494        }
6495    }
6496    pub fn get_buf(&self) -> &'a [u8] {
6497        self.buf
6498    }
6499}
6500impl<'a> Iterator for IterableActConnmarkAttrs<'a> {
6501    type Item = Result<ActConnmarkAttrs<'a>, ErrorContext>;
6502    fn next(&mut self) -> Option<Self::Item> {
6503        let pos = self.pos;
6504        let mut r#type;
6505        loop {
6506            r#type = None;
6507            if self.buf.len() == self.pos {
6508                return None;
6509            }
6510            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
6511                break;
6512            };
6513            r#type = Some(header.r#type);
6514            let res = match header.r#type {
6515                1u16 => ActConnmarkAttrs::Parms({
6516                    let res = Some(next);
6517                    let Some(val) = res else { break };
6518                    val
6519                }),
6520                2u16 => ActConnmarkAttrs::Tm({
6521                    let res = Some(TcfT::new_from_zeroed(next));
6522                    let Some(val) = res else { break };
6523                    val
6524                }),
6525                3u16 => ActConnmarkAttrs::Pad({
6526                    let res = Some(next);
6527                    let Some(val) = res else { break };
6528                    val
6529                }),
6530                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6531                n => continue,
6532            };
6533            return Some(Ok(res));
6534        }
6535        Some(Err(ErrorContext::new(
6536            "ActConnmarkAttrs",
6537            r#type.and_then(|t| ActConnmarkAttrs::attr_from_type(t)),
6538            self.orig_loc,
6539            self.buf.as_ptr().wrapping_add(pos) as usize,
6540        )))
6541    }
6542}
6543impl<'a> std::fmt::Debug for IterableActConnmarkAttrs<'_> {
6544    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6545        let mut fmt = f.debug_struct("ActConnmarkAttrs");
6546        for attr in self.clone() {
6547            let attr = match attr {
6548                Ok(a) => a,
6549                Err(err) => {
6550                    fmt.finish()?;
6551                    f.write_str("Err(")?;
6552                    err.fmt(f)?;
6553                    return f.write_str(")");
6554                }
6555            };
6556            match attr {
6557                ActConnmarkAttrs::Parms(val) => fmt.field("Parms", &val),
6558                ActConnmarkAttrs::Tm(val) => fmt.field("Tm", &val),
6559                ActConnmarkAttrs::Pad(val) => fmt.field("Pad", &val),
6560            };
6561        }
6562        fmt.finish()
6563    }
6564}
6565impl IterableActConnmarkAttrs<'_> {
6566    pub fn lookup_attr(
6567        &self,
6568        offset: usize,
6569        missing_type: Option<u16>,
6570    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6571        let mut stack = Vec::new();
6572        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6573        if missing_type.is_some() && cur == offset {
6574            stack.push(("ActConnmarkAttrs", offset));
6575            return (
6576                stack,
6577                missing_type.and_then(|t| ActConnmarkAttrs::attr_from_type(t)),
6578            );
6579        }
6580        if cur > offset || cur + self.buf.len() < offset {
6581            return (stack, None);
6582        }
6583        let mut attrs = self.clone();
6584        let mut last_off = cur + attrs.pos;
6585        while let Some(attr) = attrs.next() {
6586            let Ok(attr) = attr else { break };
6587            match attr {
6588                ActConnmarkAttrs::Parms(val) => {
6589                    if last_off == offset {
6590                        stack.push(("Parms", last_off));
6591                        break;
6592                    }
6593                }
6594                ActConnmarkAttrs::Tm(val) => {
6595                    if last_off == offset {
6596                        stack.push(("Tm", last_off));
6597                        break;
6598                    }
6599                }
6600                ActConnmarkAttrs::Pad(val) => {
6601                    if last_off == offset {
6602                        stack.push(("Pad", last_off));
6603                        break;
6604                    }
6605                }
6606                _ => {}
6607            };
6608            last_off = cur + attrs.pos;
6609        }
6610        if !stack.is_empty() {
6611            stack.push(("ActConnmarkAttrs", cur));
6612        }
6613        (stack, None)
6614    }
6615}
6616#[derive(Clone)]
6617pub enum ActCsumAttrs<'a> {
6618    Parms(&'a [u8]),
6619    Tm(TcfT),
6620    Pad(&'a [u8]),
6621}
6622impl<'a> IterableActCsumAttrs<'a> {
6623    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
6624        let mut iter = self.clone();
6625        iter.pos = 0;
6626        for attr in iter {
6627            if let ActCsumAttrs::Parms(val) = attr? {
6628                return Ok(val);
6629            }
6630        }
6631        Err(ErrorContext::new_missing(
6632            "ActCsumAttrs",
6633            "Parms",
6634            self.orig_loc,
6635            self.buf.as_ptr() as usize,
6636        ))
6637    }
6638    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
6639        let mut iter = self.clone();
6640        iter.pos = 0;
6641        for attr in iter {
6642            if let ActCsumAttrs::Tm(val) = attr? {
6643                return Ok(val);
6644            }
6645        }
6646        Err(ErrorContext::new_missing(
6647            "ActCsumAttrs",
6648            "Tm",
6649            self.orig_loc,
6650            self.buf.as_ptr() as usize,
6651        ))
6652    }
6653    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
6654        let mut iter = self.clone();
6655        iter.pos = 0;
6656        for attr in iter {
6657            if let ActCsumAttrs::Pad(val) = attr? {
6658                return Ok(val);
6659            }
6660        }
6661        Err(ErrorContext::new_missing(
6662            "ActCsumAttrs",
6663            "Pad",
6664            self.orig_loc,
6665            self.buf.as_ptr() as usize,
6666        ))
6667    }
6668}
6669impl ActCsumAttrs<'_> {
6670    pub fn new<'a>(buf: &'a [u8]) -> IterableActCsumAttrs<'a> {
6671        IterableActCsumAttrs::with_loc(buf, buf.as_ptr() as usize)
6672    }
6673    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6674        let res = match r#type {
6675            1u16 => "Parms",
6676            2u16 => "Tm",
6677            3u16 => "Pad",
6678            _ => return None,
6679        };
6680        Some(res)
6681    }
6682}
6683#[derive(Clone, Copy, Default)]
6684pub struct IterableActCsumAttrs<'a> {
6685    buf: &'a [u8],
6686    pos: usize,
6687    orig_loc: usize,
6688}
6689impl<'a> IterableActCsumAttrs<'a> {
6690    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
6691        Self {
6692            buf,
6693            pos: 0,
6694            orig_loc,
6695        }
6696    }
6697    pub fn get_buf(&self) -> &'a [u8] {
6698        self.buf
6699    }
6700}
6701impl<'a> Iterator for IterableActCsumAttrs<'a> {
6702    type Item = Result<ActCsumAttrs<'a>, ErrorContext>;
6703    fn next(&mut self) -> Option<Self::Item> {
6704        let pos = self.pos;
6705        let mut r#type;
6706        loop {
6707            r#type = None;
6708            if self.buf.len() == self.pos {
6709                return None;
6710            }
6711            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
6712                break;
6713            };
6714            r#type = Some(header.r#type);
6715            let res = match header.r#type {
6716                1u16 => ActCsumAttrs::Parms({
6717                    let res = Some(next);
6718                    let Some(val) = res else { break };
6719                    val
6720                }),
6721                2u16 => ActCsumAttrs::Tm({
6722                    let res = Some(TcfT::new_from_zeroed(next));
6723                    let Some(val) = res else { break };
6724                    val
6725                }),
6726                3u16 => ActCsumAttrs::Pad({
6727                    let res = Some(next);
6728                    let Some(val) = res else { break };
6729                    val
6730                }),
6731                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6732                n => continue,
6733            };
6734            return Some(Ok(res));
6735        }
6736        Some(Err(ErrorContext::new(
6737            "ActCsumAttrs",
6738            r#type.and_then(|t| ActCsumAttrs::attr_from_type(t)),
6739            self.orig_loc,
6740            self.buf.as_ptr().wrapping_add(pos) as usize,
6741        )))
6742    }
6743}
6744impl<'a> std::fmt::Debug for IterableActCsumAttrs<'_> {
6745    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6746        let mut fmt = f.debug_struct("ActCsumAttrs");
6747        for attr in self.clone() {
6748            let attr = match attr {
6749                Ok(a) => a,
6750                Err(err) => {
6751                    fmt.finish()?;
6752                    f.write_str("Err(")?;
6753                    err.fmt(f)?;
6754                    return f.write_str(")");
6755                }
6756            };
6757            match attr {
6758                ActCsumAttrs::Parms(val) => fmt.field("Parms", &val),
6759                ActCsumAttrs::Tm(val) => fmt.field("Tm", &val),
6760                ActCsumAttrs::Pad(val) => fmt.field("Pad", &val),
6761            };
6762        }
6763        fmt.finish()
6764    }
6765}
6766impl IterableActCsumAttrs<'_> {
6767    pub fn lookup_attr(
6768        &self,
6769        offset: usize,
6770        missing_type: Option<u16>,
6771    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6772        let mut stack = Vec::new();
6773        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6774        if missing_type.is_some() && cur == offset {
6775            stack.push(("ActCsumAttrs", offset));
6776            return (
6777                stack,
6778                missing_type.and_then(|t| ActCsumAttrs::attr_from_type(t)),
6779            );
6780        }
6781        if cur > offset || cur + self.buf.len() < offset {
6782            return (stack, None);
6783        }
6784        let mut attrs = self.clone();
6785        let mut last_off = cur + attrs.pos;
6786        while let Some(attr) = attrs.next() {
6787            let Ok(attr) = attr else { break };
6788            match attr {
6789                ActCsumAttrs::Parms(val) => {
6790                    if last_off == offset {
6791                        stack.push(("Parms", last_off));
6792                        break;
6793                    }
6794                }
6795                ActCsumAttrs::Tm(val) => {
6796                    if last_off == offset {
6797                        stack.push(("Tm", last_off));
6798                        break;
6799                    }
6800                }
6801                ActCsumAttrs::Pad(val) => {
6802                    if last_off == offset {
6803                        stack.push(("Pad", last_off));
6804                        break;
6805                    }
6806                }
6807                _ => {}
6808            };
6809            last_off = cur + attrs.pos;
6810        }
6811        if !stack.is_empty() {
6812            stack.push(("ActCsumAttrs", cur));
6813        }
6814        (stack, None)
6815    }
6816}
6817#[derive(Clone)]
6818pub enum ActCtAttrs<'a> {
6819    Parms(&'a [u8]),
6820    Tm(TcfT),
6821    Action(u16),
6822    Zone(u16),
6823    Mark(u32),
6824    MarkMask(u32),
6825    Labels(&'a [u8]),
6826    LabelsMask(&'a [u8]),
6827    NatIpv4Min(u32),
6828    NatIpv4Max(u32),
6829    NatIpv6Min(&'a [u8]),
6830    NatIpv6Max(&'a [u8]),
6831    NatPortMin(u16),
6832    NatPortMax(u16),
6833    Pad(&'a [u8]),
6834    HelperName(&'a CStr),
6835    HelperFamily(u8),
6836    HelperProto(u8),
6837}
6838impl<'a> IterableActCtAttrs<'a> {
6839    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
6840        let mut iter = self.clone();
6841        iter.pos = 0;
6842        for attr in iter {
6843            if let ActCtAttrs::Parms(val) = attr? {
6844                return Ok(val);
6845            }
6846        }
6847        Err(ErrorContext::new_missing(
6848            "ActCtAttrs",
6849            "Parms",
6850            self.orig_loc,
6851            self.buf.as_ptr() as usize,
6852        ))
6853    }
6854    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
6855        let mut iter = self.clone();
6856        iter.pos = 0;
6857        for attr in iter {
6858            if let ActCtAttrs::Tm(val) = attr? {
6859                return Ok(val);
6860            }
6861        }
6862        Err(ErrorContext::new_missing(
6863            "ActCtAttrs",
6864            "Tm",
6865            self.orig_loc,
6866            self.buf.as_ptr() as usize,
6867        ))
6868    }
6869    pub fn get_action(&self) -> Result<u16, ErrorContext> {
6870        let mut iter = self.clone();
6871        iter.pos = 0;
6872        for attr in iter {
6873            if let ActCtAttrs::Action(val) = attr? {
6874                return Ok(val);
6875            }
6876        }
6877        Err(ErrorContext::new_missing(
6878            "ActCtAttrs",
6879            "Action",
6880            self.orig_loc,
6881            self.buf.as_ptr() as usize,
6882        ))
6883    }
6884    pub fn get_zone(&self) -> Result<u16, ErrorContext> {
6885        let mut iter = self.clone();
6886        iter.pos = 0;
6887        for attr in iter {
6888            if let ActCtAttrs::Zone(val) = attr? {
6889                return Ok(val);
6890            }
6891        }
6892        Err(ErrorContext::new_missing(
6893            "ActCtAttrs",
6894            "Zone",
6895            self.orig_loc,
6896            self.buf.as_ptr() as usize,
6897        ))
6898    }
6899    pub fn get_mark(&self) -> Result<u32, ErrorContext> {
6900        let mut iter = self.clone();
6901        iter.pos = 0;
6902        for attr in iter {
6903            if let ActCtAttrs::Mark(val) = attr? {
6904                return Ok(val);
6905            }
6906        }
6907        Err(ErrorContext::new_missing(
6908            "ActCtAttrs",
6909            "Mark",
6910            self.orig_loc,
6911            self.buf.as_ptr() as usize,
6912        ))
6913    }
6914    pub fn get_mark_mask(&self) -> Result<u32, ErrorContext> {
6915        let mut iter = self.clone();
6916        iter.pos = 0;
6917        for attr in iter {
6918            if let ActCtAttrs::MarkMask(val) = attr? {
6919                return Ok(val);
6920            }
6921        }
6922        Err(ErrorContext::new_missing(
6923            "ActCtAttrs",
6924            "MarkMask",
6925            self.orig_loc,
6926            self.buf.as_ptr() as usize,
6927        ))
6928    }
6929    pub fn get_labels(&self) -> Result<&'a [u8], ErrorContext> {
6930        let mut iter = self.clone();
6931        iter.pos = 0;
6932        for attr in iter {
6933            if let ActCtAttrs::Labels(val) = attr? {
6934                return Ok(val);
6935            }
6936        }
6937        Err(ErrorContext::new_missing(
6938            "ActCtAttrs",
6939            "Labels",
6940            self.orig_loc,
6941            self.buf.as_ptr() as usize,
6942        ))
6943    }
6944    pub fn get_labels_mask(&self) -> Result<&'a [u8], ErrorContext> {
6945        let mut iter = self.clone();
6946        iter.pos = 0;
6947        for attr in iter {
6948            if let ActCtAttrs::LabelsMask(val) = attr? {
6949                return Ok(val);
6950            }
6951        }
6952        Err(ErrorContext::new_missing(
6953            "ActCtAttrs",
6954            "LabelsMask",
6955            self.orig_loc,
6956            self.buf.as_ptr() as usize,
6957        ))
6958    }
6959    pub fn get_nat_ipv4_min(&self) -> Result<u32, ErrorContext> {
6960        let mut iter = self.clone();
6961        iter.pos = 0;
6962        for attr in iter {
6963            if let ActCtAttrs::NatIpv4Min(val) = attr? {
6964                return Ok(val);
6965            }
6966        }
6967        Err(ErrorContext::new_missing(
6968            "ActCtAttrs",
6969            "NatIpv4Min",
6970            self.orig_loc,
6971            self.buf.as_ptr() as usize,
6972        ))
6973    }
6974    pub fn get_nat_ipv4_max(&self) -> Result<u32, ErrorContext> {
6975        let mut iter = self.clone();
6976        iter.pos = 0;
6977        for attr in iter {
6978            if let ActCtAttrs::NatIpv4Max(val) = attr? {
6979                return Ok(val);
6980            }
6981        }
6982        Err(ErrorContext::new_missing(
6983            "ActCtAttrs",
6984            "NatIpv4Max",
6985            self.orig_loc,
6986            self.buf.as_ptr() as usize,
6987        ))
6988    }
6989    pub fn get_nat_ipv6_min(&self) -> Result<&'a [u8], ErrorContext> {
6990        let mut iter = self.clone();
6991        iter.pos = 0;
6992        for attr in iter {
6993            if let ActCtAttrs::NatIpv6Min(val) = attr? {
6994                return Ok(val);
6995            }
6996        }
6997        Err(ErrorContext::new_missing(
6998            "ActCtAttrs",
6999            "NatIpv6Min",
7000            self.orig_loc,
7001            self.buf.as_ptr() as usize,
7002        ))
7003    }
7004    pub fn get_nat_ipv6_max(&self) -> Result<&'a [u8], ErrorContext> {
7005        let mut iter = self.clone();
7006        iter.pos = 0;
7007        for attr in iter {
7008            if let ActCtAttrs::NatIpv6Max(val) = attr? {
7009                return Ok(val);
7010            }
7011        }
7012        Err(ErrorContext::new_missing(
7013            "ActCtAttrs",
7014            "NatIpv6Max",
7015            self.orig_loc,
7016            self.buf.as_ptr() as usize,
7017        ))
7018    }
7019    pub fn get_nat_port_min(&self) -> Result<u16, ErrorContext> {
7020        let mut iter = self.clone();
7021        iter.pos = 0;
7022        for attr in iter {
7023            if let ActCtAttrs::NatPortMin(val) = attr? {
7024                return Ok(val);
7025            }
7026        }
7027        Err(ErrorContext::new_missing(
7028            "ActCtAttrs",
7029            "NatPortMin",
7030            self.orig_loc,
7031            self.buf.as_ptr() as usize,
7032        ))
7033    }
7034    pub fn get_nat_port_max(&self) -> Result<u16, ErrorContext> {
7035        let mut iter = self.clone();
7036        iter.pos = 0;
7037        for attr in iter {
7038            if let ActCtAttrs::NatPortMax(val) = attr? {
7039                return Ok(val);
7040            }
7041        }
7042        Err(ErrorContext::new_missing(
7043            "ActCtAttrs",
7044            "NatPortMax",
7045            self.orig_loc,
7046            self.buf.as_ptr() as usize,
7047        ))
7048    }
7049    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
7050        let mut iter = self.clone();
7051        iter.pos = 0;
7052        for attr in iter {
7053            if let ActCtAttrs::Pad(val) = attr? {
7054                return Ok(val);
7055            }
7056        }
7057        Err(ErrorContext::new_missing(
7058            "ActCtAttrs",
7059            "Pad",
7060            self.orig_loc,
7061            self.buf.as_ptr() as usize,
7062        ))
7063    }
7064    pub fn get_helper_name(&self) -> Result<&'a CStr, ErrorContext> {
7065        let mut iter = self.clone();
7066        iter.pos = 0;
7067        for attr in iter {
7068            if let ActCtAttrs::HelperName(val) = attr? {
7069                return Ok(val);
7070            }
7071        }
7072        Err(ErrorContext::new_missing(
7073            "ActCtAttrs",
7074            "HelperName",
7075            self.orig_loc,
7076            self.buf.as_ptr() as usize,
7077        ))
7078    }
7079    pub fn get_helper_family(&self) -> Result<u8, ErrorContext> {
7080        let mut iter = self.clone();
7081        iter.pos = 0;
7082        for attr in iter {
7083            if let ActCtAttrs::HelperFamily(val) = attr? {
7084                return Ok(val);
7085            }
7086        }
7087        Err(ErrorContext::new_missing(
7088            "ActCtAttrs",
7089            "HelperFamily",
7090            self.orig_loc,
7091            self.buf.as_ptr() as usize,
7092        ))
7093    }
7094    pub fn get_helper_proto(&self) -> Result<u8, ErrorContext> {
7095        let mut iter = self.clone();
7096        iter.pos = 0;
7097        for attr in iter {
7098            if let ActCtAttrs::HelperProto(val) = attr? {
7099                return Ok(val);
7100            }
7101        }
7102        Err(ErrorContext::new_missing(
7103            "ActCtAttrs",
7104            "HelperProto",
7105            self.orig_loc,
7106            self.buf.as_ptr() as usize,
7107        ))
7108    }
7109}
7110impl ActCtAttrs<'_> {
7111    pub fn new<'a>(buf: &'a [u8]) -> IterableActCtAttrs<'a> {
7112        IterableActCtAttrs::with_loc(buf, buf.as_ptr() as usize)
7113    }
7114    fn attr_from_type(r#type: u16) -> Option<&'static str> {
7115        let res = match r#type {
7116            1u16 => "Parms",
7117            2u16 => "Tm",
7118            3u16 => "Action",
7119            4u16 => "Zone",
7120            5u16 => "Mark",
7121            6u16 => "MarkMask",
7122            7u16 => "Labels",
7123            8u16 => "LabelsMask",
7124            9u16 => "NatIpv4Min",
7125            10u16 => "NatIpv4Max",
7126            11u16 => "NatIpv6Min",
7127            12u16 => "NatIpv6Max",
7128            13u16 => "NatPortMin",
7129            14u16 => "NatPortMax",
7130            15u16 => "Pad",
7131            16u16 => "HelperName",
7132            17u16 => "HelperFamily",
7133            18u16 => "HelperProto",
7134            _ => return None,
7135        };
7136        Some(res)
7137    }
7138}
7139#[derive(Clone, Copy, Default)]
7140pub struct IterableActCtAttrs<'a> {
7141    buf: &'a [u8],
7142    pos: usize,
7143    orig_loc: usize,
7144}
7145impl<'a> IterableActCtAttrs<'a> {
7146    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
7147        Self {
7148            buf,
7149            pos: 0,
7150            orig_loc,
7151        }
7152    }
7153    pub fn get_buf(&self) -> &'a [u8] {
7154        self.buf
7155    }
7156}
7157impl<'a> Iterator for IterableActCtAttrs<'a> {
7158    type Item = Result<ActCtAttrs<'a>, ErrorContext>;
7159    fn next(&mut self) -> Option<Self::Item> {
7160        let pos = self.pos;
7161        let mut r#type;
7162        loop {
7163            r#type = None;
7164            if self.buf.len() == self.pos {
7165                return None;
7166            }
7167            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
7168                break;
7169            };
7170            r#type = Some(header.r#type);
7171            let res = match header.r#type {
7172                1u16 => ActCtAttrs::Parms({
7173                    let res = Some(next);
7174                    let Some(val) = res else { break };
7175                    val
7176                }),
7177                2u16 => ActCtAttrs::Tm({
7178                    let res = Some(TcfT::new_from_zeroed(next));
7179                    let Some(val) = res else { break };
7180                    val
7181                }),
7182                3u16 => ActCtAttrs::Action({
7183                    let res = parse_u16(next);
7184                    let Some(val) = res else { break };
7185                    val
7186                }),
7187                4u16 => ActCtAttrs::Zone({
7188                    let res = parse_u16(next);
7189                    let Some(val) = res else { break };
7190                    val
7191                }),
7192                5u16 => ActCtAttrs::Mark({
7193                    let res = parse_u32(next);
7194                    let Some(val) = res else { break };
7195                    val
7196                }),
7197                6u16 => ActCtAttrs::MarkMask({
7198                    let res = parse_u32(next);
7199                    let Some(val) = res else { break };
7200                    val
7201                }),
7202                7u16 => ActCtAttrs::Labels({
7203                    let res = Some(next);
7204                    let Some(val) = res else { break };
7205                    val
7206                }),
7207                8u16 => ActCtAttrs::LabelsMask({
7208                    let res = Some(next);
7209                    let Some(val) = res else { break };
7210                    val
7211                }),
7212                9u16 => ActCtAttrs::NatIpv4Min({
7213                    let res = parse_be_u32(next);
7214                    let Some(val) = res else { break };
7215                    val
7216                }),
7217                10u16 => ActCtAttrs::NatIpv4Max({
7218                    let res = parse_be_u32(next);
7219                    let Some(val) = res else { break };
7220                    val
7221                }),
7222                11u16 => ActCtAttrs::NatIpv6Min({
7223                    let res = Some(next);
7224                    let Some(val) = res else { break };
7225                    val
7226                }),
7227                12u16 => ActCtAttrs::NatIpv6Max({
7228                    let res = Some(next);
7229                    let Some(val) = res else { break };
7230                    val
7231                }),
7232                13u16 => ActCtAttrs::NatPortMin({
7233                    let res = parse_be_u16(next);
7234                    let Some(val) = res else { break };
7235                    val
7236                }),
7237                14u16 => ActCtAttrs::NatPortMax({
7238                    let res = parse_be_u16(next);
7239                    let Some(val) = res else { break };
7240                    val
7241                }),
7242                15u16 => ActCtAttrs::Pad({
7243                    let res = Some(next);
7244                    let Some(val) = res else { break };
7245                    val
7246                }),
7247                16u16 => ActCtAttrs::HelperName({
7248                    let res = CStr::from_bytes_with_nul(next).ok();
7249                    let Some(val) = res else { break };
7250                    val
7251                }),
7252                17u16 => ActCtAttrs::HelperFamily({
7253                    let res = parse_u8(next);
7254                    let Some(val) = res else { break };
7255                    val
7256                }),
7257                18u16 => ActCtAttrs::HelperProto({
7258                    let res = parse_u8(next);
7259                    let Some(val) = res else { break };
7260                    val
7261                }),
7262                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
7263                n => continue,
7264            };
7265            return Some(Ok(res));
7266        }
7267        Some(Err(ErrorContext::new(
7268            "ActCtAttrs",
7269            r#type.and_then(|t| ActCtAttrs::attr_from_type(t)),
7270            self.orig_loc,
7271            self.buf.as_ptr().wrapping_add(pos) as usize,
7272        )))
7273    }
7274}
7275impl<'a> std::fmt::Debug for IterableActCtAttrs<'_> {
7276    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7277        let mut fmt = f.debug_struct("ActCtAttrs");
7278        for attr in self.clone() {
7279            let attr = match attr {
7280                Ok(a) => a,
7281                Err(err) => {
7282                    fmt.finish()?;
7283                    f.write_str("Err(")?;
7284                    err.fmt(f)?;
7285                    return f.write_str(")");
7286                }
7287            };
7288            match attr {
7289                ActCtAttrs::Parms(val) => fmt.field("Parms", &val),
7290                ActCtAttrs::Tm(val) => fmt.field("Tm", &val),
7291                ActCtAttrs::Action(val) => fmt.field("Action", &val),
7292                ActCtAttrs::Zone(val) => fmt.field("Zone", &val),
7293                ActCtAttrs::Mark(val) => fmt.field("Mark", &val),
7294                ActCtAttrs::MarkMask(val) => fmt.field("MarkMask", &val),
7295                ActCtAttrs::Labels(val) => fmt.field("Labels", &val),
7296                ActCtAttrs::LabelsMask(val) => fmt.field("LabelsMask", &val),
7297                ActCtAttrs::NatIpv4Min(val) => fmt.field("NatIpv4Min", &val),
7298                ActCtAttrs::NatIpv4Max(val) => fmt.field("NatIpv4Max", &val),
7299                ActCtAttrs::NatIpv6Min(val) => fmt.field("NatIpv6Min", &val),
7300                ActCtAttrs::NatIpv6Max(val) => fmt.field("NatIpv6Max", &val),
7301                ActCtAttrs::NatPortMin(val) => fmt.field("NatPortMin", &val),
7302                ActCtAttrs::NatPortMax(val) => fmt.field("NatPortMax", &val),
7303                ActCtAttrs::Pad(val) => fmt.field("Pad", &val),
7304                ActCtAttrs::HelperName(val) => fmt.field("HelperName", &val),
7305                ActCtAttrs::HelperFamily(val) => fmt.field("HelperFamily", &val),
7306                ActCtAttrs::HelperProto(val) => fmt.field("HelperProto", &val),
7307            };
7308        }
7309        fmt.finish()
7310    }
7311}
7312impl IterableActCtAttrs<'_> {
7313    pub fn lookup_attr(
7314        &self,
7315        offset: usize,
7316        missing_type: Option<u16>,
7317    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
7318        let mut stack = Vec::new();
7319        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
7320        if missing_type.is_some() && cur == offset {
7321            stack.push(("ActCtAttrs", offset));
7322            return (
7323                stack,
7324                missing_type.and_then(|t| ActCtAttrs::attr_from_type(t)),
7325            );
7326        }
7327        if cur > offset || cur + self.buf.len() < offset {
7328            return (stack, None);
7329        }
7330        let mut attrs = self.clone();
7331        let mut last_off = cur + attrs.pos;
7332        while let Some(attr) = attrs.next() {
7333            let Ok(attr) = attr else { break };
7334            match attr {
7335                ActCtAttrs::Parms(val) => {
7336                    if last_off == offset {
7337                        stack.push(("Parms", last_off));
7338                        break;
7339                    }
7340                }
7341                ActCtAttrs::Tm(val) => {
7342                    if last_off == offset {
7343                        stack.push(("Tm", last_off));
7344                        break;
7345                    }
7346                }
7347                ActCtAttrs::Action(val) => {
7348                    if last_off == offset {
7349                        stack.push(("Action", last_off));
7350                        break;
7351                    }
7352                }
7353                ActCtAttrs::Zone(val) => {
7354                    if last_off == offset {
7355                        stack.push(("Zone", last_off));
7356                        break;
7357                    }
7358                }
7359                ActCtAttrs::Mark(val) => {
7360                    if last_off == offset {
7361                        stack.push(("Mark", last_off));
7362                        break;
7363                    }
7364                }
7365                ActCtAttrs::MarkMask(val) => {
7366                    if last_off == offset {
7367                        stack.push(("MarkMask", last_off));
7368                        break;
7369                    }
7370                }
7371                ActCtAttrs::Labels(val) => {
7372                    if last_off == offset {
7373                        stack.push(("Labels", last_off));
7374                        break;
7375                    }
7376                }
7377                ActCtAttrs::LabelsMask(val) => {
7378                    if last_off == offset {
7379                        stack.push(("LabelsMask", last_off));
7380                        break;
7381                    }
7382                }
7383                ActCtAttrs::NatIpv4Min(val) => {
7384                    if last_off == offset {
7385                        stack.push(("NatIpv4Min", last_off));
7386                        break;
7387                    }
7388                }
7389                ActCtAttrs::NatIpv4Max(val) => {
7390                    if last_off == offset {
7391                        stack.push(("NatIpv4Max", last_off));
7392                        break;
7393                    }
7394                }
7395                ActCtAttrs::NatIpv6Min(val) => {
7396                    if last_off == offset {
7397                        stack.push(("NatIpv6Min", last_off));
7398                        break;
7399                    }
7400                }
7401                ActCtAttrs::NatIpv6Max(val) => {
7402                    if last_off == offset {
7403                        stack.push(("NatIpv6Max", last_off));
7404                        break;
7405                    }
7406                }
7407                ActCtAttrs::NatPortMin(val) => {
7408                    if last_off == offset {
7409                        stack.push(("NatPortMin", last_off));
7410                        break;
7411                    }
7412                }
7413                ActCtAttrs::NatPortMax(val) => {
7414                    if last_off == offset {
7415                        stack.push(("NatPortMax", last_off));
7416                        break;
7417                    }
7418                }
7419                ActCtAttrs::Pad(val) => {
7420                    if last_off == offset {
7421                        stack.push(("Pad", last_off));
7422                        break;
7423                    }
7424                }
7425                ActCtAttrs::HelperName(val) => {
7426                    if last_off == offset {
7427                        stack.push(("HelperName", last_off));
7428                        break;
7429                    }
7430                }
7431                ActCtAttrs::HelperFamily(val) => {
7432                    if last_off == offset {
7433                        stack.push(("HelperFamily", last_off));
7434                        break;
7435                    }
7436                }
7437                ActCtAttrs::HelperProto(val) => {
7438                    if last_off == offset {
7439                        stack.push(("HelperProto", last_off));
7440                        break;
7441                    }
7442                }
7443                _ => {}
7444            };
7445            last_off = cur + attrs.pos;
7446        }
7447        if !stack.is_empty() {
7448            stack.push(("ActCtAttrs", cur));
7449        }
7450        (stack, None)
7451    }
7452}
7453#[derive(Clone)]
7454pub enum ActCtinfoAttrs<'a> {
7455    Pad(&'a [u8]),
7456    Tm(TcfT),
7457    Act(&'a [u8]),
7458    Zone(u16),
7459    ParmsDscpMask(u32),
7460    ParmsDscpStatemask(u32),
7461    ParmsCpmarkMask(u32),
7462    StatsDscpSet(u64),
7463    StatsDscpError(u64),
7464    StatsCpmarkSet(u64),
7465}
7466impl<'a> IterableActCtinfoAttrs<'a> {
7467    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
7468        let mut iter = self.clone();
7469        iter.pos = 0;
7470        for attr in iter {
7471            if let ActCtinfoAttrs::Pad(val) = attr? {
7472                return Ok(val);
7473            }
7474        }
7475        Err(ErrorContext::new_missing(
7476            "ActCtinfoAttrs",
7477            "Pad",
7478            self.orig_loc,
7479            self.buf.as_ptr() as usize,
7480        ))
7481    }
7482    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
7483        let mut iter = self.clone();
7484        iter.pos = 0;
7485        for attr in iter {
7486            if let ActCtinfoAttrs::Tm(val) = attr? {
7487                return Ok(val);
7488            }
7489        }
7490        Err(ErrorContext::new_missing(
7491            "ActCtinfoAttrs",
7492            "Tm",
7493            self.orig_loc,
7494            self.buf.as_ptr() as usize,
7495        ))
7496    }
7497    pub fn get_act(&self) -> Result<&'a [u8], ErrorContext> {
7498        let mut iter = self.clone();
7499        iter.pos = 0;
7500        for attr in iter {
7501            if let ActCtinfoAttrs::Act(val) = attr? {
7502                return Ok(val);
7503            }
7504        }
7505        Err(ErrorContext::new_missing(
7506            "ActCtinfoAttrs",
7507            "Act",
7508            self.orig_loc,
7509            self.buf.as_ptr() as usize,
7510        ))
7511    }
7512    pub fn get_zone(&self) -> Result<u16, ErrorContext> {
7513        let mut iter = self.clone();
7514        iter.pos = 0;
7515        for attr in iter {
7516            if let ActCtinfoAttrs::Zone(val) = attr? {
7517                return Ok(val);
7518            }
7519        }
7520        Err(ErrorContext::new_missing(
7521            "ActCtinfoAttrs",
7522            "Zone",
7523            self.orig_loc,
7524            self.buf.as_ptr() as usize,
7525        ))
7526    }
7527    pub fn get_parms_dscp_mask(&self) -> Result<u32, ErrorContext> {
7528        let mut iter = self.clone();
7529        iter.pos = 0;
7530        for attr in iter {
7531            if let ActCtinfoAttrs::ParmsDscpMask(val) = attr? {
7532                return Ok(val);
7533            }
7534        }
7535        Err(ErrorContext::new_missing(
7536            "ActCtinfoAttrs",
7537            "ParmsDscpMask",
7538            self.orig_loc,
7539            self.buf.as_ptr() as usize,
7540        ))
7541    }
7542    pub fn get_parms_dscp_statemask(&self) -> Result<u32, ErrorContext> {
7543        let mut iter = self.clone();
7544        iter.pos = 0;
7545        for attr in iter {
7546            if let ActCtinfoAttrs::ParmsDscpStatemask(val) = attr? {
7547                return Ok(val);
7548            }
7549        }
7550        Err(ErrorContext::new_missing(
7551            "ActCtinfoAttrs",
7552            "ParmsDscpStatemask",
7553            self.orig_loc,
7554            self.buf.as_ptr() as usize,
7555        ))
7556    }
7557    pub fn get_parms_cpmark_mask(&self) -> Result<u32, ErrorContext> {
7558        let mut iter = self.clone();
7559        iter.pos = 0;
7560        for attr in iter {
7561            if let ActCtinfoAttrs::ParmsCpmarkMask(val) = attr? {
7562                return Ok(val);
7563            }
7564        }
7565        Err(ErrorContext::new_missing(
7566            "ActCtinfoAttrs",
7567            "ParmsCpmarkMask",
7568            self.orig_loc,
7569            self.buf.as_ptr() as usize,
7570        ))
7571    }
7572    pub fn get_stats_dscp_set(&self) -> Result<u64, ErrorContext> {
7573        let mut iter = self.clone();
7574        iter.pos = 0;
7575        for attr in iter {
7576            if let ActCtinfoAttrs::StatsDscpSet(val) = attr? {
7577                return Ok(val);
7578            }
7579        }
7580        Err(ErrorContext::new_missing(
7581            "ActCtinfoAttrs",
7582            "StatsDscpSet",
7583            self.orig_loc,
7584            self.buf.as_ptr() as usize,
7585        ))
7586    }
7587    pub fn get_stats_dscp_error(&self) -> Result<u64, ErrorContext> {
7588        let mut iter = self.clone();
7589        iter.pos = 0;
7590        for attr in iter {
7591            if let ActCtinfoAttrs::StatsDscpError(val) = attr? {
7592                return Ok(val);
7593            }
7594        }
7595        Err(ErrorContext::new_missing(
7596            "ActCtinfoAttrs",
7597            "StatsDscpError",
7598            self.orig_loc,
7599            self.buf.as_ptr() as usize,
7600        ))
7601    }
7602    pub fn get_stats_cpmark_set(&self) -> Result<u64, ErrorContext> {
7603        let mut iter = self.clone();
7604        iter.pos = 0;
7605        for attr in iter {
7606            if let ActCtinfoAttrs::StatsCpmarkSet(val) = attr? {
7607                return Ok(val);
7608            }
7609        }
7610        Err(ErrorContext::new_missing(
7611            "ActCtinfoAttrs",
7612            "StatsCpmarkSet",
7613            self.orig_loc,
7614            self.buf.as_ptr() as usize,
7615        ))
7616    }
7617}
7618impl ActCtinfoAttrs<'_> {
7619    pub fn new<'a>(buf: &'a [u8]) -> IterableActCtinfoAttrs<'a> {
7620        IterableActCtinfoAttrs::with_loc(buf, buf.as_ptr() as usize)
7621    }
7622    fn attr_from_type(r#type: u16) -> Option<&'static str> {
7623        let res = match r#type {
7624            1u16 => "Pad",
7625            2u16 => "Tm",
7626            3u16 => "Act",
7627            4u16 => "Zone",
7628            5u16 => "ParmsDscpMask",
7629            6u16 => "ParmsDscpStatemask",
7630            7u16 => "ParmsCpmarkMask",
7631            8u16 => "StatsDscpSet",
7632            9u16 => "StatsDscpError",
7633            10u16 => "StatsCpmarkSet",
7634            _ => return None,
7635        };
7636        Some(res)
7637    }
7638}
7639#[derive(Clone, Copy, Default)]
7640pub struct IterableActCtinfoAttrs<'a> {
7641    buf: &'a [u8],
7642    pos: usize,
7643    orig_loc: usize,
7644}
7645impl<'a> IterableActCtinfoAttrs<'a> {
7646    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
7647        Self {
7648            buf,
7649            pos: 0,
7650            orig_loc,
7651        }
7652    }
7653    pub fn get_buf(&self) -> &'a [u8] {
7654        self.buf
7655    }
7656}
7657impl<'a> Iterator for IterableActCtinfoAttrs<'a> {
7658    type Item = Result<ActCtinfoAttrs<'a>, ErrorContext>;
7659    fn next(&mut self) -> Option<Self::Item> {
7660        let pos = self.pos;
7661        let mut r#type;
7662        loop {
7663            r#type = None;
7664            if self.buf.len() == self.pos {
7665                return None;
7666            }
7667            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
7668                break;
7669            };
7670            r#type = Some(header.r#type);
7671            let res = match header.r#type {
7672                1u16 => ActCtinfoAttrs::Pad({
7673                    let res = Some(next);
7674                    let Some(val) = res else { break };
7675                    val
7676                }),
7677                2u16 => ActCtinfoAttrs::Tm({
7678                    let res = Some(TcfT::new_from_zeroed(next));
7679                    let Some(val) = res else { break };
7680                    val
7681                }),
7682                3u16 => ActCtinfoAttrs::Act({
7683                    let res = Some(next);
7684                    let Some(val) = res else { break };
7685                    val
7686                }),
7687                4u16 => ActCtinfoAttrs::Zone({
7688                    let res = parse_u16(next);
7689                    let Some(val) = res else { break };
7690                    val
7691                }),
7692                5u16 => ActCtinfoAttrs::ParmsDscpMask({
7693                    let res = parse_u32(next);
7694                    let Some(val) = res else { break };
7695                    val
7696                }),
7697                6u16 => ActCtinfoAttrs::ParmsDscpStatemask({
7698                    let res = parse_u32(next);
7699                    let Some(val) = res else { break };
7700                    val
7701                }),
7702                7u16 => ActCtinfoAttrs::ParmsCpmarkMask({
7703                    let res = parse_u32(next);
7704                    let Some(val) = res else { break };
7705                    val
7706                }),
7707                8u16 => ActCtinfoAttrs::StatsDscpSet({
7708                    let res = parse_u64(next);
7709                    let Some(val) = res else { break };
7710                    val
7711                }),
7712                9u16 => ActCtinfoAttrs::StatsDscpError({
7713                    let res = parse_u64(next);
7714                    let Some(val) = res else { break };
7715                    val
7716                }),
7717                10u16 => ActCtinfoAttrs::StatsCpmarkSet({
7718                    let res = parse_u64(next);
7719                    let Some(val) = res else { break };
7720                    val
7721                }),
7722                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
7723                n => continue,
7724            };
7725            return Some(Ok(res));
7726        }
7727        Some(Err(ErrorContext::new(
7728            "ActCtinfoAttrs",
7729            r#type.and_then(|t| ActCtinfoAttrs::attr_from_type(t)),
7730            self.orig_loc,
7731            self.buf.as_ptr().wrapping_add(pos) as usize,
7732        )))
7733    }
7734}
7735impl<'a> std::fmt::Debug for IterableActCtinfoAttrs<'_> {
7736    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7737        let mut fmt = f.debug_struct("ActCtinfoAttrs");
7738        for attr in self.clone() {
7739            let attr = match attr {
7740                Ok(a) => a,
7741                Err(err) => {
7742                    fmt.finish()?;
7743                    f.write_str("Err(")?;
7744                    err.fmt(f)?;
7745                    return f.write_str(")");
7746                }
7747            };
7748            match attr {
7749                ActCtinfoAttrs::Pad(val) => fmt.field("Pad", &val),
7750                ActCtinfoAttrs::Tm(val) => fmt.field("Tm", &val),
7751                ActCtinfoAttrs::Act(val) => fmt.field("Act", &val),
7752                ActCtinfoAttrs::Zone(val) => fmt.field("Zone", &val),
7753                ActCtinfoAttrs::ParmsDscpMask(val) => fmt.field("ParmsDscpMask", &val),
7754                ActCtinfoAttrs::ParmsDscpStatemask(val) => fmt.field("ParmsDscpStatemask", &val),
7755                ActCtinfoAttrs::ParmsCpmarkMask(val) => fmt.field("ParmsCpmarkMask", &val),
7756                ActCtinfoAttrs::StatsDscpSet(val) => fmt.field("StatsDscpSet", &val),
7757                ActCtinfoAttrs::StatsDscpError(val) => fmt.field("StatsDscpError", &val),
7758                ActCtinfoAttrs::StatsCpmarkSet(val) => fmt.field("StatsCpmarkSet", &val),
7759            };
7760        }
7761        fmt.finish()
7762    }
7763}
7764impl IterableActCtinfoAttrs<'_> {
7765    pub fn lookup_attr(
7766        &self,
7767        offset: usize,
7768        missing_type: Option<u16>,
7769    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
7770        let mut stack = Vec::new();
7771        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
7772        if missing_type.is_some() && cur == offset {
7773            stack.push(("ActCtinfoAttrs", offset));
7774            return (
7775                stack,
7776                missing_type.and_then(|t| ActCtinfoAttrs::attr_from_type(t)),
7777            );
7778        }
7779        if cur > offset || cur + self.buf.len() < offset {
7780            return (stack, None);
7781        }
7782        let mut attrs = self.clone();
7783        let mut last_off = cur + attrs.pos;
7784        while let Some(attr) = attrs.next() {
7785            let Ok(attr) = attr else { break };
7786            match attr {
7787                ActCtinfoAttrs::Pad(val) => {
7788                    if last_off == offset {
7789                        stack.push(("Pad", last_off));
7790                        break;
7791                    }
7792                }
7793                ActCtinfoAttrs::Tm(val) => {
7794                    if last_off == offset {
7795                        stack.push(("Tm", last_off));
7796                        break;
7797                    }
7798                }
7799                ActCtinfoAttrs::Act(val) => {
7800                    if last_off == offset {
7801                        stack.push(("Act", last_off));
7802                        break;
7803                    }
7804                }
7805                ActCtinfoAttrs::Zone(val) => {
7806                    if last_off == offset {
7807                        stack.push(("Zone", last_off));
7808                        break;
7809                    }
7810                }
7811                ActCtinfoAttrs::ParmsDscpMask(val) => {
7812                    if last_off == offset {
7813                        stack.push(("ParmsDscpMask", last_off));
7814                        break;
7815                    }
7816                }
7817                ActCtinfoAttrs::ParmsDscpStatemask(val) => {
7818                    if last_off == offset {
7819                        stack.push(("ParmsDscpStatemask", last_off));
7820                        break;
7821                    }
7822                }
7823                ActCtinfoAttrs::ParmsCpmarkMask(val) => {
7824                    if last_off == offset {
7825                        stack.push(("ParmsCpmarkMask", last_off));
7826                        break;
7827                    }
7828                }
7829                ActCtinfoAttrs::StatsDscpSet(val) => {
7830                    if last_off == offset {
7831                        stack.push(("StatsDscpSet", last_off));
7832                        break;
7833                    }
7834                }
7835                ActCtinfoAttrs::StatsDscpError(val) => {
7836                    if last_off == offset {
7837                        stack.push(("StatsDscpError", last_off));
7838                        break;
7839                    }
7840                }
7841                ActCtinfoAttrs::StatsCpmarkSet(val) => {
7842                    if last_off == offset {
7843                        stack.push(("StatsCpmarkSet", last_off));
7844                        break;
7845                    }
7846                }
7847                _ => {}
7848            };
7849            last_off = cur + attrs.pos;
7850        }
7851        if !stack.is_empty() {
7852            stack.push(("ActCtinfoAttrs", cur));
7853        }
7854        (stack, None)
7855    }
7856}
7857#[derive(Clone)]
7858pub enum ActGateAttrs<'a> {
7859    Tm(TcfT),
7860    Parms(&'a [u8]),
7861    Pad(&'a [u8]),
7862    Priority(i32),
7863    EntryList(&'a [u8]),
7864    BaseTime(u64),
7865    CycleTime(u64),
7866    CycleTimeExt(u64),
7867    Flags(u32),
7868    Clockid(i32),
7869}
7870impl<'a> IterableActGateAttrs<'a> {
7871    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
7872        let mut iter = self.clone();
7873        iter.pos = 0;
7874        for attr in iter {
7875            if let ActGateAttrs::Tm(val) = attr? {
7876                return Ok(val);
7877            }
7878        }
7879        Err(ErrorContext::new_missing(
7880            "ActGateAttrs",
7881            "Tm",
7882            self.orig_loc,
7883            self.buf.as_ptr() as usize,
7884        ))
7885    }
7886    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
7887        let mut iter = self.clone();
7888        iter.pos = 0;
7889        for attr in iter {
7890            if let ActGateAttrs::Parms(val) = attr? {
7891                return Ok(val);
7892            }
7893        }
7894        Err(ErrorContext::new_missing(
7895            "ActGateAttrs",
7896            "Parms",
7897            self.orig_loc,
7898            self.buf.as_ptr() as usize,
7899        ))
7900    }
7901    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
7902        let mut iter = self.clone();
7903        iter.pos = 0;
7904        for attr in iter {
7905            if let ActGateAttrs::Pad(val) = attr? {
7906                return Ok(val);
7907            }
7908        }
7909        Err(ErrorContext::new_missing(
7910            "ActGateAttrs",
7911            "Pad",
7912            self.orig_loc,
7913            self.buf.as_ptr() as usize,
7914        ))
7915    }
7916    pub fn get_priority(&self) -> Result<i32, ErrorContext> {
7917        let mut iter = self.clone();
7918        iter.pos = 0;
7919        for attr in iter {
7920            if let ActGateAttrs::Priority(val) = attr? {
7921                return Ok(val);
7922            }
7923        }
7924        Err(ErrorContext::new_missing(
7925            "ActGateAttrs",
7926            "Priority",
7927            self.orig_loc,
7928            self.buf.as_ptr() as usize,
7929        ))
7930    }
7931    pub fn get_entry_list(&self) -> Result<&'a [u8], ErrorContext> {
7932        let mut iter = self.clone();
7933        iter.pos = 0;
7934        for attr in iter {
7935            if let ActGateAttrs::EntryList(val) = attr? {
7936                return Ok(val);
7937            }
7938        }
7939        Err(ErrorContext::new_missing(
7940            "ActGateAttrs",
7941            "EntryList",
7942            self.orig_loc,
7943            self.buf.as_ptr() as usize,
7944        ))
7945    }
7946    pub fn get_base_time(&self) -> Result<u64, ErrorContext> {
7947        let mut iter = self.clone();
7948        iter.pos = 0;
7949        for attr in iter {
7950            if let ActGateAttrs::BaseTime(val) = attr? {
7951                return Ok(val);
7952            }
7953        }
7954        Err(ErrorContext::new_missing(
7955            "ActGateAttrs",
7956            "BaseTime",
7957            self.orig_loc,
7958            self.buf.as_ptr() as usize,
7959        ))
7960    }
7961    pub fn get_cycle_time(&self) -> Result<u64, ErrorContext> {
7962        let mut iter = self.clone();
7963        iter.pos = 0;
7964        for attr in iter {
7965            if let ActGateAttrs::CycleTime(val) = attr? {
7966                return Ok(val);
7967            }
7968        }
7969        Err(ErrorContext::new_missing(
7970            "ActGateAttrs",
7971            "CycleTime",
7972            self.orig_loc,
7973            self.buf.as_ptr() as usize,
7974        ))
7975    }
7976    pub fn get_cycle_time_ext(&self) -> Result<u64, ErrorContext> {
7977        let mut iter = self.clone();
7978        iter.pos = 0;
7979        for attr in iter {
7980            if let ActGateAttrs::CycleTimeExt(val) = attr? {
7981                return Ok(val);
7982            }
7983        }
7984        Err(ErrorContext::new_missing(
7985            "ActGateAttrs",
7986            "CycleTimeExt",
7987            self.orig_loc,
7988            self.buf.as_ptr() as usize,
7989        ))
7990    }
7991    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
7992        let mut iter = self.clone();
7993        iter.pos = 0;
7994        for attr in iter {
7995            if let ActGateAttrs::Flags(val) = attr? {
7996                return Ok(val);
7997            }
7998        }
7999        Err(ErrorContext::new_missing(
8000            "ActGateAttrs",
8001            "Flags",
8002            self.orig_loc,
8003            self.buf.as_ptr() as usize,
8004        ))
8005    }
8006    pub fn get_clockid(&self) -> Result<i32, ErrorContext> {
8007        let mut iter = self.clone();
8008        iter.pos = 0;
8009        for attr in iter {
8010            if let ActGateAttrs::Clockid(val) = attr? {
8011                return Ok(val);
8012            }
8013        }
8014        Err(ErrorContext::new_missing(
8015            "ActGateAttrs",
8016            "Clockid",
8017            self.orig_loc,
8018            self.buf.as_ptr() as usize,
8019        ))
8020    }
8021}
8022impl ActGateAttrs<'_> {
8023    pub fn new<'a>(buf: &'a [u8]) -> IterableActGateAttrs<'a> {
8024        IterableActGateAttrs::with_loc(buf, buf.as_ptr() as usize)
8025    }
8026    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8027        let res = match r#type {
8028            1u16 => "Tm",
8029            2u16 => "Parms",
8030            3u16 => "Pad",
8031            4u16 => "Priority",
8032            5u16 => "EntryList",
8033            6u16 => "BaseTime",
8034            7u16 => "CycleTime",
8035            8u16 => "CycleTimeExt",
8036            9u16 => "Flags",
8037            10u16 => "Clockid",
8038            _ => return None,
8039        };
8040        Some(res)
8041    }
8042}
8043#[derive(Clone, Copy, Default)]
8044pub struct IterableActGateAttrs<'a> {
8045    buf: &'a [u8],
8046    pos: usize,
8047    orig_loc: usize,
8048}
8049impl<'a> IterableActGateAttrs<'a> {
8050    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8051        Self {
8052            buf,
8053            pos: 0,
8054            orig_loc,
8055        }
8056    }
8057    pub fn get_buf(&self) -> &'a [u8] {
8058        self.buf
8059    }
8060}
8061impl<'a> Iterator for IterableActGateAttrs<'a> {
8062    type Item = Result<ActGateAttrs<'a>, ErrorContext>;
8063    fn next(&mut self) -> Option<Self::Item> {
8064        let pos = self.pos;
8065        let mut r#type;
8066        loop {
8067            r#type = None;
8068            if self.buf.len() == self.pos {
8069                return None;
8070            }
8071            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8072                break;
8073            };
8074            r#type = Some(header.r#type);
8075            let res = match header.r#type {
8076                1u16 => ActGateAttrs::Tm({
8077                    let res = Some(TcfT::new_from_zeroed(next));
8078                    let Some(val) = res else { break };
8079                    val
8080                }),
8081                2u16 => ActGateAttrs::Parms({
8082                    let res = Some(next);
8083                    let Some(val) = res else { break };
8084                    val
8085                }),
8086                3u16 => ActGateAttrs::Pad({
8087                    let res = Some(next);
8088                    let Some(val) = res else { break };
8089                    val
8090                }),
8091                4u16 => ActGateAttrs::Priority({
8092                    let res = parse_i32(next);
8093                    let Some(val) = res else { break };
8094                    val
8095                }),
8096                5u16 => ActGateAttrs::EntryList({
8097                    let res = Some(next);
8098                    let Some(val) = res else { break };
8099                    val
8100                }),
8101                6u16 => ActGateAttrs::BaseTime({
8102                    let res = parse_u64(next);
8103                    let Some(val) = res else { break };
8104                    val
8105                }),
8106                7u16 => ActGateAttrs::CycleTime({
8107                    let res = parse_u64(next);
8108                    let Some(val) = res else { break };
8109                    val
8110                }),
8111                8u16 => ActGateAttrs::CycleTimeExt({
8112                    let res = parse_u64(next);
8113                    let Some(val) = res else { break };
8114                    val
8115                }),
8116                9u16 => ActGateAttrs::Flags({
8117                    let res = parse_u32(next);
8118                    let Some(val) = res else { break };
8119                    val
8120                }),
8121                10u16 => ActGateAttrs::Clockid({
8122                    let res = parse_i32(next);
8123                    let Some(val) = res else { break };
8124                    val
8125                }),
8126                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8127                n => continue,
8128            };
8129            return Some(Ok(res));
8130        }
8131        Some(Err(ErrorContext::new(
8132            "ActGateAttrs",
8133            r#type.and_then(|t| ActGateAttrs::attr_from_type(t)),
8134            self.orig_loc,
8135            self.buf.as_ptr().wrapping_add(pos) as usize,
8136        )))
8137    }
8138}
8139impl<'a> std::fmt::Debug for IterableActGateAttrs<'_> {
8140    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8141        let mut fmt = f.debug_struct("ActGateAttrs");
8142        for attr in self.clone() {
8143            let attr = match attr {
8144                Ok(a) => a,
8145                Err(err) => {
8146                    fmt.finish()?;
8147                    f.write_str("Err(")?;
8148                    err.fmt(f)?;
8149                    return f.write_str(")");
8150                }
8151            };
8152            match attr {
8153                ActGateAttrs::Tm(val) => fmt.field("Tm", &val),
8154                ActGateAttrs::Parms(val) => fmt.field("Parms", &val),
8155                ActGateAttrs::Pad(val) => fmt.field("Pad", &val),
8156                ActGateAttrs::Priority(val) => fmt.field("Priority", &val),
8157                ActGateAttrs::EntryList(val) => fmt.field("EntryList", &val),
8158                ActGateAttrs::BaseTime(val) => fmt.field("BaseTime", &val),
8159                ActGateAttrs::CycleTime(val) => fmt.field("CycleTime", &val),
8160                ActGateAttrs::CycleTimeExt(val) => fmt.field("CycleTimeExt", &val),
8161                ActGateAttrs::Flags(val) => fmt.field("Flags", &val),
8162                ActGateAttrs::Clockid(val) => fmt.field("Clockid", &val),
8163            };
8164        }
8165        fmt.finish()
8166    }
8167}
8168impl IterableActGateAttrs<'_> {
8169    pub fn lookup_attr(
8170        &self,
8171        offset: usize,
8172        missing_type: Option<u16>,
8173    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8174        let mut stack = Vec::new();
8175        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8176        if missing_type.is_some() && cur == offset {
8177            stack.push(("ActGateAttrs", offset));
8178            return (
8179                stack,
8180                missing_type.and_then(|t| ActGateAttrs::attr_from_type(t)),
8181            );
8182        }
8183        if cur > offset || cur + self.buf.len() < offset {
8184            return (stack, None);
8185        }
8186        let mut attrs = self.clone();
8187        let mut last_off = cur + attrs.pos;
8188        while let Some(attr) = attrs.next() {
8189            let Ok(attr) = attr else { break };
8190            match attr {
8191                ActGateAttrs::Tm(val) => {
8192                    if last_off == offset {
8193                        stack.push(("Tm", last_off));
8194                        break;
8195                    }
8196                }
8197                ActGateAttrs::Parms(val) => {
8198                    if last_off == offset {
8199                        stack.push(("Parms", last_off));
8200                        break;
8201                    }
8202                }
8203                ActGateAttrs::Pad(val) => {
8204                    if last_off == offset {
8205                        stack.push(("Pad", last_off));
8206                        break;
8207                    }
8208                }
8209                ActGateAttrs::Priority(val) => {
8210                    if last_off == offset {
8211                        stack.push(("Priority", last_off));
8212                        break;
8213                    }
8214                }
8215                ActGateAttrs::EntryList(val) => {
8216                    if last_off == offset {
8217                        stack.push(("EntryList", last_off));
8218                        break;
8219                    }
8220                }
8221                ActGateAttrs::BaseTime(val) => {
8222                    if last_off == offset {
8223                        stack.push(("BaseTime", last_off));
8224                        break;
8225                    }
8226                }
8227                ActGateAttrs::CycleTime(val) => {
8228                    if last_off == offset {
8229                        stack.push(("CycleTime", last_off));
8230                        break;
8231                    }
8232                }
8233                ActGateAttrs::CycleTimeExt(val) => {
8234                    if last_off == offset {
8235                        stack.push(("CycleTimeExt", last_off));
8236                        break;
8237                    }
8238                }
8239                ActGateAttrs::Flags(val) => {
8240                    if last_off == offset {
8241                        stack.push(("Flags", last_off));
8242                        break;
8243                    }
8244                }
8245                ActGateAttrs::Clockid(val) => {
8246                    if last_off == offset {
8247                        stack.push(("Clockid", last_off));
8248                        break;
8249                    }
8250                }
8251                _ => {}
8252            };
8253            last_off = cur + attrs.pos;
8254        }
8255        if !stack.is_empty() {
8256            stack.push(("ActGateAttrs", cur));
8257        }
8258        (stack, None)
8259    }
8260}
8261#[derive(Clone)]
8262pub enum ActIfeAttrs<'a> {
8263    Parms(&'a [u8]),
8264    Tm(TcfT),
8265    Dmac(&'a [u8]),
8266    Smac(&'a [u8]),
8267    Type(u16),
8268    Metalst(&'a [u8]),
8269    Pad(&'a [u8]),
8270}
8271impl<'a> IterableActIfeAttrs<'a> {
8272    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
8273        let mut iter = self.clone();
8274        iter.pos = 0;
8275        for attr in iter {
8276            if let ActIfeAttrs::Parms(val) = attr? {
8277                return Ok(val);
8278            }
8279        }
8280        Err(ErrorContext::new_missing(
8281            "ActIfeAttrs",
8282            "Parms",
8283            self.orig_loc,
8284            self.buf.as_ptr() as usize,
8285        ))
8286    }
8287    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
8288        let mut iter = self.clone();
8289        iter.pos = 0;
8290        for attr in iter {
8291            if let ActIfeAttrs::Tm(val) = attr? {
8292                return Ok(val);
8293            }
8294        }
8295        Err(ErrorContext::new_missing(
8296            "ActIfeAttrs",
8297            "Tm",
8298            self.orig_loc,
8299            self.buf.as_ptr() as usize,
8300        ))
8301    }
8302    pub fn get_dmac(&self) -> Result<&'a [u8], ErrorContext> {
8303        let mut iter = self.clone();
8304        iter.pos = 0;
8305        for attr in iter {
8306            if let ActIfeAttrs::Dmac(val) = attr? {
8307                return Ok(val);
8308            }
8309        }
8310        Err(ErrorContext::new_missing(
8311            "ActIfeAttrs",
8312            "Dmac",
8313            self.orig_loc,
8314            self.buf.as_ptr() as usize,
8315        ))
8316    }
8317    pub fn get_smac(&self) -> Result<&'a [u8], ErrorContext> {
8318        let mut iter = self.clone();
8319        iter.pos = 0;
8320        for attr in iter {
8321            if let ActIfeAttrs::Smac(val) = attr? {
8322                return Ok(val);
8323            }
8324        }
8325        Err(ErrorContext::new_missing(
8326            "ActIfeAttrs",
8327            "Smac",
8328            self.orig_loc,
8329            self.buf.as_ptr() as usize,
8330        ))
8331    }
8332    pub fn get_type(&self) -> Result<u16, ErrorContext> {
8333        let mut iter = self.clone();
8334        iter.pos = 0;
8335        for attr in iter {
8336            if let ActIfeAttrs::Type(val) = attr? {
8337                return Ok(val);
8338            }
8339        }
8340        Err(ErrorContext::new_missing(
8341            "ActIfeAttrs",
8342            "Type",
8343            self.orig_loc,
8344            self.buf.as_ptr() as usize,
8345        ))
8346    }
8347    pub fn get_metalst(&self) -> Result<&'a [u8], ErrorContext> {
8348        let mut iter = self.clone();
8349        iter.pos = 0;
8350        for attr in iter {
8351            if let ActIfeAttrs::Metalst(val) = attr? {
8352                return Ok(val);
8353            }
8354        }
8355        Err(ErrorContext::new_missing(
8356            "ActIfeAttrs",
8357            "Metalst",
8358            self.orig_loc,
8359            self.buf.as_ptr() as usize,
8360        ))
8361    }
8362    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
8363        let mut iter = self.clone();
8364        iter.pos = 0;
8365        for attr in iter {
8366            if let ActIfeAttrs::Pad(val) = attr? {
8367                return Ok(val);
8368            }
8369        }
8370        Err(ErrorContext::new_missing(
8371            "ActIfeAttrs",
8372            "Pad",
8373            self.orig_loc,
8374            self.buf.as_ptr() as usize,
8375        ))
8376    }
8377}
8378impl ActIfeAttrs<'_> {
8379    pub fn new<'a>(buf: &'a [u8]) -> IterableActIfeAttrs<'a> {
8380        IterableActIfeAttrs::with_loc(buf, buf.as_ptr() as usize)
8381    }
8382    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8383        let res = match r#type {
8384            1u16 => "Parms",
8385            2u16 => "Tm",
8386            3u16 => "Dmac",
8387            4u16 => "Smac",
8388            5u16 => "Type",
8389            6u16 => "Metalst",
8390            7u16 => "Pad",
8391            _ => return None,
8392        };
8393        Some(res)
8394    }
8395}
8396#[derive(Clone, Copy, Default)]
8397pub struct IterableActIfeAttrs<'a> {
8398    buf: &'a [u8],
8399    pos: usize,
8400    orig_loc: usize,
8401}
8402impl<'a> IterableActIfeAttrs<'a> {
8403    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8404        Self {
8405            buf,
8406            pos: 0,
8407            orig_loc,
8408        }
8409    }
8410    pub fn get_buf(&self) -> &'a [u8] {
8411        self.buf
8412    }
8413}
8414impl<'a> Iterator for IterableActIfeAttrs<'a> {
8415    type Item = Result<ActIfeAttrs<'a>, ErrorContext>;
8416    fn next(&mut self) -> Option<Self::Item> {
8417        let pos = self.pos;
8418        let mut r#type;
8419        loop {
8420            r#type = None;
8421            if self.buf.len() == self.pos {
8422                return None;
8423            }
8424            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8425                break;
8426            };
8427            r#type = Some(header.r#type);
8428            let res = match header.r#type {
8429                1u16 => ActIfeAttrs::Parms({
8430                    let res = Some(next);
8431                    let Some(val) = res else { break };
8432                    val
8433                }),
8434                2u16 => ActIfeAttrs::Tm({
8435                    let res = Some(TcfT::new_from_zeroed(next));
8436                    let Some(val) = res else { break };
8437                    val
8438                }),
8439                3u16 => ActIfeAttrs::Dmac({
8440                    let res = Some(next);
8441                    let Some(val) = res else { break };
8442                    val
8443                }),
8444                4u16 => ActIfeAttrs::Smac({
8445                    let res = Some(next);
8446                    let Some(val) = res else { break };
8447                    val
8448                }),
8449                5u16 => ActIfeAttrs::Type({
8450                    let res = parse_u16(next);
8451                    let Some(val) = res else { break };
8452                    val
8453                }),
8454                6u16 => ActIfeAttrs::Metalst({
8455                    let res = Some(next);
8456                    let Some(val) = res else { break };
8457                    val
8458                }),
8459                7u16 => ActIfeAttrs::Pad({
8460                    let res = Some(next);
8461                    let Some(val) = res else { break };
8462                    val
8463                }),
8464                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8465                n => continue,
8466            };
8467            return Some(Ok(res));
8468        }
8469        Some(Err(ErrorContext::new(
8470            "ActIfeAttrs",
8471            r#type.and_then(|t| ActIfeAttrs::attr_from_type(t)),
8472            self.orig_loc,
8473            self.buf.as_ptr().wrapping_add(pos) as usize,
8474        )))
8475    }
8476}
8477impl<'a> std::fmt::Debug for IterableActIfeAttrs<'_> {
8478    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8479        let mut fmt = f.debug_struct("ActIfeAttrs");
8480        for attr in self.clone() {
8481            let attr = match attr {
8482                Ok(a) => a,
8483                Err(err) => {
8484                    fmt.finish()?;
8485                    f.write_str("Err(")?;
8486                    err.fmt(f)?;
8487                    return f.write_str(")");
8488                }
8489            };
8490            match attr {
8491                ActIfeAttrs::Parms(val) => fmt.field("Parms", &val),
8492                ActIfeAttrs::Tm(val) => fmt.field("Tm", &val),
8493                ActIfeAttrs::Dmac(val) => fmt.field("Dmac", &val),
8494                ActIfeAttrs::Smac(val) => fmt.field("Smac", &val),
8495                ActIfeAttrs::Type(val) => fmt.field("Type", &val),
8496                ActIfeAttrs::Metalst(val) => fmt.field("Metalst", &val),
8497                ActIfeAttrs::Pad(val) => fmt.field("Pad", &val),
8498            };
8499        }
8500        fmt.finish()
8501    }
8502}
8503impl IterableActIfeAttrs<'_> {
8504    pub fn lookup_attr(
8505        &self,
8506        offset: usize,
8507        missing_type: Option<u16>,
8508    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8509        let mut stack = Vec::new();
8510        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8511        if missing_type.is_some() && cur == offset {
8512            stack.push(("ActIfeAttrs", offset));
8513            return (
8514                stack,
8515                missing_type.and_then(|t| ActIfeAttrs::attr_from_type(t)),
8516            );
8517        }
8518        if cur > offset || cur + self.buf.len() < offset {
8519            return (stack, None);
8520        }
8521        let mut attrs = self.clone();
8522        let mut last_off = cur + attrs.pos;
8523        while let Some(attr) = attrs.next() {
8524            let Ok(attr) = attr else { break };
8525            match attr {
8526                ActIfeAttrs::Parms(val) => {
8527                    if last_off == offset {
8528                        stack.push(("Parms", last_off));
8529                        break;
8530                    }
8531                }
8532                ActIfeAttrs::Tm(val) => {
8533                    if last_off == offset {
8534                        stack.push(("Tm", last_off));
8535                        break;
8536                    }
8537                }
8538                ActIfeAttrs::Dmac(val) => {
8539                    if last_off == offset {
8540                        stack.push(("Dmac", last_off));
8541                        break;
8542                    }
8543                }
8544                ActIfeAttrs::Smac(val) => {
8545                    if last_off == offset {
8546                        stack.push(("Smac", last_off));
8547                        break;
8548                    }
8549                }
8550                ActIfeAttrs::Type(val) => {
8551                    if last_off == offset {
8552                        stack.push(("Type", last_off));
8553                        break;
8554                    }
8555                }
8556                ActIfeAttrs::Metalst(val) => {
8557                    if last_off == offset {
8558                        stack.push(("Metalst", last_off));
8559                        break;
8560                    }
8561                }
8562                ActIfeAttrs::Pad(val) => {
8563                    if last_off == offset {
8564                        stack.push(("Pad", last_off));
8565                        break;
8566                    }
8567                }
8568                _ => {}
8569            };
8570            last_off = cur + attrs.pos;
8571        }
8572        if !stack.is_empty() {
8573            stack.push(("ActIfeAttrs", cur));
8574        }
8575        (stack, None)
8576    }
8577}
8578#[derive(Clone)]
8579pub enum ActMirredAttrs<'a> {
8580    Tm(TcfT),
8581    Parms(&'a [u8]),
8582    Pad(&'a [u8]),
8583    Blockid(&'a [u8]),
8584}
8585impl<'a> IterableActMirredAttrs<'a> {
8586    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
8587        let mut iter = self.clone();
8588        iter.pos = 0;
8589        for attr in iter {
8590            if let ActMirredAttrs::Tm(val) = attr? {
8591                return Ok(val);
8592            }
8593        }
8594        Err(ErrorContext::new_missing(
8595            "ActMirredAttrs",
8596            "Tm",
8597            self.orig_loc,
8598            self.buf.as_ptr() as usize,
8599        ))
8600    }
8601    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
8602        let mut iter = self.clone();
8603        iter.pos = 0;
8604        for attr in iter {
8605            if let ActMirredAttrs::Parms(val) = attr? {
8606                return Ok(val);
8607            }
8608        }
8609        Err(ErrorContext::new_missing(
8610            "ActMirredAttrs",
8611            "Parms",
8612            self.orig_loc,
8613            self.buf.as_ptr() as usize,
8614        ))
8615    }
8616    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
8617        let mut iter = self.clone();
8618        iter.pos = 0;
8619        for attr in iter {
8620            if let ActMirredAttrs::Pad(val) = attr? {
8621                return Ok(val);
8622            }
8623        }
8624        Err(ErrorContext::new_missing(
8625            "ActMirredAttrs",
8626            "Pad",
8627            self.orig_loc,
8628            self.buf.as_ptr() as usize,
8629        ))
8630    }
8631    pub fn get_blockid(&self) -> Result<&'a [u8], ErrorContext> {
8632        let mut iter = self.clone();
8633        iter.pos = 0;
8634        for attr in iter {
8635            if let ActMirredAttrs::Blockid(val) = attr? {
8636                return Ok(val);
8637            }
8638        }
8639        Err(ErrorContext::new_missing(
8640            "ActMirredAttrs",
8641            "Blockid",
8642            self.orig_loc,
8643            self.buf.as_ptr() as usize,
8644        ))
8645    }
8646}
8647impl ActMirredAttrs<'_> {
8648    pub fn new<'a>(buf: &'a [u8]) -> IterableActMirredAttrs<'a> {
8649        IterableActMirredAttrs::with_loc(buf, buf.as_ptr() as usize)
8650    }
8651    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8652        let res = match r#type {
8653            1u16 => "Tm",
8654            2u16 => "Parms",
8655            3u16 => "Pad",
8656            4u16 => "Blockid",
8657            _ => return None,
8658        };
8659        Some(res)
8660    }
8661}
8662#[derive(Clone, Copy, Default)]
8663pub struct IterableActMirredAttrs<'a> {
8664    buf: &'a [u8],
8665    pos: usize,
8666    orig_loc: usize,
8667}
8668impl<'a> IterableActMirredAttrs<'a> {
8669    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8670        Self {
8671            buf,
8672            pos: 0,
8673            orig_loc,
8674        }
8675    }
8676    pub fn get_buf(&self) -> &'a [u8] {
8677        self.buf
8678    }
8679}
8680impl<'a> Iterator for IterableActMirredAttrs<'a> {
8681    type Item = Result<ActMirredAttrs<'a>, ErrorContext>;
8682    fn next(&mut self) -> Option<Self::Item> {
8683        let pos = self.pos;
8684        let mut r#type;
8685        loop {
8686            r#type = None;
8687            if self.buf.len() == self.pos {
8688                return None;
8689            }
8690            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8691                break;
8692            };
8693            r#type = Some(header.r#type);
8694            let res = match header.r#type {
8695                1u16 => ActMirredAttrs::Tm({
8696                    let res = Some(TcfT::new_from_zeroed(next));
8697                    let Some(val) = res else { break };
8698                    val
8699                }),
8700                2u16 => ActMirredAttrs::Parms({
8701                    let res = Some(next);
8702                    let Some(val) = res else { break };
8703                    val
8704                }),
8705                3u16 => ActMirredAttrs::Pad({
8706                    let res = Some(next);
8707                    let Some(val) = res else { break };
8708                    val
8709                }),
8710                4u16 => ActMirredAttrs::Blockid({
8711                    let res = Some(next);
8712                    let Some(val) = res else { break };
8713                    val
8714                }),
8715                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8716                n => continue,
8717            };
8718            return Some(Ok(res));
8719        }
8720        Some(Err(ErrorContext::new(
8721            "ActMirredAttrs",
8722            r#type.and_then(|t| ActMirredAttrs::attr_from_type(t)),
8723            self.orig_loc,
8724            self.buf.as_ptr().wrapping_add(pos) as usize,
8725        )))
8726    }
8727}
8728impl<'a> std::fmt::Debug for IterableActMirredAttrs<'_> {
8729    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8730        let mut fmt = f.debug_struct("ActMirredAttrs");
8731        for attr in self.clone() {
8732            let attr = match attr {
8733                Ok(a) => a,
8734                Err(err) => {
8735                    fmt.finish()?;
8736                    f.write_str("Err(")?;
8737                    err.fmt(f)?;
8738                    return f.write_str(")");
8739                }
8740            };
8741            match attr {
8742                ActMirredAttrs::Tm(val) => fmt.field("Tm", &val),
8743                ActMirredAttrs::Parms(val) => fmt.field("Parms", &val),
8744                ActMirredAttrs::Pad(val) => fmt.field("Pad", &val),
8745                ActMirredAttrs::Blockid(val) => fmt.field("Blockid", &val),
8746            };
8747        }
8748        fmt.finish()
8749    }
8750}
8751impl IterableActMirredAttrs<'_> {
8752    pub fn lookup_attr(
8753        &self,
8754        offset: usize,
8755        missing_type: Option<u16>,
8756    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8757        let mut stack = Vec::new();
8758        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8759        if missing_type.is_some() && cur == offset {
8760            stack.push(("ActMirredAttrs", offset));
8761            return (
8762                stack,
8763                missing_type.and_then(|t| ActMirredAttrs::attr_from_type(t)),
8764            );
8765        }
8766        if cur > offset || cur + self.buf.len() < offset {
8767            return (stack, None);
8768        }
8769        let mut attrs = self.clone();
8770        let mut last_off = cur + attrs.pos;
8771        while let Some(attr) = attrs.next() {
8772            let Ok(attr) = attr else { break };
8773            match attr {
8774                ActMirredAttrs::Tm(val) => {
8775                    if last_off == offset {
8776                        stack.push(("Tm", last_off));
8777                        break;
8778                    }
8779                }
8780                ActMirredAttrs::Parms(val) => {
8781                    if last_off == offset {
8782                        stack.push(("Parms", last_off));
8783                        break;
8784                    }
8785                }
8786                ActMirredAttrs::Pad(val) => {
8787                    if last_off == offset {
8788                        stack.push(("Pad", last_off));
8789                        break;
8790                    }
8791                }
8792                ActMirredAttrs::Blockid(val) => {
8793                    if last_off == offset {
8794                        stack.push(("Blockid", last_off));
8795                        break;
8796                    }
8797                }
8798                _ => {}
8799            };
8800            last_off = cur + attrs.pos;
8801        }
8802        if !stack.is_empty() {
8803            stack.push(("ActMirredAttrs", cur));
8804        }
8805        (stack, None)
8806    }
8807}
8808#[derive(Clone)]
8809pub enum ActMplsAttrs<'a> {
8810    Tm(TcfT),
8811    Parms(TcMpls),
8812    Pad(&'a [u8]),
8813    Proto(u16),
8814    Label(u32),
8815    Tc(u8),
8816    Ttl(u8),
8817    Bos(u8),
8818}
8819impl<'a> IterableActMplsAttrs<'a> {
8820    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
8821        let mut iter = self.clone();
8822        iter.pos = 0;
8823        for attr in iter {
8824            if let ActMplsAttrs::Tm(val) = attr? {
8825                return Ok(val);
8826            }
8827        }
8828        Err(ErrorContext::new_missing(
8829            "ActMplsAttrs",
8830            "Tm",
8831            self.orig_loc,
8832            self.buf.as_ptr() as usize,
8833        ))
8834    }
8835    pub fn get_parms(&self) -> Result<TcMpls, ErrorContext> {
8836        let mut iter = self.clone();
8837        iter.pos = 0;
8838        for attr in iter {
8839            if let ActMplsAttrs::Parms(val) = attr? {
8840                return Ok(val);
8841            }
8842        }
8843        Err(ErrorContext::new_missing(
8844            "ActMplsAttrs",
8845            "Parms",
8846            self.orig_loc,
8847            self.buf.as_ptr() as usize,
8848        ))
8849    }
8850    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
8851        let mut iter = self.clone();
8852        iter.pos = 0;
8853        for attr in iter {
8854            if let ActMplsAttrs::Pad(val) = attr? {
8855                return Ok(val);
8856            }
8857        }
8858        Err(ErrorContext::new_missing(
8859            "ActMplsAttrs",
8860            "Pad",
8861            self.orig_loc,
8862            self.buf.as_ptr() as usize,
8863        ))
8864    }
8865    pub fn get_proto(&self) -> Result<u16, ErrorContext> {
8866        let mut iter = self.clone();
8867        iter.pos = 0;
8868        for attr in iter {
8869            if let ActMplsAttrs::Proto(val) = attr? {
8870                return Ok(val);
8871            }
8872        }
8873        Err(ErrorContext::new_missing(
8874            "ActMplsAttrs",
8875            "Proto",
8876            self.orig_loc,
8877            self.buf.as_ptr() as usize,
8878        ))
8879    }
8880    pub fn get_label(&self) -> Result<u32, ErrorContext> {
8881        let mut iter = self.clone();
8882        iter.pos = 0;
8883        for attr in iter {
8884            if let ActMplsAttrs::Label(val) = attr? {
8885                return Ok(val);
8886            }
8887        }
8888        Err(ErrorContext::new_missing(
8889            "ActMplsAttrs",
8890            "Label",
8891            self.orig_loc,
8892            self.buf.as_ptr() as usize,
8893        ))
8894    }
8895    pub fn get_tc(&self) -> Result<u8, ErrorContext> {
8896        let mut iter = self.clone();
8897        iter.pos = 0;
8898        for attr in iter {
8899            if let ActMplsAttrs::Tc(val) = attr? {
8900                return Ok(val);
8901            }
8902        }
8903        Err(ErrorContext::new_missing(
8904            "ActMplsAttrs",
8905            "Tc",
8906            self.orig_loc,
8907            self.buf.as_ptr() as usize,
8908        ))
8909    }
8910    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
8911        let mut iter = self.clone();
8912        iter.pos = 0;
8913        for attr in iter {
8914            if let ActMplsAttrs::Ttl(val) = attr? {
8915                return Ok(val);
8916            }
8917        }
8918        Err(ErrorContext::new_missing(
8919            "ActMplsAttrs",
8920            "Ttl",
8921            self.orig_loc,
8922            self.buf.as_ptr() as usize,
8923        ))
8924    }
8925    pub fn get_bos(&self) -> Result<u8, ErrorContext> {
8926        let mut iter = self.clone();
8927        iter.pos = 0;
8928        for attr in iter {
8929            if let ActMplsAttrs::Bos(val) = attr? {
8930                return Ok(val);
8931            }
8932        }
8933        Err(ErrorContext::new_missing(
8934            "ActMplsAttrs",
8935            "Bos",
8936            self.orig_loc,
8937            self.buf.as_ptr() as usize,
8938        ))
8939    }
8940}
8941impl ActMplsAttrs<'_> {
8942    pub fn new<'a>(buf: &'a [u8]) -> IterableActMplsAttrs<'a> {
8943        IterableActMplsAttrs::with_loc(buf, buf.as_ptr() as usize)
8944    }
8945    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8946        let res = match r#type {
8947            1u16 => "Tm",
8948            2u16 => "Parms",
8949            3u16 => "Pad",
8950            4u16 => "Proto",
8951            5u16 => "Label",
8952            6u16 => "Tc",
8953            7u16 => "Ttl",
8954            8u16 => "Bos",
8955            _ => return None,
8956        };
8957        Some(res)
8958    }
8959}
8960#[derive(Clone, Copy, Default)]
8961pub struct IterableActMplsAttrs<'a> {
8962    buf: &'a [u8],
8963    pos: usize,
8964    orig_loc: usize,
8965}
8966impl<'a> IterableActMplsAttrs<'a> {
8967    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8968        Self {
8969            buf,
8970            pos: 0,
8971            orig_loc,
8972        }
8973    }
8974    pub fn get_buf(&self) -> &'a [u8] {
8975        self.buf
8976    }
8977}
8978impl<'a> Iterator for IterableActMplsAttrs<'a> {
8979    type Item = Result<ActMplsAttrs<'a>, ErrorContext>;
8980    fn next(&mut self) -> Option<Self::Item> {
8981        let pos = self.pos;
8982        let mut r#type;
8983        loop {
8984            r#type = None;
8985            if self.buf.len() == self.pos {
8986                return None;
8987            }
8988            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8989                break;
8990            };
8991            r#type = Some(header.r#type);
8992            let res = match header.r#type {
8993                1u16 => ActMplsAttrs::Tm({
8994                    let res = Some(TcfT::new_from_zeroed(next));
8995                    let Some(val) = res else { break };
8996                    val
8997                }),
8998                2u16 => ActMplsAttrs::Parms({
8999                    let res = Some(TcMpls::new_from_zeroed(next));
9000                    let Some(val) = res else { break };
9001                    val
9002                }),
9003                3u16 => ActMplsAttrs::Pad({
9004                    let res = Some(next);
9005                    let Some(val) = res else { break };
9006                    val
9007                }),
9008                4u16 => ActMplsAttrs::Proto({
9009                    let res = parse_be_u16(next);
9010                    let Some(val) = res else { break };
9011                    val
9012                }),
9013                5u16 => ActMplsAttrs::Label({
9014                    let res = parse_u32(next);
9015                    let Some(val) = res else { break };
9016                    val
9017                }),
9018                6u16 => ActMplsAttrs::Tc({
9019                    let res = parse_u8(next);
9020                    let Some(val) = res else { break };
9021                    val
9022                }),
9023                7u16 => ActMplsAttrs::Ttl({
9024                    let res = parse_u8(next);
9025                    let Some(val) = res else { break };
9026                    val
9027                }),
9028                8u16 => ActMplsAttrs::Bos({
9029                    let res = parse_u8(next);
9030                    let Some(val) = res else { break };
9031                    val
9032                }),
9033                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9034                n => continue,
9035            };
9036            return Some(Ok(res));
9037        }
9038        Some(Err(ErrorContext::new(
9039            "ActMplsAttrs",
9040            r#type.and_then(|t| ActMplsAttrs::attr_from_type(t)),
9041            self.orig_loc,
9042            self.buf.as_ptr().wrapping_add(pos) as usize,
9043        )))
9044    }
9045}
9046impl<'a> std::fmt::Debug for IterableActMplsAttrs<'_> {
9047    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9048        let mut fmt = f.debug_struct("ActMplsAttrs");
9049        for attr in self.clone() {
9050            let attr = match attr {
9051                Ok(a) => a,
9052                Err(err) => {
9053                    fmt.finish()?;
9054                    f.write_str("Err(")?;
9055                    err.fmt(f)?;
9056                    return f.write_str(")");
9057                }
9058            };
9059            match attr {
9060                ActMplsAttrs::Tm(val) => fmt.field("Tm", &val),
9061                ActMplsAttrs::Parms(val) => fmt.field("Parms", &val),
9062                ActMplsAttrs::Pad(val) => fmt.field("Pad", &val),
9063                ActMplsAttrs::Proto(val) => fmt.field("Proto", &val),
9064                ActMplsAttrs::Label(val) => fmt.field("Label", &val),
9065                ActMplsAttrs::Tc(val) => fmt.field("Tc", &val),
9066                ActMplsAttrs::Ttl(val) => fmt.field("Ttl", &val),
9067                ActMplsAttrs::Bos(val) => fmt.field("Bos", &val),
9068            };
9069        }
9070        fmt.finish()
9071    }
9072}
9073impl IterableActMplsAttrs<'_> {
9074    pub fn lookup_attr(
9075        &self,
9076        offset: usize,
9077        missing_type: Option<u16>,
9078    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9079        let mut stack = Vec::new();
9080        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9081        if missing_type.is_some() && cur == offset {
9082            stack.push(("ActMplsAttrs", offset));
9083            return (
9084                stack,
9085                missing_type.and_then(|t| ActMplsAttrs::attr_from_type(t)),
9086            );
9087        }
9088        if cur > offset || cur + self.buf.len() < offset {
9089            return (stack, None);
9090        }
9091        let mut attrs = self.clone();
9092        let mut last_off = cur + attrs.pos;
9093        while let Some(attr) = attrs.next() {
9094            let Ok(attr) = attr else { break };
9095            match attr {
9096                ActMplsAttrs::Tm(val) => {
9097                    if last_off == offset {
9098                        stack.push(("Tm", last_off));
9099                        break;
9100                    }
9101                }
9102                ActMplsAttrs::Parms(val) => {
9103                    if last_off == offset {
9104                        stack.push(("Parms", last_off));
9105                        break;
9106                    }
9107                }
9108                ActMplsAttrs::Pad(val) => {
9109                    if last_off == offset {
9110                        stack.push(("Pad", last_off));
9111                        break;
9112                    }
9113                }
9114                ActMplsAttrs::Proto(val) => {
9115                    if last_off == offset {
9116                        stack.push(("Proto", last_off));
9117                        break;
9118                    }
9119                }
9120                ActMplsAttrs::Label(val) => {
9121                    if last_off == offset {
9122                        stack.push(("Label", last_off));
9123                        break;
9124                    }
9125                }
9126                ActMplsAttrs::Tc(val) => {
9127                    if last_off == offset {
9128                        stack.push(("Tc", last_off));
9129                        break;
9130                    }
9131                }
9132                ActMplsAttrs::Ttl(val) => {
9133                    if last_off == offset {
9134                        stack.push(("Ttl", last_off));
9135                        break;
9136                    }
9137                }
9138                ActMplsAttrs::Bos(val) => {
9139                    if last_off == offset {
9140                        stack.push(("Bos", last_off));
9141                        break;
9142                    }
9143                }
9144                _ => {}
9145            };
9146            last_off = cur + attrs.pos;
9147        }
9148        if !stack.is_empty() {
9149            stack.push(("ActMplsAttrs", cur));
9150        }
9151        (stack, None)
9152    }
9153}
9154#[derive(Clone)]
9155pub enum ActNatAttrs<'a> {
9156    Parms(&'a [u8]),
9157    Tm(TcfT),
9158    Pad(&'a [u8]),
9159}
9160impl<'a> IterableActNatAttrs<'a> {
9161    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
9162        let mut iter = self.clone();
9163        iter.pos = 0;
9164        for attr in iter {
9165            if let ActNatAttrs::Parms(val) = attr? {
9166                return Ok(val);
9167            }
9168        }
9169        Err(ErrorContext::new_missing(
9170            "ActNatAttrs",
9171            "Parms",
9172            self.orig_loc,
9173            self.buf.as_ptr() as usize,
9174        ))
9175    }
9176    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
9177        let mut iter = self.clone();
9178        iter.pos = 0;
9179        for attr in iter {
9180            if let ActNatAttrs::Tm(val) = attr? {
9181                return Ok(val);
9182            }
9183        }
9184        Err(ErrorContext::new_missing(
9185            "ActNatAttrs",
9186            "Tm",
9187            self.orig_loc,
9188            self.buf.as_ptr() as usize,
9189        ))
9190    }
9191    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
9192        let mut iter = self.clone();
9193        iter.pos = 0;
9194        for attr in iter {
9195            if let ActNatAttrs::Pad(val) = attr? {
9196                return Ok(val);
9197            }
9198        }
9199        Err(ErrorContext::new_missing(
9200            "ActNatAttrs",
9201            "Pad",
9202            self.orig_loc,
9203            self.buf.as_ptr() as usize,
9204        ))
9205    }
9206}
9207impl ActNatAttrs<'_> {
9208    pub fn new<'a>(buf: &'a [u8]) -> IterableActNatAttrs<'a> {
9209        IterableActNatAttrs::with_loc(buf, buf.as_ptr() as usize)
9210    }
9211    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9212        let res = match r#type {
9213            1u16 => "Parms",
9214            2u16 => "Tm",
9215            3u16 => "Pad",
9216            _ => return None,
9217        };
9218        Some(res)
9219    }
9220}
9221#[derive(Clone, Copy, Default)]
9222pub struct IterableActNatAttrs<'a> {
9223    buf: &'a [u8],
9224    pos: usize,
9225    orig_loc: usize,
9226}
9227impl<'a> IterableActNatAttrs<'a> {
9228    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9229        Self {
9230            buf,
9231            pos: 0,
9232            orig_loc,
9233        }
9234    }
9235    pub fn get_buf(&self) -> &'a [u8] {
9236        self.buf
9237    }
9238}
9239impl<'a> Iterator for IterableActNatAttrs<'a> {
9240    type Item = Result<ActNatAttrs<'a>, ErrorContext>;
9241    fn next(&mut self) -> Option<Self::Item> {
9242        let pos = self.pos;
9243        let mut r#type;
9244        loop {
9245            r#type = None;
9246            if self.buf.len() == self.pos {
9247                return None;
9248            }
9249            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9250                break;
9251            };
9252            r#type = Some(header.r#type);
9253            let res = match header.r#type {
9254                1u16 => ActNatAttrs::Parms({
9255                    let res = Some(next);
9256                    let Some(val) = res else { break };
9257                    val
9258                }),
9259                2u16 => ActNatAttrs::Tm({
9260                    let res = Some(TcfT::new_from_zeroed(next));
9261                    let Some(val) = res else { break };
9262                    val
9263                }),
9264                3u16 => ActNatAttrs::Pad({
9265                    let res = Some(next);
9266                    let Some(val) = res else { break };
9267                    val
9268                }),
9269                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9270                n => continue,
9271            };
9272            return Some(Ok(res));
9273        }
9274        Some(Err(ErrorContext::new(
9275            "ActNatAttrs",
9276            r#type.and_then(|t| ActNatAttrs::attr_from_type(t)),
9277            self.orig_loc,
9278            self.buf.as_ptr().wrapping_add(pos) as usize,
9279        )))
9280    }
9281}
9282impl<'a> std::fmt::Debug for IterableActNatAttrs<'_> {
9283    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9284        let mut fmt = f.debug_struct("ActNatAttrs");
9285        for attr in self.clone() {
9286            let attr = match attr {
9287                Ok(a) => a,
9288                Err(err) => {
9289                    fmt.finish()?;
9290                    f.write_str("Err(")?;
9291                    err.fmt(f)?;
9292                    return f.write_str(")");
9293                }
9294            };
9295            match attr {
9296                ActNatAttrs::Parms(val) => fmt.field("Parms", &val),
9297                ActNatAttrs::Tm(val) => fmt.field("Tm", &val),
9298                ActNatAttrs::Pad(val) => fmt.field("Pad", &val),
9299            };
9300        }
9301        fmt.finish()
9302    }
9303}
9304impl IterableActNatAttrs<'_> {
9305    pub fn lookup_attr(
9306        &self,
9307        offset: usize,
9308        missing_type: Option<u16>,
9309    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9310        let mut stack = Vec::new();
9311        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9312        if missing_type.is_some() && cur == offset {
9313            stack.push(("ActNatAttrs", offset));
9314            return (
9315                stack,
9316                missing_type.and_then(|t| ActNatAttrs::attr_from_type(t)),
9317            );
9318        }
9319        if cur > offset || cur + self.buf.len() < offset {
9320            return (stack, None);
9321        }
9322        let mut attrs = self.clone();
9323        let mut last_off = cur + attrs.pos;
9324        while let Some(attr) = attrs.next() {
9325            let Ok(attr) = attr else { break };
9326            match attr {
9327                ActNatAttrs::Parms(val) => {
9328                    if last_off == offset {
9329                        stack.push(("Parms", last_off));
9330                        break;
9331                    }
9332                }
9333                ActNatAttrs::Tm(val) => {
9334                    if last_off == offset {
9335                        stack.push(("Tm", last_off));
9336                        break;
9337                    }
9338                }
9339                ActNatAttrs::Pad(val) => {
9340                    if last_off == offset {
9341                        stack.push(("Pad", last_off));
9342                        break;
9343                    }
9344                }
9345                _ => {}
9346            };
9347            last_off = cur + attrs.pos;
9348        }
9349        if !stack.is_empty() {
9350            stack.push(("ActNatAttrs", cur));
9351        }
9352        (stack, None)
9353    }
9354}
9355#[derive(Clone)]
9356pub enum ActPeditAttrs<'a> {
9357    Tm(TcfT),
9358    Parms(TcPeditSel),
9359    Pad(&'a [u8]),
9360    ParmsEx(&'a [u8]),
9361    KeysEx(&'a [u8]),
9362    KeyEx(&'a [u8]),
9363}
9364impl<'a> IterableActPeditAttrs<'a> {
9365    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
9366        let mut iter = self.clone();
9367        iter.pos = 0;
9368        for attr in iter {
9369            if let ActPeditAttrs::Tm(val) = attr? {
9370                return Ok(val);
9371            }
9372        }
9373        Err(ErrorContext::new_missing(
9374            "ActPeditAttrs",
9375            "Tm",
9376            self.orig_loc,
9377            self.buf.as_ptr() as usize,
9378        ))
9379    }
9380    pub fn get_parms(&self) -> Result<TcPeditSel, ErrorContext> {
9381        let mut iter = self.clone();
9382        iter.pos = 0;
9383        for attr in iter {
9384            if let ActPeditAttrs::Parms(val) = attr? {
9385                return Ok(val);
9386            }
9387        }
9388        Err(ErrorContext::new_missing(
9389            "ActPeditAttrs",
9390            "Parms",
9391            self.orig_loc,
9392            self.buf.as_ptr() as usize,
9393        ))
9394    }
9395    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
9396        let mut iter = self.clone();
9397        iter.pos = 0;
9398        for attr in iter {
9399            if let ActPeditAttrs::Pad(val) = attr? {
9400                return Ok(val);
9401            }
9402        }
9403        Err(ErrorContext::new_missing(
9404            "ActPeditAttrs",
9405            "Pad",
9406            self.orig_loc,
9407            self.buf.as_ptr() as usize,
9408        ))
9409    }
9410    pub fn get_parms_ex(&self) -> Result<&'a [u8], ErrorContext> {
9411        let mut iter = self.clone();
9412        iter.pos = 0;
9413        for attr in iter {
9414            if let ActPeditAttrs::ParmsEx(val) = attr? {
9415                return Ok(val);
9416            }
9417        }
9418        Err(ErrorContext::new_missing(
9419            "ActPeditAttrs",
9420            "ParmsEx",
9421            self.orig_loc,
9422            self.buf.as_ptr() as usize,
9423        ))
9424    }
9425    pub fn get_keys_ex(&self) -> Result<&'a [u8], ErrorContext> {
9426        let mut iter = self.clone();
9427        iter.pos = 0;
9428        for attr in iter {
9429            if let ActPeditAttrs::KeysEx(val) = attr? {
9430                return Ok(val);
9431            }
9432        }
9433        Err(ErrorContext::new_missing(
9434            "ActPeditAttrs",
9435            "KeysEx",
9436            self.orig_loc,
9437            self.buf.as_ptr() as usize,
9438        ))
9439    }
9440    pub fn get_key_ex(&self) -> Result<&'a [u8], ErrorContext> {
9441        let mut iter = self.clone();
9442        iter.pos = 0;
9443        for attr in iter {
9444            if let ActPeditAttrs::KeyEx(val) = attr? {
9445                return Ok(val);
9446            }
9447        }
9448        Err(ErrorContext::new_missing(
9449            "ActPeditAttrs",
9450            "KeyEx",
9451            self.orig_loc,
9452            self.buf.as_ptr() as usize,
9453        ))
9454    }
9455}
9456impl ActPeditAttrs<'_> {
9457    pub fn new<'a>(buf: &'a [u8]) -> IterableActPeditAttrs<'a> {
9458        IterableActPeditAttrs::with_loc(buf, buf.as_ptr() as usize)
9459    }
9460    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9461        let res = match r#type {
9462            1u16 => "Tm",
9463            2u16 => "Parms",
9464            3u16 => "Pad",
9465            4u16 => "ParmsEx",
9466            5u16 => "KeysEx",
9467            6u16 => "KeyEx",
9468            _ => return None,
9469        };
9470        Some(res)
9471    }
9472}
9473#[derive(Clone, Copy, Default)]
9474pub struct IterableActPeditAttrs<'a> {
9475    buf: &'a [u8],
9476    pos: usize,
9477    orig_loc: usize,
9478}
9479impl<'a> IterableActPeditAttrs<'a> {
9480    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9481        Self {
9482            buf,
9483            pos: 0,
9484            orig_loc,
9485        }
9486    }
9487    pub fn get_buf(&self) -> &'a [u8] {
9488        self.buf
9489    }
9490}
9491impl<'a> Iterator for IterableActPeditAttrs<'a> {
9492    type Item = Result<ActPeditAttrs<'a>, ErrorContext>;
9493    fn next(&mut self) -> Option<Self::Item> {
9494        let pos = self.pos;
9495        let mut r#type;
9496        loop {
9497            r#type = None;
9498            if self.buf.len() == self.pos {
9499                return None;
9500            }
9501            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9502                break;
9503            };
9504            r#type = Some(header.r#type);
9505            let res = match header.r#type {
9506                1u16 => ActPeditAttrs::Tm({
9507                    let res = Some(TcfT::new_from_zeroed(next));
9508                    let Some(val) = res else { break };
9509                    val
9510                }),
9511                2u16 => ActPeditAttrs::Parms({
9512                    let res = Some(TcPeditSel::new_from_zeroed(next));
9513                    let Some(val) = res else { break };
9514                    val
9515                }),
9516                3u16 => ActPeditAttrs::Pad({
9517                    let res = Some(next);
9518                    let Some(val) = res else { break };
9519                    val
9520                }),
9521                4u16 => ActPeditAttrs::ParmsEx({
9522                    let res = Some(next);
9523                    let Some(val) = res else { break };
9524                    val
9525                }),
9526                5u16 => ActPeditAttrs::KeysEx({
9527                    let res = Some(next);
9528                    let Some(val) = res else { break };
9529                    val
9530                }),
9531                6u16 => ActPeditAttrs::KeyEx({
9532                    let res = Some(next);
9533                    let Some(val) = res else { break };
9534                    val
9535                }),
9536                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9537                n => continue,
9538            };
9539            return Some(Ok(res));
9540        }
9541        Some(Err(ErrorContext::new(
9542            "ActPeditAttrs",
9543            r#type.and_then(|t| ActPeditAttrs::attr_from_type(t)),
9544            self.orig_loc,
9545            self.buf.as_ptr().wrapping_add(pos) as usize,
9546        )))
9547    }
9548}
9549impl<'a> std::fmt::Debug for IterableActPeditAttrs<'_> {
9550    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9551        let mut fmt = f.debug_struct("ActPeditAttrs");
9552        for attr in self.clone() {
9553            let attr = match attr {
9554                Ok(a) => a,
9555                Err(err) => {
9556                    fmt.finish()?;
9557                    f.write_str("Err(")?;
9558                    err.fmt(f)?;
9559                    return f.write_str(")");
9560                }
9561            };
9562            match attr {
9563                ActPeditAttrs::Tm(val) => fmt.field("Tm", &val),
9564                ActPeditAttrs::Parms(val) => fmt.field("Parms", &val),
9565                ActPeditAttrs::Pad(val) => fmt.field("Pad", &val),
9566                ActPeditAttrs::ParmsEx(val) => fmt.field("ParmsEx", &val),
9567                ActPeditAttrs::KeysEx(val) => fmt.field("KeysEx", &val),
9568                ActPeditAttrs::KeyEx(val) => fmt.field("KeyEx", &val),
9569            };
9570        }
9571        fmt.finish()
9572    }
9573}
9574impl IterableActPeditAttrs<'_> {
9575    pub fn lookup_attr(
9576        &self,
9577        offset: usize,
9578        missing_type: Option<u16>,
9579    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9580        let mut stack = Vec::new();
9581        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9582        if missing_type.is_some() && cur == offset {
9583            stack.push(("ActPeditAttrs", offset));
9584            return (
9585                stack,
9586                missing_type.and_then(|t| ActPeditAttrs::attr_from_type(t)),
9587            );
9588        }
9589        if cur > offset || cur + self.buf.len() < offset {
9590            return (stack, None);
9591        }
9592        let mut attrs = self.clone();
9593        let mut last_off = cur + attrs.pos;
9594        while let Some(attr) = attrs.next() {
9595            let Ok(attr) = attr else { break };
9596            match attr {
9597                ActPeditAttrs::Tm(val) => {
9598                    if last_off == offset {
9599                        stack.push(("Tm", last_off));
9600                        break;
9601                    }
9602                }
9603                ActPeditAttrs::Parms(val) => {
9604                    if last_off == offset {
9605                        stack.push(("Parms", last_off));
9606                        break;
9607                    }
9608                }
9609                ActPeditAttrs::Pad(val) => {
9610                    if last_off == offset {
9611                        stack.push(("Pad", last_off));
9612                        break;
9613                    }
9614                }
9615                ActPeditAttrs::ParmsEx(val) => {
9616                    if last_off == offset {
9617                        stack.push(("ParmsEx", last_off));
9618                        break;
9619                    }
9620                }
9621                ActPeditAttrs::KeysEx(val) => {
9622                    if last_off == offset {
9623                        stack.push(("KeysEx", last_off));
9624                        break;
9625                    }
9626                }
9627                ActPeditAttrs::KeyEx(val) => {
9628                    if last_off == offset {
9629                        stack.push(("KeyEx", last_off));
9630                        break;
9631                    }
9632                }
9633                _ => {}
9634            };
9635            last_off = cur + attrs.pos;
9636        }
9637        if !stack.is_empty() {
9638            stack.push(("ActPeditAttrs", cur));
9639        }
9640        (stack, None)
9641    }
9642}
9643#[derive(Clone)]
9644pub enum ActSimpleAttrs<'a> {
9645    Tm(TcfT),
9646    Parms(&'a [u8]),
9647    Data(&'a [u8]),
9648    Pad(&'a [u8]),
9649}
9650impl<'a> IterableActSimpleAttrs<'a> {
9651    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
9652        let mut iter = self.clone();
9653        iter.pos = 0;
9654        for attr in iter {
9655            if let ActSimpleAttrs::Tm(val) = attr? {
9656                return Ok(val);
9657            }
9658        }
9659        Err(ErrorContext::new_missing(
9660            "ActSimpleAttrs",
9661            "Tm",
9662            self.orig_loc,
9663            self.buf.as_ptr() as usize,
9664        ))
9665    }
9666    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
9667        let mut iter = self.clone();
9668        iter.pos = 0;
9669        for attr in iter {
9670            if let ActSimpleAttrs::Parms(val) = attr? {
9671                return Ok(val);
9672            }
9673        }
9674        Err(ErrorContext::new_missing(
9675            "ActSimpleAttrs",
9676            "Parms",
9677            self.orig_loc,
9678            self.buf.as_ptr() as usize,
9679        ))
9680    }
9681    pub fn get_data(&self) -> Result<&'a [u8], ErrorContext> {
9682        let mut iter = self.clone();
9683        iter.pos = 0;
9684        for attr in iter {
9685            if let ActSimpleAttrs::Data(val) = attr? {
9686                return Ok(val);
9687            }
9688        }
9689        Err(ErrorContext::new_missing(
9690            "ActSimpleAttrs",
9691            "Data",
9692            self.orig_loc,
9693            self.buf.as_ptr() as usize,
9694        ))
9695    }
9696    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
9697        let mut iter = self.clone();
9698        iter.pos = 0;
9699        for attr in iter {
9700            if let ActSimpleAttrs::Pad(val) = attr? {
9701                return Ok(val);
9702            }
9703        }
9704        Err(ErrorContext::new_missing(
9705            "ActSimpleAttrs",
9706            "Pad",
9707            self.orig_loc,
9708            self.buf.as_ptr() as usize,
9709        ))
9710    }
9711}
9712impl ActSimpleAttrs<'_> {
9713    pub fn new<'a>(buf: &'a [u8]) -> IterableActSimpleAttrs<'a> {
9714        IterableActSimpleAttrs::with_loc(buf, buf.as_ptr() as usize)
9715    }
9716    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9717        let res = match r#type {
9718            1u16 => "Tm",
9719            2u16 => "Parms",
9720            3u16 => "Data",
9721            4u16 => "Pad",
9722            _ => return None,
9723        };
9724        Some(res)
9725    }
9726}
9727#[derive(Clone, Copy, Default)]
9728pub struct IterableActSimpleAttrs<'a> {
9729    buf: &'a [u8],
9730    pos: usize,
9731    orig_loc: usize,
9732}
9733impl<'a> IterableActSimpleAttrs<'a> {
9734    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9735        Self {
9736            buf,
9737            pos: 0,
9738            orig_loc,
9739        }
9740    }
9741    pub fn get_buf(&self) -> &'a [u8] {
9742        self.buf
9743    }
9744}
9745impl<'a> Iterator for IterableActSimpleAttrs<'a> {
9746    type Item = Result<ActSimpleAttrs<'a>, ErrorContext>;
9747    fn next(&mut self) -> Option<Self::Item> {
9748        let pos = self.pos;
9749        let mut r#type;
9750        loop {
9751            r#type = None;
9752            if self.buf.len() == self.pos {
9753                return None;
9754            }
9755            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9756                break;
9757            };
9758            r#type = Some(header.r#type);
9759            let res = match header.r#type {
9760                1u16 => ActSimpleAttrs::Tm({
9761                    let res = Some(TcfT::new_from_zeroed(next));
9762                    let Some(val) = res else { break };
9763                    val
9764                }),
9765                2u16 => ActSimpleAttrs::Parms({
9766                    let res = Some(next);
9767                    let Some(val) = res else { break };
9768                    val
9769                }),
9770                3u16 => ActSimpleAttrs::Data({
9771                    let res = Some(next);
9772                    let Some(val) = res else { break };
9773                    val
9774                }),
9775                4u16 => ActSimpleAttrs::Pad({
9776                    let res = Some(next);
9777                    let Some(val) = res else { break };
9778                    val
9779                }),
9780                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9781                n => continue,
9782            };
9783            return Some(Ok(res));
9784        }
9785        Some(Err(ErrorContext::new(
9786            "ActSimpleAttrs",
9787            r#type.and_then(|t| ActSimpleAttrs::attr_from_type(t)),
9788            self.orig_loc,
9789            self.buf.as_ptr().wrapping_add(pos) as usize,
9790        )))
9791    }
9792}
9793impl<'a> std::fmt::Debug for IterableActSimpleAttrs<'_> {
9794    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9795        let mut fmt = f.debug_struct("ActSimpleAttrs");
9796        for attr in self.clone() {
9797            let attr = match attr {
9798                Ok(a) => a,
9799                Err(err) => {
9800                    fmt.finish()?;
9801                    f.write_str("Err(")?;
9802                    err.fmt(f)?;
9803                    return f.write_str(")");
9804                }
9805            };
9806            match attr {
9807                ActSimpleAttrs::Tm(val) => fmt.field("Tm", &val),
9808                ActSimpleAttrs::Parms(val) => fmt.field("Parms", &val),
9809                ActSimpleAttrs::Data(val) => fmt.field("Data", &val),
9810                ActSimpleAttrs::Pad(val) => fmt.field("Pad", &val),
9811            };
9812        }
9813        fmt.finish()
9814    }
9815}
9816impl IterableActSimpleAttrs<'_> {
9817    pub fn lookup_attr(
9818        &self,
9819        offset: usize,
9820        missing_type: Option<u16>,
9821    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9822        let mut stack = Vec::new();
9823        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9824        if missing_type.is_some() && cur == offset {
9825            stack.push(("ActSimpleAttrs", offset));
9826            return (
9827                stack,
9828                missing_type.and_then(|t| ActSimpleAttrs::attr_from_type(t)),
9829            );
9830        }
9831        if cur > offset || cur + self.buf.len() < offset {
9832            return (stack, None);
9833        }
9834        let mut attrs = self.clone();
9835        let mut last_off = cur + attrs.pos;
9836        while let Some(attr) = attrs.next() {
9837            let Ok(attr) = attr else { break };
9838            match attr {
9839                ActSimpleAttrs::Tm(val) => {
9840                    if last_off == offset {
9841                        stack.push(("Tm", last_off));
9842                        break;
9843                    }
9844                }
9845                ActSimpleAttrs::Parms(val) => {
9846                    if last_off == offset {
9847                        stack.push(("Parms", last_off));
9848                        break;
9849                    }
9850                }
9851                ActSimpleAttrs::Data(val) => {
9852                    if last_off == offset {
9853                        stack.push(("Data", last_off));
9854                        break;
9855                    }
9856                }
9857                ActSimpleAttrs::Pad(val) => {
9858                    if last_off == offset {
9859                        stack.push(("Pad", last_off));
9860                        break;
9861                    }
9862                }
9863                _ => {}
9864            };
9865            last_off = cur + attrs.pos;
9866        }
9867        if !stack.is_empty() {
9868            stack.push(("ActSimpleAttrs", cur));
9869        }
9870        (stack, None)
9871    }
9872}
9873#[derive(Clone)]
9874pub enum ActSkbeditAttrs<'a> {
9875    Tm(TcfT),
9876    Parms(&'a [u8]),
9877    Priority(u32),
9878    QueueMapping(u16),
9879    Mark(u32),
9880    Pad(&'a [u8]),
9881    Ptype(u16),
9882    Mask(u32),
9883    Flags(u64),
9884    QueueMappingMax(u16),
9885}
9886impl<'a> IterableActSkbeditAttrs<'a> {
9887    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
9888        let mut iter = self.clone();
9889        iter.pos = 0;
9890        for attr in iter {
9891            if let ActSkbeditAttrs::Tm(val) = attr? {
9892                return Ok(val);
9893            }
9894        }
9895        Err(ErrorContext::new_missing(
9896            "ActSkbeditAttrs",
9897            "Tm",
9898            self.orig_loc,
9899            self.buf.as_ptr() as usize,
9900        ))
9901    }
9902    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
9903        let mut iter = self.clone();
9904        iter.pos = 0;
9905        for attr in iter {
9906            if let ActSkbeditAttrs::Parms(val) = attr? {
9907                return Ok(val);
9908            }
9909        }
9910        Err(ErrorContext::new_missing(
9911            "ActSkbeditAttrs",
9912            "Parms",
9913            self.orig_loc,
9914            self.buf.as_ptr() as usize,
9915        ))
9916    }
9917    pub fn get_priority(&self) -> Result<u32, ErrorContext> {
9918        let mut iter = self.clone();
9919        iter.pos = 0;
9920        for attr in iter {
9921            if let ActSkbeditAttrs::Priority(val) = attr? {
9922                return Ok(val);
9923            }
9924        }
9925        Err(ErrorContext::new_missing(
9926            "ActSkbeditAttrs",
9927            "Priority",
9928            self.orig_loc,
9929            self.buf.as_ptr() as usize,
9930        ))
9931    }
9932    pub fn get_queue_mapping(&self) -> Result<u16, ErrorContext> {
9933        let mut iter = self.clone();
9934        iter.pos = 0;
9935        for attr in iter {
9936            if let ActSkbeditAttrs::QueueMapping(val) = attr? {
9937                return Ok(val);
9938            }
9939        }
9940        Err(ErrorContext::new_missing(
9941            "ActSkbeditAttrs",
9942            "QueueMapping",
9943            self.orig_loc,
9944            self.buf.as_ptr() as usize,
9945        ))
9946    }
9947    pub fn get_mark(&self) -> Result<u32, ErrorContext> {
9948        let mut iter = self.clone();
9949        iter.pos = 0;
9950        for attr in iter {
9951            if let ActSkbeditAttrs::Mark(val) = attr? {
9952                return Ok(val);
9953            }
9954        }
9955        Err(ErrorContext::new_missing(
9956            "ActSkbeditAttrs",
9957            "Mark",
9958            self.orig_loc,
9959            self.buf.as_ptr() as usize,
9960        ))
9961    }
9962    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
9963        let mut iter = self.clone();
9964        iter.pos = 0;
9965        for attr in iter {
9966            if let ActSkbeditAttrs::Pad(val) = attr? {
9967                return Ok(val);
9968            }
9969        }
9970        Err(ErrorContext::new_missing(
9971            "ActSkbeditAttrs",
9972            "Pad",
9973            self.orig_loc,
9974            self.buf.as_ptr() as usize,
9975        ))
9976    }
9977    pub fn get_ptype(&self) -> Result<u16, ErrorContext> {
9978        let mut iter = self.clone();
9979        iter.pos = 0;
9980        for attr in iter {
9981            if let ActSkbeditAttrs::Ptype(val) = attr? {
9982                return Ok(val);
9983            }
9984        }
9985        Err(ErrorContext::new_missing(
9986            "ActSkbeditAttrs",
9987            "Ptype",
9988            self.orig_loc,
9989            self.buf.as_ptr() as usize,
9990        ))
9991    }
9992    pub fn get_mask(&self) -> Result<u32, ErrorContext> {
9993        let mut iter = self.clone();
9994        iter.pos = 0;
9995        for attr in iter {
9996            if let ActSkbeditAttrs::Mask(val) = attr? {
9997                return Ok(val);
9998            }
9999        }
10000        Err(ErrorContext::new_missing(
10001            "ActSkbeditAttrs",
10002            "Mask",
10003            self.orig_loc,
10004            self.buf.as_ptr() as usize,
10005        ))
10006    }
10007    pub fn get_flags(&self) -> Result<u64, ErrorContext> {
10008        let mut iter = self.clone();
10009        iter.pos = 0;
10010        for attr in iter {
10011            if let ActSkbeditAttrs::Flags(val) = attr? {
10012                return Ok(val);
10013            }
10014        }
10015        Err(ErrorContext::new_missing(
10016            "ActSkbeditAttrs",
10017            "Flags",
10018            self.orig_loc,
10019            self.buf.as_ptr() as usize,
10020        ))
10021    }
10022    pub fn get_queue_mapping_max(&self) -> Result<u16, ErrorContext> {
10023        let mut iter = self.clone();
10024        iter.pos = 0;
10025        for attr in iter {
10026            if let ActSkbeditAttrs::QueueMappingMax(val) = attr? {
10027                return Ok(val);
10028            }
10029        }
10030        Err(ErrorContext::new_missing(
10031            "ActSkbeditAttrs",
10032            "QueueMappingMax",
10033            self.orig_loc,
10034            self.buf.as_ptr() as usize,
10035        ))
10036    }
10037}
10038impl ActSkbeditAttrs<'_> {
10039    pub fn new<'a>(buf: &'a [u8]) -> IterableActSkbeditAttrs<'a> {
10040        IterableActSkbeditAttrs::with_loc(buf, buf.as_ptr() as usize)
10041    }
10042    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10043        let res = match r#type {
10044            1u16 => "Tm",
10045            2u16 => "Parms",
10046            3u16 => "Priority",
10047            4u16 => "QueueMapping",
10048            5u16 => "Mark",
10049            6u16 => "Pad",
10050            7u16 => "Ptype",
10051            8u16 => "Mask",
10052            9u16 => "Flags",
10053            10u16 => "QueueMappingMax",
10054            _ => return None,
10055        };
10056        Some(res)
10057    }
10058}
10059#[derive(Clone, Copy, Default)]
10060pub struct IterableActSkbeditAttrs<'a> {
10061    buf: &'a [u8],
10062    pos: usize,
10063    orig_loc: usize,
10064}
10065impl<'a> IterableActSkbeditAttrs<'a> {
10066    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10067        Self {
10068            buf,
10069            pos: 0,
10070            orig_loc,
10071        }
10072    }
10073    pub fn get_buf(&self) -> &'a [u8] {
10074        self.buf
10075    }
10076}
10077impl<'a> Iterator for IterableActSkbeditAttrs<'a> {
10078    type Item = Result<ActSkbeditAttrs<'a>, ErrorContext>;
10079    fn next(&mut self) -> Option<Self::Item> {
10080        let pos = self.pos;
10081        let mut r#type;
10082        loop {
10083            r#type = None;
10084            if self.buf.len() == self.pos {
10085                return None;
10086            }
10087            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
10088                break;
10089            };
10090            r#type = Some(header.r#type);
10091            let res = match header.r#type {
10092                1u16 => ActSkbeditAttrs::Tm({
10093                    let res = Some(TcfT::new_from_zeroed(next));
10094                    let Some(val) = res else { break };
10095                    val
10096                }),
10097                2u16 => ActSkbeditAttrs::Parms({
10098                    let res = Some(next);
10099                    let Some(val) = res else { break };
10100                    val
10101                }),
10102                3u16 => ActSkbeditAttrs::Priority({
10103                    let res = parse_u32(next);
10104                    let Some(val) = res else { break };
10105                    val
10106                }),
10107                4u16 => ActSkbeditAttrs::QueueMapping({
10108                    let res = parse_u16(next);
10109                    let Some(val) = res else { break };
10110                    val
10111                }),
10112                5u16 => ActSkbeditAttrs::Mark({
10113                    let res = parse_u32(next);
10114                    let Some(val) = res else { break };
10115                    val
10116                }),
10117                6u16 => ActSkbeditAttrs::Pad({
10118                    let res = Some(next);
10119                    let Some(val) = res else { break };
10120                    val
10121                }),
10122                7u16 => ActSkbeditAttrs::Ptype({
10123                    let res = parse_u16(next);
10124                    let Some(val) = res else { break };
10125                    val
10126                }),
10127                8u16 => ActSkbeditAttrs::Mask({
10128                    let res = parse_u32(next);
10129                    let Some(val) = res else { break };
10130                    val
10131                }),
10132                9u16 => ActSkbeditAttrs::Flags({
10133                    let res = parse_u64(next);
10134                    let Some(val) = res else { break };
10135                    val
10136                }),
10137                10u16 => ActSkbeditAttrs::QueueMappingMax({
10138                    let res = parse_u16(next);
10139                    let Some(val) = res else { break };
10140                    val
10141                }),
10142                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
10143                n => continue,
10144            };
10145            return Some(Ok(res));
10146        }
10147        Some(Err(ErrorContext::new(
10148            "ActSkbeditAttrs",
10149            r#type.and_then(|t| ActSkbeditAttrs::attr_from_type(t)),
10150            self.orig_loc,
10151            self.buf.as_ptr().wrapping_add(pos) as usize,
10152        )))
10153    }
10154}
10155impl<'a> std::fmt::Debug for IterableActSkbeditAttrs<'_> {
10156    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10157        let mut fmt = f.debug_struct("ActSkbeditAttrs");
10158        for attr in self.clone() {
10159            let attr = match attr {
10160                Ok(a) => a,
10161                Err(err) => {
10162                    fmt.finish()?;
10163                    f.write_str("Err(")?;
10164                    err.fmt(f)?;
10165                    return f.write_str(")");
10166                }
10167            };
10168            match attr {
10169                ActSkbeditAttrs::Tm(val) => fmt.field("Tm", &val),
10170                ActSkbeditAttrs::Parms(val) => fmt.field("Parms", &val),
10171                ActSkbeditAttrs::Priority(val) => fmt.field("Priority", &val),
10172                ActSkbeditAttrs::QueueMapping(val) => fmt.field("QueueMapping", &val),
10173                ActSkbeditAttrs::Mark(val) => fmt.field("Mark", &val),
10174                ActSkbeditAttrs::Pad(val) => fmt.field("Pad", &val),
10175                ActSkbeditAttrs::Ptype(val) => fmt.field("Ptype", &val),
10176                ActSkbeditAttrs::Mask(val) => fmt.field("Mask", &val),
10177                ActSkbeditAttrs::Flags(val) => fmt.field("Flags", &val),
10178                ActSkbeditAttrs::QueueMappingMax(val) => fmt.field("QueueMappingMax", &val),
10179            };
10180        }
10181        fmt.finish()
10182    }
10183}
10184impl IterableActSkbeditAttrs<'_> {
10185    pub fn lookup_attr(
10186        &self,
10187        offset: usize,
10188        missing_type: Option<u16>,
10189    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10190        let mut stack = Vec::new();
10191        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10192        if missing_type.is_some() && cur == offset {
10193            stack.push(("ActSkbeditAttrs", offset));
10194            return (
10195                stack,
10196                missing_type.and_then(|t| ActSkbeditAttrs::attr_from_type(t)),
10197            );
10198        }
10199        if cur > offset || cur + self.buf.len() < offset {
10200            return (stack, None);
10201        }
10202        let mut attrs = self.clone();
10203        let mut last_off = cur + attrs.pos;
10204        while let Some(attr) = attrs.next() {
10205            let Ok(attr) = attr else { break };
10206            match attr {
10207                ActSkbeditAttrs::Tm(val) => {
10208                    if last_off == offset {
10209                        stack.push(("Tm", last_off));
10210                        break;
10211                    }
10212                }
10213                ActSkbeditAttrs::Parms(val) => {
10214                    if last_off == offset {
10215                        stack.push(("Parms", last_off));
10216                        break;
10217                    }
10218                }
10219                ActSkbeditAttrs::Priority(val) => {
10220                    if last_off == offset {
10221                        stack.push(("Priority", last_off));
10222                        break;
10223                    }
10224                }
10225                ActSkbeditAttrs::QueueMapping(val) => {
10226                    if last_off == offset {
10227                        stack.push(("QueueMapping", last_off));
10228                        break;
10229                    }
10230                }
10231                ActSkbeditAttrs::Mark(val) => {
10232                    if last_off == offset {
10233                        stack.push(("Mark", last_off));
10234                        break;
10235                    }
10236                }
10237                ActSkbeditAttrs::Pad(val) => {
10238                    if last_off == offset {
10239                        stack.push(("Pad", last_off));
10240                        break;
10241                    }
10242                }
10243                ActSkbeditAttrs::Ptype(val) => {
10244                    if last_off == offset {
10245                        stack.push(("Ptype", last_off));
10246                        break;
10247                    }
10248                }
10249                ActSkbeditAttrs::Mask(val) => {
10250                    if last_off == offset {
10251                        stack.push(("Mask", last_off));
10252                        break;
10253                    }
10254                }
10255                ActSkbeditAttrs::Flags(val) => {
10256                    if last_off == offset {
10257                        stack.push(("Flags", last_off));
10258                        break;
10259                    }
10260                }
10261                ActSkbeditAttrs::QueueMappingMax(val) => {
10262                    if last_off == offset {
10263                        stack.push(("QueueMappingMax", last_off));
10264                        break;
10265                    }
10266                }
10267                _ => {}
10268            };
10269            last_off = cur + attrs.pos;
10270        }
10271        if !stack.is_empty() {
10272            stack.push(("ActSkbeditAttrs", cur));
10273        }
10274        (stack, None)
10275    }
10276}
10277#[derive(Clone)]
10278pub enum ActSkbmodAttrs<'a> {
10279    Tm(TcfT),
10280    Parms(&'a [u8]),
10281    Dmac(&'a [u8]),
10282    Smac(&'a [u8]),
10283    Etype(&'a [u8]),
10284    Pad(&'a [u8]),
10285}
10286impl<'a> IterableActSkbmodAttrs<'a> {
10287    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
10288        let mut iter = self.clone();
10289        iter.pos = 0;
10290        for attr in iter {
10291            if let ActSkbmodAttrs::Tm(val) = attr? {
10292                return Ok(val);
10293            }
10294        }
10295        Err(ErrorContext::new_missing(
10296            "ActSkbmodAttrs",
10297            "Tm",
10298            self.orig_loc,
10299            self.buf.as_ptr() as usize,
10300        ))
10301    }
10302    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
10303        let mut iter = self.clone();
10304        iter.pos = 0;
10305        for attr in iter {
10306            if let ActSkbmodAttrs::Parms(val) = attr? {
10307                return Ok(val);
10308            }
10309        }
10310        Err(ErrorContext::new_missing(
10311            "ActSkbmodAttrs",
10312            "Parms",
10313            self.orig_loc,
10314            self.buf.as_ptr() as usize,
10315        ))
10316    }
10317    pub fn get_dmac(&self) -> Result<&'a [u8], ErrorContext> {
10318        let mut iter = self.clone();
10319        iter.pos = 0;
10320        for attr in iter {
10321            if let ActSkbmodAttrs::Dmac(val) = attr? {
10322                return Ok(val);
10323            }
10324        }
10325        Err(ErrorContext::new_missing(
10326            "ActSkbmodAttrs",
10327            "Dmac",
10328            self.orig_loc,
10329            self.buf.as_ptr() as usize,
10330        ))
10331    }
10332    pub fn get_smac(&self) -> Result<&'a [u8], ErrorContext> {
10333        let mut iter = self.clone();
10334        iter.pos = 0;
10335        for attr in iter {
10336            if let ActSkbmodAttrs::Smac(val) = attr? {
10337                return Ok(val);
10338            }
10339        }
10340        Err(ErrorContext::new_missing(
10341            "ActSkbmodAttrs",
10342            "Smac",
10343            self.orig_loc,
10344            self.buf.as_ptr() as usize,
10345        ))
10346    }
10347    pub fn get_etype(&self) -> Result<&'a [u8], ErrorContext> {
10348        let mut iter = self.clone();
10349        iter.pos = 0;
10350        for attr in iter {
10351            if let ActSkbmodAttrs::Etype(val) = attr? {
10352                return Ok(val);
10353            }
10354        }
10355        Err(ErrorContext::new_missing(
10356            "ActSkbmodAttrs",
10357            "Etype",
10358            self.orig_loc,
10359            self.buf.as_ptr() as usize,
10360        ))
10361    }
10362    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
10363        let mut iter = self.clone();
10364        iter.pos = 0;
10365        for attr in iter {
10366            if let ActSkbmodAttrs::Pad(val) = attr? {
10367                return Ok(val);
10368            }
10369        }
10370        Err(ErrorContext::new_missing(
10371            "ActSkbmodAttrs",
10372            "Pad",
10373            self.orig_loc,
10374            self.buf.as_ptr() as usize,
10375        ))
10376    }
10377}
10378impl ActSkbmodAttrs<'_> {
10379    pub fn new<'a>(buf: &'a [u8]) -> IterableActSkbmodAttrs<'a> {
10380        IterableActSkbmodAttrs::with_loc(buf, buf.as_ptr() as usize)
10381    }
10382    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10383        let res = match r#type {
10384            1u16 => "Tm",
10385            2u16 => "Parms",
10386            3u16 => "Dmac",
10387            4u16 => "Smac",
10388            5u16 => "Etype",
10389            6u16 => "Pad",
10390            _ => return None,
10391        };
10392        Some(res)
10393    }
10394}
10395#[derive(Clone, Copy, Default)]
10396pub struct IterableActSkbmodAttrs<'a> {
10397    buf: &'a [u8],
10398    pos: usize,
10399    orig_loc: usize,
10400}
10401impl<'a> IterableActSkbmodAttrs<'a> {
10402    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10403        Self {
10404            buf,
10405            pos: 0,
10406            orig_loc,
10407        }
10408    }
10409    pub fn get_buf(&self) -> &'a [u8] {
10410        self.buf
10411    }
10412}
10413impl<'a> Iterator for IterableActSkbmodAttrs<'a> {
10414    type Item = Result<ActSkbmodAttrs<'a>, ErrorContext>;
10415    fn next(&mut self) -> Option<Self::Item> {
10416        let pos = self.pos;
10417        let mut r#type;
10418        loop {
10419            r#type = None;
10420            if self.buf.len() == self.pos {
10421                return None;
10422            }
10423            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
10424                break;
10425            };
10426            r#type = Some(header.r#type);
10427            let res = match header.r#type {
10428                1u16 => ActSkbmodAttrs::Tm({
10429                    let res = Some(TcfT::new_from_zeroed(next));
10430                    let Some(val) = res else { break };
10431                    val
10432                }),
10433                2u16 => ActSkbmodAttrs::Parms({
10434                    let res = Some(next);
10435                    let Some(val) = res else { break };
10436                    val
10437                }),
10438                3u16 => ActSkbmodAttrs::Dmac({
10439                    let res = Some(next);
10440                    let Some(val) = res else { break };
10441                    val
10442                }),
10443                4u16 => ActSkbmodAttrs::Smac({
10444                    let res = Some(next);
10445                    let Some(val) = res else { break };
10446                    val
10447                }),
10448                5u16 => ActSkbmodAttrs::Etype({
10449                    let res = Some(next);
10450                    let Some(val) = res else { break };
10451                    val
10452                }),
10453                6u16 => ActSkbmodAttrs::Pad({
10454                    let res = Some(next);
10455                    let Some(val) = res else { break };
10456                    val
10457                }),
10458                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
10459                n => continue,
10460            };
10461            return Some(Ok(res));
10462        }
10463        Some(Err(ErrorContext::new(
10464            "ActSkbmodAttrs",
10465            r#type.and_then(|t| ActSkbmodAttrs::attr_from_type(t)),
10466            self.orig_loc,
10467            self.buf.as_ptr().wrapping_add(pos) as usize,
10468        )))
10469    }
10470}
10471impl<'a> std::fmt::Debug for IterableActSkbmodAttrs<'_> {
10472    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10473        let mut fmt = f.debug_struct("ActSkbmodAttrs");
10474        for attr in self.clone() {
10475            let attr = match attr {
10476                Ok(a) => a,
10477                Err(err) => {
10478                    fmt.finish()?;
10479                    f.write_str("Err(")?;
10480                    err.fmt(f)?;
10481                    return f.write_str(")");
10482                }
10483            };
10484            match attr {
10485                ActSkbmodAttrs::Tm(val) => fmt.field("Tm", &val),
10486                ActSkbmodAttrs::Parms(val) => fmt.field("Parms", &val),
10487                ActSkbmodAttrs::Dmac(val) => fmt.field("Dmac", &val),
10488                ActSkbmodAttrs::Smac(val) => fmt.field("Smac", &val),
10489                ActSkbmodAttrs::Etype(val) => fmt.field("Etype", &val),
10490                ActSkbmodAttrs::Pad(val) => fmt.field("Pad", &val),
10491            };
10492        }
10493        fmt.finish()
10494    }
10495}
10496impl IterableActSkbmodAttrs<'_> {
10497    pub fn lookup_attr(
10498        &self,
10499        offset: usize,
10500        missing_type: Option<u16>,
10501    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10502        let mut stack = Vec::new();
10503        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10504        if missing_type.is_some() && cur == offset {
10505            stack.push(("ActSkbmodAttrs", offset));
10506            return (
10507                stack,
10508                missing_type.and_then(|t| ActSkbmodAttrs::attr_from_type(t)),
10509            );
10510        }
10511        if cur > offset || cur + self.buf.len() < offset {
10512            return (stack, None);
10513        }
10514        let mut attrs = self.clone();
10515        let mut last_off = cur + attrs.pos;
10516        while let Some(attr) = attrs.next() {
10517            let Ok(attr) = attr else { break };
10518            match attr {
10519                ActSkbmodAttrs::Tm(val) => {
10520                    if last_off == offset {
10521                        stack.push(("Tm", last_off));
10522                        break;
10523                    }
10524                }
10525                ActSkbmodAttrs::Parms(val) => {
10526                    if last_off == offset {
10527                        stack.push(("Parms", last_off));
10528                        break;
10529                    }
10530                }
10531                ActSkbmodAttrs::Dmac(val) => {
10532                    if last_off == offset {
10533                        stack.push(("Dmac", last_off));
10534                        break;
10535                    }
10536                }
10537                ActSkbmodAttrs::Smac(val) => {
10538                    if last_off == offset {
10539                        stack.push(("Smac", last_off));
10540                        break;
10541                    }
10542                }
10543                ActSkbmodAttrs::Etype(val) => {
10544                    if last_off == offset {
10545                        stack.push(("Etype", last_off));
10546                        break;
10547                    }
10548                }
10549                ActSkbmodAttrs::Pad(val) => {
10550                    if last_off == offset {
10551                        stack.push(("Pad", last_off));
10552                        break;
10553                    }
10554                }
10555                _ => {}
10556            };
10557            last_off = cur + attrs.pos;
10558        }
10559        if !stack.is_empty() {
10560            stack.push(("ActSkbmodAttrs", cur));
10561        }
10562        (stack, None)
10563    }
10564}
10565#[derive(Clone)]
10566pub enum ActTunnelKeyAttrs<'a> {
10567    Tm(TcfT),
10568    Parms(&'a [u8]),
10569    EncIpv4Src(u32),
10570    EncIpv4Dst(u32),
10571    EncIpv6Src(&'a [u8]),
10572    EncIpv6Dst(&'a [u8]),
10573    EncKeyId(u64),
10574    Pad(&'a [u8]),
10575    EncDstPort(u16),
10576    NoCsum(u8),
10577    EncOpts(&'a [u8]),
10578    EncTos(u8),
10579    EncTtl(u8),
10580    NoFrag(()),
10581}
10582impl<'a> IterableActTunnelKeyAttrs<'a> {
10583    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
10584        let mut iter = self.clone();
10585        iter.pos = 0;
10586        for attr in iter {
10587            if let ActTunnelKeyAttrs::Tm(val) = attr? {
10588                return Ok(val);
10589            }
10590        }
10591        Err(ErrorContext::new_missing(
10592            "ActTunnelKeyAttrs",
10593            "Tm",
10594            self.orig_loc,
10595            self.buf.as_ptr() as usize,
10596        ))
10597    }
10598    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
10599        let mut iter = self.clone();
10600        iter.pos = 0;
10601        for attr in iter {
10602            if let ActTunnelKeyAttrs::Parms(val) = attr? {
10603                return Ok(val);
10604            }
10605        }
10606        Err(ErrorContext::new_missing(
10607            "ActTunnelKeyAttrs",
10608            "Parms",
10609            self.orig_loc,
10610            self.buf.as_ptr() as usize,
10611        ))
10612    }
10613    pub fn get_enc_ipv4_src(&self) -> Result<u32, ErrorContext> {
10614        let mut iter = self.clone();
10615        iter.pos = 0;
10616        for attr in iter {
10617            if let ActTunnelKeyAttrs::EncIpv4Src(val) = attr? {
10618                return Ok(val);
10619            }
10620        }
10621        Err(ErrorContext::new_missing(
10622            "ActTunnelKeyAttrs",
10623            "EncIpv4Src",
10624            self.orig_loc,
10625            self.buf.as_ptr() as usize,
10626        ))
10627    }
10628    pub fn get_enc_ipv4_dst(&self) -> Result<u32, ErrorContext> {
10629        let mut iter = self.clone();
10630        iter.pos = 0;
10631        for attr in iter {
10632            if let ActTunnelKeyAttrs::EncIpv4Dst(val) = attr? {
10633                return Ok(val);
10634            }
10635        }
10636        Err(ErrorContext::new_missing(
10637            "ActTunnelKeyAttrs",
10638            "EncIpv4Dst",
10639            self.orig_loc,
10640            self.buf.as_ptr() as usize,
10641        ))
10642    }
10643    pub fn get_enc_ipv6_src(&self) -> Result<&'a [u8], ErrorContext> {
10644        let mut iter = self.clone();
10645        iter.pos = 0;
10646        for attr in iter {
10647            if let ActTunnelKeyAttrs::EncIpv6Src(val) = attr? {
10648                return Ok(val);
10649            }
10650        }
10651        Err(ErrorContext::new_missing(
10652            "ActTunnelKeyAttrs",
10653            "EncIpv6Src",
10654            self.orig_loc,
10655            self.buf.as_ptr() as usize,
10656        ))
10657    }
10658    pub fn get_enc_ipv6_dst(&self) -> Result<&'a [u8], ErrorContext> {
10659        let mut iter = self.clone();
10660        iter.pos = 0;
10661        for attr in iter {
10662            if let ActTunnelKeyAttrs::EncIpv6Dst(val) = attr? {
10663                return Ok(val);
10664            }
10665        }
10666        Err(ErrorContext::new_missing(
10667            "ActTunnelKeyAttrs",
10668            "EncIpv6Dst",
10669            self.orig_loc,
10670            self.buf.as_ptr() as usize,
10671        ))
10672    }
10673    pub fn get_enc_key_id(&self) -> Result<u64, ErrorContext> {
10674        let mut iter = self.clone();
10675        iter.pos = 0;
10676        for attr in iter {
10677            if let ActTunnelKeyAttrs::EncKeyId(val) = attr? {
10678                return Ok(val);
10679            }
10680        }
10681        Err(ErrorContext::new_missing(
10682            "ActTunnelKeyAttrs",
10683            "EncKeyId",
10684            self.orig_loc,
10685            self.buf.as_ptr() as usize,
10686        ))
10687    }
10688    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
10689        let mut iter = self.clone();
10690        iter.pos = 0;
10691        for attr in iter {
10692            if let ActTunnelKeyAttrs::Pad(val) = attr? {
10693                return Ok(val);
10694            }
10695        }
10696        Err(ErrorContext::new_missing(
10697            "ActTunnelKeyAttrs",
10698            "Pad",
10699            self.orig_loc,
10700            self.buf.as_ptr() as usize,
10701        ))
10702    }
10703    pub fn get_enc_dst_port(&self) -> Result<u16, ErrorContext> {
10704        let mut iter = self.clone();
10705        iter.pos = 0;
10706        for attr in iter {
10707            if let ActTunnelKeyAttrs::EncDstPort(val) = attr? {
10708                return Ok(val);
10709            }
10710        }
10711        Err(ErrorContext::new_missing(
10712            "ActTunnelKeyAttrs",
10713            "EncDstPort",
10714            self.orig_loc,
10715            self.buf.as_ptr() as usize,
10716        ))
10717    }
10718    pub fn get_no_csum(&self) -> Result<u8, ErrorContext> {
10719        let mut iter = self.clone();
10720        iter.pos = 0;
10721        for attr in iter {
10722            if let ActTunnelKeyAttrs::NoCsum(val) = attr? {
10723                return Ok(val);
10724            }
10725        }
10726        Err(ErrorContext::new_missing(
10727            "ActTunnelKeyAttrs",
10728            "NoCsum",
10729            self.orig_loc,
10730            self.buf.as_ptr() as usize,
10731        ))
10732    }
10733    pub fn get_enc_opts(&self) -> Result<&'a [u8], ErrorContext> {
10734        let mut iter = self.clone();
10735        iter.pos = 0;
10736        for attr in iter {
10737            if let ActTunnelKeyAttrs::EncOpts(val) = attr? {
10738                return Ok(val);
10739            }
10740        }
10741        Err(ErrorContext::new_missing(
10742            "ActTunnelKeyAttrs",
10743            "EncOpts",
10744            self.orig_loc,
10745            self.buf.as_ptr() as usize,
10746        ))
10747    }
10748    pub fn get_enc_tos(&self) -> Result<u8, ErrorContext> {
10749        let mut iter = self.clone();
10750        iter.pos = 0;
10751        for attr in iter {
10752            if let ActTunnelKeyAttrs::EncTos(val) = attr? {
10753                return Ok(val);
10754            }
10755        }
10756        Err(ErrorContext::new_missing(
10757            "ActTunnelKeyAttrs",
10758            "EncTos",
10759            self.orig_loc,
10760            self.buf.as_ptr() as usize,
10761        ))
10762    }
10763    pub fn get_enc_ttl(&self) -> Result<u8, ErrorContext> {
10764        let mut iter = self.clone();
10765        iter.pos = 0;
10766        for attr in iter {
10767            if let ActTunnelKeyAttrs::EncTtl(val) = attr? {
10768                return Ok(val);
10769            }
10770        }
10771        Err(ErrorContext::new_missing(
10772            "ActTunnelKeyAttrs",
10773            "EncTtl",
10774            self.orig_loc,
10775            self.buf.as_ptr() as usize,
10776        ))
10777    }
10778    pub fn get_no_frag(&self) -> Result<(), ErrorContext> {
10779        let mut iter = self.clone();
10780        iter.pos = 0;
10781        for attr in iter {
10782            if let ActTunnelKeyAttrs::NoFrag(val) = attr? {
10783                return Ok(val);
10784            }
10785        }
10786        Err(ErrorContext::new_missing(
10787            "ActTunnelKeyAttrs",
10788            "NoFrag",
10789            self.orig_loc,
10790            self.buf.as_ptr() as usize,
10791        ))
10792    }
10793}
10794impl ActTunnelKeyAttrs<'_> {
10795    pub fn new<'a>(buf: &'a [u8]) -> IterableActTunnelKeyAttrs<'a> {
10796        IterableActTunnelKeyAttrs::with_loc(buf, buf.as_ptr() as usize)
10797    }
10798    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10799        let res = match r#type {
10800            1u16 => "Tm",
10801            2u16 => "Parms",
10802            3u16 => "EncIpv4Src",
10803            4u16 => "EncIpv4Dst",
10804            5u16 => "EncIpv6Src",
10805            6u16 => "EncIpv6Dst",
10806            7u16 => "EncKeyId",
10807            8u16 => "Pad",
10808            9u16 => "EncDstPort",
10809            10u16 => "NoCsum",
10810            11u16 => "EncOpts",
10811            12u16 => "EncTos",
10812            13u16 => "EncTtl",
10813            14u16 => "NoFrag",
10814            _ => return None,
10815        };
10816        Some(res)
10817    }
10818}
10819#[derive(Clone, Copy, Default)]
10820pub struct IterableActTunnelKeyAttrs<'a> {
10821    buf: &'a [u8],
10822    pos: usize,
10823    orig_loc: usize,
10824}
10825impl<'a> IterableActTunnelKeyAttrs<'a> {
10826    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10827        Self {
10828            buf,
10829            pos: 0,
10830            orig_loc,
10831        }
10832    }
10833    pub fn get_buf(&self) -> &'a [u8] {
10834        self.buf
10835    }
10836}
10837impl<'a> Iterator for IterableActTunnelKeyAttrs<'a> {
10838    type Item = Result<ActTunnelKeyAttrs<'a>, ErrorContext>;
10839    fn next(&mut self) -> Option<Self::Item> {
10840        let pos = self.pos;
10841        let mut r#type;
10842        loop {
10843            r#type = None;
10844            if self.buf.len() == self.pos {
10845                return None;
10846            }
10847            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
10848                break;
10849            };
10850            r#type = Some(header.r#type);
10851            let res = match header.r#type {
10852                1u16 => ActTunnelKeyAttrs::Tm({
10853                    let res = Some(TcfT::new_from_zeroed(next));
10854                    let Some(val) = res else { break };
10855                    val
10856                }),
10857                2u16 => ActTunnelKeyAttrs::Parms({
10858                    let res = Some(next);
10859                    let Some(val) = res else { break };
10860                    val
10861                }),
10862                3u16 => ActTunnelKeyAttrs::EncIpv4Src({
10863                    let res = parse_be_u32(next);
10864                    let Some(val) = res else { break };
10865                    val
10866                }),
10867                4u16 => ActTunnelKeyAttrs::EncIpv4Dst({
10868                    let res = parse_be_u32(next);
10869                    let Some(val) = res else { break };
10870                    val
10871                }),
10872                5u16 => ActTunnelKeyAttrs::EncIpv6Src({
10873                    let res = Some(next);
10874                    let Some(val) = res else { break };
10875                    val
10876                }),
10877                6u16 => ActTunnelKeyAttrs::EncIpv6Dst({
10878                    let res = Some(next);
10879                    let Some(val) = res else { break };
10880                    val
10881                }),
10882                7u16 => ActTunnelKeyAttrs::EncKeyId({
10883                    let res = parse_be_u64(next);
10884                    let Some(val) = res else { break };
10885                    val
10886                }),
10887                8u16 => ActTunnelKeyAttrs::Pad({
10888                    let res = Some(next);
10889                    let Some(val) = res else { break };
10890                    val
10891                }),
10892                9u16 => ActTunnelKeyAttrs::EncDstPort({
10893                    let res = parse_be_u16(next);
10894                    let Some(val) = res else { break };
10895                    val
10896                }),
10897                10u16 => ActTunnelKeyAttrs::NoCsum({
10898                    let res = parse_u8(next);
10899                    let Some(val) = res else { break };
10900                    val
10901                }),
10902                11u16 => ActTunnelKeyAttrs::EncOpts({
10903                    let res = Some(next);
10904                    let Some(val) = res else { break };
10905                    val
10906                }),
10907                12u16 => ActTunnelKeyAttrs::EncTos({
10908                    let res = parse_u8(next);
10909                    let Some(val) = res else { break };
10910                    val
10911                }),
10912                13u16 => ActTunnelKeyAttrs::EncTtl({
10913                    let res = parse_u8(next);
10914                    let Some(val) = res else { break };
10915                    val
10916                }),
10917                14u16 => ActTunnelKeyAttrs::NoFrag(()),
10918                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
10919                n => continue,
10920            };
10921            return Some(Ok(res));
10922        }
10923        Some(Err(ErrorContext::new(
10924            "ActTunnelKeyAttrs",
10925            r#type.and_then(|t| ActTunnelKeyAttrs::attr_from_type(t)),
10926            self.orig_loc,
10927            self.buf.as_ptr().wrapping_add(pos) as usize,
10928        )))
10929    }
10930}
10931impl<'a> std::fmt::Debug for IterableActTunnelKeyAttrs<'_> {
10932    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10933        let mut fmt = f.debug_struct("ActTunnelKeyAttrs");
10934        for attr in self.clone() {
10935            let attr = match attr {
10936                Ok(a) => a,
10937                Err(err) => {
10938                    fmt.finish()?;
10939                    f.write_str("Err(")?;
10940                    err.fmt(f)?;
10941                    return f.write_str(")");
10942                }
10943            };
10944            match attr {
10945                ActTunnelKeyAttrs::Tm(val) => fmt.field("Tm", &val),
10946                ActTunnelKeyAttrs::Parms(val) => fmt.field("Parms", &val),
10947                ActTunnelKeyAttrs::EncIpv4Src(val) => fmt.field("EncIpv4Src", &val),
10948                ActTunnelKeyAttrs::EncIpv4Dst(val) => fmt.field("EncIpv4Dst", &val),
10949                ActTunnelKeyAttrs::EncIpv6Src(val) => fmt.field("EncIpv6Src", &val),
10950                ActTunnelKeyAttrs::EncIpv6Dst(val) => fmt.field("EncIpv6Dst", &val),
10951                ActTunnelKeyAttrs::EncKeyId(val) => fmt.field("EncKeyId", &val),
10952                ActTunnelKeyAttrs::Pad(val) => fmt.field("Pad", &val),
10953                ActTunnelKeyAttrs::EncDstPort(val) => fmt.field("EncDstPort", &val),
10954                ActTunnelKeyAttrs::NoCsum(val) => fmt.field("NoCsum", &val),
10955                ActTunnelKeyAttrs::EncOpts(val) => fmt.field("EncOpts", &val),
10956                ActTunnelKeyAttrs::EncTos(val) => fmt.field("EncTos", &val),
10957                ActTunnelKeyAttrs::EncTtl(val) => fmt.field("EncTtl", &val),
10958                ActTunnelKeyAttrs::NoFrag(val) => fmt.field("NoFrag", &val),
10959            };
10960        }
10961        fmt.finish()
10962    }
10963}
10964impl IterableActTunnelKeyAttrs<'_> {
10965    pub fn lookup_attr(
10966        &self,
10967        offset: usize,
10968        missing_type: Option<u16>,
10969    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10970        let mut stack = Vec::new();
10971        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10972        if missing_type.is_some() && cur == offset {
10973            stack.push(("ActTunnelKeyAttrs", offset));
10974            return (
10975                stack,
10976                missing_type.and_then(|t| ActTunnelKeyAttrs::attr_from_type(t)),
10977            );
10978        }
10979        if cur > offset || cur + self.buf.len() < offset {
10980            return (stack, None);
10981        }
10982        let mut attrs = self.clone();
10983        let mut last_off = cur + attrs.pos;
10984        while let Some(attr) = attrs.next() {
10985            let Ok(attr) = attr else { break };
10986            match attr {
10987                ActTunnelKeyAttrs::Tm(val) => {
10988                    if last_off == offset {
10989                        stack.push(("Tm", last_off));
10990                        break;
10991                    }
10992                }
10993                ActTunnelKeyAttrs::Parms(val) => {
10994                    if last_off == offset {
10995                        stack.push(("Parms", last_off));
10996                        break;
10997                    }
10998                }
10999                ActTunnelKeyAttrs::EncIpv4Src(val) => {
11000                    if last_off == offset {
11001                        stack.push(("EncIpv4Src", last_off));
11002                        break;
11003                    }
11004                }
11005                ActTunnelKeyAttrs::EncIpv4Dst(val) => {
11006                    if last_off == offset {
11007                        stack.push(("EncIpv4Dst", last_off));
11008                        break;
11009                    }
11010                }
11011                ActTunnelKeyAttrs::EncIpv6Src(val) => {
11012                    if last_off == offset {
11013                        stack.push(("EncIpv6Src", last_off));
11014                        break;
11015                    }
11016                }
11017                ActTunnelKeyAttrs::EncIpv6Dst(val) => {
11018                    if last_off == offset {
11019                        stack.push(("EncIpv6Dst", last_off));
11020                        break;
11021                    }
11022                }
11023                ActTunnelKeyAttrs::EncKeyId(val) => {
11024                    if last_off == offset {
11025                        stack.push(("EncKeyId", last_off));
11026                        break;
11027                    }
11028                }
11029                ActTunnelKeyAttrs::Pad(val) => {
11030                    if last_off == offset {
11031                        stack.push(("Pad", last_off));
11032                        break;
11033                    }
11034                }
11035                ActTunnelKeyAttrs::EncDstPort(val) => {
11036                    if last_off == offset {
11037                        stack.push(("EncDstPort", last_off));
11038                        break;
11039                    }
11040                }
11041                ActTunnelKeyAttrs::NoCsum(val) => {
11042                    if last_off == offset {
11043                        stack.push(("NoCsum", last_off));
11044                        break;
11045                    }
11046                }
11047                ActTunnelKeyAttrs::EncOpts(val) => {
11048                    if last_off == offset {
11049                        stack.push(("EncOpts", last_off));
11050                        break;
11051                    }
11052                }
11053                ActTunnelKeyAttrs::EncTos(val) => {
11054                    if last_off == offset {
11055                        stack.push(("EncTos", last_off));
11056                        break;
11057                    }
11058                }
11059                ActTunnelKeyAttrs::EncTtl(val) => {
11060                    if last_off == offset {
11061                        stack.push(("EncTtl", last_off));
11062                        break;
11063                    }
11064                }
11065                ActTunnelKeyAttrs::NoFrag(val) => {
11066                    if last_off == offset {
11067                        stack.push(("NoFrag", last_off));
11068                        break;
11069                    }
11070                }
11071                _ => {}
11072            };
11073            last_off = cur + attrs.pos;
11074        }
11075        if !stack.is_empty() {
11076            stack.push(("ActTunnelKeyAttrs", cur));
11077        }
11078        (stack, None)
11079    }
11080}
11081#[derive(Clone)]
11082pub enum ActVlanAttrs<'a> {
11083    Tm(TcfT),
11084    Parms(TcVlan),
11085    PushVlanId(u16),
11086    PushVlanProtocol(u16),
11087    Pad(&'a [u8]),
11088    PushVlanPriority(u8),
11089    PushEthDst(&'a [u8]),
11090    PushEthSrc(&'a [u8]),
11091}
11092impl<'a> IterableActVlanAttrs<'a> {
11093    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
11094        let mut iter = self.clone();
11095        iter.pos = 0;
11096        for attr in iter {
11097            if let ActVlanAttrs::Tm(val) = attr? {
11098                return Ok(val);
11099            }
11100        }
11101        Err(ErrorContext::new_missing(
11102            "ActVlanAttrs",
11103            "Tm",
11104            self.orig_loc,
11105            self.buf.as_ptr() as usize,
11106        ))
11107    }
11108    pub fn get_parms(&self) -> Result<TcVlan, ErrorContext> {
11109        let mut iter = self.clone();
11110        iter.pos = 0;
11111        for attr in iter {
11112            if let ActVlanAttrs::Parms(val) = attr? {
11113                return Ok(val);
11114            }
11115        }
11116        Err(ErrorContext::new_missing(
11117            "ActVlanAttrs",
11118            "Parms",
11119            self.orig_loc,
11120            self.buf.as_ptr() as usize,
11121        ))
11122    }
11123    pub fn get_push_vlan_id(&self) -> Result<u16, ErrorContext> {
11124        let mut iter = self.clone();
11125        iter.pos = 0;
11126        for attr in iter {
11127            if let ActVlanAttrs::PushVlanId(val) = attr? {
11128                return Ok(val);
11129            }
11130        }
11131        Err(ErrorContext::new_missing(
11132            "ActVlanAttrs",
11133            "PushVlanId",
11134            self.orig_loc,
11135            self.buf.as_ptr() as usize,
11136        ))
11137    }
11138    pub fn get_push_vlan_protocol(&self) -> Result<u16, ErrorContext> {
11139        let mut iter = self.clone();
11140        iter.pos = 0;
11141        for attr in iter {
11142            if let ActVlanAttrs::PushVlanProtocol(val) = attr? {
11143                return Ok(val);
11144            }
11145        }
11146        Err(ErrorContext::new_missing(
11147            "ActVlanAttrs",
11148            "PushVlanProtocol",
11149            self.orig_loc,
11150            self.buf.as_ptr() as usize,
11151        ))
11152    }
11153    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
11154        let mut iter = self.clone();
11155        iter.pos = 0;
11156        for attr in iter {
11157            if let ActVlanAttrs::Pad(val) = attr? {
11158                return Ok(val);
11159            }
11160        }
11161        Err(ErrorContext::new_missing(
11162            "ActVlanAttrs",
11163            "Pad",
11164            self.orig_loc,
11165            self.buf.as_ptr() as usize,
11166        ))
11167    }
11168    pub fn get_push_vlan_priority(&self) -> Result<u8, ErrorContext> {
11169        let mut iter = self.clone();
11170        iter.pos = 0;
11171        for attr in iter {
11172            if let ActVlanAttrs::PushVlanPriority(val) = attr? {
11173                return Ok(val);
11174            }
11175        }
11176        Err(ErrorContext::new_missing(
11177            "ActVlanAttrs",
11178            "PushVlanPriority",
11179            self.orig_loc,
11180            self.buf.as_ptr() as usize,
11181        ))
11182    }
11183    pub fn get_push_eth_dst(&self) -> Result<&'a [u8], ErrorContext> {
11184        let mut iter = self.clone();
11185        iter.pos = 0;
11186        for attr in iter {
11187            if let ActVlanAttrs::PushEthDst(val) = attr? {
11188                return Ok(val);
11189            }
11190        }
11191        Err(ErrorContext::new_missing(
11192            "ActVlanAttrs",
11193            "PushEthDst",
11194            self.orig_loc,
11195            self.buf.as_ptr() as usize,
11196        ))
11197    }
11198    pub fn get_push_eth_src(&self) -> Result<&'a [u8], ErrorContext> {
11199        let mut iter = self.clone();
11200        iter.pos = 0;
11201        for attr in iter {
11202            if let ActVlanAttrs::PushEthSrc(val) = attr? {
11203                return Ok(val);
11204            }
11205        }
11206        Err(ErrorContext::new_missing(
11207            "ActVlanAttrs",
11208            "PushEthSrc",
11209            self.orig_loc,
11210            self.buf.as_ptr() as usize,
11211        ))
11212    }
11213}
11214impl ActVlanAttrs<'_> {
11215    pub fn new<'a>(buf: &'a [u8]) -> IterableActVlanAttrs<'a> {
11216        IterableActVlanAttrs::with_loc(buf, buf.as_ptr() as usize)
11217    }
11218    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11219        let res = match r#type {
11220            1u16 => "Tm",
11221            2u16 => "Parms",
11222            3u16 => "PushVlanId",
11223            4u16 => "PushVlanProtocol",
11224            5u16 => "Pad",
11225            6u16 => "PushVlanPriority",
11226            7u16 => "PushEthDst",
11227            8u16 => "PushEthSrc",
11228            _ => return None,
11229        };
11230        Some(res)
11231    }
11232}
11233#[derive(Clone, Copy, Default)]
11234pub struct IterableActVlanAttrs<'a> {
11235    buf: &'a [u8],
11236    pos: usize,
11237    orig_loc: usize,
11238}
11239impl<'a> IterableActVlanAttrs<'a> {
11240    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11241        Self {
11242            buf,
11243            pos: 0,
11244            orig_loc,
11245        }
11246    }
11247    pub fn get_buf(&self) -> &'a [u8] {
11248        self.buf
11249    }
11250}
11251impl<'a> Iterator for IterableActVlanAttrs<'a> {
11252    type Item = Result<ActVlanAttrs<'a>, ErrorContext>;
11253    fn next(&mut self) -> Option<Self::Item> {
11254        let pos = self.pos;
11255        let mut r#type;
11256        loop {
11257            r#type = None;
11258            if self.buf.len() == self.pos {
11259                return None;
11260            }
11261            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11262                break;
11263            };
11264            r#type = Some(header.r#type);
11265            let res = match header.r#type {
11266                1u16 => ActVlanAttrs::Tm({
11267                    let res = Some(TcfT::new_from_zeroed(next));
11268                    let Some(val) = res else { break };
11269                    val
11270                }),
11271                2u16 => ActVlanAttrs::Parms({
11272                    let res = Some(TcVlan::new_from_zeroed(next));
11273                    let Some(val) = res else { break };
11274                    val
11275                }),
11276                3u16 => ActVlanAttrs::PushVlanId({
11277                    let res = parse_u16(next);
11278                    let Some(val) = res else { break };
11279                    val
11280                }),
11281                4u16 => ActVlanAttrs::PushVlanProtocol({
11282                    let res = parse_u16(next);
11283                    let Some(val) = res else { break };
11284                    val
11285                }),
11286                5u16 => ActVlanAttrs::Pad({
11287                    let res = Some(next);
11288                    let Some(val) = res else { break };
11289                    val
11290                }),
11291                6u16 => ActVlanAttrs::PushVlanPriority({
11292                    let res = parse_u8(next);
11293                    let Some(val) = res else { break };
11294                    val
11295                }),
11296                7u16 => ActVlanAttrs::PushEthDst({
11297                    let res = Some(next);
11298                    let Some(val) = res else { break };
11299                    val
11300                }),
11301                8u16 => ActVlanAttrs::PushEthSrc({
11302                    let res = Some(next);
11303                    let Some(val) = res else { break };
11304                    val
11305                }),
11306                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11307                n => continue,
11308            };
11309            return Some(Ok(res));
11310        }
11311        Some(Err(ErrorContext::new(
11312            "ActVlanAttrs",
11313            r#type.and_then(|t| ActVlanAttrs::attr_from_type(t)),
11314            self.orig_loc,
11315            self.buf.as_ptr().wrapping_add(pos) as usize,
11316        )))
11317    }
11318}
11319impl<'a> std::fmt::Debug for IterableActVlanAttrs<'_> {
11320    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11321        let mut fmt = f.debug_struct("ActVlanAttrs");
11322        for attr in self.clone() {
11323            let attr = match attr {
11324                Ok(a) => a,
11325                Err(err) => {
11326                    fmt.finish()?;
11327                    f.write_str("Err(")?;
11328                    err.fmt(f)?;
11329                    return f.write_str(")");
11330                }
11331            };
11332            match attr {
11333                ActVlanAttrs::Tm(val) => fmt.field("Tm", &val),
11334                ActVlanAttrs::Parms(val) => fmt.field("Parms", &val),
11335                ActVlanAttrs::PushVlanId(val) => fmt.field("PushVlanId", &val),
11336                ActVlanAttrs::PushVlanProtocol(val) => fmt.field("PushVlanProtocol", &val),
11337                ActVlanAttrs::Pad(val) => fmt.field("Pad", &val),
11338                ActVlanAttrs::PushVlanPriority(val) => fmt.field("PushVlanPriority", &val),
11339                ActVlanAttrs::PushEthDst(val) => fmt.field("PushEthDst", &val),
11340                ActVlanAttrs::PushEthSrc(val) => fmt.field("PushEthSrc", &val),
11341            };
11342        }
11343        fmt.finish()
11344    }
11345}
11346impl IterableActVlanAttrs<'_> {
11347    pub fn lookup_attr(
11348        &self,
11349        offset: usize,
11350        missing_type: Option<u16>,
11351    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11352        let mut stack = Vec::new();
11353        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11354        if missing_type.is_some() && cur == offset {
11355            stack.push(("ActVlanAttrs", offset));
11356            return (
11357                stack,
11358                missing_type.and_then(|t| ActVlanAttrs::attr_from_type(t)),
11359            );
11360        }
11361        if cur > offset || cur + self.buf.len() < offset {
11362            return (stack, None);
11363        }
11364        let mut attrs = self.clone();
11365        let mut last_off = cur + attrs.pos;
11366        while let Some(attr) = attrs.next() {
11367            let Ok(attr) = attr else { break };
11368            match attr {
11369                ActVlanAttrs::Tm(val) => {
11370                    if last_off == offset {
11371                        stack.push(("Tm", last_off));
11372                        break;
11373                    }
11374                }
11375                ActVlanAttrs::Parms(val) => {
11376                    if last_off == offset {
11377                        stack.push(("Parms", last_off));
11378                        break;
11379                    }
11380                }
11381                ActVlanAttrs::PushVlanId(val) => {
11382                    if last_off == offset {
11383                        stack.push(("PushVlanId", last_off));
11384                        break;
11385                    }
11386                }
11387                ActVlanAttrs::PushVlanProtocol(val) => {
11388                    if last_off == offset {
11389                        stack.push(("PushVlanProtocol", last_off));
11390                        break;
11391                    }
11392                }
11393                ActVlanAttrs::Pad(val) => {
11394                    if last_off == offset {
11395                        stack.push(("Pad", last_off));
11396                        break;
11397                    }
11398                }
11399                ActVlanAttrs::PushVlanPriority(val) => {
11400                    if last_off == offset {
11401                        stack.push(("PushVlanPriority", last_off));
11402                        break;
11403                    }
11404                }
11405                ActVlanAttrs::PushEthDst(val) => {
11406                    if last_off == offset {
11407                        stack.push(("PushEthDst", last_off));
11408                        break;
11409                    }
11410                }
11411                ActVlanAttrs::PushEthSrc(val) => {
11412                    if last_off == offset {
11413                        stack.push(("PushEthSrc", last_off));
11414                        break;
11415                    }
11416                }
11417                _ => {}
11418            };
11419            last_off = cur + attrs.pos;
11420        }
11421        if !stack.is_empty() {
11422            stack.push(("ActVlanAttrs", cur));
11423        }
11424        (stack, None)
11425    }
11426}
11427#[derive(Clone)]
11428pub enum BasicAttrs<'a> {
11429    Classid(u32),
11430    Ematches(IterableEmatchAttrs<'a>),
11431    Act(IterableArrayActAttrs<'a>),
11432    Police(IterablePoliceAttrs<'a>),
11433    Pcnt(TcBasicPcnt),
11434    Pad(&'a [u8]),
11435}
11436impl<'a> IterableBasicAttrs<'a> {
11437    pub fn get_classid(&self) -> Result<u32, ErrorContext> {
11438        let mut iter = self.clone();
11439        iter.pos = 0;
11440        for attr in iter {
11441            if let BasicAttrs::Classid(val) = attr? {
11442                return Ok(val);
11443            }
11444        }
11445        Err(ErrorContext::new_missing(
11446            "BasicAttrs",
11447            "Classid",
11448            self.orig_loc,
11449            self.buf.as_ptr() as usize,
11450        ))
11451    }
11452    pub fn get_ematches(&self) -> Result<IterableEmatchAttrs<'a>, ErrorContext> {
11453        let mut iter = self.clone();
11454        iter.pos = 0;
11455        for attr in iter {
11456            if let BasicAttrs::Ematches(val) = attr? {
11457                return Ok(val);
11458            }
11459        }
11460        Err(ErrorContext::new_missing(
11461            "BasicAttrs",
11462            "Ematches",
11463            self.orig_loc,
11464            self.buf.as_ptr() as usize,
11465        ))
11466    }
11467    pub fn get_act(
11468        &self,
11469    ) -> Result<ArrayIterable<IterableArrayActAttrs<'a>, IterableActAttrs<'a>>, ErrorContext> {
11470        for attr in self.clone() {
11471            if let BasicAttrs::Act(val) = attr? {
11472                return Ok(ArrayIterable::new(val));
11473            }
11474        }
11475        Err(ErrorContext::new_missing(
11476            "BasicAttrs",
11477            "Act",
11478            self.orig_loc,
11479            self.buf.as_ptr() as usize,
11480        ))
11481    }
11482    pub fn get_police(&self) -> Result<IterablePoliceAttrs<'a>, ErrorContext> {
11483        let mut iter = self.clone();
11484        iter.pos = 0;
11485        for attr in iter {
11486            if let BasicAttrs::Police(val) = attr? {
11487                return Ok(val);
11488            }
11489        }
11490        Err(ErrorContext::new_missing(
11491            "BasicAttrs",
11492            "Police",
11493            self.orig_loc,
11494            self.buf.as_ptr() as usize,
11495        ))
11496    }
11497    pub fn get_pcnt(&self) -> Result<TcBasicPcnt, ErrorContext> {
11498        let mut iter = self.clone();
11499        iter.pos = 0;
11500        for attr in iter {
11501            if let BasicAttrs::Pcnt(val) = attr? {
11502                return Ok(val);
11503            }
11504        }
11505        Err(ErrorContext::new_missing(
11506            "BasicAttrs",
11507            "Pcnt",
11508            self.orig_loc,
11509            self.buf.as_ptr() as usize,
11510        ))
11511    }
11512    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
11513        let mut iter = self.clone();
11514        iter.pos = 0;
11515        for attr in iter {
11516            if let BasicAttrs::Pad(val) = attr? {
11517                return Ok(val);
11518            }
11519        }
11520        Err(ErrorContext::new_missing(
11521            "BasicAttrs",
11522            "Pad",
11523            self.orig_loc,
11524            self.buf.as_ptr() as usize,
11525        ))
11526    }
11527}
11528impl<'a> ActAttrs<'a> {
11529    pub fn new_array(buf: &[u8]) -> IterableArrayActAttrs<'_> {
11530        IterableArrayActAttrs::with_loc(buf, buf.as_ptr() as usize)
11531    }
11532}
11533#[derive(Clone, Copy, Default)]
11534pub struct IterableArrayActAttrs<'a> {
11535    buf: &'a [u8],
11536    pos: usize,
11537    orig_loc: usize,
11538}
11539impl<'a> IterableArrayActAttrs<'a> {
11540    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11541        Self {
11542            buf,
11543            pos: 0,
11544            orig_loc,
11545        }
11546    }
11547    pub fn get_buf(&self) -> &'a [u8] {
11548        self.buf
11549    }
11550}
11551impl<'a> Iterator for IterableArrayActAttrs<'a> {
11552    type Item = Result<IterableActAttrs<'a>, ErrorContext>;
11553    fn next(&mut self) -> Option<Self::Item> {
11554        if self.buf.len() == self.pos {
11555            return None;
11556        }
11557        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
11558            {
11559                return Some(Ok(IterableActAttrs::with_loc(next, self.orig_loc)));
11560            }
11561        }
11562        Some(Err(ErrorContext::new(
11563            "ActAttrs",
11564            None,
11565            self.orig_loc,
11566            self.buf.as_ptr().wrapping_add(self.pos) as usize,
11567        )))
11568    }
11569}
11570impl BasicAttrs<'_> {
11571    pub fn new<'a>(buf: &'a [u8]) -> IterableBasicAttrs<'a> {
11572        IterableBasicAttrs::with_loc(buf, buf.as_ptr() as usize)
11573    }
11574    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11575        let res = match r#type {
11576            1u16 => "Classid",
11577            2u16 => "Ematches",
11578            3u16 => "Act",
11579            4u16 => "Police",
11580            5u16 => "Pcnt",
11581            6u16 => "Pad",
11582            _ => return None,
11583        };
11584        Some(res)
11585    }
11586}
11587#[derive(Clone, Copy, Default)]
11588pub struct IterableBasicAttrs<'a> {
11589    buf: &'a [u8],
11590    pos: usize,
11591    orig_loc: usize,
11592}
11593impl<'a> IterableBasicAttrs<'a> {
11594    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11595        Self {
11596            buf,
11597            pos: 0,
11598            orig_loc,
11599        }
11600    }
11601    pub fn get_buf(&self) -> &'a [u8] {
11602        self.buf
11603    }
11604}
11605impl<'a> Iterator for IterableBasicAttrs<'a> {
11606    type Item = Result<BasicAttrs<'a>, ErrorContext>;
11607    fn next(&mut self) -> Option<Self::Item> {
11608        let pos = self.pos;
11609        let mut r#type;
11610        loop {
11611            r#type = None;
11612            if self.buf.len() == self.pos {
11613                return None;
11614            }
11615            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11616                break;
11617            };
11618            r#type = Some(header.r#type);
11619            let res = match header.r#type {
11620                1u16 => BasicAttrs::Classid({
11621                    let res = parse_u32(next);
11622                    let Some(val) = res else { break };
11623                    val
11624                }),
11625                2u16 => BasicAttrs::Ematches({
11626                    let res = Some(IterableEmatchAttrs::with_loc(next, self.orig_loc));
11627                    let Some(val) = res else { break };
11628                    val
11629                }),
11630                3u16 => BasicAttrs::Act({
11631                    let res = Some(IterableArrayActAttrs::with_loc(next, self.orig_loc));
11632                    let Some(val) = res else { break };
11633                    val
11634                }),
11635                4u16 => BasicAttrs::Police({
11636                    let res = Some(IterablePoliceAttrs::with_loc(next, self.orig_loc));
11637                    let Some(val) = res else { break };
11638                    val
11639                }),
11640                5u16 => BasicAttrs::Pcnt({
11641                    let res = Some(TcBasicPcnt::new_from_zeroed(next));
11642                    let Some(val) = res else { break };
11643                    val
11644                }),
11645                6u16 => BasicAttrs::Pad({
11646                    let res = Some(next);
11647                    let Some(val) = res else { break };
11648                    val
11649                }),
11650                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11651                n => continue,
11652            };
11653            return Some(Ok(res));
11654        }
11655        Some(Err(ErrorContext::new(
11656            "BasicAttrs",
11657            r#type.and_then(|t| BasicAttrs::attr_from_type(t)),
11658            self.orig_loc,
11659            self.buf.as_ptr().wrapping_add(pos) as usize,
11660        )))
11661    }
11662}
11663impl std::fmt::Debug for IterableArrayActAttrs<'_> {
11664    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11665        fmt.debug_list()
11666            .entries(self.clone().map(FlattenErrorContext))
11667            .finish()
11668    }
11669}
11670impl<'a> std::fmt::Debug for IterableBasicAttrs<'_> {
11671    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11672        let mut fmt = f.debug_struct("BasicAttrs");
11673        for attr in self.clone() {
11674            let attr = match attr {
11675                Ok(a) => a,
11676                Err(err) => {
11677                    fmt.finish()?;
11678                    f.write_str("Err(")?;
11679                    err.fmt(f)?;
11680                    return f.write_str(")");
11681                }
11682            };
11683            match attr {
11684                BasicAttrs::Classid(val) => fmt.field("Classid", &val),
11685                BasicAttrs::Ematches(val) => fmt.field("Ematches", &val),
11686                BasicAttrs::Act(val) => fmt.field("Act", &val),
11687                BasicAttrs::Police(val) => fmt.field("Police", &val),
11688                BasicAttrs::Pcnt(val) => fmt.field("Pcnt", &val),
11689                BasicAttrs::Pad(val) => fmt.field("Pad", &val),
11690            };
11691        }
11692        fmt.finish()
11693    }
11694}
11695impl IterableBasicAttrs<'_> {
11696    pub fn lookup_attr(
11697        &self,
11698        offset: usize,
11699        missing_type: Option<u16>,
11700    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11701        let mut stack = Vec::new();
11702        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11703        if missing_type.is_some() && cur == offset {
11704            stack.push(("BasicAttrs", offset));
11705            return (
11706                stack,
11707                missing_type.and_then(|t| BasicAttrs::attr_from_type(t)),
11708            );
11709        }
11710        if cur > offset || cur + self.buf.len() < offset {
11711            return (stack, None);
11712        }
11713        let mut attrs = self.clone();
11714        let mut last_off = cur + attrs.pos;
11715        let mut missing = None;
11716        while let Some(attr) = attrs.next() {
11717            let Ok(attr) = attr else { break };
11718            match attr {
11719                BasicAttrs::Classid(val) => {
11720                    if last_off == offset {
11721                        stack.push(("Classid", last_off));
11722                        break;
11723                    }
11724                }
11725                BasicAttrs::Ematches(val) => {
11726                    (stack, missing) = val.lookup_attr(offset, missing_type);
11727                    if !stack.is_empty() {
11728                        break;
11729                    }
11730                }
11731                BasicAttrs::Act(val) => {
11732                    for entry in val {
11733                        let Ok(attr) = entry else { break };
11734                        (stack, missing) = attr.lookup_attr(offset, missing_type);
11735                        if !stack.is_empty() {
11736                            break;
11737                        }
11738                    }
11739                    if !stack.is_empty() {
11740                        stack.push(("Act", last_off));
11741                        break;
11742                    }
11743                }
11744                BasicAttrs::Police(val) => {
11745                    (stack, missing) = val.lookup_attr(offset, missing_type);
11746                    if !stack.is_empty() {
11747                        break;
11748                    }
11749                }
11750                BasicAttrs::Pcnt(val) => {
11751                    if last_off == offset {
11752                        stack.push(("Pcnt", last_off));
11753                        break;
11754                    }
11755                }
11756                BasicAttrs::Pad(val) => {
11757                    if last_off == offset {
11758                        stack.push(("Pad", last_off));
11759                        break;
11760                    }
11761                }
11762                _ => {}
11763            };
11764            last_off = cur + attrs.pos;
11765        }
11766        if !stack.is_empty() {
11767            stack.push(("BasicAttrs", cur));
11768        }
11769        (stack, missing)
11770    }
11771}
11772#[derive(Clone)]
11773pub enum BpfAttrs<'a> {
11774    Act(IterableArrayActAttrs<'a>),
11775    Police(IterablePoliceAttrs<'a>),
11776    Classid(u32),
11777    OpsLen(u16),
11778    Ops(&'a [u8]),
11779    Fd(u32),
11780    Name(&'a CStr),
11781    Flags(u32),
11782    FlagsGen(u32),
11783    Tag(&'a [u8]),
11784    Id(u32),
11785}
11786impl<'a> IterableBpfAttrs<'a> {
11787    pub fn get_act(
11788        &self,
11789    ) -> Result<ArrayIterable<IterableArrayActAttrs<'a>, IterableActAttrs<'a>>, ErrorContext> {
11790        for attr in self.clone() {
11791            if let BpfAttrs::Act(val) = attr? {
11792                return Ok(ArrayIterable::new(val));
11793            }
11794        }
11795        Err(ErrorContext::new_missing(
11796            "BpfAttrs",
11797            "Act",
11798            self.orig_loc,
11799            self.buf.as_ptr() as usize,
11800        ))
11801    }
11802    pub fn get_police(&self) -> Result<IterablePoliceAttrs<'a>, ErrorContext> {
11803        let mut iter = self.clone();
11804        iter.pos = 0;
11805        for attr in iter {
11806            if let BpfAttrs::Police(val) = attr? {
11807                return Ok(val);
11808            }
11809        }
11810        Err(ErrorContext::new_missing(
11811            "BpfAttrs",
11812            "Police",
11813            self.orig_loc,
11814            self.buf.as_ptr() as usize,
11815        ))
11816    }
11817    pub fn get_classid(&self) -> Result<u32, ErrorContext> {
11818        let mut iter = self.clone();
11819        iter.pos = 0;
11820        for attr in iter {
11821            if let BpfAttrs::Classid(val) = attr? {
11822                return Ok(val);
11823            }
11824        }
11825        Err(ErrorContext::new_missing(
11826            "BpfAttrs",
11827            "Classid",
11828            self.orig_loc,
11829            self.buf.as_ptr() as usize,
11830        ))
11831    }
11832    pub fn get_ops_len(&self) -> Result<u16, ErrorContext> {
11833        let mut iter = self.clone();
11834        iter.pos = 0;
11835        for attr in iter {
11836            if let BpfAttrs::OpsLen(val) = attr? {
11837                return Ok(val);
11838            }
11839        }
11840        Err(ErrorContext::new_missing(
11841            "BpfAttrs",
11842            "OpsLen",
11843            self.orig_loc,
11844            self.buf.as_ptr() as usize,
11845        ))
11846    }
11847    pub fn get_ops(&self) -> Result<&'a [u8], ErrorContext> {
11848        let mut iter = self.clone();
11849        iter.pos = 0;
11850        for attr in iter {
11851            if let BpfAttrs::Ops(val) = attr? {
11852                return Ok(val);
11853            }
11854        }
11855        Err(ErrorContext::new_missing(
11856            "BpfAttrs",
11857            "Ops",
11858            self.orig_loc,
11859            self.buf.as_ptr() as usize,
11860        ))
11861    }
11862    pub fn get_fd(&self) -> Result<u32, ErrorContext> {
11863        let mut iter = self.clone();
11864        iter.pos = 0;
11865        for attr in iter {
11866            if let BpfAttrs::Fd(val) = attr? {
11867                return Ok(val);
11868            }
11869        }
11870        Err(ErrorContext::new_missing(
11871            "BpfAttrs",
11872            "Fd",
11873            self.orig_loc,
11874            self.buf.as_ptr() as usize,
11875        ))
11876    }
11877    pub fn get_name(&self) -> Result<&'a CStr, ErrorContext> {
11878        let mut iter = self.clone();
11879        iter.pos = 0;
11880        for attr in iter {
11881            if let BpfAttrs::Name(val) = attr? {
11882                return Ok(val);
11883            }
11884        }
11885        Err(ErrorContext::new_missing(
11886            "BpfAttrs",
11887            "Name",
11888            self.orig_loc,
11889            self.buf.as_ptr() as usize,
11890        ))
11891    }
11892    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
11893        let mut iter = self.clone();
11894        iter.pos = 0;
11895        for attr in iter {
11896            if let BpfAttrs::Flags(val) = attr? {
11897                return Ok(val);
11898            }
11899        }
11900        Err(ErrorContext::new_missing(
11901            "BpfAttrs",
11902            "Flags",
11903            self.orig_loc,
11904            self.buf.as_ptr() as usize,
11905        ))
11906    }
11907    pub fn get_flags_gen(&self) -> Result<u32, ErrorContext> {
11908        let mut iter = self.clone();
11909        iter.pos = 0;
11910        for attr in iter {
11911            if let BpfAttrs::FlagsGen(val) = attr? {
11912                return Ok(val);
11913            }
11914        }
11915        Err(ErrorContext::new_missing(
11916            "BpfAttrs",
11917            "FlagsGen",
11918            self.orig_loc,
11919            self.buf.as_ptr() as usize,
11920        ))
11921    }
11922    pub fn get_tag(&self) -> Result<&'a [u8], ErrorContext> {
11923        let mut iter = self.clone();
11924        iter.pos = 0;
11925        for attr in iter {
11926            if let BpfAttrs::Tag(val) = attr? {
11927                return Ok(val);
11928            }
11929        }
11930        Err(ErrorContext::new_missing(
11931            "BpfAttrs",
11932            "Tag",
11933            self.orig_loc,
11934            self.buf.as_ptr() as usize,
11935        ))
11936    }
11937    pub fn get_id(&self) -> Result<u32, ErrorContext> {
11938        let mut iter = self.clone();
11939        iter.pos = 0;
11940        for attr in iter {
11941            if let BpfAttrs::Id(val) = attr? {
11942                return Ok(val);
11943            }
11944        }
11945        Err(ErrorContext::new_missing(
11946            "BpfAttrs",
11947            "Id",
11948            self.orig_loc,
11949            self.buf.as_ptr() as usize,
11950        ))
11951    }
11952}
11953impl BpfAttrs<'_> {
11954    pub fn new<'a>(buf: &'a [u8]) -> IterableBpfAttrs<'a> {
11955        IterableBpfAttrs::with_loc(buf, buf.as_ptr() as usize)
11956    }
11957    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11958        let res = match r#type {
11959            1u16 => "Act",
11960            2u16 => "Police",
11961            3u16 => "Classid",
11962            4u16 => "OpsLen",
11963            5u16 => "Ops",
11964            6u16 => "Fd",
11965            7u16 => "Name",
11966            8u16 => "Flags",
11967            9u16 => "FlagsGen",
11968            10u16 => "Tag",
11969            11u16 => "Id",
11970            _ => return None,
11971        };
11972        Some(res)
11973    }
11974}
11975#[derive(Clone, Copy, Default)]
11976pub struct IterableBpfAttrs<'a> {
11977    buf: &'a [u8],
11978    pos: usize,
11979    orig_loc: usize,
11980}
11981impl<'a> IterableBpfAttrs<'a> {
11982    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11983        Self {
11984            buf,
11985            pos: 0,
11986            orig_loc,
11987        }
11988    }
11989    pub fn get_buf(&self) -> &'a [u8] {
11990        self.buf
11991    }
11992}
11993impl<'a> Iterator for IterableBpfAttrs<'a> {
11994    type Item = Result<BpfAttrs<'a>, ErrorContext>;
11995    fn next(&mut self) -> Option<Self::Item> {
11996        let pos = self.pos;
11997        let mut r#type;
11998        loop {
11999            r#type = None;
12000            if self.buf.len() == self.pos {
12001                return None;
12002            }
12003            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
12004                break;
12005            };
12006            r#type = Some(header.r#type);
12007            let res = match header.r#type {
12008                1u16 => BpfAttrs::Act({
12009                    let res = Some(IterableArrayActAttrs::with_loc(next, self.orig_loc));
12010                    let Some(val) = res else { break };
12011                    val
12012                }),
12013                2u16 => BpfAttrs::Police({
12014                    let res = Some(IterablePoliceAttrs::with_loc(next, self.orig_loc));
12015                    let Some(val) = res else { break };
12016                    val
12017                }),
12018                3u16 => BpfAttrs::Classid({
12019                    let res = parse_u32(next);
12020                    let Some(val) = res else { break };
12021                    val
12022                }),
12023                4u16 => BpfAttrs::OpsLen({
12024                    let res = parse_u16(next);
12025                    let Some(val) = res else { break };
12026                    val
12027                }),
12028                5u16 => BpfAttrs::Ops({
12029                    let res = Some(next);
12030                    let Some(val) = res else { break };
12031                    val
12032                }),
12033                6u16 => BpfAttrs::Fd({
12034                    let res = parse_u32(next);
12035                    let Some(val) = res else { break };
12036                    val
12037                }),
12038                7u16 => BpfAttrs::Name({
12039                    let res = CStr::from_bytes_with_nul(next).ok();
12040                    let Some(val) = res else { break };
12041                    val
12042                }),
12043                8u16 => BpfAttrs::Flags({
12044                    let res = parse_u32(next);
12045                    let Some(val) = res else { break };
12046                    val
12047                }),
12048                9u16 => BpfAttrs::FlagsGen({
12049                    let res = parse_u32(next);
12050                    let Some(val) = res else { break };
12051                    val
12052                }),
12053                10u16 => BpfAttrs::Tag({
12054                    let res = Some(next);
12055                    let Some(val) = res else { break };
12056                    val
12057                }),
12058                11u16 => BpfAttrs::Id({
12059                    let res = parse_u32(next);
12060                    let Some(val) = res else { break };
12061                    val
12062                }),
12063                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
12064                n => continue,
12065            };
12066            return Some(Ok(res));
12067        }
12068        Some(Err(ErrorContext::new(
12069            "BpfAttrs",
12070            r#type.and_then(|t| BpfAttrs::attr_from_type(t)),
12071            self.orig_loc,
12072            self.buf.as_ptr().wrapping_add(pos) as usize,
12073        )))
12074    }
12075}
12076impl<'a> std::fmt::Debug for IterableBpfAttrs<'_> {
12077    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12078        let mut fmt = f.debug_struct("BpfAttrs");
12079        for attr in self.clone() {
12080            let attr = match attr {
12081                Ok(a) => a,
12082                Err(err) => {
12083                    fmt.finish()?;
12084                    f.write_str("Err(")?;
12085                    err.fmt(f)?;
12086                    return f.write_str(")");
12087                }
12088            };
12089            match attr {
12090                BpfAttrs::Act(val) => fmt.field("Act", &val),
12091                BpfAttrs::Police(val) => fmt.field("Police", &val),
12092                BpfAttrs::Classid(val) => fmt.field("Classid", &val),
12093                BpfAttrs::OpsLen(val) => fmt.field("OpsLen", &val),
12094                BpfAttrs::Ops(val) => fmt.field("Ops", &val),
12095                BpfAttrs::Fd(val) => fmt.field("Fd", &val),
12096                BpfAttrs::Name(val) => fmt.field("Name", &val),
12097                BpfAttrs::Flags(val) => fmt.field("Flags", &val),
12098                BpfAttrs::FlagsGen(val) => fmt.field("FlagsGen", &val),
12099                BpfAttrs::Tag(val) => fmt.field("Tag", &val),
12100                BpfAttrs::Id(val) => fmt.field("Id", &val),
12101            };
12102        }
12103        fmt.finish()
12104    }
12105}
12106impl IterableBpfAttrs<'_> {
12107    pub fn lookup_attr(
12108        &self,
12109        offset: usize,
12110        missing_type: Option<u16>,
12111    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
12112        let mut stack = Vec::new();
12113        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
12114        if missing_type.is_some() && cur == offset {
12115            stack.push(("BpfAttrs", offset));
12116            return (
12117                stack,
12118                missing_type.and_then(|t| BpfAttrs::attr_from_type(t)),
12119            );
12120        }
12121        if cur > offset || cur + self.buf.len() < offset {
12122            return (stack, None);
12123        }
12124        let mut attrs = self.clone();
12125        let mut last_off = cur + attrs.pos;
12126        let mut missing = None;
12127        while let Some(attr) = attrs.next() {
12128            let Ok(attr) = attr else { break };
12129            match attr {
12130                BpfAttrs::Act(val) => {
12131                    for entry in val {
12132                        let Ok(attr) = entry else { break };
12133                        (stack, missing) = attr.lookup_attr(offset, missing_type);
12134                        if !stack.is_empty() {
12135                            break;
12136                        }
12137                    }
12138                    if !stack.is_empty() {
12139                        stack.push(("Act", last_off));
12140                        break;
12141                    }
12142                }
12143                BpfAttrs::Police(val) => {
12144                    (stack, missing) = val.lookup_attr(offset, missing_type);
12145                    if !stack.is_empty() {
12146                        break;
12147                    }
12148                }
12149                BpfAttrs::Classid(val) => {
12150                    if last_off == offset {
12151                        stack.push(("Classid", last_off));
12152                        break;
12153                    }
12154                }
12155                BpfAttrs::OpsLen(val) => {
12156                    if last_off == offset {
12157                        stack.push(("OpsLen", last_off));
12158                        break;
12159                    }
12160                }
12161                BpfAttrs::Ops(val) => {
12162                    if last_off == offset {
12163                        stack.push(("Ops", last_off));
12164                        break;
12165                    }
12166                }
12167                BpfAttrs::Fd(val) => {
12168                    if last_off == offset {
12169                        stack.push(("Fd", last_off));
12170                        break;
12171                    }
12172                }
12173                BpfAttrs::Name(val) => {
12174                    if last_off == offset {
12175                        stack.push(("Name", last_off));
12176                        break;
12177                    }
12178                }
12179                BpfAttrs::Flags(val) => {
12180                    if last_off == offset {
12181                        stack.push(("Flags", last_off));
12182                        break;
12183                    }
12184                }
12185                BpfAttrs::FlagsGen(val) => {
12186                    if last_off == offset {
12187                        stack.push(("FlagsGen", last_off));
12188                        break;
12189                    }
12190                }
12191                BpfAttrs::Tag(val) => {
12192                    if last_off == offset {
12193                        stack.push(("Tag", last_off));
12194                        break;
12195                    }
12196                }
12197                BpfAttrs::Id(val) => {
12198                    if last_off == offset {
12199                        stack.push(("Id", last_off));
12200                        break;
12201                    }
12202                }
12203                _ => {}
12204            };
12205            last_off = cur + attrs.pos;
12206        }
12207        if !stack.is_empty() {
12208            stack.push(("BpfAttrs", cur));
12209        }
12210        (stack, missing)
12211    }
12212}
12213#[derive(Clone)]
12214pub enum CakeAttrs<'a> {
12215    Pad(&'a [u8]),
12216    BaseRate64(u64),
12217    DiffservMode(u32),
12218    Atm(u32),
12219    FlowMode(u32),
12220    Overhead(u32),
12221    Rtt(u32),
12222    Target(u32),
12223    Autorate(u32),
12224    Memory(u32),
12225    Nat(u32),
12226    Raw(u32),
12227    Wash(u32),
12228    Mpu(u32),
12229    Ingress(u32),
12230    AckFilter(u32),
12231    SplitGso(u32),
12232    Fwmark(u32),
12233}
12234impl<'a> IterableCakeAttrs<'a> {
12235    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
12236        let mut iter = self.clone();
12237        iter.pos = 0;
12238        for attr in iter {
12239            if let CakeAttrs::Pad(val) = attr? {
12240                return Ok(val);
12241            }
12242        }
12243        Err(ErrorContext::new_missing(
12244            "CakeAttrs",
12245            "Pad",
12246            self.orig_loc,
12247            self.buf.as_ptr() as usize,
12248        ))
12249    }
12250    pub fn get_base_rate64(&self) -> Result<u64, ErrorContext> {
12251        let mut iter = self.clone();
12252        iter.pos = 0;
12253        for attr in iter {
12254            if let CakeAttrs::BaseRate64(val) = attr? {
12255                return Ok(val);
12256            }
12257        }
12258        Err(ErrorContext::new_missing(
12259            "CakeAttrs",
12260            "BaseRate64",
12261            self.orig_loc,
12262            self.buf.as_ptr() as usize,
12263        ))
12264    }
12265    pub fn get_diffserv_mode(&self) -> Result<u32, ErrorContext> {
12266        let mut iter = self.clone();
12267        iter.pos = 0;
12268        for attr in iter {
12269            if let CakeAttrs::DiffservMode(val) = attr? {
12270                return Ok(val);
12271            }
12272        }
12273        Err(ErrorContext::new_missing(
12274            "CakeAttrs",
12275            "DiffservMode",
12276            self.orig_loc,
12277            self.buf.as_ptr() as usize,
12278        ))
12279    }
12280    pub fn get_atm(&self) -> Result<u32, ErrorContext> {
12281        let mut iter = self.clone();
12282        iter.pos = 0;
12283        for attr in iter {
12284            if let CakeAttrs::Atm(val) = attr? {
12285                return Ok(val);
12286            }
12287        }
12288        Err(ErrorContext::new_missing(
12289            "CakeAttrs",
12290            "Atm",
12291            self.orig_loc,
12292            self.buf.as_ptr() as usize,
12293        ))
12294    }
12295    pub fn get_flow_mode(&self) -> Result<u32, ErrorContext> {
12296        let mut iter = self.clone();
12297        iter.pos = 0;
12298        for attr in iter {
12299            if let CakeAttrs::FlowMode(val) = attr? {
12300                return Ok(val);
12301            }
12302        }
12303        Err(ErrorContext::new_missing(
12304            "CakeAttrs",
12305            "FlowMode",
12306            self.orig_loc,
12307            self.buf.as_ptr() as usize,
12308        ))
12309    }
12310    pub fn get_overhead(&self) -> Result<u32, ErrorContext> {
12311        let mut iter = self.clone();
12312        iter.pos = 0;
12313        for attr in iter {
12314            if let CakeAttrs::Overhead(val) = attr? {
12315                return Ok(val);
12316            }
12317        }
12318        Err(ErrorContext::new_missing(
12319            "CakeAttrs",
12320            "Overhead",
12321            self.orig_loc,
12322            self.buf.as_ptr() as usize,
12323        ))
12324    }
12325    pub fn get_rtt(&self) -> Result<u32, ErrorContext> {
12326        let mut iter = self.clone();
12327        iter.pos = 0;
12328        for attr in iter {
12329            if let CakeAttrs::Rtt(val) = attr? {
12330                return Ok(val);
12331            }
12332        }
12333        Err(ErrorContext::new_missing(
12334            "CakeAttrs",
12335            "Rtt",
12336            self.orig_loc,
12337            self.buf.as_ptr() as usize,
12338        ))
12339    }
12340    pub fn get_target(&self) -> Result<u32, ErrorContext> {
12341        let mut iter = self.clone();
12342        iter.pos = 0;
12343        for attr in iter {
12344            if let CakeAttrs::Target(val) = attr? {
12345                return Ok(val);
12346            }
12347        }
12348        Err(ErrorContext::new_missing(
12349            "CakeAttrs",
12350            "Target",
12351            self.orig_loc,
12352            self.buf.as_ptr() as usize,
12353        ))
12354    }
12355    pub fn get_autorate(&self) -> Result<u32, ErrorContext> {
12356        let mut iter = self.clone();
12357        iter.pos = 0;
12358        for attr in iter {
12359            if let CakeAttrs::Autorate(val) = attr? {
12360                return Ok(val);
12361            }
12362        }
12363        Err(ErrorContext::new_missing(
12364            "CakeAttrs",
12365            "Autorate",
12366            self.orig_loc,
12367            self.buf.as_ptr() as usize,
12368        ))
12369    }
12370    pub fn get_memory(&self) -> Result<u32, ErrorContext> {
12371        let mut iter = self.clone();
12372        iter.pos = 0;
12373        for attr in iter {
12374            if let CakeAttrs::Memory(val) = attr? {
12375                return Ok(val);
12376            }
12377        }
12378        Err(ErrorContext::new_missing(
12379            "CakeAttrs",
12380            "Memory",
12381            self.orig_loc,
12382            self.buf.as_ptr() as usize,
12383        ))
12384    }
12385    pub fn get_nat(&self) -> Result<u32, ErrorContext> {
12386        let mut iter = self.clone();
12387        iter.pos = 0;
12388        for attr in iter {
12389            if let CakeAttrs::Nat(val) = attr? {
12390                return Ok(val);
12391            }
12392        }
12393        Err(ErrorContext::new_missing(
12394            "CakeAttrs",
12395            "Nat",
12396            self.orig_loc,
12397            self.buf.as_ptr() as usize,
12398        ))
12399    }
12400    pub fn get_raw(&self) -> Result<u32, ErrorContext> {
12401        let mut iter = self.clone();
12402        iter.pos = 0;
12403        for attr in iter {
12404            if let CakeAttrs::Raw(val) = attr? {
12405                return Ok(val);
12406            }
12407        }
12408        Err(ErrorContext::new_missing(
12409            "CakeAttrs",
12410            "Raw",
12411            self.orig_loc,
12412            self.buf.as_ptr() as usize,
12413        ))
12414    }
12415    pub fn get_wash(&self) -> Result<u32, ErrorContext> {
12416        let mut iter = self.clone();
12417        iter.pos = 0;
12418        for attr in iter {
12419            if let CakeAttrs::Wash(val) = attr? {
12420                return Ok(val);
12421            }
12422        }
12423        Err(ErrorContext::new_missing(
12424            "CakeAttrs",
12425            "Wash",
12426            self.orig_loc,
12427            self.buf.as_ptr() as usize,
12428        ))
12429    }
12430    pub fn get_mpu(&self) -> Result<u32, ErrorContext> {
12431        let mut iter = self.clone();
12432        iter.pos = 0;
12433        for attr in iter {
12434            if let CakeAttrs::Mpu(val) = attr? {
12435                return Ok(val);
12436            }
12437        }
12438        Err(ErrorContext::new_missing(
12439            "CakeAttrs",
12440            "Mpu",
12441            self.orig_loc,
12442            self.buf.as_ptr() as usize,
12443        ))
12444    }
12445    pub fn get_ingress(&self) -> Result<u32, ErrorContext> {
12446        let mut iter = self.clone();
12447        iter.pos = 0;
12448        for attr in iter {
12449            if let CakeAttrs::Ingress(val) = attr? {
12450                return Ok(val);
12451            }
12452        }
12453        Err(ErrorContext::new_missing(
12454            "CakeAttrs",
12455            "Ingress",
12456            self.orig_loc,
12457            self.buf.as_ptr() as usize,
12458        ))
12459    }
12460    pub fn get_ack_filter(&self) -> Result<u32, ErrorContext> {
12461        let mut iter = self.clone();
12462        iter.pos = 0;
12463        for attr in iter {
12464            if let CakeAttrs::AckFilter(val) = attr? {
12465                return Ok(val);
12466            }
12467        }
12468        Err(ErrorContext::new_missing(
12469            "CakeAttrs",
12470            "AckFilter",
12471            self.orig_loc,
12472            self.buf.as_ptr() as usize,
12473        ))
12474    }
12475    pub fn get_split_gso(&self) -> Result<u32, ErrorContext> {
12476        let mut iter = self.clone();
12477        iter.pos = 0;
12478        for attr in iter {
12479            if let CakeAttrs::SplitGso(val) = attr? {
12480                return Ok(val);
12481            }
12482        }
12483        Err(ErrorContext::new_missing(
12484            "CakeAttrs",
12485            "SplitGso",
12486            self.orig_loc,
12487            self.buf.as_ptr() as usize,
12488        ))
12489    }
12490    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
12491        let mut iter = self.clone();
12492        iter.pos = 0;
12493        for attr in iter {
12494            if let CakeAttrs::Fwmark(val) = attr? {
12495                return Ok(val);
12496            }
12497        }
12498        Err(ErrorContext::new_missing(
12499            "CakeAttrs",
12500            "Fwmark",
12501            self.orig_loc,
12502            self.buf.as_ptr() as usize,
12503        ))
12504    }
12505}
12506impl CakeAttrs<'_> {
12507    pub fn new<'a>(buf: &'a [u8]) -> IterableCakeAttrs<'a> {
12508        IterableCakeAttrs::with_loc(buf, buf.as_ptr() as usize)
12509    }
12510    fn attr_from_type(r#type: u16) -> Option<&'static str> {
12511        let res = match r#type {
12512            1u16 => "Pad",
12513            2u16 => "BaseRate64",
12514            3u16 => "DiffservMode",
12515            4u16 => "Atm",
12516            5u16 => "FlowMode",
12517            6u16 => "Overhead",
12518            7u16 => "Rtt",
12519            8u16 => "Target",
12520            9u16 => "Autorate",
12521            10u16 => "Memory",
12522            11u16 => "Nat",
12523            12u16 => "Raw",
12524            13u16 => "Wash",
12525            14u16 => "Mpu",
12526            15u16 => "Ingress",
12527            16u16 => "AckFilter",
12528            17u16 => "SplitGso",
12529            18u16 => "Fwmark",
12530            _ => return None,
12531        };
12532        Some(res)
12533    }
12534}
12535#[derive(Clone, Copy, Default)]
12536pub struct IterableCakeAttrs<'a> {
12537    buf: &'a [u8],
12538    pos: usize,
12539    orig_loc: usize,
12540}
12541impl<'a> IterableCakeAttrs<'a> {
12542    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
12543        Self {
12544            buf,
12545            pos: 0,
12546            orig_loc,
12547        }
12548    }
12549    pub fn get_buf(&self) -> &'a [u8] {
12550        self.buf
12551    }
12552}
12553impl<'a> Iterator for IterableCakeAttrs<'a> {
12554    type Item = Result<CakeAttrs<'a>, ErrorContext>;
12555    fn next(&mut self) -> Option<Self::Item> {
12556        let pos = self.pos;
12557        let mut r#type;
12558        loop {
12559            r#type = None;
12560            if self.buf.len() == self.pos {
12561                return None;
12562            }
12563            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
12564                break;
12565            };
12566            r#type = Some(header.r#type);
12567            let res = match header.r#type {
12568                1u16 => CakeAttrs::Pad({
12569                    let res = Some(next);
12570                    let Some(val) = res else { break };
12571                    val
12572                }),
12573                2u16 => CakeAttrs::BaseRate64({
12574                    let res = parse_u64(next);
12575                    let Some(val) = res else { break };
12576                    val
12577                }),
12578                3u16 => CakeAttrs::DiffservMode({
12579                    let res = parse_u32(next);
12580                    let Some(val) = res else { break };
12581                    val
12582                }),
12583                4u16 => CakeAttrs::Atm({
12584                    let res = parse_u32(next);
12585                    let Some(val) = res else { break };
12586                    val
12587                }),
12588                5u16 => CakeAttrs::FlowMode({
12589                    let res = parse_u32(next);
12590                    let Some(val) = res else { break };
12591                    val
12592                }),
12593                6u16 => CakeAttrs::Overhead({
12594                    let res = parse_u32(next);
12595                    let Some(val) = res else { break };
12596                    val
12597                }),
12598                7u16 => CakeAttrs::Rtt({
12599                    let res = parse_u32(next);
12600                    let Some(val) = res else { break };
12601                    val
12602                }),
12603                8u16 => CakeAttrs::Target({
12604                    let res = parse_u32(next);
12605                    let Some(val) = res else { break };
12606                    val
12607                }),
12608                9u16 => CakeAttrs::Autorate({
12609                    let res = parse_u32(next);
12610                    let Some(val) = res else { break };
12611                    val
12612                }),
12613                10u16 => CakeAttrs::Memory({
12614                    let res = parse_u32(next);
12615                    let Some(val) = res else { break };
12616                    val
12617                }),
12618                11u16 => CakeAttrs::Nat({
12619                    let res = parse_u32(next);
12620                    let Some(val) = res else { break };
12621                    val
12622                }),
12623                12u16 => CakeAttrs::Raw({
12624                    let res = parse_u32(next);
12625                    let Some(val) = res else { break };
12626                    val
12627                }),
12628                13u16 => CakeAttrs::Wash({
12629                    let res = parse_u32(next);
12630                    let Some(val) = res else { break };
12631                    val
12632                }),
12633                14u16 => CakeAttrs::Mpu({
12634                    let res = parse_u32(next);
12635                    let Some(val) = res else { break };
12636                    val
12637                }),
12638                15u16 => CakeAttrs::Ingress({
12639                    let res = parse_u32(next);
12640                    let Some(val) = res else { break };
12641                    val
12642                }),
12643                16u16 => CakeAttrs::AckFilter({
12644                    let res = parse_u32(next);
12645                    let Some(val) = res else { break };
12646                    val
12647                }),
12648                17u16 => CakeAttrs::SplitGso({
12649                    let res = parse_u32(next);
12650                    let Some(val) = res else { break };
12651                    val
12652                }),
12653                18u16 => CakeAttrs::Fwmark({
12654                    let res = parse_u32(next);
12655                    let Some(val) = res else { break };
12656                    val
12657                }),
12658                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
12659                n => continue,
12660            };
12661            return Some(Ok(res));
12662        }
12663        Some(Err(ErrorContext::new(
12664            "CakeAttrs",
12665            r#type.and_then(|t| CakeAttrs::attr_from_type(t)),
12666            self.orig_loc,
12667            self.buf.as_ptr().wrapping_add(pos) as usize,
12668        )))
12669    }
12670}
12671impl<'a> std::fmt::Debug for IterableCakeAttrs<'_> {
12672    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12673        let mut fmt = f.debug_struct("CakeAttrs");
12674        for attr in self.clone() {
12675            let attr = match attr {
12676                Ok(a) => a,
12677                Err(err) => {
12678                    fmt.finish()?;
12679                    f.write_str("Err(")?;
12680                    err.fmt(f)?;
12681                    return f.write_str(")");
12682                }
12683            };
12684            match attr {
12685                CakeAttrs::Pad(val) => fmt.field("Pad", &val),
12686                CakeAttrs::BaseRate64(val) => fmt.field("BaseRate64", &val),
12687                CakeAttrs::DiffservMode(val) => fmt.field("DiffservMode", &val),
12688                CakeAttrs::Atm(val) => fmt.field("Atm", &val),
12689                CakeAttrs::FlowMode(val) => fmt.field("FlowMode", &val),
12690                CakeAttrs::Overhead(val) => fmt.field("Overhead", &val),
12691                CakeAttrs::Rtt(val) => fmt.field("Rtt", &val),
12692                CakeAttrs::Target(val) => fmt.field("Target", &val),
12693                CakeAttrs::Autorate(val) => fmt.field("Autorate", &val),
12694                CakeAttrs::Memory(val) => fmt.field("Memory", &val),
12695                CakeAttrs::Nat(val) => fmt.field("Nat", &val),
12696                CakeAttrs::Raw(val) => fmt.field("Raw", &val),
12697                CakeAttrs::Wash(val) => fmt.field("Wash", &val),
12698                CakeAttrs::Mpu(val) => fmt.field("Mpu", &val),
12699                CakeAttrs::Ingress(val) => fmt.field("Ingress", &val),
12700                CakeAttrs::AckFilter(val) => fmt.field("AckFilter", &val),
12701                CakeAttrs::SplitGso(val) => fmt.field("SplitGso", &val),
12702                CakeAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
12703            };
12704        }
12705        fmt.finish()
12706    }
12707}
12708impl IterableCakeAttrs<'_> {
12709    pub fn lookup_attr(
12710        &self,
12711        offset: usize,
12712        missing_type: Option<u16>,
12713    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
12714        let mut stack = Vec::new();
12715        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
12716        if missing_type.is_some() && cur == offset {
12717            stack.push(("CakeAttrs", offset));
12718            return (
12719                stack,
12720                missing_type.and_then(|t| CakeAttrs::attr_from_type(t)),
12721            );
12722        }
12723        if cur > offset || cur + self.buf.len() < offset {
12724            return (stack, None);
12725        }
12726        let mut attrs = self.clone();
12727        let mut last_off = cur + attrs.pos;
12728        while let Some(attr) = attrs.next() {
12729            let Ok(attr) = attr else { break };
12730            match attr {
12731                CakeAttrs::Pad(val) => {
12732                    if last_off == offset {
12733                        stack.push(("Pad", last_off));
12734                        break;
12735                    }
12736                }
12737                CakeAttrs::BaseRate64(val) => {
12738                    if last_off == offset {
12739                        stack.push(("BaseRate64", last_off));
12740                        break;
12741                    }
12742                }
12743                CakeAttrs::DiffservMode(val) => {
12744                    if last_off == offset {
12745                        stack.push(("DiffservMode", last_off));
12746                        break;
12747                    }
12748                }
12749                CakeAttrs::Atm(val) => {
12750                    if last_off == offset {
12751                        stack.push(("Atm", last_off));
12752                        break;
12753                    }
12754                }
12755                CakeAttrs::FlowMode(val) => {
12756                    if last_off == offset {
12757                        stack.push(("FlowMode", last_off));
12758                        break;
12759                    }
12760                }
12761                CakeAttrs::Overhead(val) => {
12762                    if last_off == offset {
12763                        stack.push(("Overhead", last_off));
12764                        break;
12765                    }
12766                }
12767                CakeAttrs::Rtt(val) => {
12768                    if last_off == offset {
12769                        stack.push(("Rtt", last_off));
12770                        break;
12771                    }
12772                }
12773                CakeAttrs::Target(val) => {
12774                    if last_off == offset {
12775                        stack.push(("Target", last_off));
12776                        break;
12777                    }
12778                }
12779                CakeAttrs::Autorate(val) => {
12780                    if last_off == offset {
12781                        stack.push(("Autorate", last_off));
12782                        break;
12783                    }
12784                }
12785                CakeAttrs::Memory(val) => {
12786                    if last_off == offset {
12787                        stack.push(("Memory", last_off));
12788                        break;
12789                    }
12790                }
12791                CakeAttrs::Nat(val) => {
12792                    if last_off == offset {
12793                        stack.push(("Nat", last_off));
12794                        break;
12795                    }
12796                }
12797                CakeAttrs::Raw(val) => {
12798                    if last_off == offset {
12799                        stack.push(("Raw", last_off));
12800                        break;
12801                    }
12802                }
12803                CakeAttrs::Wash(val) => {
12804                    if last_off == offset {
12805                        stack.push(("Wash", last_off));
12806                        break;
12807                    }
12808                }
12809                CakeAttrs::Mpu(val) => {
12810                    if last_off == offset {
12811                        stack.push(("Mpu", last_off));
12812                        break;
12813                    }
12814                }
12815                CakeAttrs::Ingress(val) => {
12816                    if last_off == offset {
12817                        stack.push(("Ingress", last_off));
12818                        break;
12819                    }
12820                }
12821                CakeAttrs::AckFilter(val) => {
12822                    if last_off == offset {
12823                        stack.push(("AckFilter", last_off));
12824                        break;
12825                    }
12826                }
12827                CakeAttrs::SplitGso(val) => {
12828                    if last_off == offset {
12829                        stack.push(("SplitGso", last_off));
12830                        break;
12831                    }
12832                }
12833                CakeAttrs::Fwmark(val) => {
12834                    if last_off == offset {
12835                        stack.push(("Fwmark", last_off));
12836                        break;
12837                    }
12838                }
12839                _ => {}
12840            };
12841            last_off = cur + attrs.pos;
12842        }
12843        if !stack.is_empty() {
12844            stack.push(("CakeAttrs", cur));
12845        }
12846        (stack, None)
12847    }
12848}
12849#[derive(Clone)]
12850pub enum CakeStatsAttrs<'a> {
12851    Pad(&'a [u8]),
12852    CapacityEstimate64(u64),
12853    MemoryLimit(u32),
12854    MemoryUsed(u32),
12855    AvgNetoff(u32),
12856    MinNetlen(u32),
12857    MaxNetlen(u32),
12858    MinAdjlen(u32),
12859    MaxAdjlen(u32),
12860    TinStats(IterableArrayCakeTinStatsAttrs<'a>),
12861    Deficit(i32),
12862    CobaltCount(u32),
12863    Dropping(u32),
12864    DropNextUs(i32),
12865    PDrop(u32),
12866    BlueTimerUs(i32),
12867    ActiveQueues(u32),
12868}
12869impl<'a> IterableCakeStatsAttrs<'a> {
12870    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
12871        let mut iter = self.clone();
12872        iter.pos = 0;
12873        for attr in iter {
12874            if let CakeStatsAttrs::Pad(val) = attr? {
12875                return Ok(val);
12876            }
12877        }
12878        Err(ErrorContext::new_missing(
12879            "CakeStatsAttrs",
12880            "Pad",
12881            self.orig_loc,
12882            self.buf.as_ptr() as usize,
12883        ))
12884    }
12885    pub fn get_capacity_estimate64(&self) -> Result<u64, ErrorContext> {
12886        let mut iter = self.clone();
12887        iter.pos = 0;
12888        for attr in iter {
12889            if let CakeStatsAttrs::CapacityEstimate64(val) = attr? {
12890                return Ok(val);
12891            }
12892        }
12893        Err(ErrorContext::new_missing(
12894            "CakeStatsAttrs",
12895            "CapacityEstimate64",
12896            self.orig_loc,
12897            self.buf.as_ptr() as usize,
12898        ))
12899    }
12900    pub fn get_memory_limit(&self) -> Result<u32, ErrorContext> {
12901        let mut iter = self.clone();
12902        iter.pos = 0;
12903        for attr in iter {
12904            if let CakeStatsAttrs::MemoryLimit(val) = attr? {
12905                return Ok(val);
12906            }
12907        }
12908        Err(ErrorContext::new_missing(
12909            "CakeStatsAttrs",
12910            "MemoryLimit",
12911            self.orig_loc,
12912            self.buf.as_ptr() as usize,
12913        ))
12914    }
12915    pub fn get_memory_used(&self) -> Result<u32, ErrorContext> {
12916        let mut iter = self.clone();
12917        iter.pos = 0;
12918        for attr in iter {
12919            if let CakeStatsAttrs::MemoryUsed(val) = attr? {
12920                return Ok(val);
12921            }
12922        }
12923        Err(ErrorContext::new_missing(
12924            "CakeStatsAttrs",
12925            "MemoryUsed",
12926            self.orig_loc,
12927            self.buf.as_ptr() as usize,
12928        ))
12929    }
12930    pub fn get_avg_netoff(&self) -> Result<u32, ErrorContext> {
12931        let mut iter = self.clone();
12932        iter.pos = 0;
12933        for attr in iter {
12934            if let CakeStatsAttrs::AvgNetoff(val) = attr? {
12935                return Ok(val);
12936            }
12937        }
12938        Err(ErrorContext::new_missing(
12939            "CakeStatsAttrs",
12940            "AvgNetoff",
12941            self.orig_loc,
12942            self.buf.as_ptr() as usize,
12943        ))
12944    }
12945    pub fn get_min_netlen(&self) -> Result<u32, ErrorContext> {
12946        let mut iter = self.clone();
12947        iter.pos = 0;
12948        for attr in iter {
12949            if let CakeStatsAttrs::MinNetlen(val) = attr? {
12950                return Ok(val);
12951            }
12952        }
12953        Err(ErrorContext::new_missing(
12954            "CakeStatsAttrs",
12955            "MinNetlen",
12956            self.orig_loc,
12957            self.buf.as_ptr() as usize,
12958        ))
12959    }
12960    pub fn get_max_netlen(&self) -> Result<u32, ErrorContext> {
12961        let mut iter = self.clone();
12962        iter.pos = 0;
12963        for attr in iter {
12964            if let CakeStatsAttrs::MaxNetlen(val) = attr? {
12965                return Ok(val);
12966            }
12967        }
12968        Err(ErrorContext::new_missing(
12969            "CakeStatsAttrs",
12970            "MaxNetlen",
12971            self.orig_loc,
12972            self.buf.as_ptr() as usize,
12973        ))
12974    }
12975    pub fn get_min_adjlen(&self) -> Result<u32, ErrorContext> {
12976        let mut iter = self.clone();
12977        iter.pos = 0;
12978        for attr in iter {
12979            if let CakeStatsAttrs::MinAdjlen(val) = attr? {
12980                return Ok(val);
12981            }
12982        }
12983        Err(ErrorContext::new_missing(
12984            "CakeStatsAttrs",
12985            "MinAdjlen",
12986            self.orig_loc,
12987            self.buf.as_ptr() as usize,
12988        ))
12989    }
12990    pub fn get_max_adjlen(&self) -> Result<u32, ErrorContext> {
12991        let mut iter = self.clone();
12992        iter.pos = 0;
12993        for attr in iter {
12994            if let CakeStatsAttrs::MaxAdjlen(val) = attr? {
12995                return Ok(val);
12996            }
12997        }
12998        Err(ErrorContext::new_missing(
12999            "CakeStatsAttrs",
13000            "MaxAdjlen",
13001            self.orig_loc,
13002            self.buf.as_ptr() as usize,
13003        ))
13004    }
13005    pub fn get_tin_stats(
13006        &self,
13007    ) -> Result<
13008        ArrayIterable<IterableArrayCakeTinStatsAttrs<'a>, IterableCakeTinStatsAttrs<'a>>,
13009        ErrorContext,
13010    > {
13011        for attr in self.clone() {
13012            if let CakeStatsAttrs::TinStats(val) = attr? {
13013                return Ok(ArrayIterable::new(val));
13014            }
13015        }
13016        Err(ErrorContext::new_missing(
13017            "CakeStatsAttrs",
13018            "TinStats",
13019            self.orig_loc,
13020            self.buf.as_ptr() as usize,
13021        ))
13022    }
13023    pub fn get_deficit(&self) -> Result<i32, ErrorContext> {
13024        let mut iter = self.clone();
13025        iter.pos = 0;
13026        for attr in iter {
13027            if let CakeStatsAttrs::Deficit(val) = attr? {
13028                return Ok(val);
13029            }
13030        }
13031        Err(ErrorContext::new_missing(
13032            "CakeStatsAttrs",
13033            "Deficit",
13034            self.orig_loc,
13035            self.buf.as_ptr() as usize,
13036        ))
13037    }
13038    pub fn get_cobalt_count(&self) -> Result<u32, ErrorContext> {
13039        let mut iter = self.clone();
13040        iter.pos = 0;
13041        for attr in iter {
13042            if let CakeStatsAttrs::CobaltCount(val) = attr? {
13043                return Ok(val);
13044            }
13045        }
13046        Err(ErrorContext::new_missing(
13047            "CakeStatsAttrs",
13048            "CobaltCount",
13049            self.orig_loc,
13050            self.buf.as_ptr() as usize,
13051        ))
13052    }
13053    pub fn get_dropping(&self) -> Result<u32, ErrorContext> {
13054        let mut iter = self.clone();
13055        iter.pos = 0;
13056        for attr in iter {
13057            if let CakeStatsAttrs::Dropping(val) = attr? {
13058                return Ok(val);
13059            }
13060        }
13061        Err(ErrorContext::new_missing(
13062            "CakeStatsAttrs",
13063            "Dropping",
13064            self.orig_loc,
13065            self.buf.as_ptr() as usize,
13066        ))
13067    }
13068    pub fn get_drop_next_us(&self) -> Result<i32, ErrorContext> {
13069        let mut iter = self.clone();
13070        iter.pos = 0;
13071        for attr in iter {
13072            if let CakeStatsAttrs::DropNextUs(val) = attr? {
13073                return Ok(val);
13074            }
13075        }
13076        Err(ErrorContext::new_missing(
13077            "CakeStatsAttrs",
13078            "DropNextUs",
13079            self.orig_loc,
13080            self.buf.as_ptr() as usize,
13081        ))
13082    }
13083    pub fn get_p_drop(&self) -> Result<u32, ErrorContext> {
13084        let mut iter = self.clone();
13085        iter.pos = 0;
13086        for attr in iter {
13087            if let CakeStatsAttrs::PDrop(val) = attr? {
13088                return Ok(val);
13089            }
13090        }
13091        Err(ErrorContext::new_missing(
13092            "CakeStatsAttrs",
13093            "PDrop",
13094            self.orig_loc,
13095            self.buf.as_ptr() as usize,
13096        ))
13097    }
13098    pub fn get_blue_timer_us(&self) -> Result<i32, ErrorContext> {
13099        let mut iter = self.clone();
13100        iter.pos = 0;
13101        for attr in iter {
13102            if let CakeStatsAttrs::BlueTimerUs(val) = attr? {
13103                return Ok(val);
13104            }
13105        }
13106        Err(ErrorContext::new_missing(
13107            "CakeStatsAttrs",
13108            "BlueTimerUs",
13109            self.orig_loc,
13110            self.buf.as_ptr() as usize,
13111        ))
13112    }
13113    pub fn get_active_queues(&self) -> Result<u32, ErrorContext> {
13114        let mut iter = self.clone();
13115        iter.pos = 0;
13116        for attr in iter {
13117            if let CakeStatsAttrs::ActiveQueues(val) = attr? {
13118                return Ok(val);
13119            }
13120        }
13121        Err(ErrorContext::new_missing(
13122            "CakeStatsAttrs",
13123            "ActiveQueues",
13124            self.orig_loc,
13125            self.buf.as_ptr() as usize,
13126        ))
13127    }
13128}
13129impl<'a> CakeTinStatsAttrs<'a> {
13130    pub fn new_array(buf: &[u8]) -> IterableArrayCakeTinStatsAttrs<'_> {
13131        IterableArrayCakeTinStatsAttrs::with_loc(buf, buf.as_ptr() as usize)
13132    }
13133}
13134#[derive(Clone, Copy, Default)]
13135pub struct IterableArrayCakeTinStatsAttrs<'a> {
13136    buf: &'a [u8],
13137    pos: usize,
13138    orig_loc: usize,
13139}
13140impl<'a> IterableArrayCakeTinStatsAttrs<'a> {
13141    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13142        Self {
13143            buf,
13144            pos: 0,
13145            orig_loc,
13146        }
13147    }
13148    pub fn get_buf(&self) -> &'a [u8] {
13149        self.buf
13150    }
13151}
13152impl<'a> Iterator for IterableArrayCakeTinStatsAttrs<'a> {
13153    type Item = Result<IterableCakeTinStatsAttrs<'a>, ErrorContext>;
13154    fn next(&mut self) -> Option<Self::Item> {
13155        if self.buf.len() == self.pos {
13156            return None;
13157        }
13158        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
13159            {
13160                return Some(Ok(IterableCakeTinStatsAttrs::with_loc(next, self.orig_loc)));
13161            }
13162        }
13163        Some(Err(ErrorContext::new(
13164            "CakeTinStatsAttrs",
13165            None,
13166            self.orig_loc,
13167            self.buf.as_ptr().wrapping_add(self.pos) as usize,
13168        )))
13169    }
13170}
13171impl CakeStatsAttrs<'_> {
13172    pub fn new<'a>(buf: &'a [u8]) -> IterableCakeStatsAttrs<'a> {
13173        IterableCakeStatsAttrs::with_loc(buf, buf.as_ptr() as usize)
13174    }
13175    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13176        let res = match r#type {
13177            1u16 => "Pad",
13178            2u16 => "CapacityEstimate64",
13179            3u16 => "MemoryLimit",
13180            4u16 => "MemoryUsed",
13181            5u16 => "AvgNetoff",
13182            6u16 => "MinNetlen",
13183            7u16 => "MaxNetlen",
13184            8u16 => "MinAdjlen",
13185            9u16 => "MaxAdjlen",
13186            10u16 => "TinStats",
13187            11u16 => "Deficit",
13188            12u16 => "CobaltCount",
13189            13u16 => "Dropping",
13190            14u16 => "DropNextUs",
13191            15u16 => "PDrop",
13192            16u16 => "BlueTimerUs",
13193            17u16 => "ActiveQueues",
13194            _ => return None,
13195        };
13196        Some(res)
13197    }
13198}
13199#[derive(Clone, Copy, Default)]
13200pub struct IterableCakeStatsAttrs<'a> {
13201    buf: &'a [u8],
13202    pos: usize,
13203    orig_loc: usize,
13204}
13205impl<'a> IterableCakeStatsAttrs<'a> {
13206    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13207        Self {
13208            buf,
13209            pos: 0,
13210            orig_loc,
13211        }
13212    }
13213    pub fn get_buf(&self) -> &'a [u8] {
13214        self.buf
13215    }
13216}
13217impl<'a> Iterator for IterableCakeStatsAttrs<'a> {
13218    type Item = Result<CakeStatsAttrs<'a>, ErrorContext>;
13219    fn next(&mut self) -> Option<Self::Item> {
13220        let pos = self.pos;
13221        let mut r#type;
13222        loop {
13223            r#type = None;
13224            if self.buf.len() == self.pos {
13225                return None;
13226            }
13227            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
13228                break;
13229            };
13230            r#type = Some(header.r#type);
13231            let res = match header.r#type {
13232                1u16 => CakeStatsAttrs::Pad({
13233                    let res = Some(next);
13234                    let Some(val) = res else { break };
13235                    val
13236                }),
13237                2u16 => CakeStatsAttrs::CapacityEstimate64({
13238                    let res = parse_u64(next);
13239                    let Some(val) = res else { break };
13240                    val
13241                }),
13242                3u16 => CakeStatsAttrs::MemoryLimit({
13243                    let res = parse_u32(next);
13244                    let Some(val) = res else { break };
13245                    val
13246                }),
13247                4u16 => CakeStatsAttrs::MemoryUsed({
13248                    let res = parse_u32(next);
13249                    let Some(val) = res else { break };
13250                    val
13251                }),
13252                5u16 => CakeStatsAttrs::AvgNetoff({
13253                    let res = parse_u32(next);
13254                    let Some(val) = res else { break };
13255                    val
13256                }),
13257                6u16 => CakeStatsAttrs::MinNetlen({
13258                    let res = parse_u32(next);
13259                    let Some(val) = res else { break };
13260                    val
13261                }),
13262                7u16 => CakeStatsAttrs::MaxNetlen({
13263                    let res = parse_u32(next);
13264                    let Some(val) = res else { break };
13265                    val
13266                }),
13267                8u16 => CakeStatsAttrs::MinAdjlen({
13268                    let res = parse_u32(next);
13269                    let Some(val) = res else { break };
13270                    val
13271                }),
13272                9u16 => CakeStatsAttrs::MaxAdjlen({
13273                    let res = parse_u32(next);
13274                    let Some(val) = res else { break };
13275                    val
13276                }),
13277                10u16 => CakeStatsAttrs::TinStats({
13278                    let res = Some(IterableArrayCakeTinStatsAttrs::with_loc(
13279                        next,
13280                        self.orig_loc,
13281                    ));
13282                    let Some(val) = res else { break };
13283                    val
13284                }),
13285                11u16 => CakeStatsAttrs::Deficit({
13286                    let res = parse_i32(next);
13287                    let Some(val) = res else { break };
13288                    val
13289                }),
13290                12u16 => CakeStatsAttrs::CobaltCount({
13291                    let res = parse_u32(next);
13292                    let Some(val) = res else { break };
13293                    val
13294                }),
13295                13u16 => CakeStatsAttrs::Dropping({
13296                    let res = parse_u32(next);
13297                    let Some(val) = res else { break };
13298                    val
13299                }),
13300                14u16 => CakeStatsAttrs::DropNextUs({
13301                    let res = parse_i32(next);
13302                    let Some(val) = res else { break };
13303                    val
13304                }),
13305                15u16 => CakeStatsAttrs::PDrop({
13306                    let res = parse_u32(next);
13307                    let Some(val) = res else { break };
13308                    val
13309                }),
13310                16u16 => CakeStatsAttrs::BlueTimerUs({
13311                    let res = parse_i32(next);
13312                    let Some(val) = res else { break };
13313                    val
13314                }),
13315                17u16 => CakeStatsAttrs::ActiveQueues({
13316                    let res = parse_u32(next);
13317                    let Some(val) = res else { break };
13318                    val
13319                }),
13320                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
13321                n => continue,
13322            };
13323            return Some(Ok(res));
13324        }
13325        Some(Err(ErrorContext::new(
13326            "CakeStatsAttrs",
13327            r#type.and_then(|t| CakeStatsAttrs::attr_from_type(t)),
13328            self.orig_loc,
13329            self.buf.as_ptr().wrapping_add(pos) as usize,
13330        )))
13331    }
13332}
13333impl std::fmt::Debug for IterableArrayCakeTinStatsAttrs<'_> {
13334    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13335        fmt.debug_list()
13336            .entries(self.clone().map(FlattenErrorContext))
13337            .finish()
13338    }
13339}
13340impl<'a> std::fmt::Debug for IterableCakeStatsAttrs<'_> {
13341    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13342        let mut fmt = f.debug_struct("CakeStatsAttrs");
13343        for attr in self.clone() {
13344            let attr = match attr {
13345                Ok(a) => a,
13346                Err(err) => {
13347                    fmt.finish()?;
13348                    f.write_str("Err(")?;
13349                    err.fmt(f)?;
13350                    return f.write_str(")");
13351                }
13352            };
13353            match attr {
13354                CakeStatsAttrs::Pad(val) => fmt.field("Pad", &val),
13355                CakeStatsAttrs::CapacityEstimate64(val) => fmt.field("CapacityEstimate64", &val),
13356                CakeStatsAttrs::MemoryLimit(val) => fmt.field("MemoryLimit", &val),
13357                CakeStatsAttrs::MemoryUsed(val) => fmt.field("MemoryUsed", &val),
13358                CakeStatsAttrs::AvgNetoff(val) => fmt.field("AvgNetoff", &val),
13359                CakeStatsAttrs::MinNetlen(val) => fmt.field("MinNetlen", &val),
13360                CakeStatsAttrs::MaxNetlen(val) => fmt.field("MaxNetlen", &val),
13361                CakeStatsAttrs::MinAdjlen(val) => fmt.field("MinAdjlen", &val),
13362                CakeStatsAttrs::MaxAdjlen(val) => fmt.field("MaxAdjlen", &val),
13363                CakeStatsAttrs::TinStats(val) => fmt.field("TinStats", &val),
13364                CakeStatsAttrs::Deficit(val) => fmt.field("Deficit", &val),
13365                CakeStatsAttrs::CobaltCount(val) => fmt.field("CobaltCount", &val),
13366                CakeStatsAttrs::Dropping(val) => fmt.field("Dropping", &val),
13367                CakeStatsAttrs::DropNextUs(val) => fmt.field("DropNextUs", &val),
13368                CakeStatsAttrs::PDrop(val) => fmt.field("PDrop", &val),
13369                CakeStatsAttrs::BlueTimerUs(val) => fmt.field("BlueTimerUs", &val),
13370                CakeStatsAttrs::ActiveQueues(val) => fmt.field("ActiveQueues", &val),
13371            };
13372        }
13373        fmt.finish()
13374    }
13375}
13376impl IterableCakeStatsAttrs<'_> {
13377    pub fn lookup_attr(
13378        &self,
13379        offset: usize,
13380        missing_type: Option<u16>,
13381    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13382        let mut stack = Vec::new();
13383        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13384        if missing_type.is_some() && cur == offset {
13385            stack.push(("CakeStatsAttrs", offset));
13386            return (
13387                stack,
13388                missing_type.and_then(|t| CakeStatsAttrs::attr_from_type(t)),
13389            );
13390        }
13391        if cur > offset || cur + self.buf.len() < offset {
13392            return (stack, None);
13393        }
13394        let mut attrs = self.clone();
13395        let mut last_off = cur + attrs.pos;
13396        let mut missing = None;
13397        while let Some(attr) = attrs.next() {
13398            let Ok(attr) = attr else { break };
13399            match attr {
13400                CakeStatsAttrs::Pad(val) => {
13401                    if last_off == offset {
13402                        stack.push(("Pad", last_off));
13403                        break;
13404                    }
13405                }
13406                CakeStatsAttrs::CapacityEstimate64(val) => {
13407                    if last_off == offset {
13408                        stack.push(("CapacityEstimate64", last_off));
13409                        break;
13410                    }
13411                }
13412                CakeStatsAttrs::MemoryLimit(val) => {
13413                    if last_off == offset {
13414                        stack.push(("MemoryLimit", last_off));
13415                        break;
13416                    }
13417                }
13418                CakeStatsAttrs::MemoryUsed(val) => {
13419                    if last_off == offset {
13420                        stack.push(("MemoryUsed", last_off));
13421                        break;
13422                    }
13423                }
13424                CakeStatsAttrs::AvgNetoff(val) => {
13425                    if last_off == offset {
13426                        stack.push(("AvgNetoff", last_off));
13427                        break;
13428                    }
13429                }
13430                CakeStatsAttrs::MinNetlen(val) => {
13431                    if last_off == offset {
13432                        stack.push(("MinNetlen", last_off));
13433                        break;
13434                    }
13435                }
13436                CakeStatsAttrs::MaxNetlen(val) => {
13437                    if last_off == offset {
13438                        stack.push(("MaxNetlen", last_off));
13439                        break;
13440                    }
13441                }
13442                CakeStatsAttrs::MinAdjlen(val) => {
13443                    if last_off == offset {
13444                        stack.push(("MinAdjlen", last_off));
13445                        break;
13446                    }
13447                }
13448                CakeStatsAttrs::MaxAdjlen(val) => {
13449                    if last_off == offset {
13450                        stack.push(("MaxAdjlen", last_off));
13451                        break;
13452                    }
13453                }
13454                CakeStatsAttrs::TinStats(val) => {
13455                    for entry in val {
13456                        let Ok(attr) = entry else { break };
13457                        (stack, missing) = attr.lookup_attr(offset, missing_type);
13458                        if !stack.is_empty() {
13459                            break;
13460                        }
13461                    }
13462                    if !stack.is_empty() {
13463                        stack.push(("TinStats", last_off));
13464                        break;
13465                    }
13466                }
13467                CakeStatsAttrs::Deficit(val) => {
13468                    if last_off == offset {
13469                        stack.push(("Deficit", last_off));
13470                        break;
13471                    }
13472                }
13473                CakeStatsAttrs::CobaltCount(val) => {
13474                    if last_off == offset {
13475                        stack.push(("CobaltCount", last_off));
13476                        break;
13477                    }
13478                }
13479                CakeStatsAttrs::Dropping(val) => {
13480                    if last_off == offset {
13481                        stack.push(("Dropping", last_off));
13482                        break;
13483                    }
13484                }
13485                CakeStatsAttrs::DropNextUs(val) => {
13486                    if last_off == offset {
13487                        stack.push(("DropNextUs", last_off));
13488                        break;
13489                    }
13490                }
13491                CakeStatsAttrs::PDrop(val) => {
13492                    if last_off == offset {
13493                        stack.push(("PDrop", last_off));
13494                        break;
13495                    }
13496                }
13497                CakeStatsAttrs::BlueTimerUs(val) => {
13498                    if last_off == offset {
13499                        stack.push(("BlueTimerUs", last_off));
13500                        break;
13501                    }
13502                }
13503                CakeStatsAttrs::ActiveQueues(val) => {
13504                    if last_off == offset {
13505                        stack.push(("ActiveQueues", last_off));
13506                        break;
13507                    }
13508                }
13509                _ => {}
13510            };
13511            last_off = cur + attrs.pos;
13512        }
13513        if !stack.is_empty() {
13514            stack.push(("CakeStatsAttrs", cur));
13515        }
13516        (stack, missing)
13517    }
13518}
13519#[derive(Clone)]
13520pub enum CakeTinStatsAttrs<'a> {
13521    Pad(&'a [u8]),
13522    SentPackets(u32),
13523    SentBytes64(u64),
13524    DroppedPackets(u32),
13525    DroppedBytes64(u64),
13526    AcksDroppedPackets(u32),
13527    AcksDroppedBytes64(u64),
13528    EcnMarkedPackets(u32),
13529    EcnMarkedBytes64(u64),
13530    BacklogPackets(u32),
13531    BacklogBytes(u32),
13532    ThresholdRate64(u64),
13533    TargetUs(u32),
13534    IntervalUs(u32),
13535    WayIndirectHits(u32),
13536    WayMisses(u32),
13537    WayCollisions(u32),
13538    PeakDelayUs(u32),
13539    AvgDelayUs(u32),
13540    BaseDelayUs(u32),
13541    SparseFlows(u32),
13542    BulkFlows(u32),
13543    UnresponsiveFlows(u32),
13544    MaxSkblen(u32),
13545    FlowQuantum(u32),
13546}
13547impl<'a> IterableCakeTinStatsAttrs<'a> {
13548    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
13549        let mut iter = self.clone();
13550        iter.pos = 0;
13551        for attr in iter {
13552            if let CakeTinStatsAttrs::Pad(val) = attr? {
13553                return Ok(val);
13554            }
13555        }
13556        Err(ErrorContext::new_missing(
13557            "CakeTinStatsAttrs",
13558            "Pad",
13559            self.orig_loc,
13560            self.buf.as_ptr() as usize,
13561        ))
13562    }
13563    pub fn get_sent_packets(&self) -> Result<u32, ErrorContext> {
13564        let mut iter = self.clone();
13565        iter.pos = 0;
13566        for attr in iter {
13567            if let CakeTinStatsAttrs::SentPackets(val) = attr? {
13568                return Ok(val);
13569            }
13570        }
13571        Err(ErrorContext::new_missing(
13572            "CakeTinStatsAttrs",
13573            "SentPackets",
13574            self.orig_loc,
13575            self.buf.as_ptr() as usize,
13576        ))
13577    }
13578    pub fn get_sent_bytes64(&self) -> Result<u64, ErrorContext> {
13579        let mut iter = self.clone();
13580        iter.pos = 0;
13581        for attr in iter {
13582            if let CakeTinStatsAttrs::SentBytes64(val) = attr? {
13583                return Ok(val);
13584            }
13585        }
13586        Err(ErrorContext::new_missing(
13587            "CakeTinStatsAttrs",
13588            "SentBytes64",
13589            self.orig_loc,
13590            self.buf.as_ptr() as usize,
13591        ))
13592    }
13593    pub fn get_dropped_packets(&self) -> Result<u32, ErrorContext> {
13594        let mut iter = self.clone();
13595        iter.pos = 0;
13596        for attr in iter {
13597            if let CakeTinStatsAttrs::DroppedPackets(val) = attr? {
13598                return Ok(val);
13599            }
13600        }
13601        Err(ErrorContext::new_missing(
13602            "CakeTinStatsAttrs",
13603            "DroppedPackets",
13604            self.orig_loc,
13605            self.buf.as_ptr() as usize,
13606        ))
13607    }
13608    pub fn get_dropped_bytes64(&self) -> Result<u64, ErrorContext> {
13609        let mut iter = self.clone();
13610        iter.pos = 0;
13611        for attr in iter {
13612            if let CakeTinStatsAttrs::DroppedBytes64(val) = attr? {
13613                return Ok(val);
13614            }
13615        }
13616        Err(ErrorContext::new_missing(
13617            "CakeTinStatsAttrs",
13618            "DroppedBytes64",
13619            self.orig_loc,
13620            self.buf.as_ptr() as usize,
13621        ))
13622    }
13623    pub fn get_acks_dropped_packets(&self) -> Result<u32, ErrorContext> {
13624        let mut iter = self.clone();
13625        iter.pos = 0;
13626        for attr in iter {
13627            if let CakeTinStatsAttrs::AcksDroppedPackets(val) = attr? {
13628                return Ok(val);
13629            }
13630        }
13631        Err(ErrorContext::new_missing(
13632            "CakeTinStatsAttrs",
13633            "AcksDroppedPackets",
13634            self.orig_loc,
13635            self.buf.as_ptr() as usize,
13636        ))
13637    }
13638    pub fn get_acks_dropped_bytes64(&self) -> Result<u64, ErrorContext> {
13639        let mut iter = self.clone();
13640        iter.pos = 0;
13641        for attr in iter {
13642            if let CakeTinStatsAttrs::AcksDroppedBytes64(val) = attr? {
13643                return Ok(val);
13644            }
13645        }
13646        Err(ErrorContext::new_missing(
13647            "CakeTinStatsAttrs",
13648            "AcksDroppedBytes64",
13649            self.orig_loc,
13650            self.buf.as_ptr() as usize,
13651        ))
13652    }
13653    pub fn get_ecn_marked_packets(&self) -> Result<u32, ErrorContext> {
13654        let mut iter = self.clone();
13655        iter.pos = 0;
13656        for attr in iter {
13657            if let CakeTinStatsAttrs::EcnMarkedPackets(val) = attr? {
13658                return Ok(val);
13659            }
13660        }
13661        Err(ErrorContext::new_missing(
13662            "CakeTinStatsAttrs",
13663            "EcnMarkedPackets",
13664            self.orig_loc,
13665            self.buf.as_ptr() as usize,
13666        ))
13667    }
13668    pub fn get_ecn_marked_bytes64(&self) -> Result<u64, ErrorContext> {
13669        let mut iter = self.clone();
13670        iter.pos = 0;
13671        for attr in iter {
13672            if let CakeTinStatsAttrs::EcnMarkedBytes64(val) = attr? {
13673                return Ok(val);
13674            }
13675        }
13676        Err(ErrorContext::new_missing(
13677            "CakeTinStatsAttrs",
13678            "EcnMarkedBytes64",
13679            self.orig_loc,
13680            self.buf.as_ptr() as usize,
13681        ))
13682    }
13683    pub fn get_backlog_packets(&self) -> Result<u32, ErrorContext> {
13684        let mut iter = self.clone();
13685        iter.pos = 0;
13686        for attr in iter {
13687            if let CakeTinStatsAttrs::BacklogPackets(val) = attr? {
13688                return Ok(val);
13689            }
13690        }
13691        Err(ErrorContext::new_missing(
13692            "CakeTinStatsAttrs",
13693            "BacklogPackets",
13694            self.orig_loc,
13695            self.buf.as_ptr() as usize,
13696        ))
13697    }
13698    pub fn get_backlog_bytes(&self) -> Result<u32, ErrorContext> {
13699        let mut iter = self.clone();
13700        iter.pos = 0;
13701        for attr in iter {
13702            if let CakeTinStatsAttrs::BacklogBytes(val) = attr? {
13703                return Ok(val);
13704            }
13705        }
13706        Err(ErrorContext::new_missing(
13707            "CakeTinStatsAttrs",
13708            "BacklogBytes",
13709            self.orig_loc,
13710            self.buf.as_ptr() as usize,
13711        ))
13712    }
13713    pub fn get_threshold_rate64(&self) -> Result<u64, ErrorContext> {
13714        let mut iter = self.clone();
13715        iter.pos = 0;
13716        for attr in iter {
13717            if let CakeTinStatsAttrs::ThresholdRate64(val) = attr? {
13718                return Ok(val);
13719            }
13720        }
13721        Err(ErrorContext::new_missing(
13722            "CakeTinStatsAttrs",
13723            "ThresholdRate64",
13724            self.orig_loc,
13725            self.buf.as_ptr() as usize,
13726        ))
13727    }
13728    pub fn get_target_us(&self) -> Result<u32, ErrorContext> {
13729        let mut iter = self.clone();
13730        iter.pos = 0;
13731        for attr in iter {
13732            if let CakeTinStatsAttrs::TargetUs(val) = attr? {
13733                return Ok(val);
13734            }
13735        }
13736        Err(ErrorContext::new_missing(
13737            "CakeTinStatsAttrs",
13738            "TargetUs",
13739            self.orig_loc,
13740            self.buf.as_ptr() as usize,
13741        ))
13742    }
13743    pub fn get_interval_us(&self) -> Result<u32, ErrorContext> {
13744        let mut iter = self.clone();
13745        iter.pos = 0;
13746        for attr in iter {
13747            if let CakeTinStatsAttrs::IntervalUs(val) = attr? {
13748                return Ok(val);
13749            }
13750        }
13751        Err(ErrorContext::new_missing(
13752            "CakeTinStatsAttrs",
13753            "IntervalUs",
13754            self.orig_loc,
13755            self.buf.as_ptr() as usize,
13756        ))
13757    }
13758    pub fn get_way_indirect_hits(&self) -> Result<u32, ErrorContext> {
13759        let mut iter = self.clone();
13760        iter.pos = 0;
13761        for attr in iter {
13762            if let CakeTinStatsAttrs::WayIndirectHits(val) = attr? {
13763                return Ok(val);
13764            }
13765        }
13766        Err(ErrorContext::new_missing(
13767            "CakeTinStatsAttrs",
13768            "WayIndirectHits",
13769            self.orig_loc,
13770            self.buf.as_ptr() as usize,
13771        ))
13772    }
13773    pub fn get_way_misses(&self) -> Result<u32, ErrorContext> {
13774        let mut iter = self.clone();
13775        iter.pos = 0;
13776        for attr in iter {
13777            if let CakeTinStatsAttrs::WayMisses(val) = attr? {
13778                return Ok(val);
13779            }
13780        }
13781        Err(ErrorContext::new_missing(
13782            "CakeTinStatsAttrs",
13783            "WayMisses",
13784            self.orig_loc,
13785            self.buf.as_ptr() as usize,
13786        ))
13787    }
13788    pub fn get_way_collisions(&self) -> Result<u32, ErrorContext> {
13789        let mut iter = self.clone();
13790        iter.pos = 0;
13791        for attr in iter {
13792            if let CakeTinStatsAttrs::WayCollisions(val) = attr? {
13793                return Ok(val);
13794            }
13795        }
13796        Err(ErrorContext::new_missing(
13797            "CakeTinStatsAttrs",
13798            "WayCollisions",
13799            self.orig_loc,
13800            self.buf.as_ptr() as usize,
13801        ))
13802    }
13803    pub fn get_peak_delay_us(&self) -> Result<u32, ErrorContext> {
13804        let mut iter = self.clone();
13805        iter.pos = 0;
13806        for attr in iter {
13807            if let CakeTinStatsAttrs::PeakDelayUs(val) = attr? {
13808                return Ok(val);
13809            }
13810        }
13811        Err(ErrorContext::new_missing(
13812            "CakeTinStatsAttrs",
13813            "PeakDelayUs",
13814            self.orig_loc,
13815            self.buf.as_ptr() as usize,
13816        ))
13817    }
13818    pub fn get_avg_delay_us(&self) -> Result<u32, ErrorContext> {
13819        let mut iter = self.clone();
13820        iter.pos = 0;
13821        for attr in iter {
13822            if let CakeTinStatsAttrs::AvgDelayUs(val) = attr? {
13823                return Ok(val);
13824            }
13825        }
13826        Err(ErrorContext::new_missing(
13827            "CakeTinStatsAttrs",
13828            "AvgDelayUs",
13829            self.orig_loc,
13830            self.buf.as_ptr() as usize,
13831        ))
13832    }
13833    pub fn get_base_delay_us(&self) -> Result<u32, ErrorContext> {
13834        let mut iter = self.clone();
13835        iter.pos = 0;
13836        for attr in iter {
13837            if let CakeTinStatsAttrs::BaseDelayUs(val) = attr? {
13838                return Ok(val);
13839            }
13840        }
13841        Err(ErrorContext::new_missing(
13842            "CakeTinStatsAttrs",
13843            "BaseDelayUs",
13844            self.orig_loc,
13845            self.buf.as_ptr() as usize,
13846        ))
13847    }
13848    pub fn get_sparse_flows(&self) -> Result<u32, ErrorContext> {
13849        let mut iter = self.clone();
13850        iter.pos = 0;
13851        for attr in iter {
13852            if let CakeTinStatsAttrs::SparseFlows(val) = attr? {
13853                return Ok(val);
13854            }
13855        }
13856        Err(ErrorContext::new_missing(
13857            "CakeTinStatsAttrs",
13858            "SparseFlows",
13859            self.orig_loc,
13860            self.buf.as_ptr() as usize,
13861        ))
13862    }
13863    pub fn get_bulk_flows(&self) -> Result<u32, ErrorContext> {
13864        let mut iter = self.clone();
13865        iter.pos = 0;
13866        for attr in iter {
13867            if let CakeTinStatsAttrs::BulkFlows(val) = attr? {
13868                return Ok(val);
13869            }
13870        }
13871        Err(ErrorContext::new_missing(
13872            "CakeTinStatsAttrs",
13873            "BulkFlows",
13874            self.orig_loc,
13875            self.buf.as_ptr() as usize,
13876        ))
13877    }
13878    pub fn get_unresponsive_flows(&self) -> Result<u32, ErrorContext> {
13879        let mut iter = self.clone();
13880        iter.pos = 0;
13881        for attr in iter {
13882            if let CakeTinStatsAttrs::UnresponsiveFlows(val) = attr? {
13883                return Ok(val);
13884            }
13885        }
13886        Err(ErrorContext::new_missing(
13887            "CakeTinStatsAttrs",
13888            "UnresponsiveFlows",
13889            self.orig_loc,
13890            self.buf.as_ptr() as usize,
13891        ))
13892    }
13893    pub fn get_max_skblen(&self) -> Result<u32, ErrorContext> {
13894        let mut iter = self.clone();
13895        iter.pos = 0;
13896        for attr in iter {
13897            if let CakeTinStatsAttrs::MaxSkblen(val) = attr? {
13898                return Ok(val);
13899            }
13900        }
13901        Err(ErrorContext::new_missing(
13902            "CakeTinStatsAttrs",
13903            "MaxSkblen",
13904            self.orig_loc,
13905            self.buf.as_ptr() as usize,
13906        ))
13907    }
13908    pub fn get_flow_quantum(&self) -> Result<u32, ErrorContext> {
13909        let mut iter = self.clone();
13910        iter.pos = 0;
13911        for attr in iter {
13912            if let CakeTinStatsAttrs::FlowQuantum(val) = attr? {
13913                return Ok(val);
13914            }
13915        }
13916        Err(ErrorContext::new_missing(
13917            "CakeTinStatsAttrs",
13918            "FlowQuantum",
13919            self.orig_loc,
13920            self.buf.as_ptr() as usize,
13921        ))
13922    }
13923}
13924impl CakeTinStatsAttrs<'_> {
13925    pub fn new<'a>(buf: &'a [u8]) -> IterableCakeTinStatsAttrs<'a> {
13926        IterableCakeTinStatsAttrs::with_loc(buf, buf.as_ptr() as usize)
13927    }
13928    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13929        let res = match r#type {
13930            1u16 => "Pad",
13931            2u16 => "SentPackets",
13932            3u16 => "SentBytes64",
13933            4u16 => "DroppedPackets",
13934            5u16 => "DroppedBytes64",
13935            6u16 => "AcksDroppedPackets",
13936            7u16 => "AcksDroppedBytes64",
13937            8u16 => "EcnMarkedPackets",
13938            9u16 => "EcnMarkedBytes64",
13939            10u16 => "BacklogPackets",
13940            11u16 => "BacklogBytes",
13941            12u16 => "ThresholdRate64",
13942            13u16 => "TargetUs",
13943            14u16 => "IntervalUs",
13944            15u16 => "WayIndirectHits",
13945            16u16 => "WayMisses",
13946            17u16 => "WayCollisions",
13947            18u16 => "PeakDelayUs",
13948            19u16 => "AvgDelayUs",
13949            20u16 => "BaseDelayUs",
13950            21u16 => "SparseFlows",
13951            22u16 => "BulkFlows",
13952            23u16 => "UnresponsiveFlows",
13953            24u16 => "MaxSkblen",
13954            25u16 => "FlowQuantum",
13955            _ => return None,
13956        };
13957        Some(res)
13958    }
13959}
13960#[derive(Clone, Copy, Default)]
13961pub struct IterableCakeTinStatsAttrs<'a> {
13962    buf: &'a [u8],
13963    pos: usize,
13964    orig_loc: usize,
13965}
13966impl<'a> IterableCakeTinStatsAttrs<'a> {
13967    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13968        Self {
13969            buf,
13970            pos: 0,
13971            orig_loc,
13972        }
13973    }
13974    pub fn get_buf(&self) -> &'a [u8] {
13975        self.buf
13976    }
13977}
13978impl<'a> Iterator for IterableCakeTinStatsAttrs<'a> {
13979    type Item = Result<CakeTinStatsAttrs<'a>, ErrorContext>;
13980    fn next(&mut self) -> Option<Self::Item> {
13981        let pos = self.pos;
13982        let mut r#type;
13983        loop {
13984            r#type = None;
13985            if self.buf.len() == self.pos {
13986                return None;
13987            }
13988            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
13989                break;
13990            };
13991            r#type = Some(header.r#type);
13992            let res = match header.r#type {
13993                1u16 => CakeTinStatsAttrs::Pad({
13994                    let res = Some(next);
13995                    let Some(val) = res else { break };
13996                    val
13997                }),
13998                2u16 => CakeTinStatsAttrs::SentPackets({
13999                    let res = parse_u32(next);
14000                    let Some(val) = res else { break };
14001                    val
14002                }),
14003                3u16 => CakeTinStatsAttrs::SentBytes64({
14004                    let res = parse_u64(next);
14005                    let Some(val) = res else { break };
14006                    val
14007                }),
14008                4u16 => CakeTinStatsAttrs::DroppedPackets({
14009                    let res = parse_u32(next);
14010                    let Some(val) = res else { break };
14011                    val
14012                }),
14013                5u16 => CakeTinStatsAttrs::DroppedBytes64({
14014                    let res = parse_u64(next);
14015                    let Some(val) = res else { break };
14016                    val
14017                }),
14018                6u16 => CakeTinStatsAttrs::AcksDroppedPackets({
14019                    let res = parse_u32(next);
14020                    let Some(val) = res else { break };
14021                    val
14022                }),
14023                7u16 => CakeTinStatsAttrs::AcksDroppedBytes64({
14024                    let res = parse_u64(next);
14025                    let Some(val) = res else { break };
14026                    val
14027                }),
14028                8u16 => CakeTinStatsAttrs::EcnMarkedPackets({
14029                    let res = parse_u32(next);
14030                    let Some(val) = res else { break };
14031                    val
14032                }),
14033                9u16 => CakeTinStatsAttrs::EcnMarkedBytes64({
14034                    let res = parse_u64(next);
14035                    let Some(val) = res else { break };
14036                    val
14037                }),
14038                10u16 => CakeTinStatsAttrs::BacklogPackets({
14039                    let res = parse_u32(next);
14040                    let Some(val) = res else { break };
14041                    val
14042                }),
14043                11u16 => CakeTinStatsAttrs::BacklogBytes({
14044                    let res = parse_u32(next);
14045                    let Some(val) = res else { break };
14046                    val
14047                }),
14048                12u16 => CakeTinStatsAttrs::ThresholdRate64({
14049                    let res = parse_u64(next);
14050                    let Some(val) = res else { break };
14051                    val
14052                }),
14053                13u16 => CakeTinStatsAttrs::TargetUs({
14054                    let res = parse_u32(next);
14055                    let Some(val) = res else { break };
14056                    val
14057                }),
14058                14u16 => CakeTinStatsAttrs::IntervalUs({
14059                    let res = parse_u32(next);
14060                    let Some(val) = res else { break };
14061                    val
14062                }),
14063                15u16 => CakeTinStatsAttrs::WayIndirectHits({
14064                    let res = parse_u32(next);
14065                    let Some(val) = res else { break };
14066                    val
14067                }),
14068                16u16 => CakeTinStatsAttrs::WayMisses({
14069                    let res = parse_u32(next);
14070                    let Some(val) = res else { break };
14071                    val
14072                }),
14073                17u16 => CakeTinStatsAttrs::WayCollisions({
14074                    let res = parse_u32(next);
14075                    let Some(val) = res else { break };
14076                    val
14077                }),
14078                18u16 => CakeTinStatsAttrs::PeakDelayUs({
14079                    let res = parse_u32(next);
14080                    let Some(val) = res else { break };
14081                    val
14082                }),
14083                19u16 => CakeTinStatsAttrs::AvgDelayUs({
14084                    let res = parse_u32(next);
14085                    let Some(val) = res else { break };
14086                    val
14087                }),
14088                20u16 => CakeTinStatsAttrs::BaseDelayUs({
14089                    let res = parse_u32(next);
14090                    let Some(val) = res else { break };
14091                    val
14092                }),
14093                21u16 => CakeTinStatsAttrs::SparseFlows({
14094                    let res = parse_u32(next);
14095                    let Some(val) = res else { break };
14096                    val
14097                }),
14098                22u16 => CakeTinStatsAttrs::BulkFlows({
14099                    let res = parse_u32(next);
14100                    let Some(val) = res else { break };
14101                    val
14102                }),
14103                23u16 => CakeTinStatsAttrs::UnresponsiveFlows({
14104                    let res = parse_u32(next);
14105                    let Some(val) = res else { break };
14106                    val
14107                }),
14108                24u16 => CakeTinStatsAttrs::MaxSkblen({
14109                    let res = parse_u32(next);
14110                    let Some(val) = res else { break };
14111                    val
14112                }),
14113                25u16 => CakeTinStatsAttrs::FlowQuantum({
14114                    let res = parse_u32(next);
14115                    let Some(val) = res else { break };
14116                    val
14117                }),
14118                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
14119                n => continue,
14120            };
14121            return Some(Ok(res));
14122        }
14123        Some(Err(ErrorContext::new(
14124            "CakeTinStatsAttrs",
14125            r#type.and_then(|t| CakeTinStatsAttrs::attr_from_type(t)),
14126            self.orig_loc,
14127            self.buf.as_ptr().wrapping_add(pos) as usize,
14128        )))
14129    }
14130}
14131impl<'a> std::fmt::Debug for IterableCakeTinStatsAttrs<'_> {
14132    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14133        let mut fmt = f.debug_struct("CakeTinStatsAttrs");
14134        for attr in self.clone() {
14135            let attr = match attr {
14136                Ok(a) => a,
14137                Err(err) => {
14138                    fmt.finish()?;
14139                    f.write_str("Err(")?;
14140                    err.fmt(f)?;
14141                    return f.write_str(")");
14142                }
14143            };
14144            match attr {
14145                CakeTinStatsAttrs::Pad(val) => fmt.field("Pad", &val),
14146                CakeTinStatsAttrs::SentPackets(val) => fmt.field("SentPackets", &val),
14147                CakeTinStatsAttrs::SentBytes64(val) => fmt.field("SentBytes64", &val),
14148                CakeTinStatsAttrs::DroppedPackets(val) => fmt.field("DroppedPackets", &val),
14149                CakeTinStatsAttrs::DroppedBytes64(val) => fmt.field("DroppedBytes64", &val),
14150                CakeTinStatsAttrs::AcksDroppedPackets(val) => fmt.field("AcksDroppedPackets", &val),
14151                CakeTinStatsAttrs::AcksDroppedBytes64(val) => fmt.field("AcksDroppedBytes64", &val),
14152                CakeTinStatsAttrs::EcnMarkedPackets(val) => fmt.field("EcnMarkedPackets", &val),
14153                CakeTinStatsAttrs::EcnMarkedBytes64(val) => fmt.field("EcnMarkedBytes64", &val),
14154                CakeTinStatsAttrs::BacklogPackets(val) => fmt.field("BacklogPackets", &val),
14155                CakeTinStatsAttrs::BacklogBytes(val) => fmt.field("BacklogBytes", &val),
14156                CakeTinStatsAttrs::ThresholdRate64(val) => fmt.field("ThresholdRate64", &val),
14157                CakeTinStatsAttrs::TargetUs(val) => fmt.field("TargetUs", &val),
14158                CakeTinStatsAttrs::IntervalUs(val) => fmt.field("IntervalUs", &val),
14159                CakeTinStatsAttrs::WayIndirectHits(val) => fmt.field("WayIndirectHits", &val),
14160                CakeTinStatsAttrs::WayMisses(val) => fmt.field("WayMisses", &val),
14161                CakeTinStatsAttrs::WayCollisions(val) => fmt.field("WayCollisions", &val),
14162                CakeTinStatsAttrs::PeakDelayUs(val) => fmt.field("PeakDelayUs", &val),
14163                CakeTinStatsAttrs::AvgDelayUs(val) => fmt.field("AvgDelayUs", &val),
14164                CakeTinStatsAttrs::BaseDelayUs(val) => fmt.field("BaseDelayUs", &val),
14165                CakeTinStatsAttrs::SparseFlows(val) => fmt.field("SparseFlows", &val),
14166                CakeTinStatsAttrs::BulkFlows(val) => fmt.field("BulkFlows", &val),
14167                CakeTinStatsAttrs::UnresponsiveFlows(val) => fmt.field("UnresponsiveFlows", &val),
14168                CakeTinStatsAttrs::MaxSkblen(val) => fmt.field("MaxSkblen", &val),
14169                CakeTinStatsAttrs::FlowQuantum(val) => fmt.field("FlowQuantum", &val),
14170            };
14171        }
14172        fmt.finish()
14173    }
14174}
14175impl IterableCakeTinStatsAttrs<'_> {
14176    pub fn lookup_attr(
14177        &self,
14178        offset: usize,
14179        missing_type: Option<u16>,
14180    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14181        let mut stack = Vec::new();
14182        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14183        if missing_type.is_some() && cur == offset {
14184            stack.push(("CakeTinStatsAttrs", offset));
14185            return (
14186                stack,
14187                missing_type.and_then(|t| CakeTinStatsAttrs::attr_from_type(t)),
14188            );
14189        }
14190        if cur > offset || cur + self.buf.len() < offset {
14191            return (stack, None);
14192        }
14193        let mut attrs = self.clone();
14194        let mut last_off = cur + attrs.pos;
14195        while let Some(attr) = attrs.next() {
14196            let Ok(attr) = attr else { break };
14197            match attr {
14198                CakeTinStatsAttrs::Pad(val) => {
14199                    if last_off == offset {
14200                        stack.push(("Pad", last_off));
14201                        break;
14202                    }
14203                }
14204                CakeTinStatsAttrs::SentPackets(val) => {
14205                    if last_off == offset {
14206                        stack.push(("SentPackets", last_off));
14207                        break;
14208                    }
14209                }
14210                CakeTinStatsAttrs::SentBytes64(val) => {
14211                    if last_off == offset {
14212                        stack.push(("SentBytes64", last_off));
14213                        break;
14214                    }
14215                }
14216                CakeTinStatsAttrs::DroppedPackets(val) => {
14217                    if last_off == offset {
14218                        stack.push(("DroppedPackets", last_off));
14219                        break;
14220                    }
14221                }
14222                CakeTinStatsAttrs::DroppedBytes64(val) => {
14223                    if last_off == offset {
14224                        stack.push(("DroppedBytes64", last_off));
14225                        break;
14226                    }
14227                }
14228                CakeTinStatsAttrs::AcksDroppedPackets(val) => {
14229                    if last_off == offset {
14230                        stack.push(("AcksDroppedPackets", last_off));
14231                        break;
14232                    }
14233                }
14234                CakeTinStatsAttrs::AcksDroppedBytes64(val) => {
14235                    if last_off == offset {
14236                        stack.push(("AcksDroppedBytes64", last_off));
14237                        break;
14238                    }
14239                }
14240                CakeTinStatsAttrs::EcnMarkedPackets(val) => {
14241                    if last_off == offset {
14242                        stack.push(("EcnMarkedPackets", last_off));
14243                        break;
14244                    }
14245                }
14246                CakeTinStatsAttrs::EcnMarkedBytes64(val) => {
14247                    if last_off == offset {
14248                        stack.push(("EcnMarkedBytes64", last_off));
14249                        break;
14250                    }
14251                }
14252                CakeTinStatsAttrs::BacklogPackets(val) => {
14253                    if last_off == offset {
14254                        stack.push(("BacklogPackets", last_off));
14255                        break;
14256                    }
14257                }
14258                CakeTinStatsAttrs::BacklogBytes(val) => {
14259                    if last_off == offset {
14260                        stack.push(("BacklogBytes", last_off));
14261                        break;
14262                    }
14263                }
14264                CakeTinStatsAttrs::ThresholdRate64(val) => {
14265                    if last_off == offset {
14266                        stack.push(("ThresholdRate64", last_off));
14267                        break;
14268                    }
14269                }
14270                CakeTinStatsAttrs::TargetUs(val) => {
14271                    if last_off == offset {
14272                        stack.push(("TargetUs", last_off));
14273                        break;
14274                    }
14275                }
14276                CakeTinStatsAttrs::IntervalUs(val) => {
14277                    if last_off == offset {
14278                        stack.push(("IntervalUs", last_off));
14279                        break;
14280                    }
14281                }
14282                CakeTinStatsAttrs::WayIndirectHits(val) => {
14283                    if last_off == offset {
14284                        stack.push(("WayIndirectHits", last_off));
14285                        break;
14286                    }
14287                }
14288                CakeTinStatsAttrs::WayMisses(val) => {
14289                    if last_off == offset {
14290                        stack.push(("WayMisses", last_off));
14291                        break;
14292                    }
14293                }
14294                CakeTinStatsAttrs::WayCollisions(val) => {
14295                    if last_off == offset {
14296                        stack.push(("WayCollisions", last_off));
14297                        break;
14298                    }
14299                }
14300                CakeTinStatsAttrs::PeakDelayUs(val) => {
14301                    if last_off == offset {
14302                        stack.push(("PeakDelayUs", last_off));
14303                        break;
14304                    }
14305                }
14306                CakeTinStatsAttrs::AvgDelayUs(val) => {
14307                    if last_off == offset {
14308                        stack.push(("AvgDelayUs", last_off));
14309                        break;
14310                    }
14311                }
14312                CakeTinStatsAttrs::BaseDelayUs(val) => {
14313                    if last_off == offset {
14314                        stack.push(("BaseDelayUs", last_off));
14315                        break;
14316                    }
14317                }
14318                CakeTinStatsAttrs::SparseFlows(val) => {
14319                    if last_off == offset {
14320                        stack.push(("SparseFlows", last_off));
14321                        break;
14322                    }
14323                }
14324                CakeTinStatsAttrs::BulkFlows(val) => {
14325                    if last_off == offset {
14326                        stack.push(("BulkFlows", last_off));
14327                        break;
14328                    }
14329                }
14330                CakeTinStatsAttrs::UnresponsiveFlows(val) => {
14331                    if last_off == offset {
14332                        stack.push(("UnresponsiveFlows", last_off));
14333                        break;
14334                    }
14335                }
14336                CakeTinStatsAttrs::MaxSkblen(val) => {
14337                    if last_off == offset {
14338                        stack.push(("MaxSkblen", last_off));
14339                        break;
14340                    }
14341                }
14342                CakeTinStatsAttrs::FlowQuantum(val) => {
14343                    if last_off == offset {
14344                        stack.push(("FlowQuantum", last_off));
14345                        break;
14346                    }
14347                }
14348                _ => {}
14349            };
14350            last_off = cur + attrs.pos;
14351        }
14352        if !stack.is_empty() {
14353            stack.push(("CakeTinStatsAttrs", cur));
14354        }
14355        (stack, None)
14356    }
14357}
14358#[derive(Clone)]
14359pub enum CbsAttrs {
14360    Parms(TcCbsQopt),
14361}
14362impl<'a> IterableCbsAttrs<'a> {
14363    pub fn get_parms(&self) -> Result<TcCbsQopt, ErrorContext> {
14364        let mut iter = self.clone();
14365        iter.pos = 0;
14366        for attr in iter {
14367            if let CbsAttrs::Parms(val) = attr? {
14368                return Ok(val);
14369            }
14370        }
14371        Err(ErrorContext::new_missing(
14372            "CbsAttrs",
14373            "Parms",
14374            self.orig_loc,
14375            self.buf.as_ptr() as usize,
14376        ))
14377    }
14378}
14379impl CbsAttrs {
14380    pub fn new<'a>(buf: &'a [u8]) -> IterableCbsAttrs<'a> {
14381        IterableCbsAttrs::with_loc(buf, buf.as_ptr() as usize)
14382    }
14383    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14384        let res = match r#type {
14385            1u16 => "Parms",
14386            _ => return None,
14387        };
14388        Some(res)
14389    }
14390}
14391#[derive(Clone, Copy, Default)]
14392pub struct IterableCbsAttrs<'a> {
14393    buf: &'a [u8],
14394    pos: usize,
14395    orig_loc: usize,
14396}
14397impl<'a> IterableCbsAttrs<'a> {
14398    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14399        Self {
14400            buf,
14401            pos: 0,
14402            orig_loc,
14403        }
14404    }
14405    pub fn get_buf(&self) -> &'a [u8] {
14406        self.buf
14407    }
14408}
14409impl<'a> Iterator for IterableCbsAttrs<'a> {
14410    type Item = Result<CbsAttrs, ErrorContext>;
14411    fn next(&mut self) -> Option<Self::Item> {
14412        let pos = self.pos;
14413        let mut r#type;
14414        loop {
14415            r#type = None;
14416            if self.buf.len() == self.pos {
14417                return None;
14418            }
14419            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
14420                break;
14421            };
14422            r#type = Some(header.r#type);
14423            let res = match header.r#type {
14424                1u16 => CbsAttrs::Parms({
14425                    let res = Some(TcCbsQopt::new_from_zeroed(next));
14426                    let Some(val) = res else { break };
14427                    val
14428                }),
14429                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
14430                n => continue,
14431            };
14432            return Some(Ok(res));
14433        }
14434        Some(Err(ErrorContext::new(
14435            "CbsAttrs",
14436            r#type.and_then(|t| CbsAttrs::attr_from_type(t)),
14437            self.orig_loc,
14438            self.buf.as_ptr().wrapping_add(pos) as usize,
14439        )))
14440    }
14441}
14442impl std::fmt::Debug for IterableCbsAttrs<'_> {
14443    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14444        let mut fmt = f.debug_struct("CbsAttrs");
14445        for attr in self.clone() {
14446            let attr = match attr {
14447                Ok(a) => a,
14448                Err(err) => {
14449                    fmt.finish()?;
14450                    f.write_str("Err(")?;
14451                    err.fmt(f)?;
14452                    return f.write_str(")");
14453                }
14454            };
14455            match attr {
14456                CbsAttrs::Parms(val) => fmt.field("Parms", &val),
14457            };
14458        }
14459        fmt.finish()
14460    }
14461}
14462impl IterableCbsAttrs<'_> {
14463    pub fn lookup_attr(
14464        &self,
14465        offset: usize,
14466        missing_type: Option<u16>,
14467    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14468        let mut stack = Vec::new();
14469        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14470        if missing_type.is_some() && cur == offset {
14471            stack.push(("CbsAttrs", offset));
14472            return (
14473                stack,
14474                missing_type.and_then(|t| CbsAttrs::attr_from_type(t)),
14475            );
14476        }
14477        if cur > offset || cur + self.buf.len() < offset {
14478            return (stack, None);
14479        }
14480        let mut attrs = self.clone();
14481        let mut last_off = cur + attrs.pos;
14482        while let Some(attr) = attrs.next() {
14483            let Ok(attr) = attr else { break };
14484            match attr {
14485                CbsAttrs::Parms(val) => {
14486                    if last_off == offset {
14487                        stack.push(("Parms", last_off));
14488                        break;
14489                    }
14490                }
14491                _ => {}
14492            };
14493            last_off = cur + attrs.pos;
14494        }
14495        if !stack.is_empty() {
14496            stack.push(("CbsAttrs", cur));
14497        }
14498        (stack, None)
14499    }
14500}
14501#[derive(Clone)]
14502pub enum CgroupAttrs<'a> {
14503    Act(IterableArrayActAttrs<'a>),
14504    Police(IterablePoliceAttrs<'a>),
14505    Ematches(&'a [u8]),
14506}
14507impl<'a> IterableCgroupAttrs<'a> {
14508    pub fn get_act(
14509        &self,
14510    ) -> Result<ArrayIterable<IterableArrayActAttrs<'a>, IterableActAttrs<'a>>, ErrorContext> {
14511        for attr in self.clone() {
14512            if let CgroupAttrs::Act(val) = attr? {
14513                return Ok(ArrayIterable::new(val));
14514            }
14515        }
14516        Err(ErrorContext::new_missing(
14517            "CgroupAttrs",
14518            "Act",
14519            self.orig_loc,
14520            self.buf.as_ptr() as usize,
14521        ))
14522    }
14523    pub fn get_police(&self) -> Result<IterablePoliceAttrs<'a>, ErrorContext> {
14524        let mut iter = self.clone();
14525        iter.pos = 0;
14526        for attr in iter {
14527            if let CgroupAttrs::Police(val) = attr? {
14528                return Ok(val);
14529            }
14530        }
14531        Err(ErrorContext::new_missing(
14532            "CgroupAttrs",
14533            "Police",
14534            self.orig_loc,
14535            self.buf.as_ptr() as usize,
14536        ))
14537    }
14538    pub fn get_ematches(&self) -> Result<&'a [u8], ErrorContext> {
14539        let mut iter = self.clone();
14540        iter.pos = 0;
14541        for attr in iter {
14542            if let CgroupAttrs::Ematches(val) = attr? {
14543                return Ok(val);
14544            }
14545        }
14546        Err(ErrorContext::new_missing(
14547            "CgroupAttrs",
14548            "Ematches",
14549            self.orig_loc,
14550            self.buf.as_ptr() as usize,
14551        ))
14552    }
14553}
14554impl CgroupAttrs<'_> {
14555    pub fn new<'a>(buf: &'a [u8]) -> IterableCgroupAttrs<'a> {
14556        IterableCgroupAttrs::with_loc(buf, buf.as_ptr() as usize)
14557    }
14558    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14559        let res = match r#type {
14560            1u16 => "Act",
14561            2u16 => "Police",
14562            3u16 => "Ematches",
14563            _ => return None,
14564        };
14565        Some(res)
14566    }
14567}
14568#[derive(Clone, Copy, Default)]
14569pub struct IterableCgroupAttrs<'a> {
14570    buf: &'a [u8],
14571    pos: usize,
14572    orig_loc: usize,
14573}
14574impl<'a> IterableCgroupAttrs<'a> {
14575    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14576        Self {
14577            buf,
14578            pos: 0,
14579            orig_loc,
14580        }
14581    }
14582    pub fn get_buf(&self) -> &'a [u8] {
14583        self.buf
14584    }
14585}
14586impl<'a> Iterator for IterableCgroupAttrs<'a> {
14587    type Item = Result<CgroupAttrs<'a>, ErrorContext>;
14588    fn next(&mut self) -> Option<Self::Item> {
14589        let pos = self.pos;
14590        let mut r#type;
14591        loop {
14592            r#type = None;
14593            if self.buf.len() == self.pos {
14594                return None;
14595            }
14596            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
14597                break;
14598            };
14599            r#type = Some(header.r#type);
14600            let res = match header.r#type {
14601                1u16 => CgroupAttrs::Act({
14602                    let res = Some(IterableArrayActAttrs::with_loc(next, self.orig_loc));
14603                    let Some(val) = res else { break };
14604                    val
14605                }),
14606                2u16 => CgroupAttrs::Police({
14607                    let res = Some(IterablePoliceAttrs::with_loc(next, self.orig_loc));
14608                    let Some(val) = res else { break };
14609                    val
14610                }),
14611                3u16 => CgroupAttrs::Ematches({
14612                    let res = Some(next);
14613                    let Some(val) = res else { break };
14614                    val
14615                }),
14616                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
14617                n => continue,
14618            };
14619            return Some(Ok(res));
14620        }
14621        Some(Err(ErrorContext::new(
14622            "CgroupAttrs",
14623            r#type.and_then(|t| CgroupAttrs::attr_from_type(t)),
14624            self.orig_loc,
14625            self.buf.as_ptr().wrapping_add(pos) as usize,
14626        )))
14627    }
14628}
14629impl<'a> std::fmt::Debug for IterableCgroupAttrs<'_> {
14630    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14631        let mut fmt = f.debug_struct("CgroupAttrs");
14632        for attr in self.clone() {
14633            let attr = match attr {
14634                Ok(a) => a,
14635                Err(err) => {
14636                    fmt.finish()?;
14637                    f.write_str("Err(")?;
14638                    err.fmt(f)?;
14639                    return f.write_str(")");
14640                }
14641            };
14642            match attr {
14643                CgroupAttrs::Act(val) => fmt.field("Act", &val),
14644                CgroupAttrs::Police(val) => fmt.field("Police", &val),
14645                CgroupAttrs::Ematches(val) => fmt.field("Ematches", &val),
14646            };
14647        }
14648        fmt.finish()
14649    }
14650}
14651impl IterableCgroupAttrs<'_> {
14652    pub fn lookup_attr(
14653        &self,
14654        offset: usize,
14655        missing_type: Option<u16>,
14656    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14657        let mut stack = Vec::new();
14658        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14659        if missing_type.is_some() && cur == offset {
14660            stack.push(("CgroupAttrs", offset));
14661            return (
14662                stack,
14663                missing_type.and_then(|t| CgroupAttrs::attr_from_type(t)),
14664            );
14665        }
14666        if cur > offset || cur + self.buf.len() < offset {
14667            return (stack, None);
14668        }
14669        let mut attrs = self.clone();
14670        let mut last_off = cur + attrs.pos;
14671        let mut missing = None;
14672        while let Some(attr) = attrs.next() {
14673            let Ok(attr) = attr else { break };
14674            match attr {
14675                CgroupAttrs::Act(val) => {
14676                    for entry in val {
14677                        let Ok(attr) = entry else { break };
14678                        (stack, missing) = attr.lookup_attr(offset, missing_type);
14679                        if !stack.is_empty() {
14680                            break;
14681                        }
14682                    }
14683                    if !stack.is_empty() {
14684                        stack.push(("Act", last_off));
14685                        break;
14686                    }
14687                }
14688                CgroupAttrs::Police(val) => {
14689                    (stack, missing) = val.lookup_attr(offset, missing_type);
14690                    if !stack.is_empty() {
14691                        break;
14692                    }
14693                }
14694                CgroupAttrs::Ematches(val) => {
14695                    if last_off == offset {
14696                        stack.push(("Ematches", last_off));
14697                        break;
14698                    }
14699                }
14700                _ => {}
14701            };
14702            last_off = cur + attrs.pos;
14703        }
14704        if !stack.is_empty() {
14705            stack.push(("CgroupAttrs", cur));
14706        }
14707        (stack, missing)
14708    }
14709}
14710#[derive(Clone)]
14711pub enum ChokeAttrs<'a> {
14712    Parms(TcRedQopt),
14713    Stab(&'a [u8]),
14714    MaxP(u32),
14715}
14716impl<'a> IterableChokeAttrs<'a> {
14717    pub fn get_parms(&self) -> Result<TcRedQopt, ErrorContext> {
14718        let mut iter = self.clone();
14719        iter.pos = 0;
14720        for attr in iter {
14721            if let ChokeAttrs::Parms(val) = attr? {
14722                return Ok(val);
14723            }
14724        }
14725        Err(ErrorContext::new_missing(
14726            "ChokeAttrs",
14727            "Parms",
14728            self.orig_loc,
14729            self.buf.as_ptr() as usize,
14730        ))
14731    }
14732    pub fn get_stab(&self) -> Result<&'a [u8], ErrorContext> {
14733        let mut iter = self.clone();
14734        iter.pos = 0;
14735        for attr in iter {
14736            if let ChokeAttrs::Stab(val) = attr? {
14737                return Ok(val);
14738            }
14739        }
14740        Err(ErrorContext::new_missing(
14741            "ChokeAttrs",
14742            "Stab",
14743            self.orig_loc,
14744            self.buf.as_ptr() as usize,
14745        ))
14746    }
14747    pub fn get_max_p(&self) -> Result<u32, ErrorContext> {
14748        let mut iter = self.clone();
14749        iter.pos = 0;
14750        for attr in iter {
14751            if let ChokeAttrs::MaxP(val) = attr? {
14752                return Ok(val);
14753            }
14754        }
14755        Err(ErrorContext::new_missing(
14756            "ChokeAttrs",
14757            "MaxP",
14758            self.orig_loc,
14759            self.buf.as_ptr() as usize,
14760        ))
14761    }
14762}
14763impl ChokeAttrs<'_> {
14764    pub fn new<'a>(buf: &'a [u8]) -> IterableChokeAttrs<'a> {
14765        IterableChokeAttrs::with_loc(buf, buf.as_ptr() as usize)
14766    }
14767    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14768        let res = match r#type {
14769            1u16 => "Parms",
14770            2u16 => "Stab",
14771            3u16 => "MaxP",
14772            _ => return None,
14773        };
14774        Some(res)
14775    }
14776}
14777#[derive(Clone, Copy, Default)]
14778pub struct IterableChokeAttrs<'a> {
14779    buf: &'a [u8],
14780    pos: usize,
14781    orig_loc: usize,
14782}
14783impl<'a> IterableChokeAttrs<'a> {
14784    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14785        Self {
14786            buf,
14787            pos: 0,
14788            orig_loc,
14789        }
14790    }
14791    pub fn get_buf(&self) -> &'a [u8] {
14792        self.buf
14793    }
14794}
14795impl<'a> Iterator for IterableChokeAttrs<'a> {
14796    type Item = Result<ChokeAttrs<'a>, ErrorContext>;
14797    fn next(&mut self) -> Option<Self::Item> {
14798        let pos = self.pos;
14799        let mut r#type;
14800        loop {
14801            r#type = None;
14802            if self.buf.len() == self.pos {
14803                return None;
14804            }
14805            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
14806                break;
14807            };
14808            r#type = Some(header.r#type);
14809            let res = match header.r#type {
14810                1u16 => ChokeAttrs::Parms({
14811                    let res = Some(TcRedQopt::new_from_zeroed(next));
14812                    let Some(val) = res else { break };
14813                    val
14814                }),
14815                2u16 => ChokeAttrs::Stab({
14816                    let res = Some(next);
14817                    let Some(val) = res else { break };
14818                    val
14819                }),
14820                3u16 => ChokeAttrs::MaxP({
14821                    let res = parse_u32(next);
14822                    let Some(val) = res else { break };
14823                    val
14824                }),
14825                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
14826                n => continue,
14827            };
14828            return Some(Ok(res));
14829        }
14830        Some(Err(ErrorContext::new(
14831            "ChokeAttrs",
14832            r#type.and_then(|t| ChokeAttrs::attr_from_type(t)),
14833            self.orig_loc,
14834            self.buf.as_ptr().wrapping_add(pos) as usize,
14835        )))
14836    }
14837}
14838impl<'a> std::fmt::Debug for IterableChokeAttrs<'_> {
14839    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14840        let mut fmt = f.debug_struct("ChokeAttrs");
14841        for attr in self.clone() {
14842            let attr = match attr {
14843                Ok(a) => a,
14844                Err(err) => {
14845                    fmt.finish()?;
14846                    f.write_str("Err(")?;
14847                    err.fmt(f)?;
14848                    return f.write_str(")");
14849                }
14850            };
14851            match attr {
14852                ChokeAttrs::Parms(val) => fmt.field("Parms", &val),
14853                ChokeAttrs::Stab(val) => fmt.field("Stab", &val),
14854                ChokeAttrs::MaxP(val) => fmt.field("MaxP", &val),
14855            };
14856        }
14857        fmt.finish()
14858    }
14859}
14860impl IterableChokeAttrs<'_> {
14861    pub fn lookup_attr(
14862        &self,
14863        offset: usize,
14864        missing_type: Option<u16>,
14865    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14866        let mut stack = Vec::new();
14867        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14868        if missing_type.is_some() && cur == offset {
14869            stack.push(("ChokeAttrs", offset));
14870            return (
14871                stack,
14872                missing_type.and_then(|t| ChokeAttrs::attr_from_type(t)),
14873            );
14874        }
14875        if cur > offset || cur + self.buf.len() < offset {
14876            return (stack, None);
14877        }
14878        let mut attrs = self.clone();
14879        let mut last_off = cur + attrs.pos;
14880        while let Some(attr) = attrs.next() {
14881            let Ok(attr) = attr else { break };
14882            match attr {
14883                ChokeAttrs::Parms(val) => {
14884                    if last_off == offset {
14885                        stack.push(("Parms", last_off));
14886                        break;
14887                    }
14888                }
14889                ChokeAttrs::Stab(val) => {
14890                    if last_off == offset {
14891                        stack.push(("Stab", last_off));
14892                        break;
14893                    }
14894                }
14895                ChokeAttrs::MaxP(val) => {
14896                    if last_off == offset {
14897                        stack.push(("MaxP", last_off));
14898                        break;
14899                    }
14900                }
14901                _ => {}
14902            };
14903            last_off = cur + attrs.pos;
14904        }
14905        if !stack.is_empty() {
14906            stack.push(("ChokeAttrs", cur));
14907        }
14908        (stack, None)
14909    }
14910}
14911#[derive(Clone)]
14912pub enum CodelAttrs {
14913    Target(u32),
14914    Limit(u32),
14915    Interval(u32),
14916    Ecn(u32),
14917    CeThreshold(u32),
14918}
14919impl<'a> IterableCodelAttrs<'a> {
14920    pub fn get_target(&self) -> Result<u32, ErrorContext> {
14921        let mut iter = self.clone();
14922        iter.pos = 0;
14923        for attr in iter {
14924            if let CodelAttrs::Target(val) = attr? {
14925                return Ok(val);
14926            }
14927        }
14928        Err(ErrorContext::new_missing(
14929            "CodelAttrs",
14930            "Target",
14931            self.orig_loc,
14932            self.buf.as_ptr() as usize,
14933        ))
14934    }
14935    pub fn get_limit(&self) -> Result<u32, ErrorContext> {
14936        let mut iter = self.clone();
14937        iter.pos = 0;
14938        for attr in iter {
14939            if let CodelAttrs::Limit(val) = attr? {
14940                return Ok(val);
14941            }
14942        }
14943        Err(ErrorContext::new_missing(
14944            "CodelAttrs",
14945            "Limit",
14946            self.orig_loc,
14947            self.buf.as_ptr() as usize,
14948        ))
14949    }
14950    pub fn get_interval(&self) -> Result<u32, ErrorContext> {
14951        let mut iter = self.clone();
14952        iter.pos = 0;
14953        for attr in iter {
14954            if let CodelAttrs::Interval(val) = attr? {
14955                return Ok(val);
14956            }
14957        }
14958        Err(ErrorContext::new_missing(
14959            "CodelAttrs",
14960            "Interval",
14961            self.orig_loc,
14962            self.buf.as_ptr() as usize,
14963        ))
14964    }
14965    pub fn get_ecn(&self) -> Result<u32, ErrorContext> {
14966        let mut iter = self.clone();
14967        iter.pos = 0;
14968        for attr in iter {
14969            if let CodelAttrs::Ecn(val) = attr? {
14970                return Ok(val);
14971            }
14972        }
14973        Err(ErrorContext::new_missing(
14974            "CodelAttrs",
14975            "Ecn",
14976            self.orig_loc,
14977            self.buf.as_ptr() as usize,
14978        ))
14979    }
14980    pub fn get_ce_threshold(&self) -> Result<u32, ErrorContext> {
14981        let mut iter = self.clone();
14982        iter.pos = 0;
14983        for attr in iter {
14984            if let CodelAttrs::CeThreshold(val) = attr? {
14985                return Ok(val);
14986            }
14987        }
14988        Err(ErrorContext::new_missing(
14989            "CodelAttrs",
14990            "CeThreshold",
14991            self.orig_loc,
14992            self.buf.as_ptr() as usize,
14993        ))
14994    }
14995}
14996impl CodelAttrs {
14997    pub fn new<'a>(buf: &'a [u8]) -> IterableCodelAttrs<'a> {
14998        IterableCodelAttrs::with_loc(buf, buf.as_ptr() as usize)
14999    }
15000    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15001        let res = match r#type {
15002            1u16 => "Target",
15003            2u16 => "Limit",
15004            3u16 => "Interval",
15005            4u16 => "Ecn",
15006            5u16 => "CeThreshold",
15007            _ => return None,
15008        };
15009        Some(res)
15010    }
15011}
15012#[derive(Clone, Copy, Default)]
15013pub struct IterableCodelAttrs<'a> {
15014    buf: &'a [u8],
15015    pos: usize,
15016    orig_loc: usize,
15017}
15018impl<'a> IterableCodelAttrs<'a> {
15019    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15020        Self {
15021            buf,
15022            pos: 0,
15023            orig_loc,
15024        }
15025    }
15026    pub fn get_buf(&self) -> &'a [u8] {
15027        self.buf
15028    }
15029}
15030impl<'a> Iterator for IterableCodelAttrs<'a> {
15031    type Item = Result<CodelAttrs, ErrorContext>;
15032    fn next(&mut self) -> Option<Self::Item> {
15033        let pos = self.pos;
15034        let mut r#type;
15035        loop {
15036            r#type = None;
15037            if self.buf.len() == self.pos {
15038                return None;
15039            }
15040            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
15041                break;
15042            };
15043            r#type = Some(header.r#type);
15044            let res = match header.r#type {
15045                1u16 => CodelAttrs::Target({
15046                    let res = parse_u32(next);
15047                    let Some(val) = res else { break };
15048                    val
15049                }),
15050                2u16 => CodelAttrs::Limit({
15051                    let res = parse_u32(next);
15052                    let Some(val) = res else { break };
15053                    val
15054                }),
15055                3u16 => CodelAttrs::Interval({
15056                    let res = parse_u32(next);
15057                    let Some(val) = res else { break };
15058                    val
15059                }),
15060                4u16 => CodelAttrs::Ecn({
15061                    let res = parse_u32(next);
15062                    let Some(val) = res else { break };
15063                    val
15064                }),
15065                5u16 => CodelAttrs::CeThreshold({
15066                    let res = parse_u32(next);
15067                    let Some(val) = res else { break };
15068                    val
15069                }),
15070                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
15071                n => continue,
15072            };
15073            return Some(Ok(res));
15074        }
15075        Some(Err(ErrorContext::new(
15076            "CodelAttrs",
15077            r#type.and_then(|t| CodelAttrs::attr_from_type(t)),
15078            self.orig_loc,
15079            self.buf.as_ptr().wrapping_add(pos) as usize,
15080        )))
15081    }
15082}
15083impl std::fmt::Debug for IterableCodelAttrs<'_> {
15084    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15085        let mut fmt = f.debug_struct("CodelAttrs");
15086        for attr in self.clone() {
15087            let attr = match attr {
15088                Ok(a) => a,
15089                Err(err) => {
15090                    fmt.finish()?;
15091                    f.write_str("Err(")?;
15092                    err.fmt(f)?;
15093                    return f.write_str(")");
15094                }
15095            };
15096            match attr {
15097                CodelAttrs::Target(val) => fmt.field("Target", &val),
15098                CodelAttrs::Limit(val) => fmt.field("Limit", &val),
15099                CodelAttrs::Interval(val) => fmt.field("Interval", &val),
15100                CodelAttrs::Ecn(val) => fmt.field("Ecn", &val),
15101                CodelAttrs::CeThreshold(val) => fmt.field("CeThreshold", &val),
15102            };
15103        }
15104        fmt.finish()
15105    }
15106}
15107impl IterableCodelAttrs<'_> {
15108    pub fn lookup_attr(
15109        &self,
15110        offset: usize,
15111        missing_type: Option<u16>,
15112    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15113        let mut stack = Vec::new();
15114        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15115        if missing_type.is_some() && cur == offset {
15116            stack.push(("CodelAttrs", offset));
15117            return (
15118                stack,
15119                missing_type.and_then(|t| CodelAttrs::attr_from_type(t)),
15120            );
15121        }
15122        if cur > offset || cur + self.buf.len() < offset {
15123            return (stack, None);
15124        }
15125        let mut attrs = self.clone();
15126        let mut last_off = cur + attrs.pos;
15127        while let Some(attr) = attrs.next() {
15128            let Ok(attr) = attr else { break };
15129            match attr {
15130                CodelAttrs::Target(val) => {
15131                    if last_off == offset {
15132                        stack.push(("Target", last_off));
15133                        break;
15134                    }
15135                }
15136                CodelAttrs::Limit(val) => {
15137                    if last_off == offset {
15138                        stack.push(("Limit", last_off));
15139                        break;
15140                    }
15141                }
15142                CodelAttrs::Interval(val) => {
15143                    if last_off == offset {
15144                        stack.push(("Interval", last_off));
15145                        break;
15146                    }
15147                }
15148                CodelAttrs::Ecn(val) => {
15149                    if last_off == offset {
15150                        stack.push(("Ecn", last_off));
15151                        break;
15152                    }
15153                }
15154                CodelAttrs::CeThreshold(val) => {
15155                    if last_off == offset {
15156                        stack.push(("CeThreshold", last_off));
15157                        break;
15158                    }
15159                }
15160                _ => {}
15161            };
15162            last_off = cur + attrs.pos;
15163        }
15164        if !stack.is_empty() {
15165            stack.push(("CodelAttrs", cur));
15166        }
15167        (stack, None)
15168    }
15169}
15170#[derive(Clone)]
15171pub enum DrrAttrs {
15172    Quantum(u32),
15173}
15174impl<'a> IterableDrrAttrs<'a> {
15175    pub fn get_quantum(&self) -> Result<u32, ErrorContext> {
15176        let mut iter = self.clone();
15177        iter.pos = 0;
15178        for attr in iter {
15179            if let DrrAttrs::Quantum(val) = attr? {
15180                return Ok(val);
15181            }
15182        }
15183        Err(ErrorContext::new_missing(
15184            "DrrAttrs",
15185            "Quantum",
15186            self.orig_loc,
15187            self.buf.as_ptr() as usize,
15188        ))
15189    }
15190}
15191impl DrrAttrs {
15192    pub fn new<'a>(buf: &'a [u8]) -> IterableDrrAttrs<'a> {
15193        IterableDrrAttrs::with_loc(buf, buf.as_ptr() as usize)
15194    }
15195    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15196        let res = match r#type {
15197            1u16 => "Quantum",
15198            _ => return None,
15199        };
15200        Some(res)
15201    }
15202}
15203#[derive(Clone, Copy, Default)]
15204pub struct IterableDrrAttrs<'a> {
15205    buf: &'a [u8],
15206    pos: usize,
15207    orig_loc: usize,
15208}
15209impl<'a> IterableDrrAttrs<'a> {
15210    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15211        Self {
15212            buf,
15213            pos: 0,
15214            orig_loc,
15215        }
15216    }
15217    pub fn get_buf(&self) -> &'a [u8] {
15218        self.buf
15219    }
15220}
15221impl<'a> Iterator for IterableDrrAttrs<'a> {
15222    type Item = Result<DrrAttrs, ErrorContext>;
15223    fn next(&mut self) -> Option<Self::Item> {
15224        let pos = self.pos;
15225        let mut r#type;
15226        loop {
15227            r#type = None;
15228            if self.buf.len() == self.pos {
15229                return None;
15230            }
15231            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
15232                break;
15233            };
15234            r#type = Some(header.r#type);
15235            let res = match header.r#type {
15236                1u16 => DrrAttrs::Quantum({
15237                    let res = parse_u32(next);
15238                    let Some(val) = res else { break };
15239                    val
15240                }),
15241                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
15242                n => continue,
15243            };
15244            return Some(Ok(res));
15245        }
15246        Some(Err(ErrorContext::new(
15247            "DrrAttrs",
15248            r#type.and_then(|t| DrrAttrs::attr_from_type(t)),
15249            self.orig_loc,
15250            self.buf.as_ptr().wrapping_add(pos) as usize,
15251        )))
15252    }
15253}
15254impl std::fmt::Debug for IterableDrrAttrs<'_> {
15255    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15256        let mut fmt = f.debug_struct("DrrAttrs");
15257        for attr in self.clone() {
15258            let attr = match attr {
15259                Ok(a) => a,
15260                Err(err) => {
15261                    fmt.finish()?;
15262                    f.write_str("Err(")?;
15263                    err.fmt(f)?;
15264                    return f.write_str(")");
15265                }
15266            };
15267            match attr {
15268                DrrAttrs::Quantum(val) => fmt.field("Quantum", &val),
15269            };
15270        }
15271        fmt.finish()
15272    }
15273}
15274impl IterableDrrAttrs<'_> {
15275    pub fn lookup_attr(
15276        &self,
15277        offset: usize,
15278        missing_type: Option<u16>,
15279    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15280        let mut stack = Vec::new();
15281        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15282        if missing_type.is_some() && cur == offset {
15283            stack.push(("DrrAttrs", offset));
15284            return (
15285                stack,
15286                missing_type.and_then(|t| DrrAttrs::attr_from_type(t)),
15287            );
15288        }
15289        if cur > offset || cur + self.buf.len() < offset {
15290            return (stack, None);
15291        }
15292        let mut attrs = self.clone();
15293        let mut last_off = cur + attrs.pos;
15294        while let Some(attr) = attrs.next() {
15295            let Ok(attr) = attr else { break };
15296            match attr {
15297                DrrAttrs::Quantum(val) => {
15298                    if last_off == offset {
15299                        stack.push(("Quantum", last_off));
15300                        break;
15301                    }
15302                }
15303                _ => {}
15304            };
15305            last_off = cur + attrs.pos;
15306        }
15307        if !stack.is_empty() {
15308            stack.push(("DrrAttrs", cur));
15309        }
15310        (stack, None)
15311    }
15312}
15313#[derive(Clone)]
15314pub enum Dualpi2Attrs {
15315    #[doc = "Limit of total number of packets in queue"]
15316    Limit(u32),
15317    #[doc = "Memory limit of total number of packets in queue"]
15318    MemoryLimit(u32),
15319    #[doc = "Classic target delay in microseconds"]
15320    Target(u32),
15321    #[doc = "Drop probability update interval time in microseconds"]
15322    Tupdate(u32),
15323    #[doc = "Integral gain factor in Hz for PI controller"]
15324    Alpha(u32),
15325    #[doc = "Proportional gain factor in Hz for PI controller"]
15326    Beta(u32),
15327    #[doc = "L4S step marking threshold in packets"]
15328    StepThreshPkts(u32),
15329    #[doc = "L4S Step marking threshold in microseconds"]
15330    StepThreshUs(u32),
15331    #[doc = "Packets enqueued to the L\\-queue can apply the step threshold when the queue length of L\\-queue is larger than this value\\. (0 is recommended)"]
15332    MinQlenStep(u32),
15333    #[doc = "Probability coupling factor between Classic and L4S (2 is recommended)"]
15334    Coupling(u8),
15335    #[doc = "Control the overload strategy (drop to preserve latency or let the queue overflow)\nAssociated type: [`Dualpi2DropOverload`] (enum)"]
15336    DropOverload(u8),
15337    #[doc = "Decide where the Classic packets are PI\\-based dropped or marked\nAssociated type: [`Dualpi2DropEarly`] (enum)"]
15338    DropEarly(u8),
15339    #[doc = "Classic WRR weight in percentage (from 0 to 100)"]
15340    CProtection(u8),
15341    #[doc = "Configure the L\\-queue ECN classifier\nAssociated type: [`Dualpi2EcnMask`] (enum)"]
15342    EcnMask(u8),
15343    #[doc = "Split aggregated skb or not\nAssociated type: [`Dualpi2SplitGso`] (enum)"]
15344    SplitGso(u8),
15345}
15346impl<'a> IterableDualpi2Attrs<'a> {
15347    #[doc = "Limit of total number of packets in queue"]
15348    pub fn get_limit(&self) -> Result<u32, ErrorContext> {
15349        let mut iter = self.clone();
15350        iter.pos = 0;
15351        for attr in iter {
15352            if let Dualpi2Attrs::Limit(val) = attr? {
15353                return Ok(val);
15354            }
15355        }
15356        Err(ErrorContext::new_missing(
15357            "Dualpi2Attrs",
15358            "Limit",
15359            self.orig_loc,
15360            self.buf.as_ptr() as usize,
15361        ))
15362    }
15363    #[doc = "Memory limit of total number of packets in queue"]
15364    pub fn get_memory_limit(&self) -> Result<u32, ErrorContext> {
15365        let mut iter = self.clone();
15366        iter.pos = 0;
15367        for attr in iter {
15368            if let Dualpi2Attrs::MemoryLimit(val) = attr? {
15369                return Ok(val);
15370            }
15371        }
15372        Err(ErrorContext::new_missing(
15373            "Dualpi2Attrs",
15374            "MemoryLimit",
15375            self.orig_loc,
15376            self.buf.as_ptr() as usize,
15377        ))
15378    }
15379    #[doc = "Classic target delay in microseconds"]
15380    pub fn get_target(&self) -> Result<u32, ErrorContext> {
15381        let mut iter = self.clone();
15382        iter.pos = 0;
15383        for attr in iter {
15384            if let Dualpi2Attrs::Target(val) = attr? {
15385                return Ok(val);
15386            }
15387        }
15388        Err(ErrorContext::new_missing(
15389            "Dualpi2Attrs",
15390            "Target",
15391            self.orig_loc,
15392            self.buf.as_ptr() as usize,
15393        ))
15394    }
15395    #[doc = "Drop probability update interval time in microseconds"]
15396    pub fn get_tupdate(&self) -> Result<u32, ErrorContext> {
15397        let mut iter = self.clone();
15398        iter.pos = 0;
15399        for attr in iter {
15400            if let Dualpi2Attrs::Tupdate(val) = attr? {
15401                return Ok(val);
15402            }
15403        }
15404        Err(ErrorContext::new_missing(
15405            "Dualpi2Attrs",
15406            "Tupdate",
15407            self.orig_loc,
15408            self.buf.as_ptr() as usize,
15409        ))
15410    }
15411    #[doc = "Integral gain factor in Hz for PI controller"]
15412    pub fn get_alpha(&self) -> Result<u32, ErrorContext> {
15413        let mut iter = self.clone();
15414        iter.pos = 0;
15415        for attr in iter {
15416            if let Dualpi2Attrs::Alpha(val) = attr? {
15417                return Ok(val);
15418            }
15419        }
15420        Err(ErrorContext::new_missing(
15421            "Dualpi2Attrs",
15422            "Alpha",
15423            self.orig_loc,
15424            self.buf.as_ptr() as usize,
15425        ))
15426    }
15427    #[doc = "Proportional gain factor in Hz for PI controller"]
15428    pub fn get_beta(&self) -> Result<u32, ErrorContext> {
15429        let mut iter = self.clone();
15430        iter.pos = 0;
15431        for attr in iter {
15432            if let Dualpi2Attrs::Beta(val) = attr? {
15433                return Ok(val);
15434            }
15435        }
15436        Err(ErrorContext::new_missing(
15437            "Dualpi2Attrs",
15438            "Beta",
15439            self.orig_loc,
15440            self.buf.as_ptr() as usize,
15441        ))
15442    }
15443    #[doc = "L4S step marking threshold in packets"]
15444    pub fn get_step_thresh_pkts(&self) -> Result<u32, ErrorContext> {
15445        let mut iter = self.clone();
15446        iter.pos = 0;
15447        for attr in iter {
15448            if let Dualpi2Attrs::StepThreshPkts(val) = attr? {
15449                return Ok(val);
15450            }
15451        }
15452        Err(ErrorContext::new_missing(
15453            "Dualpi2Attrs",
15454            "StepThreshPkts",
15455            self.orig_loc,
15456            self.buf.as_ptr() as usize,
15457        ))
15458    }
15459    #[doc = "L4S Step marking threshold in microseconds"]
15460    pub fn get_step_thresh_us(&self) -> Result<u32, ErrorContext> {
15461        let mut iter = self.clone();
15462        iter.pos = 0;
15463        for attr in iter {
15464            if let Dualpi2Attrs::StepThreshUs(val) = attr? {
15465                return Ok(val);
15466            }
15467        }
15468        Err(ErrorContext::new_missing(
15469            "Dualpi2Attrs",
15470            "StepThreshUs",
15471            self.orig_loc,
15472            self.buf.as_ptr() as usize,
15473        ))
15474    }
15475    #[doc = "Packets enqueued to the L\\-queue can apply the step threshold when the queue length of L\\-queue is larger than this value\\. (0 is recommended)"]
15476    pub fn get_min_qlen_step(&self) -> Result<u32, ErrorContext> {
15477        let mut iter = self.clone();
15478        iter.pos = 0;
15479        for attr in iter {
15480            if let Dualpi2Attrs::MinQlenStep(val) = attr? {
15481                return Ok(val);
15482            }
15483        }
15484        Err(ErrorContext::new_missing(
15485            "Dualpi2Attrs",
15486            "MinQlenStep",
15487            self.orig_loc,
15488            self.buf.as_ptr() as usize,
15489        ))
15490    }
15491    #[doc = "Probability coupling factor between Classic and L4S (2 is recommended)"]
15492    pub fn get_coupling(&self) -> Result<u8, ErrorContext> {
15493        let mut iter = self.clone();
15494        iter.pos = 0;
15495        for attr in iter {
15496            if let Dualpi2Attrs::Coupling(val) = attr? {
15497                return Ok(val);
15498            }
15499        }
15500        Err(ErrorContext::new_missing(
15501            "Dualpi2Attrs",
15502            "Coupling",
15503            self.orig_loc,
15504            self.buf.as_ptr() as usize,
15505        ))
15506    }
15507    #[doc = "Control the overload strategy (drop to preserve latency or let the queue overflow)\nAssociated type: [`Dualpi2DropOverload`] (enum)"]
15508    pub fn get_drop_overload(&self) -> Result<u8, ErrorContext> {
15509        let mut iter = self.clone();
15510        iter.pos = 0;
15511        for attr in iter {
15512            if let Dualpi2Attrs::DropOverload(val) = attr? {
15513                return Ok(val);
15514            }
15515        }
15516        Err(ErrorContext::new_missing(
15517            "Dualpi2Attrs",
15518            "DropOverload",
15519            self.orig_loc,
15520            self.buf.as_ptr() as usize,
15521        ))
15522    }
15523    #[doc = "Decide where the Classic packets are PI\\-based dropped or marked\nAssociated type: [`Dualpi2DropEarly`] (enum)"]
15524    pub fn get_drop_early(&self) -> Result<u8, ErrorContext> {
15525        let mut iter = self.clone();
15526        iter.pos = 0;
15527        for attr in iter {
15528            if let Dualpi2Attrs::DropEarly(val) = attr? {
15529                return Ok(val);
15530            }
15531        }
15532        Err(ErrorContext::new_missing(
15533            "Dualpi2Attrs",
15534            "DropEarly",
15535            self.orig_loc,
15536            self.buf.as_ptr() as usize,
15537        ))
15538    }
15539    #[doc = "Classic WRR weight in percentage (from 0 to 100)"]
15540    pub fn get_c_protection(&self) -> Result<u8, ErrorContext> {
15541        let mut iter = self.clone();
15542        iter.pos = 0;
15543        for attr in iter {
15544            if let Dualpi2Attrs::CProtection(val) = attr? {
15545                return Ok(val);
15546            }
15547        }
15548        Err(ErrorContext::new_missing(
15549            "Dualpi2Attrs",
15550            "CProtection",
15551            self.orig_loc,
15552            self.buf.as_ptr() as usize,
15553        ))
15554    }
15555    #[doc = "Configure the L\\-queue ECN classifier\nAssociated type: [`Dualpi2EcnMask`] (enum)"]
15556    pub fn get_ecn_mask(&self) -> Result<u8, ErrorContext> {
15557        let mut iter = self.clone();
15558        iter.pos = 0;
15559        for attr in iter {
15560            if let Dualpi2Attrs::EcnMask(val) = attr? {
15561                return Ok(val);
15562            }
15563        }
15564        Err(ErrorContext::new_missing(
15565            "Dualpi2Attrs",
15566            "EcnMask",
15567            self.orig_loc,
15568            self.buf.as_ptr() as usize,
15569        ))
15570    }
15571    #[doc = "Split aggregated skb or not\nAssociated type: [`Dualpi2SplitGso`] (enum)"]
15572    pub fn get_split_gso(&self) -> Result<u8, ErrorContext> {
15573        let mut iter = self.clone();
15574        iter.pos = 0;
15575        for attr in iter {
15576            if let Dualpi2Attrs::SplitGso(val) = attr? {
15577                return Ok(val);
15578            }
15579        }
15580        Err(ErrorContext::new_missing(
15581            "Dualpi2Attrs",
15582            "SplitGso",
15583            self.orig_loc,
15584            self.buf.as_ptr() as usize,
15585        ))
15586    }
15587}
15588impl Dualpi2Attrs {
15589    pub fn new<'a>(buf: &'a [u8]) -> IterableDualpi2Attrs<'a> {
15590        IterableDualpi2Attrs::with_loc(buf, buf.as_ptr() as usize)
15591    }
15592    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15593        let res = match r#type {
15594            1u16 => "Limit",
15595            2u16 => "MemoryLimit",
15596            3u16 => "Target",
15597            4u16 => "Tupdate",
15598            5u16 => "Alpha",
15599            6u16 => "Beta",
15600            7u16 => "StepThreshPkts",
15601            8u16 => "StepThreshUs",
15602            9u16 => "MinQlenStep",
15603            10u16 => "Coupling",
15604            11u16 => "DropOverload",
15605            12u16 => "DropEarly",
15606            13u16 => "CProtection",
15607            14u16 => "EcnMask",
15608            15u16 => "SplitGso",
15609            _ => return None,
15610        };
15611        Some(res)
15612    }
15613}
15614#[derive(Clone, Copy, Default)]
15615pub struct IterableDualpi2Attrs<'a> {
15616    buf: &'a [u8],
15617    pos: usize,
15618    orig_loc: usize,
15619}
15620impl<'a> IterableDualpi2Attrs<'a> {
15621    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15622        Self {
15623            buf,
15624            pos: 0,
15625            orig_loc,
15626        }
15627    }
15628    pub fn get_buf(&self) -> &'a [u8] {
15629        self.buf
15630    }
15631}
15632impl<'a> Iterator for IterableDualpi2Attrs<'a> {
15633    type Item = Result<Dualpi2Attrs, ErrorContext>;
15634    fn next(&mut self) -> Option<Self::Item> {
15635        let pos = self.pos;
15636        let mut r#type;
15637        loop {
15638            r#type = None;
15639            if self.buf.len() == self.pos {
15640                return None;
15641            }
15642            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
15643                break;
15644            };
15645            r#type = Some(header.r#type);
15646            let res = match header.r#type {
15647                1u16 => Dualpi2Attrs::Limit({
15648                    let res = parse_u32(next);
15649                    let Some(val) = res else { break };
15650                    val
15651                }),
15652                2u16 => Dualpi2Attrs::MemoryLimit({
15653                    let res = parse_u32(next);
15654                    let Some(val) = res else { break };
15655                    val
15656                }),
15657                3u16 => Dualpi2Attrs::Target({
15658                    let res = parse_u32(next);
15659                    let Some(val) = res else { break };
15660                    val
15661                }),
15662                4u16 => Dualpi2Attrs::Tupdate({
15663                    let res = parse_u32(next);
15664                    let Some(val) = res else { break };
15665                    val
15666                }),
15667                5u16 => Dualpi2Attrs::Alpha({
15668                    let res = parse_u32(next);
15669                    let Some(val) = res else { break };
15670                    val
15671                }),
15672                6u16 => Dualpi2Attrs::Beta({
15673                    let res = parse_u32(next);
15674                    let Some(val) = res else { break };
15675                    val
15676                }),
15677                7u16 => Dualpi2Attrs::StepThreshPkts({
15678                    let res = parse_u32(next);
15679                    let Some(val) = res else { break };
15680                    val
15681                }),
15682                8u16 => Dualpi2Attrs::StepThreshUs({
15683                    let res = parse_u32(next);
15684                    let Some(val) = res else { break };
15685                    val
15686                }),
15687                9u16 => Dualpi2Attrs::MinQlenStep({
15688                    let res = parse_u32(next);
15689                    let Some(val) = res else { break };
15690                    val
15691                }),
15692                10u16 => Dualpi2Attrs::Coupling({
15693                    let res = parse_u8(next);
15694                    let Some(val) = res else { break };
15695                    val
15696                }),
15697                11u16 => Dualpi2Attrs::DropOverload({
15698                    let res = parse_u8(next);
15699                    let Some(val) = res else { break };
15700                    val
15701                }),
15702                12u16 => Dualpi2Attrs::DropEarly({
15703                    let res = parse_u8(next);
15704                    let Some(val) = res else { break };
15705                    val
15706                }),
15707                13u16 => Dualpi2Attrs::CProtection({
15708                    let res = parse_u8(next);
15709                    let Some(val) = res else { break };
15710                    val
15711                }),
15712                14u16 => Dualpi2Attrs::EcnMask({
15713                    let res = parse_u8(next);
15714                    let Some(val) = res else { break };
15715                    val
15716                }),
15717                15u16 => Dualpi2Attrs::SplitGso({
15718                    let res = parse_u8(next);
15719                    let Some(val) = res else { break };
15720                    val
15721                }),
15722                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
15723                n => continue,
15724            };
15725            return Some(Ok(res));
15726        }
15727        Some(Err(ErrorContext::new(
15728            "Dualpi2Attrs",
15729            r#type.and_then(|t| Dualpi2Attrs::attr_from_type(t)),
15730            self.orig_loc,
15731            self.buf.as_ptr().wrapping_add(pos) as usize,
15732        )))
15733    }
15734}
15735impl std::fmt::Debug for IterableDualpi2Attrs<'_> {
15736    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15737        let mut fmt = f.debug_struct("Dualpi2Attrs");
15738        for attr in self.clone() {
15739            let attr = match attr {
15740                Ok(a) => a,
15741                Err(err) => {
15742                    fmt.finish()?;
15743                    f.write_str("Err(")?;
15744                    err.fmt(f)?;
15745                    return f.write_str(")");
15746                }
15747            };
15748            match attr {
15749                Dualpi2Attrs::Limit(val) => fmt.field("Limit", &val),
15750                Dualpi2Attrs::MemoryLimit(val) => fmt.field("MemoryLimit", &val),
15751                Dualpi2Attrs::Target(val) => fmt.field("Target", &val),
15752                Dualpi2Attrs::Tupdate(val) => fmt.field("Tupdate", &val),
15753                Dualpi2Attrs::Alpha(val) => fmt.field("Alpha", &val),
15754                Dualpi2Attrs::Beta(val) => fmt.field("Beta", &val),
15755                Dualpi2Attrs::StepThreshPkts(val) => fmt.field("StepThreshPkts", &val),
15756                Dualpi2Attrs::StepThreshUs(val) => fmt.field("StepThreshUs", &val),
15757                Dualpi2Attrs::MinQlenStep(val) => fmt.field("MinQlenStep", &val),
15758                Dualpi2Attrs::Coupling(val) => fmt.field("Coupling", &val),
15759                Dualpi2Attrs::DropOverload(val) => fmt.field(
15760                    "DropOverload",
15761                    &FormatEnum(val.into(), Dualpi2DropOverload::from_value),
15762                ),
15763                Dualpi2Attrs::DropEarly(val) => fmt.field(
15764                    "DropEarly",
15765                    &FormatEnum(val.into(), Dualpi2DropEarly::from_value),
15766                ),
15767                Dualpi2Attrs::CProtection(val) => fmt.field("CProtection", &val),
15768                Dualpi2Attrs::EcnMask(val) => fmt.field(
15769                    "EcnMask",
15770                    &FormatEnum(val.into(), Dualpi2EcnMask::from_value),
15771                ),
15772                Dualpi2Attrs::SplitGso(val) => fmt.field(
15773                    "SplitGso",
15774                    &FormatEnum(val.into(), Dualpi2SplitGso::from_value),
15775                ),
15776            };
15777        }
15778        fmt.finish()
15779    }
15780}
15781impl IterableDualpi2Attrs<'_> {
15782    pub fn lookup_attr(
15783        &self,
15784        offset: usize,
15785        missing_type: Option<u16>,
15786    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15787        let mut stack = Vec::new();
15788        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15789        if missing_type.is_some() && cur == offset {
15790            stack.push(("Dualpi2Attrs", offset));
15791            return (
15792                stack,
15793                missing_type.and_then(|t| Dualpi2Attrs::attr_from_type(t)),
15794            );
15795        }
15796        if cur > offset || cur + self.buf.len() < offset {
15797            return (stack, None);
15798        }
15799        let mut attrs = self.clone();
15800        let mut last_off = cur + attrs.pos;
15801        while let Some(attr) = attrs.next() {
15802            let Ok(attr) = attr else { break };
15803            match attr {
15804                Dualpi2Attrs::Limit(val) => {
15805                    if last_off == offset {
15806                        stack.push(("Limit", last_off));
15807                        break;
15808                    }
15809                }
15810                Dualpi2Attrs::MemoryLimit(val) => {
15811                    if last_off == offset {
15812                        stack.push(("MemoryLimit", last_off));
15813                        break;
15814                    }
15815                }
15816                Dualpi2Attrs::Target(val) => {
15817                    if last_off == offset {
15818                        stack.push(("Target", last_off));
15819                        break;
15820                    }
15821                }
15822                Dualpi2Attrs::Tupdate(val) => {
15823                    if last_off == offset {
15824                        stack.push(("Tupdate", last_off));
15825                        break;
15826                    }
15827                }
15828                Dualpi2Attrs::Alpha(val) => {
15829                    if last_off == offset {
15830                        stack.push(("Alpha", last_off));
15831                        break;
15832                    }
15833                }
15834                Dualpi2Attrs::Beta(val) => {
15835                    if last_off == offset {
15836                        stack.push(("Beta", last_off));
15837                        break;
15838                    }
15839                }
15840                Dualpi2Attrs::StepThreshPkts(val) => {
15841                    if last_off == offset {
15842                        stack.push(("StepThreshPkts", last_off));
15843                        break;
15844                    }
15845                }
15846                Dualpi2Attrs::StepThreshUs(val) => {
15847                    if last_off == offset {
15848                        stack.push(("StepThreshUs", last_off));
15849                        break;
15850                    }
15851                }
15852                Dualpi2Attrs::MinQlenStep(val) => {
15853                    if last_off == offset {
15854                        stack.push(("MinQlenStep", last_off));
15855                        break;
15856                    }
15857                }
15858                Dualpi2Attrs::Coupling(val) => {
15859                    if last_off == offset {
15860                        stack.push(("Coupling", last_off));
15861                        break;
15862                    }
15863                }
15864                Dualpi2Attrs::DropOverload(val) => {
15865                    if last_off == offset {
15866                        stack.push(("DropOverload", last_off));
15867                        break;
15868                    }
15869                }
15870                Dualpi2Attrs::DropEarly(val) => {
15871                    if last_off == offset {
15872                        stack.push(("DropEarly", last_off));
15873                        break;
15874                    }
15875                }
15876                Dualpi2Attrs::CProtection(val) => {
15877                    if last_off == offset {
15878                        stack.push(("CProtection", last_off));
15879                        break;
15880                    }
15881                }
15882                Dualpi2Attrs::EcnMask(val) => {
15883                    if last_off == offset {
15884                        stack.push(("EcnMask", last_off));
15885                        break;
15886                    }
15887                }
15888                Dualpi2Attrs::SplitGso(val) => {
15889                    if last_off == offset {
15890                        stack.push(("SplitGso", last_off));
15891                        break;
15892                    }
15893                }
15894                _ => {}
15895            };
15896            last_off = cur + attrs.pos;
15897        }
15898        if !stack.is_empty() {
15899            stack.push(("Dualpi2Attrs", cur));
15900        }
15901        (stack, None)
15902    }
15903}
15904#[derive(Clone)]
15905pub enum EmatchAttrs<'a> {
15906    TreeHdr(TcfEmatchTreeHdr),
15907    TreeList(&'a [u8]),
15908}
15909impl<'a> IterableEmatchAttrs<'a> {
15910    pub fn get_tree_hdr(&self) -> Result<TcfEmatchTreeHdr, ErrorContext> {
15911        let mut iter = self.clone();
15912        iter.pos = 0;
15913        for attr in iter {
15914            if let EmatchAttrs::TreeHdr(val) = attr? {
15915                return Ok(val);
15916            }
15917        }
15918        Err(ErrorContext::new_missing(
15919            "EmatchAttrs",
15920            "TreeHdr",
15921            self.orig_loc,
15922            self.buf.as_ptr() as usize,
15923        ))
15924    }
15925    pub fn get_tree_list(&self) -> Result<&'a [u8], ErrorContext> {
15926        let mut iter = self.clone();
15927        iter.pos = 0;
15928        for attr in iter {
15929            if let EmatchAttrs::TreeList(val) = attr? {
15930                return Ok(val);
15931            }
15932        }
15933        Err(ErrorContext::new_missing(
15934            "EmatchAttrs",
15935            "TreeList",
15936            self.orig_loc,
15937            self.buf.as_ptr() as usize,
15938        ))
15939    }
15940}
15941impl EmatchAttrs<'_> {
15942    pub fn new<'a>(buf: &'a [u8]) -> IterableEmatchAttrs<'a> {
15943        IterableEmatchAttrs::with_loc(buf, buf.as_ptr() as usize)
15944    }
15945    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15946        let res = match r#type {
15947            1u16 => "TreeHdr",
15948            2u16 => "TreeList",
15949            _ => return None,
15950        };
15951        Some(res)
15952    }
15953}
15954#[derive(Clone, Copy, Default)]
15955pub struct IterableEmatchAttrs<'a> {
15956    buf: &'a [u8],
15957    pos: usize,
15958    orig_loc: usize,
15959}
15960impl<'a> IterableEmatchAttrs<'a> {
15961    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15962        Self {
15963            buf,
15964            pos: 0,
15965            orig_loc,
15966        }
15967    }
15968    pub fn get_buf(&self) -> &'a [u8] {
15969        self.buf
15970    }
15971}
15972impl<'a> Iterator for IterableEmatchAttrs<'a> {
15973    type Item = Result<EmatchAttrs<'a>, ErrorContext>;
15974    fn next(&mut self) -> Option<Self::Item> {
15975        let pos = self.pos;
15976        let mut r#type;
15977        loop {
15978            r#type = None;
15979            if self.buf.len() == self.pos {
15980                return None;
15981            }
15982            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
15983                break;
15984            };
15985            r#type = Some(header.r#type);
15986            let res = match header.r#type {
15987                1u16 => EmatchAttrs::TreeHdr({
15988                    let res = Some(TcfEmatchTreeHdr::new_from_zeroed(next));
15989                    let Some(val) = res else { break };
15990                    val
15991                }),
15992                2u16 => EmatchAttrs::TreeList({
15993                    let res = Some(next);
15994                    let Some(val) = res else { break };
15995                    val
15996                }),
15997                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
15998                n => continue,
15999            };
16000            return Some(Ok(res));
16001        }
16002        Some(Err(ErrorContext::new(
16003            "EmatchAttrs",
16004            r#type.and_then(|t| EmatchAttrs::attr_from_type(t)),
16005            self.orig_loc,
16006            self.buf.as_ptr().wrapping_add(pos) as usize,
16007        )))
16008    }
16009}
16010impl<'a> std::fmt::Debug for IterableEmatchAttrs<'_> {
16011    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16012        let mut fmt = f.debug_struct("EmatchAttrs");
16013        for attr in self.clone() {
16014            let attr = match attr {
16015                Ok(a) => a,
16016                Err(err) => {
16017                    fmt.finish()?;
16018                    f.write_str("Err(")?;
16019                    err.fmt(f)?;
16020                    return f.write_str(")");
16021                }
16022            };
16023            match attr {
16024                EmatchAttrs::TreeHdr(val) => fmt.field("TreeHdr", &val),
16025                EmatchAttrs::TreeList(val) => fmt.field("TreeList", &val),
16026            };
16027        }
16028        fmt.finish()
16029    }
16030}
16031impl IterableEmatchAttrs<'_> {
16032    pub fn lookup_attr(
16033        &self,
16034        offset: usize,
16035        missing_type: Option<u16>,
16036    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16037        let mut stack = Vec::new();
16038        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
16039        if missing_type.is_some() && cur == offset {
16040            stack.push(("EmatchAttrs", offset));
16041            return (
16042                stack,
16043                missing_type.and_then(|t| EmatchAttrs::attr_from_type(t)),
16044            );
16045        }
16046        if cur > offset || cur + self.buf.len() < offset {
16047            return (stack, None);
16048        }
16049        let mut attrs = self.clone();
16050        let mut last_off = cur + attrs.pos;
16051        while let Some(attr) = attrs.next() {
16052            let Ok(attr) = attr else { break };
16053            match attr {
16054                EmatchAttrs::TreeHdr(val) => {
16055                    if last_off == offset {
16056                        stack.push(("TreeHdr", last_off));
16057                        break;
16058                    }
16059                }
16060                EmatchAttrs::TreeList(val) => {
16061                    if last_off == offset {
16062                        stack.push(("TreeList", last_off));
16063                        break;
16064                    }
16065                }
16066                _ => {}
16067            };
16068            last_off = cur + attrs.pos;
16069        }
16070        if !stack.is_empty() {
16071            stack.push(("EmatchAttrs", cur));
16072        }
16073        (stack, None)
16074    }
16075}
16076#[derive(Clone)]
16077pub enum FlowAttrs<'a> {
16078    Keys(u32),
16079    Mode(u32),
16080    Baseclass(u32),
16081    Rshift(u32),
16082    Addend(u32),
16083    Mask(u32),
16084    Xor(u32),
16085    Divisor(u32),
16086    Act(&'a [u8]),
16087    Police(IterablePoliceAttrs<'a>),
16088    Ematches(&'a [u8]),
16089    Perturb(u32),
16090}
16091impl<'a> IterableFlowAttrs<'a> {
16092    pub fn get_keys(&self) -> Result<u32, ErrorContext> {
16093        let mut iter = self.clone();
16094        iter.pos = 0;
16095        for attr in iter {
16096            if let FlowAttrs::Keys(val) = attr? {
16097                return Ok(val);
16098            }
16099        }
16100        Err(ErrorContext::new_missing(
16101            "FlowAttrs",
16102            "Keys",
16103            self.orig_loc,
16104            self.buf.as_ptr() as usize,
16105        ))
16106    }
16107    pub fn get_mode(&self) -> Result<u32, ErrorContext> {
16108        let mut iter = self.clone();
16109        iter.pos = 0;
16110        for attr in iter {
16111            if let FlowAttrs::Mode(val) = attr? {
16112                return Ok(val);
16113            }
16114        }
16115        Err(ErrorContext::new_missing(
16116            "FlowAttrs",
16117            "Mode",
16118            self.orig_loc,
16119            self.buf.as_ptr() as usize,
16120        ))
16121    }
16122    pub fn get_baseclass(&self) -> Result<u32, ErrorContext> {
16123        let mut iter = self.clone();
16124        iter.pos = 0;
16125        for attr in iter {
16126            if let FlowAttrs::Baseclass(val) = attr? {
16127                return Ok(val);
16128            }
16129        }
16130        Err(ErrorContext::new_missing(
16131            "FlowAttrs",
16132            "Baseclass",
16133            self.orig_loc,
16134            self.buf.as_ptr() as usize,
16135        ))
16136    }
16137    pub fn get_rshift(&self) -> Result<u32, ErrorContext> {
16138        let mut iter = self.clone();
16139        iter.pos = 0;
16140        for attr in iter {
16141            if let FlowAttrs::Rshift(val) = attr? {
16142                return Ok(val);
16143            }
16144        }
16145        Err(ErrorContext::new_missing(
16146            "FlowAttrs",
16147            "Rshift",
16148            self.orig_loc,
16149            self.buf.as_ptr() as usize,
16150        ))
16151    }
16152    pub fn get_addend(&self) -> Result<u32, ErrorContext> {
16153        let mut iter = self.clone();
16154        iter.pos = 0;
16155        for attr in iter {
16156            if let FlowAttrs::Addend(val) = attr? {
16157                return Ok(val);
16158            }
16159        }
16160        Err(ErrorContext::new_missing(
16161            "FlowAttrs",
16162            "Addend",
16163            self.orig_loc,
16164            self.buf.as_ptr() as usize,
16165        ))
16166    }
16167    pub fn get_mask(&self) -> Result<u32, ErrorContext> {
16168        let mut iter = self.clone();
16169        iter.pos = 0;
16170        for attr in iter {
16171            if let FlowAttrs::Mask(val) = attr? {
16172                return Ok(val);
16173            }
16174        }
16175        Err(ErrorContext::new_missing(
16176            "FlowAttrs",
16177            "Mask",
16178            self.orig_loc,
16179            self.buf.as_ptr() as usize,
16180        ))
16181    }
16182    pub fn get_xor(&self) -> Result<u32, ErrorContext> {
16183        let mut iter = self.clone();
16184        iter.pos = 0;
16185        for attr in iter {
16186            if let FlowAttrs::Xor(val) = attr? {
16187                return Ok(val);
16188            }
16189        }
16190        Err(ErrorContext::new_missing(
16191            "FlowAttrs",
16192            "Xor",
16193            self.orig_loc,
16194            self.buf.as_ptr() as usize,
16195        ))
16196    }
16197    pub fn get_divisor(&self) -> Result<u32, ErrorContext> {
16198        let mut iter = self.clone();
16199        iter.pos = 0;
16200        for attr in iter {
16201            if let FlowAttrs::Divisor(val) = attr? {
16202                return Ok(val);
16203            }
16204        }
16205        Err(ErrorContext::new_missing(
16206            "FlowAttrs",
16207            "Divisor",
16208            self.orig_loc,
16209            self.buf.as_ptr() as usize,
16210        ))
16211    }
16212    pub fn get_act(&self) -> Result<&'a [u8], ErrorContext> {
16213        let mut iter = self.clone();
16214        iter.pos = 0;
16215        for attr in iter {
16216            if let FlowAttrs::Act(val) = attr? {
16217                return Ok(val);
16218            }
16219        }
16220        Err(ErrorContext::new_missing(
16221            "FlowAttrs",
16222            "Act",
16223            self.orig_loc,
16224            self.buf.as_ptr() as usize,
16225        ))
16226    }
16227    pub fn get_police(&self) -> Result<IterablePoliceAttrs<'a>, ErrorContext> {
16228        let mut iter = self.clone();
16229        iter.pos = 0;
16230        for attr in iter {
16231            if let FlowAttrs::Police(val) = attr? {
16232                return Ok(val);
16233            }
16234        }
16235        Err(ErrorContext::new_missing(
16236            "FlowAttrs",
16237            "Police",
16238            self.orig_loc,
16239            self.buf.as_ptr() as usize,
16240        ))
16241    }
16242    pub fn get_ematches(&self) -> Result<&'a [u8], ErrorContext> {
16243        let mut iter = self.clone();
16244        iter.pos = 0;
16245        for attr in iter {
16246            if let FlowAttrs::Ematches(val) = attr? {
16247                return Ok(val);
16248            }
16249        }
16250        Err(ErrorContext::new_missing(
16251            "FlowAttrs",
16252            "Ematches",
16253            self.orig_loc,
16254            self.buf.as_ptr() as usize,
16255        ))
16256    }
16257    pub fn get_perturb(&self) -> Result<u32, ErrorContext> {
16258        let mut iter = self.clone();
16259        iter.pos = 0;
16260        for attr in iter {
16261            if let FlowAttrs::Perturb(val) = attr? {
16262                return Ok(val);
16263            }
16264        }
16265        Err(ErrorContext::new_missing(
16266            "FlowAttrs",
16267            "Perturb",
16268            self.orig_loc,
16269            self.buf.as_ptr() as usize,
16270        ))
16271    }
16272}
16273impl FlowAttrs<'_> {
16274    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowAttrs<'a> {
16275        IterableFlowAttrs::with_loc(buf, buf.as_ptr() as usize)
16276    }
16277    fn attr_from_type(r#type: u16) -> Option<&'static str> {
16278        let res = match r#type {
16279            1u16 => "Keys",
16280            2u16 => "Mode",
16281            3u16 => "Baseclass",
16282            4u16 => "Rshift",
16283            5u16 => "Addend",
16284            6u16 => "Mask",
16285            7u16 => "Xor",
16286            8u16 => "Divisor",
16287            9u16 => "Act",
16288            10u16 => "Police",
16289            11u16 => "Ematches",
16290            12u16 => "Perturb",
16291            _ => return None,
16292        };
16293        Some(res)
16294    }
16295}
16296#[derive(Clone, Copy, Default)]
16297pub struct IterableFlowAttrs<'a> {
16298    buf: &'a [u8],
16299    pos: usize,
16300    orig_loc: usize,
16301}
16302impl<'a> IterableFlowAttrs<'a> {
16303    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
16304        Self {
16305            buf,
16306            pos: 0,
16307            orig_loc,
16308        }
16309    }
16310    pub fn get_buf(&self) -> &'a [u8] {
16311        self.buf
16312    }
16313}
16314impl<'a> Iterator for IterableFlowAttrs<'a> {
16315    type Item = Result<FlowAttrs<'a>, ErrorContext>;
16316    fn next(&mut self) -> Option<Self::Item> {
16317        let pos = self.pos;
16318        let mut r#type;
16319        loop {
16320            r#type = None;
16321            if self.buf.len() == self.pos {
16322                return None;
16323            }
16324            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
16325                break;
16326            };
16327            r#type = Some(header.r#type);
16328            let res = match header.r#type {
16329                1u16 => FlowAttrs::Keys({
16330                    let res = parse_u32(next);
16331                    let Some(val) = res else { break };
16332                    val
16333                }),
16334                2u16 => FlowAttrs::Mode({
16335                    let res = parse_u32(next);
16336                    let Some(val) = res else { break };
16337                    val
16338                }),
16339                3u16 => FlowAttrs::Baseclass({
16340                    let res = parse_u32(next);
16341                    let Some(val) = res else { break };
16342                    val
16343                }),
16344                4u16 => FlowAttrs::Rshift({
16345                    let res = parse_u32(next);
16346                    let Some(val) = res else { break };
16347                    val
16348                }),
16349                5u16 => FlowAttrs::Addend({
16350                    let res = parse_u32(next);
16351                    let Some(val) = res else { break };
16352                    val
16353                }),
16354                6u16 => FlowAttrs::Mask({
16355                    let res = parse_u32(next);
16356                    let Some(val) = res else { break };
16357                    val
16358                }),
16359                7u16 => FlowAttrs::Xor({
16360                    let res = parse_u32(next);
16361                    let Some(val) = res else { break };
16362                    val
16363                }),
16364                8u16 => FlowAttrs::Divisor({
16365                    let res = parse_u32(next);
16366                    let Some(val) = res else { break };
16367                    val
16368                }),
16369                9u16 => FlowAttrs::Act({
16370                    let res = Some(next);
16371                    let Some(val) = res else { break };
16372                    val
16373                }),
16374                10u16 => FlowAttrs::Police({
16375                    let res = Some(IterablePoliceAttrs::with_loc(next, self.orig_loc));
16376                    let Some(val) = res else { break };
16377                    val
16378                }),
16379                11u16 => FlowAttrs::Ematches({
16380                    let res = Some(next);
16381                    let Some(val) = res else { break };
16382                    val
16383                }),
16384                12u16 => FlowAttrs::Perturb({
16385                    let res = parse_u32(next);
16386                    let Some(val) = res else { break };
16387                    val
16388                }),
16389                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
16390                n => continue,
16391            };
16392            return Some(Ok(res));
16393        }
16394        Some(Err(ErrorContext::new(
16395            "FlowAttrs",
16396            r#type.and_then(|t| FlowAttrs::attr_from_type(t)),
16397            self.orig_loc,
16398            self.buf.as_ptr().wrapping_add(pos) as usize,
16399        )))
16400    }
16401}
16402impl<'a> std::fmt::Debug for IterableFlowAttrs<'_> {
16403    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16404        let mut fmt = f.debug_struct("FlowAttrs");
16405        for attr in self.clone() {
16406            let attr = match attr {
16407                Ok(a) => a,
16408                Err(err) => {
16409                    fmt.finish()?;
16410                    f.write_str("Err(")?;
16411                    err.fmt(f)?;
16412                    return f.write_str(")");
16413                }
16414            };
16415            match attr {
16416                FlowAttrs::Keys(val) => fmt.field("Keys", &val),
16417                FlowAttrs::Mode(val) => fmt.field("Mode", &val),
16418                FlowAttrs::Baseclass(val) => fmt.field("Baseclass", &val),
16419                FlowAttrs::Rshift(val) => fmt.field("Rshift", &val),
16420                FlowAttrs::Addend(val) => fmt.field("Addend", &val),
16421                FlowAttrs::Mask(val) => fmt.field("Mask", &val),
16422                FlowAttrs::Xor(val) => fmt.field("Xor", &val),
16423                FlowAttrs::Divisor(val) => fmt.field("Divisor", &val),
16424                FlowAttrs::Act(val) => fmt.field("Act", &val),
16425                FlowAttrs::Police(val) => fmt.field("Police", &val),
16426                FlowAttrs::Ematches(val) => fmt.field("Ematches", &val),
16427                FlowAttrs::Perturb(val) => fmt.field("Perturb", &val),
16428            };
16429        }
16430        fmt.finish()
16431    }
16432}
16433impl IterableFlowAttrs<'_> {
16434    pub fn lookup_attr(
16435        &self,
16436        offset: usize,
16437        missing_type: Option<u16>,
16438    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16439        let mut stack = Vec::new();
16440        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
16441        if missing_type.is_some() && cur == offset {
16442            stack.push(("FlowAttrs", offset));
16443            return (
16444                stack,
16445                missing_type.and_then(|t| FlowAttrs::attr_from_type(t)),
16446            );
16447        }
16448        if cur > offset || cur + self.buf.len() < offset {
16449            return (stack, None);
16450        }
16451        let mut attrs = self.clone();
16452        let mut last_off = cur + attrs.pos;
16453        let mut missing = None;
16454        while let Some(attr) = attrs.next() {
16455            let Ok(attr) = attr else { break };
16456            match attr {
16457                FlowAttrs::Keys(val) => {
16458                    if last_off == offset {
16459                        stack.push(("Keys", last_off));
16460                        break;
16461                    }
16462                }
16463                FlowAttrs::Mode(val) => {
16464                    if last_off == offset {
16465                        stack.push(("Mode", last_off));
16466                        break;
16467                    }
16468                }
16469                FlowAttrs::Baseclass(val) => {
16470                    if last_off == offset {
16471                        stack.push(("Baseclass", last_off));
16472                        break;
16473                    }
16474                }
16475                FlowAttrs::Rshift(val) => {
16476                    if last_off == offset {
16477                        stack.push(("Rshift", last_off));
16478                        break;
16479                    }
16480                }
16481                FlowAttrs::Addend(val) => {
16482                    if last_off == offset {
16483                        stack.push(("Addend", last_off));
16484                        break;
16485                    }
16486                }
16487                FlowAttrs::Mask(val) => {
16488                    if last_off == offset {
16489                        stack.push(("Mask", last_off));
16490                        break;
16491                    }
16492                }
16493                FlowAttrs::Xor(val) => {
16494                    if last_off == offset {
16495                        stack.push(("Xor", last_off));
16496                        break;
16497                    }
16498                }
16499                FlowAttrs::Divisor(val) => {
16500                    if last_off == offset {
16501                        stack.push(("Divisor", last_off));
16502                        break;
16503                    }
16504                }
16505                FlowAttrs::Act(val) => {
16506                    if last_off == offset {
16507                        stack.push(("Act", last_off));
16508                        break;
16509                    }
16510                }
16511                FlowAttrs::Police(val) => {
16512                    (stack, missing) = val.lookup_attr(offset, missing_type);
16513                    if !stack.is_empty() {
16514                        break;
16515                    }
16516                }
16517                FlowAttrs::Ematches(val) => {
16518                    if last_off == offset {
16519                        stack.push(("Ematches", last_off));
16520                        break;
16521                    }
16522                }
16523                FlowAttrs::Perturb(val) => {
16524                    if last_off == offset {
16525                        stack.push(("Perturb", last_off));
16526                        break;
16527                    }
16528                }
16529                _ => {}
16530            };
16531            last_off = cur + attrs.pos;
16532        }
16533        if !stack.is_empty() {
16534            stack.push(("FlowAttrs", cur));
16535        }
16536        (stack, missing)
16537    }
16538}
16539#[derive(Clone)]
16540pub enum FlowerAttrs<'a> {
16541    Classid(u32),
16542    Indev(&'a CStr),
16543    Act(IterableArrayActAttrs<'a>),
16544    KeyEthDst(&'a [u8]),
16545    KeyEthDstMask(&'a [u8]),
16546    KeyEthSrc(&'a [u8]),
16547    KeyEthSrcMask(&'a [u8]),
16548    KeyEthType(u16),
16549    KeyIpProto(u8),
16550    KeyIpv4Src(std::net::Ipv4Addr),
16551    KeyIpv4SrcMask(std::net::Ipv4Addr),
16552    KeyIpv4Dst(std::net::Ipv4Addr),
16553    KeyIpv4DstMask(std::net::Ipv4Addr),
16554    KeyIpv6Src(&'a [u8]),
16555    KeyIpv6SrcMask(&'a [u8]),
16556    KeyIpv6Dst(&'a [u8]),
16557    KeyIpv6DstMask(&'a [u8]),
16558    KeyTcpSrc(u16),
16559    KeyTcpDst(u16),
16560    KeyUdpSrc(u16),
16561    KeyUdpDst(u16),
16562    #[doc = "Associated type: [`ClsFlags`] (1 bit per enumeration)"]
16563    Flags(u32),
16564    KeyVlanId(u16),
16565    KeyVlanPrio(u8),
16566    KeyVlanEthType(u16),
16567    KeyEncKeyId(u32),
16568    KeyEncIpv4Src(std::net::Ipv4Addr),
16569    KeyEncIpv4SrcMask(std::net::Ipv4Addr),
16570    KeyEncIpv4Dst(std::net::Ipv4Addr),
16571    KeyEncIpv4DstMask(std::net::Ipv4Addr),
16572    KeyEncIpv6Src(&'a [u8]),
16573    KeyEncIpv6SrcMask(&'a [u8]),
16574    KeyEncIpv6Dst(&'a [u8]),
16575    KeyEncIpv6DstMask(&'a [u8]),
16576    KeyTcpSrcMask(u16),
16577    KeyTcpDstMask(u16),
16578    KeyUdpSrcMask(u16),
16579    KeyUdpDstMask(u16),
16580    KeySctpSrcMask(u16),
16581    KeySctpDstMask(u16),
16582    KeySctpSrc(u16),
16583    KeySctpDst(u16),
16584    KeyEncUdpSrcPort(u16),
16585    KeyEncUdpSrcPortMask(u16),
16586    KeyEncUdpDstPort(u16),
16587    KeyEncUdpDstPortMask(u16),
16588    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
16589    KeyFlags(u32),
16590    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
16591    KeyFlagsMask(u32),
16592    KeyIcmpv4Code(u8),
16593    KeyIcmpv4CodeMask(u8),
16594    KeyIcmpv4Type(u8),
16595    KeyIcmpv4TypeMask(u8),
16596    KeyIcmpv6Code(u8),
16597    KeyIcmpv6CodeMask(u8),
16598    KeyIcmpv6Type(u8),
16599    KeyIcmpv6TypeMask(u8),
16600    KeyArpSip(u32),
16601    KeyArpSipMask(u32),
16602    KeyArpTip(u32),
16603    KeyArpTipMask(u32),
16604    KeyArpOp(u8),
16605    KeyArpOpMask(u8),
16606    KeyArpSha(&'a [u8]),
16607    KeyArpShaMask(&'a [u8]),
16608    KeyArpTha(&'a [u8]),
16609    KeyArpThaMask(&'a [u8]),
16610    KeyMplsTtl(u8),
16611    KeyMplsBos(u8),
16612    KeyMplsTc(u8),
16613    KeyMplsLabel(u32),
16614    KeyTcpFlags(u16),
16615    KeyTcpFlagsMask(u16),
16616    KeyIpTos(u8),
16617    KeyIpTosMask(u8),
16618    KeyIpTtl(u8),
16619    KeyIpTtlMask(u8),
16620    KeyCvlanId(u16),
16621    KeyCvlanPrio(u8),
16622    KeyCvlanEthType(u16),
16623    KeyEncIpTos(u8),
16624    KeyEncIpTosMask(u8),
16625    KeyEncIpTtl(u8),
16626    KeyEncIpTtlMask(u8),
16627    KeyEncOpts(IterableFlowerKeyEncOptsAttrs<'a>),
16628    KeyEncOptsMask(IterableFlowerKeyEncOptsAttrs<'a>),
16629    InHwCount(u32),
16630    KeyPortSrcMin(u16),
16631    KeyPortSrcMax(u16),
16632    KeyPortDstMin(u16),
16633    KeyPortDstMax(u16),
16634    KeyCtState(u16),
16635    KeyCtStateMask(u16),
16636    KeyCtZone(u16),
16637    KeyCtZoneMask(u16),
16638    KeyCtMark(u32),
16639    KeyCtMarkMask(u32),
16640    KeyCtLabels(&'a [u8]),
16641    KeyCtLabelsMask(&'a [u8]),
16642    KeyMplsOpts(IterableFlowerKeyMplsOptAttrs<'a>),
16643    KeyHash(u32),
16644    KeyHashMask(u32),
16645    KeyNumOfVlans(u8),
16646    KeyPppoeSid(u16),
16647    KeyPppProto(u16),
16648    KeyL2tpv3Sid(u32),
16649    L2Miss(u8),
16650    KeyCfm(IterableFlowerKeyCfmAttrs<'a>),
16651    KeySpi(u32),
16652    KeySpiMask(u32),
16653    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
16654    KeyEncFlags(u32),
16655    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
16656    KeyEncFlagsMask(u32),
16657}
16658impl<'a> IterableFlowerAttrs<'a> {
16659    pub fn get_classid(&self) -> Result<u32, ErrorContext> {
16660        let mut iter = self.clone();
16661        iter.pos = 0;
16662        for attr in iter {
16663            if let FlowerAttrs::Classid(val) = attr? {
16664                return Ok(val);
16665            }
16666        }
16667        Err(ErrorContext::new_missing(
16668            "FlowerAttrs",
16669            "Classid",
16670            self.orig_loc,
16671            self.buf.as_ptr() as usize,
16672        ))
16673    }
16674    pub fn get_indev(&self) -> Result<&'a CStr, ErrorContext> {
16675        let mut iter = self.clone();
16676        iter.pos = 0;
16677        for attr in iter {
16678            if let FlowerAttrs::Indev(val) = attr? {
16679                return Ok(val);
16680            }
16681        }
16682        Err(ErrorContext::new_missing(
16683            "FlowerAttrs",
16684            "Indev",
16685            self.orig_loc,
16686            self.buf.as_ptr() as usize,
16687        ))
16688    }
16689    pub fn get_act(
16690        &self,
16691    ) -> Result<ArrayIterable<IterableArrayActAttrs<'a>, IterableActAttrs<'a>>, ErrorContext> {
16692        for attr in self.clone() {
16693            if let FlowerAttrs::Act(val) = attr? {
16694                return Ok(ArrayIterable::new(val));
16695            }
16696        }
16697        Err(ErrorContext::new_missing(
16698            "FlowerAttrs",
16699            "Act",
16700            self.orig_loc,
16701            self.buf.as_ptr() as usize,
16702        ))
16703    }
16704    pub fn get_key_eth_dst(&self) -> Result<&'a [u8], ErrorContext> {
16705        let mut iter = self.clone();
16706        iter.pos = 0;
16707        for attr in iter {
16708            if let FlowerAttrs::KeyEthDst(val) = attr? {
16709                return Ok(val);
16710            }
16711        }
16712        Err(ErrorContext::new_missing(
16713            "FlowerAttrs",
16714            "KeyEthDst",
16715            self.orig_loc,
16716            self.buf.as_ptr() as usize,
16717        ))
16718    }
16719    pub fn get_key_eth_dst_mask(&self) -> Result<&'a [u8], ErrorContext> {
16720        let mut iter = self.clone();
16721        iter.pos = 0;
16722        for attr in iter {
16723            if let FlowerAttrs::KeyEthDstMask(val) = attr? {
16724                return Ok(val);
16725            }
16726        }
16727        Err(ErrorContext::new_missing(
16728            "FlowerAttrs",
16729            "KeyEthDstMask",
16730            self.orig_loc,
16731            self.buf.as_ptr() as usize,
16732        ))
16733    }
16734    pub fn get_key_eth_src(&self) -> Result<&'a [u8], ErrorContext> {
16735        let mut iter = self.clone();
16736        iter.pos = 0;
16737        for attr in iter {
16738            if let FlowerAttrs::KeyEthSrc(val) = attr? {
16739                return Ok(val);
16740            }
16741        }
16742        Err(ErrorContext::new_missing(
16743            "FlowerAttrs",
16744            "KeyEthSrc",
16745            self.orig_loc,
16746            self.buf.as_ptr() as usize,
16747        ))
16748    }
16749    pub fn get_key_eth_src_mask(&self) -> Result<&'a [u8], ErrorContext> {
16750        let mut iter = self.clone();
16751        iter.pos = 0;
16752        for attr in iter {
16753            if let FlowerAttrs::KeyEthSrcMask(val) = attr? {
16754                return Ok(val);
16755            }
16756        }
16757        Err(ErrorContext::new_missing(
16758            "FlowerAttrs",
16759            "KeyEthSrcMask",
16760            self.orig_loc,
16761            self.buf.as_ptr() as usize,
16762        ))
16763    }
16764    pub fn get_key_eth_type(&self) -> Result<u16, ErrorContext> {
16765        let mut iter = self.clone();
16766        iter.pos = 0;
16767        for attr in iter {
16768            if let FlowerAttrs::KeyEthType(val) = attr? {
16769                return Ok(val);
16770            }
16771        }
16772        Err(ErrorContext::new_missing(
16773            "FlowerAttrs",
16774            "KeyEthType",
16775            self.orig_loc,
16776            self.buf.as_ptr() as usize,
16777        ))
16778    }
16779    pub fn get_key_ip_proto(&self) -> Result<u8, ErrorContext> {
16780        let mut iter = self.clone();
16781        iter.pos = 0;
16782        for attr in iter {
16783            if let FlowerAttrs::KeyIpProto(val) = attr? {
16784                return Ok(val);
16785            }
16786        }
16787        Err(ErrorContext::new_missing(
16788            "FlowerAttrs",
16789            "KeyIpProto",
16790            self.orig_loc,
16791            self.buf.as_ptr() as usize,
16792        ))
16793    }
16794    pub fn get_key_ipv4_src(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
16795        let mut iter = self.clone();
16796        iter.pos = 0;
16797        for attr in iter {
16798            if let FlowerAttrs::KeyIpv4Src(val) = attr? {
16799                return Ok(val);
16800            }
16801        }
16802        Err(ErrorContext::new_missing(
16803            "FlowerAttrs",
16804            "KeyIpv4Src",
16805            self.orig_loc,
16806            self.buf.as_ptr() as usize,
16807        ))
16808    }
16809    pub fn get_key_ipv4_src_mask(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
16810        let mut iter = self.clone();
16811        iter.pos = 0;
16812        for attr in iter {
16813            if let FlowerAttrs::KeyIpv4SrcMask(val) = attr? {
16814                return Ok(val);
16815            }
16816        }
16817        Err(ErrorContext::new_missing(
16818            "FlowerAttrs",
16819            "KeyIpv4SrcMask",
16820            self.orig_loc,
16821            self.buf.as_ptr() as usize,
16822        ))
16823    }
16824    pub fn get_key_ipv4_dst(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
16825        let mut iter = self.clone();
16826        iter.pos = 0;
16827        for attr in iter {
16828            if let FlowerAttrs::KeyIpv4Dst(val) = attr? {
16829                return Ok(val);
16830            }
16831        }
16832        Err(ErrorContext::new_missing(
16833            "FlowerAttrs",
16834            "KeyIpv4Dst",
16835            self.orig_loc,
16836            self.buf.as_ptr() as usize,
16837        ))
16838    }
16839    pub fn get_key_ipv4_dst_mask(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
16840        let mut iter = self.clone();
16841        iter.pos = 0;
16842        for attr in iter {
16843            if let FlowerAttrs::KeyIpv4DstMask(val) = attr? {
16844                return Ok(val);
16845            }
16846        }
16847        Err(ErrorContext::new_missing(
16848            "FlowerAttrs",
16849            "KeyIpv4DstMask",
16850            self.orig_loc,
16851            self.buf.as_ptr() as usize,
16852        ))
16853    }
16854    pub fn get_key_ipv6_src(&self) -> Result<&'a [u8], ErrorContext> {
16855        let mut iter = self.clone();
16856        iter.pos = 0;
16857        for attr in iter {
16858            if let FlowerAttrs::KeyIpv6Src(val) = attr? {
16859                return Ok(val);
16860            }
16861        }
16862        Err(ErrorContext::new_missing(
16863            "FlowerAttrs",
16864            "KeyIpv6Src",
16865            self.orig_loc,
16866            self.buf.as_ptr() as usize,
16867        ))
16868    }
16869    pub fn get_key_ipv6_src_mask(&self) -> Result<&'a [u8], ErrorContext> {
16870        let mut iter = self.clone();
16871        iter.pos = 0;
16872        for attr in iter {
16873            if let FlowerAttrs::KeyIpv6SrcMask(val) = attr? {
16874                return Ok(val);
16875            }
16876        }
16877        Err(ErrorContext::new_missing(
16878            "FlowerAttrs",
16879            "KeyIpv6SrcMask",
16880            self.orig_loc,
16881            self.buf.as_ptr() as usize,
16882        ))
16883    }
16884    pub fn get_key_ipv6_dst(&self) -> Result<&'a [u8], ErrorContext> {
16885        let mut iter = self.clone();
16886        iter.pos = 0;
16887        for attr in iter {
16888            if let FlowerAttrs::KeyIpv6Dst(val) = attr? {
16889                return Ok(val);
16890            }
16891        }
16892        Err(ErrorContext::new_missing(
16893            "FlowerAttrs",
16894            "KeyIpv6Dst",
16895            self.orig_loc,
16896            self.buf.as_ptr() as usize,
16897        ))
16898    }
16899    pub fn get_key_ipv6_dst_mask(&self) -> Result<&'a [u8], ErrorContext> {
16900        let mut iter = self.clone();
16901        iter.pos = 0;
16902        for attr in iter {
16903            if let FlowerAttrs::KeyIpv6DstMask(val) = attr? {
16904                return Ok(val);
16905            }
16906        }
16907        Err(ErrorContext::new_missing(
16908            "FlowerAttrs",
16909            "KeyIpv6DstMask",
16910            self.orig_loc,
16911            self.buf.as_ptr() as usize,
16912        ))
16913    }
16914    pub fn get_key_tcp_src(&self) -> Result<u16, ErrorContext> {
16915        let mut iter = self.clone();
16916        iter.pos = 0;
16917        for attr in iter {
16918            if let FlowerAttrs::KeyTcpSrc(val) = attr? {
16919                return Ok(val);
16920            }
16921        }
16922        Err(ErrorContext::new_missing(
16923            "FlowerAttrs",
16924            "KeyTcpSrc",
16925            self.orig_loc,
16926            self.buf.as_ptr() as usize,
16927        ))
16928    }
16929    pub fn get_key_tcp_dst(&self) -> Result<u16, ErrorContext> {
16930        let mut iter = self.clone();
16931        iter.pos = 0;
16932        for attr in iter {
16933            if let FlowerAttrs::KeyTcpDst(val) = attr? {
16934                return Ok(val);
16935            }
16936        }
16937        Err(ErrorContext::new_missing(
16938            "FlowerAttrs",
16939            "KeyTcpDst",
16940            self.orig_loc,
16941            self.buf.as_ptr() as usize,
16942        ))
16943    }
16944    pub fn get_key_udp_src(&self) -> Result<u16, ErrorContext> {
16945        let mut iter = self.clone();
16946        iter.pos = 0;
16947        for attr in iter {
16948            if let FlowerAttrs::KeyUdpSrc(val) = attr? {
16949                return Ok(val);
16950            }
16951        }
16952        Err(ErrorContext::new_missing(
16953            "FlowerAttrs",
16954            "KeyUdpSrc",
16955            self.orig_loc,
16956            self.buf.as_ptr() as usize,
16957        ))
16958    }
16959    pub fn get_key_udp_dst(&self) -> Result<u16, ErrorContext> {
16960        let mut iter = self.clone();
16961        iter.pos = 0;
16962        for attr in iter {
16963            if let FlowerAttrs::KeyUdpDst(val) = attr? {
16964                return Ok(val);
16965            }
16966        }
16967        Err(ErrorContext::new_missing(
16968            "FlowerAttrs",
16969            "KeyUdpDst",
16970            self.orig_loc,
16971            self.buf.as_ptr() as usize,
16972        ))
16973    }
16974    #[doc = "Associated type: [`ClsFlags`] (1 bit per enumeration)"]
16975    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
16976        let mut iter = self.clone();
16977        iter.pos = 0;
16978        for attr in iter {
16979            if let FlowerAttrs::Flags(val) = attr? {
16980                return Ok(val);
16981            }
16982        }
16983        Err(ErrorContext::new_missing(
16984            "FlowerAttrs",
16985            "Flags",
16986            self.orig_loc,
16987            self.buf.as_ptr() as usize,
16988        ))
16989    }
16990    pub fn get_key_vlan_id(&self) -> Result<u16, ErrorContext> {
16991        let mut iter = self.clone();
16992        iter.pos = 0;
16993        for attr in iter {
16994            if let FlowerAttrs::KeyVlanId(val) = attr? {
16995                return Ok(val);
16996            }
16997        }
16998        Err(ErrorContext::new_missing(
16999            "FlowerAttrs",
17000            "KeyVlanId",
17001            self.orig_loc,
17002            self.buf.as_ptr() as usize,
17003        ))
17004    }
17005    pub fn get_key_vlan_prio(&self) -> Result<u8, ErrorContext> {
17006        let mut iter = self.clone();
17007        iter.pos = 0;
17008        for attr in iter {
17009            if let FlowerAttrs::KeyVlanPrio(val) = attr? {
17010                return Ok(val);
17011            }
17012        }
17013        Err(ErrorContext::new_missing(
17014            "FlowerAttrs",
17015            "KeyVlanPrio",
17016            self.orig_loc,
17017            self.buf.as_ptr() as usize,
17018        ))
17019    }
17020    pub fn get_key_vlan_eth_type(&self) -> Result<u16, ErrorContext> {
17021        let mut iter = self.clone();
17022        iter.pos = 0;
17023        for attr in iter {
17024            if let FlowerAttrs::KeyVlanEthType(val) = attr? {
17025                return Ok(val);
17026            }
17027        }
17028        Err(ErrorContext::new_missing(
17029            "FlowerAttrs",
17030            "KeyVlanEthType",
17031            self.orig_loc,
17032            self.buf.as_ptr() as usize,
17033        ))
17034    }
17035    pub fn get_key_enc_key_id(&self) -> Result<u32, ErrorContext> {
17036        let mut iter = self.clone();
17037        iter.pos = 0;
17038        for attr in iter {
17039            if let FlowerAttrs::KeyEncKeyId(val) = attr? {
17040                return Ok(val);
17041            }
17042        }
17043        Err(ErrorContext::new_missing(
17044            "FlowerAttrs",
17045            "KeyEncKeyId",
17046            self.orig_loc,
17047            self.buf.as_ptr() as usize,
17048        ))
17049    }
17050    pub fn get_key_enc_ipv4_src(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
17051        let mut iter = self.clone();
17052        iter.pos = 0;
17053        for attr in iter {
17054            if let FlowerAttrs::KeyEncIpv4Src(val) = attr? {
17055                return Ok(val);
17056            }
17057        }
17058        Err(ErrorContext::new_missing(
17059            "FlowerAttrs",
17060            "KeyEncIpv4Src",
17061            self.orig_loc,
17062            self.buf.as_ptr() as usize,
17063        ))
17064    }
17065    pub fn get_key_enc_ipv4_src_mask(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
17066        let mut iter = self.clone();
17067        iter.pos = 0;
17068        for attr in iter {
17069            if let FlowerAttrs::KeyEncIpv4SrcMask(val) = attr? {
17070                return Ok(val);
17071            }
17072        }
17073        Err(ErrorContext::new_missing(
17074            "FlowerAttrs",
17075            "KeyEncIpv4SrcMask",
17076            self.orig_loc,
17077            self.buf.as_ptr() as usize,
17078        ))
17079    }
17080    pub fn get_key_enc_ipv4_dst(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
17081        let mut iter = self.clone();
17082        iter.pos = 0;
17083        for attr in iter {
17084            if let FlowerAttrs::KeyEncIpv4Dst(val) = attr? {
17085                return Ok(val);
17086            }
17087        }
17088        Err(ErrorContext::new_missing(
17089            "FlowerAttrs",
17090            "KeyEncIpv4Dst",
17091            self.orig_loc,
17092            self.buf.as_ptr() as usize,
17093        ))
17094    }
17095    pub fn get_key_enc_ipv4_dst_mask(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
17096        let mut iter = self.clone();
17097        iter.pos = 0;
17098        for attr in iter {
17099            if let FlowerAttrs::KeyEncIpv4DstMask(val) = attr? {
17100                return Ok(val);
17101            }
17102        }
17103        Err(ErrorContext::new_missing(
17104            "FlowerAttrs",
17105            "KeyEncIpv4DstMask",
17106            self.orig_loc,
17107            self.buf.as_ptr() as usize,
17108        ))
17109    }
17110    pub fn get_key_enc_ipv6_src(&self) -> Result<&'a [u8], ErrorContext> {
17111        let mut iter = self.clone();
17112        iter.pos = 0;
17113        for attr in iter {
17114            if let FlowerAttrs::KeyEncIpv6Src(val) = attr? {
17115                return Ok(val);
17116            }
17117        }
17118        Err(ErrorContext::new_missing(
17119            "FlowerAttrs",
17120            "KeyEncIpv6Src",
17121            self.orig_loc,
17122            self.buf.as_ptr() as usize,
17123        ))
17124    }
17125    pub fn get_key_enc_ipv6_src_mask(&self) -> Result<&'a [u8], ErrorContext> {
17126        let mut iter = self.clone();
17127        iter.pos = 0;
17128        for attr in iter {
17129            if let FlowerAttrs::KeyEncIpv6SrcMask(val) = attr? {
17130                return Ok(val);
17131            }
17132        }
17133        Err(ErrorContext::new_missing(
17134            "FlowerAttrs",
17135            "KeyEncIpv6SrcMask",
17136            self.orig_loc,
17137            self.buf.as_ptr() as usize,
17138        ))
17139    }
17140    pub fn get_key_enc_ipv6_dst(&self) -> Result<&'a [u8], ErrorContext> {
17141        let mut iter = self.clone();
17142        iter.pos = 0;
17143        for attr in iter {
17144            if let FlowerAttrs::KeyEncIpv6Dst(val) = attr? {
17145                return Ok(val);
17146            }
17147        }
17148        Err(ErrorContext::new_missing(
17149            "FlowerAttrs",
17150            "KeyEncIpv6Dst",
17151            self.orig_loc,
17152            self.buf.as_ptr() as usize,
17153        ))
17154    }
17155    pub fn get_key_enc_ipv6_dst_mask(&self) -> Result<&'a [u8], ErrorContext> {
17156        let mut iter = self.clone();
17157        iter.pos = 0;
17158        for attr in iter {
17159            if let FlowerAttrs::KeyEncIpv6DstMask(val) = attr? {
17160                return Ok(val);
17161            }
17162        }
17163        Err(ErrorContext::new_missing(
17164            "FlowerAttrs",
17165            "KeyEncIpv6DstMask",
17166            self.orig_loc,
17167            self.buf.as_ptr() as usize,
17168        ))
17169    }
17170    pub fn get_key_tcp_src_mask(&self) -> Result<u16, ErrorContext> {
17171        let mut iter = self.clone();
17172        iter.pos = 0;
17173        for attr in iter {
17174            if let FlowerAttrs::KeyTcpSrcMask(val) = attr? {
17175                return Ok(val);
17176            }
17177        }
17178        Err(ErrorContext::new_missing(
17179            "FlowerAttrs",
17180            "KeyTcpSrcMask",
17181            self.orig_loc,
17182            self.buf.as_ptr() as usize,
17183        ))
17184    }
17185    pub fn get_key_tcp_dst_mask(&self) -> Result<u16, ErrorContext> {
17186        let mut iter = self.clone();
17187        iter.pos = 0;
17188        for attr in iter {
17189            if let FlowerAttrs::KeyTcpDstMask(val) = attr? {
17190                return Ok(val);
17191            }
17192        }
17193        Err(ErrorContext::new_missing(
17194            "FlowerAttrs",
17195            "KeyTcpDstMask",
17196            self.orig_loc,
17197            self.buf.as_ptr() as usize,
17198        ))
17199    }
17200    pub fn get_key_udp_src_mask(&self) -> Result<u16, ErrorContext> {
17201        let mut iter = self.clone();
17202        iter.pos = 0;
17203        for attr in iter {
17204            if let FlowerAttrs::KeyUdpSrcMask(val) = attr? {
17205                return Ok(val);
17206            }
17207        }
17208        Err(ErrorContext::new_missing(
17209            "FlowerAttrs",
17210            "KeyUdpSrcMask",
17211            self.orig_loc,
17212            self.buf.as_ptr() as usize,
17213        ))
17214    }
17215    pub fn get_key_udp_dst_mask(&self) -> Result<u16, ErrorContext> {
17216        let mut iter = self.clone();
17217        iter.pos = 0;
17218        for attr in iter {
17219            if let FlowerAttrs::KeyUdpDstMask(val) = attr? {
17220                return Ok(val);
17221            }
17222        }
17223        Err(ErrorContext::new_missing(
17224            "FlowerAttrs",
17225            "KeyUdpDstMask",
17226            self.orig_loc,
17227            self.buf.as_ptr() as usize,
17228        ))
17229    }
17230    pub fn get_key_sctp_src_mask(&self) -> Result<u16, ErrorContext> {
17231        let mut iter = self.clone();
17232        iter.pos = 0;
17233        for attr in iter {
17234            if let FlowerAttrs::KeySctpSrcMask(val) = attr? {
17235                return Ok(val);
17236            }
17237        }
17238        Err(ErrorContext::new_missing(
17239            "FlowerAttrs",
17240            "KeySctpSrcMask",
17241            self.orig_loc,
17242            self.buf.as_ptr() as usize,
17243        ))
17244    }
17245    pub fn get_key_sctp_dst_mask(&self) -> Result<u16, ErrorContext> {
17246        let mut iter = self.clone();
17247        iter.pos = 0;
17248        for attr in iter {
17249            if let FlowerAttrs::KeySctpDstMask(val) = attr? {
17250                return Ok(val);
17251            }
17252        }
17253        Err(ErrorContext::new_missing(
17254            "FlowerAttrs",
17255            "KeySctpDstMask",
17256            self.orig_loc,
17257            self.buf.as_ptr() as usize,
17258        ))
17259    }
17260    pub fn get_key_sctp_src(&self) -> Result<u16, ErrorContext> {
17261        let mut iter = self.clone();
17262        iter.pos = 0;
17263        for attr in iter {
17264            if let FlowerAttrs::KeySctpSrc(val) = attr? {
17265                return Ok(val);
17266            }
17267        }
17268        Err(ErrorContext::new_missing(
17269            "FlowerAttrs",
17270            "KeySctpSrc",
17271            self.orig_loc,
17272            self.buf.as_ptr() as usize,
17273        ))
17274    }
17275    pub fn get_key_sctp_dst(&self) -> Result<u16, ErrorContext> {
17276        let mut iter = self.clone();
17277        iter.pos = 0;
17278        for attr in iter {
17279            if let FlowerAttrs::KeySctpDst(val) = attr? {
17280                return Ok(val);
17281            }
17282        }
17283        Err(ErrorContext::new_missing(
17284            "FlowerAttrs",
17285            "KeySctpDst",
17286            self.orig_loc,
17287            self.buf.as_ptr() as usize,
17288        ))
17289    }
17290    pub fn get_key_enc_udp_src_port(&self) -> Result<u16, ErrorContext> {
17291        let mut iter = self.clone();
17292        iter.pos = 0;
17293        for attr in iter {
17294            if let FlowerAttrs::KeyEncUdpSrcPort(val) = attr? {
17295                return Ok(val);
17296            }
17297        }
17298        Err(ErrorContext::new_missing(
17299            "FlowerAttrs",
17300            "KeyEncUdpSrcPort",
17301            self.orig_loc,
17302            self.buf.as_ptr() as usize,
17303        ))
17304    }
17305    pub fn get_key_enc_udp_src_port_mask(&self) -> Result<u16, ErrorContext> {
17306        let mut iter = self.clone();
17307        iter.pos = 0;
17308        for attr in iter {
17309            if let FlowerAttrs::KeyEncUdpSrcPortMask(val) = attr? {
17310                return Ok(val);
17311            }
17312        }
17313        Err(ErrorContext::new_missing(
17314            "FlowerAttrs",
17315            "KeyEncUdpSrcPortMask",
17316            self.orig_loc,
17317            self.buf.as_ptr() as usize,
17318        ))
17319    }
17320    pub fn get_key_enc_udp_dst_port(&self) -> Result<u16, ErrorContext> {
17321        let mut iter = self.clone();
17322        iter.pos = 0;
17323        for attr in iter {
17324            if let FlowerAttrs::KeyEncUdpDstPort(val) = attr? {
17325                return Ok(val);
17326            }
17327        }
17328        Err(ErrorContext::new_missing(
17329            "FlowerAttrs",
17330            "KeyEncUdpDstPort",
17331            self.orig_loc,
17332            self.buf.as_ptr() as usize,
17333        ))
17334    }
17335    pub fn get_key_enc_udp_dst_port_mask(&self) -> Result<u16, ErrorContext> {
17336        let mut iter = self.clone();
17337        iter.pos = 0;
17338        for attr in iter {
17339            if let FlowerAttrs::KeyEncUdpDstPortMask(val) = attr? {
17340                return Ok(val);
17341            }
17342        }
17343        Err(ErrorContext::new_missing(
17344            "FlowerAttrs",
17345            "KeyEncUdpDstPortMask",
17346            self.orig_loc,
17347            self.buf.as_ptr() as usize,
17348        ))
17349    }
17350    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
17351    pub fn get_key_flags(&self) -> Result<u32, ErrorContext> {
17352        let mut iter = self.clone();
17353        iter.pos = 0;
17354        for attr in iter {
17355            if let FlowerAttrs::KeyFlags(val) = attr? {
17356                return Ok(val);
17357            }
17358        }
17359        Err(ErrorContext::new_missing(
17360            "FlowerAttrs",
17361            "KeyFlags",
17362            self.orig_loc,
17363            self.buf.as_ptr() as usize,
17364        ))
17365    }
17366    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
17367    pub fn get_key_flags_mask(&self) -> Result<u32, ErrorContext> {
17368        let mut iter = self.clone();
17369        iter.pos = 0;
17370        for attr in iter {
17371            if let FlowerAttrs::KeyFlagsMask(val) = attr? {
17372                return Ok(val);
17373            }
17374        }
17375        Err(ErrorContext::new_missing(
17376            "FlowerAttrs",
17377            "KeyFlagsMask",
17378            self.orig_loc,
17379            self.buf.as_ptr() as usize,
17380        ))
17381    }
17382    pub fn get_key_icmpv4_code(&self) -> Result<u8, ErrorContext> {
17383        let mut iter = self.clone();
17384        iter.pos = 0;
17385        for attr in iter {
17386            if let FlowerAttrs::KeyIcmpv4Code(val) = attr? {
17387                return Ok(val);
17388            }
17389        }
17390        Err(ErrorContext::new_missing(
17391            "FlowerAttrs",
17392            "KeyIcmpv4Code",
17393            self.orig_loc,
17394            self.buf.as_ptr() as usize,
17395        ))
17396    }
17397    pub fn get_key_icmpv4_code_mask(&self) -> Result<u8, ErrorContext> {
17398        let mut iter = self.clone();
17399        iter.pos = 0;
17400        for attr in iter {
17401            if let FlowerAttrs::KeyIcmpv4CodeMask(val) = attr? {
17402                return Ok(val);
17403            }
17404        }
17405        Err(ErrorContext::new_missing(
17406            "FlowerAttrs",
17407            "KeyIcmpv4CodeMask",
17408            self.orig_loc,
17409            self.buf.as_ptr() as usize,
17410        ))
17411    }
17412    pub fn get_key_icmpv4_type(&self) -> Result<u8, ErrorContext> {
17413        let mut iter = self.clone();
17414        iter.pos = 0;
17415        for attr in iter {
17416            if let FlowerAttrs::KeyIcmpv4Type(val) = attr? {
17417                return Ok(val);
17418            }
17419        }
17420        Err(ErrorContext::new_missing(
17421            "FlowerAttrs",
17422            "KeyIcmpv4Type",
17423            self.orig_loc,
17424            self.buf.as_ptr() as usize,
17425        ))
17426    }
17427    pub fn get_key_icmpv4_type_mask(&self) -> Result<u8, ErrorContext> {
17428        let mut iter = self.clone();
17429        iter.pos = 0;
17430        for attr in iter {
17431            if let FlowerAttrs::KeyIcmpv4TypeMask(val) = attr? {
17432                return Ok(val);
17433            }
17434        }
17435        Err(ErrorContext::new_missing(
17436            "FlowerAttrs",
17437            "KeyIcmpv4TypeMask",
17438            self.orig_loc,
17439            self.buf.as_ptr() as usize,
17440        ))
17441    }
17442    pub fn get_key_icmpv6_code(&self) -> Result<u8, ErrorContext> {
17443        let mut iter = self.clone();
17444        iter.pos = 0;
17445        for attr in iter {
17446            if let FlowerAttrs::KeyIcmpv6Code(val) = attr? {
17447                return Ok(val);
17448            }
17449        }
17450        Err(ErrorContext::new_missing(
17451            "FlowerAttrs",
17452            "KeyIcmpv6Code",
17453            self.orig_loc,
17454            self.buf.as_ptr() as usize,
17455        ))
17456    }
17457    pub fn get_key_icmpv6_code_mask(&self) -> Result<u8, ErrorContext> {
17458        let mut iter = self.clone();
17459        iter.pos = 0;
17460        for attr in iter {
17461            if let FlowerAttrs::KeyIcmpv6CodeMask(val) = attr? {
17462                return Ok(val);
17463            }
17464        }
17465        Err(ErrorContext::new_missing(
17466            "FlowerAttrs",
17467            "KeyIcmpv6CodeMask",
17468            self.orig_loc,
17469            self.buf.as_ptr() as usize,
17470        ))
17471    }
17472    pub fn get_key_icmpv6_type(&self) -> Result<u8, ErrorContext> {
17473        let mut iter = self.clone();
17474        iter.pos = 0;
17475        for attr in iter {
17476            if let FlowerAttrs::KeyIcmpv6Type(val) = attr? {
17477                return Ok(val);
17478            }
17479        }
17480        Err(ErrorContext::new_missing(
17481            "FlowerAttrs",
17482            "KeyIcmpv6Type",
17483            self.orig_loc,
17484            self.buf.as_ptr() as usize,
17485        ))
17486    }
17487    pub fn get_key_icmpv6_type_mask(&self) -> Result<u8, ErrorContext> {
17488        let mut iter = self.clone();
17489        iter.pos = 0;
17490        for attr in iter {
17491            if let FlowerAttrs::KeyIcmpv6TypeMask(val) = attr? {
17492                return Ok(val);
17493            }
17494        }
17495        Err(ErrorContext::new_missing(
17496            "FlowerAttrs",
17497            "KeyIcmpv6TypeMask",
17498            self.orig_loc,
17499            self.buf.as_ptr() as usize,
17500        ))
17501    }
17502    pub fn get_key_arp_sip(&self) -> Result<u32, ErrorContext> {
17503        let mut iter = self.clone();
17504        iter.pos = 0;
17505        for attr in iter {
17506            if let FlowerAttrs::KeyArpSip(val) = attr? {
17507                return Ok(val);
17508            }
17509        }
17510        Err(ErrorContext::new_missing(
17511            "FlowerAttrs",
17512            "KeyArpSip",
17513            self.orig_loc,
17514            self.buf.as_ptr() as usize,
17515        ))
17516    }
17517    pub fn get_key_arp_sip_mask(&self) -> Result<u32, ErrorContext> {
17518        let mut iter = self.clone();
17519        iter.pos = 0;
17520        for attr in iter {
17521            if let FlowerAttrs::KeyArpSipMask(val) = attr? {
17522                return Ok(val);
17523            }
17524        }
17525        Err(ErrorContext::new_missing(
17526            "FlowerAttrs",
17527            "KeyArpSipMask",
17528            self.orig_loc,
17529            self.buf.as_ptr() as usize,
17530        ))
17531    }
17532    pub fn get_key_arp_tip(&self) -> Result<u32, ErrorContext> {
17533        let mut iter = self.clone();
17534        iter.pos = 0;
17535        for attr in iter {
17536            if let FlowerAttrs::KeyArpTip(val) = attr? {
17537                return Ok(val);
17538            }
17539        }
17540        Err(ErrorContext::new_missing(
17541            "FlowerAttrs",
17542            "KeyArpTip",
17543            self.orig_loc,
17544            self.buf.as_ptr() as usize,
17545        ))
17546    }
17547    pub fn get_key_arp_tip_mask(&self) -> Result<u32, ErrorContext> {
17548        let mut iter = self.clone();
17549        iter.pos = 0;
17550        for attr in iter {
17551            if let FlowerAttrs::KeyArpTipMask(val) = attr? {
17552                return Ok(val);
17553            }
17554        }
17555        Err(ErrorContext::new_missing(
17556            "FlowerAttrs",
17557            "KeyArpTipMask",
17558            self.orig_loc,
17559            self.buf.as_ptr() as usize,
17560        ))
17561    }
17562    pub fn get_key_arp_op(&self) -> Result<u8, ErrorContext> {
17563        let mut iter = self.clone();
17564        iter.pos = 0;
17565        for attr in iter {
17566            if let FlowerAttrs::KeyArpOp(val) = attr? {
17567                return Ok(val);
17568            }
17569        }
17570        Err(ErrorContext::new_missing(
17571            "FlowerAttrs",
17572            "KeyArpOp",
17573            self.orig_loc,
17574            self.buf.as_ptr() as usize,
17575        ))
17576    }
17577    pub fn get_key_arp_op_mask(&self) -> Result<u8, ErrorContext> {
17578        let mut iter = self.clone();
17579        iter.pos = 0;
17580        for attr in iter {
17581            if let FlowerAttrs::KeyArpOpMask(val) = attr? {
17582                return Ok(val);
17583            }
17584        }
17585        Err(ErrorContext::new_missing(
17586            "FlowerAttrs",
17587            "KeyArpOpMask",
17588            self.orig_loc,
17589            self.buf.as_ptr() as usize,
17590        ))
17591    }
17592    pub fn get_key_arp_sha(&self) -> Result<&'a [u8], ErrorContext> {
17593        let mut iter = self.clone();
17594        iter.pos = 0;
17595        for attr in iter {
17596            if let FlowerAttrs::KeyArpSha(val) = attr? {
17597                return Ok(val);
17598            }
17599        }
17600        Err(ErrorContext::new_missing(
17601            "FlowerAttrs",
17602            "KeyArpSha",
17603            self.orig_loc,
17604            self.buf.as_ptr() as usize,
17605        ))
17606    }
17607    pub fn get_key_arp_sha_mask(&self) -> Result<&'a [u8], ErrorContext> {
17608        let mut iter = self.clone();
17609        iter.pos = 0;
17610        for attr in iter {
17611            if let FlowerAttrs::KeyArpShaMask(val) = attr? {
17612                return Ok(val);
17613            }
17614        }
17615        Err(ErrorContext::new_missing(
17616            "FlowerAttrs",
17617            "KeyArpShaMask",
17618            self.orig_loc,
17619            self.buf.as_ptr() as usize,
17620        ))
17621    }
17622    pub fn get_key_arp_tha(&self) -> Result<&'a [u8], ErrorContext> {
17623        let mut iter = self.clone();
17624        iter.pos = 0;
17625        for attr in iter {
17626            if let FlowerAttrs::KeyArpTha(val) = attr? {
17627                return Ok(val);
17628            }
17629        }
17630        Err(ErrorContext::new_missing(
17631            "FlowerAttrs",
17632            "KeyArpTha",
17633            self.orig_loc,
17634            self.buf.as_ptr() as usize,
17635        ))
17636    }
17637    pub fn get_key_arp_tha_mask(&self) -> Result<&'a [u8], ErrorContext> {
17638        let mut iter = self.clone();
17639        iter.pos = 0;
17640        for attr in iter {
17641            if let FlowerAttrs::KeyArpThaMask(val) = attr? {
17642                return Ok(val);
17643            }
17644        }
17645        Err(ErrorContext::new_missing(
17646            "FlowerAttrs",
17647            "KeyArpThaMask",
17648            self.orig_loc,
17649            self.buf.as_ptr() as usize,
17650        ))
17651    }
17652    pub fn get_key_mpls_ttl(&self) -> Result<u8, ErrorContext> {
17653        let mut iter = self.clone();
17654        iter.pos = 0;
17655        for attr in iter {
17656            if let FlowerAttrs::KeyMplsTtl(val) = attr? {
17657                return Ok(val);
17658            }
17659        }
17660        Err(ErrorContext::new_missing(
17661            "FlowerAttrs",
17662            "KeyMplsTtl",
17663            self.orig_loc,
17664            self.buf.as_ptr() as usize,
17665        ))
17666    }
17667    pub fn get_key_mpls_bos(&self) -> Result<u8, ErrorContext> {
17668        let mut iter = self.clone();
17669        iter.pos = 0;
17670        for attr in iter {
17671            if let FlowerAttrs::KeyMplsBos(val) = attr? {
17672                return Ok(val);
17673            }
17674        }
17675        Err(ErrorContext::new_missing(
17676            "FlowerAttrs",
17677            "KeyMplsBos",
17678            self.orig_loc,
17679            self.buf.as_ptr() as usize,
17680        ))
17681    }
17682    pub fn get_key_mpls_tc(&self) -> Result<u8, ErrorContext> {
17683        let mut iter = self.clone();
17684        iter.pos = 0;
17685        for attr in iter {
17686            if let FlowerAttrs::KeyMplsTc(val) = attr? {
17687                return Ok(val);
17688            }
17689        }
17690        Err(ErrorContext::new_missing(
17691            "FlowerAttrs",
17692            "KeyMplsTc",
17693            self.orig_loc,
17694            self.buf.as_ptr() as usize,
17695        ))
17696    }
17697    pub fn get_key_mpls_label(&self) -> Result<u32, ErrorContext> {
17698        let mut iter = self.clone();
17699        iter.pos = 0;
17700        for attr in iter {
17701            if let FlowerAttrs::KeyMplsLabel(val) = attr? {
17702                return Ok(val);
17703            }
17704        }
17705        Err(ErrorContext::new_missing(
17706            "FlowerAttrs",
17707            "KeyMplsLabel",
17708            self.orig_loc,
17709            self.buf.as_ptr() as usize,
17710        ))
17711    }
17712    pub fn get_key_tcp_flags(&self) -> Result<u16, ErrorContext> {
17713        let mut iter = self.clone();
17714        iter.pos = 0;
17715        for attr in iter {
17716            if let FlowerAttrs::KeyTcpFlags(val) = attr? {
17717                return Ok(val);
17718            }
17719        }
17720        Err(ErrorContext::new_missing(
17721            "FlowerAttrs",
17722            "KeyTcpFlags",
17723            self.orig_loc,
17724            self.buf.as_ptr() as usize,
17725        ))
17726    }
17727    pub fn get_key_tcp_flags_mask(&self) -> Result<u16, ErrorContext> {
17728        let mut iter = self.clone();
17729        iter.pos = 0;
17730        for attr in iter {
17731            if let FlowerAttrs::KeyTcpFlagsMask(val) = attr? {
17732                return Ok(val);
17733            }
17734        }
17735        Err(ErrorContext::new_missing(
17736            "FlowerAttrs",
17737            "KeyTcpFlagsMask",
17738            self.orig_loc,
17739            self.buf.as_ptr() as usize,
17740        ))
17741    }
17742    pub fn get_key_ip_tos(&self) -> Result<u8, ErrorContext> {
17743        let mut iter = self.clone();
17744        iter.pos = 0;
17745        for attr in iter {
17746            if let FlowerAttrs::KeyIpTos(val) = attr? {
17747                return Ok(val);
17748            }
17749        }
17750        Err(ErrorContext::new_missing(
17751            "FlowerAttrs",
17752            "KeyIpTos",
17753            self.orig_loc,
17754            self.buf.as_ptr() as usize,
17755        ))
17756    }
17757    pub fn get_key_ip_tos_mask(&self) -> Result<u8, ErrorContext> {
17758        let mut iter = self.clone();
17759        iter.pos = 0;
17760        for attr in iter {
17761            if let FlowerAttrs::KeyIpTosMask(val) = attr? {
17762                return Ok(val);
17763            }
17764        }
17765        Err(ErrorContext::new_missing(
17766            "FlowerAttrs",
17767            "KeyIpTosMask",
17768            self.orig_loc,
17769            self.buf.as_ptr() as usize,
17770        ))
17771    }
17772    pub fn get_key_ip_ttl(&self) -> Result<u8, ErrorContext> {
17773        let mut iter = self.clone();
17774        iter.pos = 0;
17775        for attr in iter {
17776            if let FlowerAttrs::KeyIpTtl(val) = attr? {
17777                return Ok(val);
17778            }
17779        }
17780        Err(ErrorContext::new_missing(
17781            "FlowerAttrs",
17782            "KeyIpTtl",
17783            self.orig_loc,
17784            self.buf.as_ptr() as usize,
17785        ))
17786    }
17787    pub fn get_key_ip_ttl_mask(&self) -> Result<u8, ErrorContext> {
17788        let mut iter = self.clone();
17789        iter.pos = 0;
17790        for attr in iter {
17791            if let FlowerAttrs::KeyIpTtlMask(val) = attr? {
17792                return Ok(val);
17793            }
17794        }
17795        Err(ErrorContext::new_missing(
17796            "FlowerAttrs",
17797            "KeyIpTtlMask",
17798            self.orig_loc,
17799            self.buf.as_ptr() as usize,
17800        ))
17801    }
17802    pub fn get_key_cvlan_id(&self) -> Result<u16, ErrorContext> {
17803        let mut iter = self.clone();
17804        iter.pos = 0;
17805        for attr in iter {
17806            if let FlowerAttrs::KeyCvlanId(val) = attr? {
17807                return Ok(val);
17808            }
17809        }
17810        Err(ErrorContext::new_missing(
17811            "FlowerAttrs",
17812            "KeyCvlanId",
17813            self.orig_loc,
17814            self.buf.as_ptr() as usize,
17815        ))
17816    }
17817    pub fn get_key_cvlan_prio(&self) -> Result<u8, ErrorContext> {
17818        let mut iter = self.clone();
17819        iter.pos = 0;
17820        for attr in iter {
17821            if let FlowerAttrs::KeyCvlanPrio(val) = attr? {
17822                return Ok(val);
17823            }
17824        }
17825        Err(ErrorContext::new_missing(
17826            "FlowerAttrs",
17827            "KeyCvlanPrio",
17828            self.orig_loc,
17829            self.buf.as_ptr() as usize,
17830        ))
17831    }
17832    pub fn get_key_cvlan_eth_type(&self) -> Result<u16, ErrorContext> {
17833        let mut iter = self.clone();
17834        iter.pos = 0;
17835        for attr in iter {
17836            if let FlowerAttrs::KeyCvlanEthType(val) = attr? {
17837                return Ok(val);
17838            }
17839        }
17840        Err(ErrorContext::new_missing(
17841            "FlowerAttrs",
17842            "KeyCvlanEthType",
17843            self.orig_loc,
17844            self.buf.as_ptr() as usize,
17845        ))
17846    }
17847    pub fn get_key_enc_ip_tos(&self) -> Result<u8, ErrorContext> {
17848        let mut iter = self.clone();
17849        iter.pos = 0;
17850        for attr in iter {
17851            if let FlowerAttrs::KeyEncIpTos(val) = attr? {
17852                return Ok(val);
17853            }
17854        }
17855        Err(ErrorContext::new_missing(
17856            "FlowerAttrs",
17857            "KeyEncIpTos",
17858            self.orig_loc,
17859            self.buf.as_ptr() as usize,
17860        ))
17861    }
17862    pub fn get_key_enc_ip_tos_mask(&self) -> Result<u8, ErrorContext> {
17863        let mut iter = self.clone();
17864        iter.pos = 0;
17865        for attr in iter {
17866            if let FlowerAttrs::KeyEncIpTosMask(val) = attr? {
17867                return Ok(val);
17868            }
17869        }
17870        Err(ErrorContext::new_missing(
17871            "FlowerAttrs",
17872            "KeyEncIpTosMask",
17873            self.orig_loc,
17874            self.buf.as_ptr() as usize,
17875        ))
17876    }
17877    pub fn get_key_enc_ip_ttl(&self) -> Result<u8, ErrorContext> {
17878        let mut iter = self.clone();
17879        iter.pos = 0;
17880        for attr in iter {
17881            if let FlowerAttrs::KeyEncIpTtl(val) = attr? {
17882                return Ok(val);
17883            }
17884        }
17885        Err(ErrorContext::new_missing(
17886            "FlowerAttrs",
17887            "KeyEncIpTtl",
17888            self.orig_loc,
17889            self.buf.as_ptr() as usize,
17890        ))
17891    }
17892    pub fn get_key_enc_ip_ttl_mask(&self) -> Result<u8, ErrorContext> {
17893        let mut iter = self.clone();
17894        iter.pos = 0;
17895        for attr in iter {
17896            if let FlowerAttrs::KeyEncIpTtlMask(val) = attr? {
17897                return Ok(val);
17898            }
17899        }
17900        Err(ErrorContext::new_missing(
17901            "FlowerAttrs",
17902            "KeyEncIpTtlMask",
17903            self.orig_loc,
17904            self.buf.as_ptr() as usize,
17905        ))
17906    }
17907    pub fn get_key_enc_opts(&self) -> Result<IterableFlowerKeyEncOptsAttrs<'a>, ErrorContext> {
17908        let mut iter = self.clone();
17909        iter.pos = 0;
17910        for attr in iter {
17911            if let FlowerAttrs::KeyEncOpts(val) = attr? {
17912                return Ok(val);
17913            }
17914        }
17915        Err(ErrorContext::new_missing(
17916            "FlowerAttrs",
17917            "KeyEncOpts",
17918            self.orig_loc,
17919            self.buf.as_ptr() as usize,
17920        ))
17921    }
17922    pub fn get_key_enc_opts_mask(&self) -> Result<IterableFlowerKeyEncOptsAttrs<'a>, ErrorContext> {
17923        let mut iter = self.clone();
17924        iter.pos = 0;
17925        for attr in iter {
17926            if let FlowerAttrs::KeyEncOptsMask(val) = attr? {
17927                return Ok(val);
17928            }
17929        }
17930        Err(ErrorContext::new_missing(
17931            "FlowerAttrs",
17932            "KeyEncOptsMask",
17933            self.orig_loc,
17934            self.buf.as_ptr() as usize,
17935        ))
17936    }
17937    pub fn get_in_hw_count(&self) -> Result<u32, ErrorContext> {
17938        let mut iter = self.clone();
17939        iter.pos = 0;
17940        for attr in iter {
17941            if let FlowerAttrs::InHwCount(val) = attr? {
17942                return Ok(val);
17943            }
17944        }
17945        Err(ErrorContext::new_missing(
17946            "FlowerAttrs",
17947            "InHwCount",
17948            self.orig_loc,
17949            self.buf.as_ptr() as usize,
17950        ))
17951    }
17952    pub fn get_key_port_src_min(&self) -> Result<u16, ErrorContext> {
17953        let mut iter = self.clone();
17954        iter.pos = 0;
17955        for attr in iter {
17956            if let FlowerAttrs::KeyPortSrcMin(val) = attr? {
17957                return Ok(val);
17958            }
17959        }
17960        Err(ErrorContext::new_missing(
17961            "FlowerAttrs",
17962            "KeyPortSrcMin",
17963            self.orig_loc,
17964            self.buf.as_ptr() as usize,
17965        ))
17966    }
17967    pub fn get_key_port_src_max(&self) -> Result<u16, ErrorContext> {
17968        let mut iter = self.clone();
17969        iter.pos = 0;
17970        for attr in iter {
17971            if let FlowerAttrs::KeyPortSrcMax(val) = attr? {
17972                return Ok(val);
17973            }
17974        }
17975        Err(ErrorContext::new_missing(
17976            "FlowerAttrs",
17977            "KeyPortSrcMax",
17978            self.orig_loc,
17979            self.buf.as_ptr() as usize,
17980        ))
17981    }
17982    pub fn get_key_port_dst_min(&self) -> Result<u16, ErrorContext> {
17983        let mut iter = self.clone();
17984        iter.pos = 0;
17985        for attr in iter {
17986            if let FlowerAttrs::KeyPortDstMin(val) = attr? {
17987                return Ok(val);
17988            }
17989        }
17990        Err(ErrorContext::new_missing(
17991            "FlowerAttrs",
17992            "KeyPortDstMin",
17993            self.orig_loc,
17994            self.buf.as_ptr() as usize,
17995        ))
17996    }
17997    pub fn get_key_port_dst_max(&self) -> Result<u16, ErrorContext> {
17998        let mut iter = self.clone();
17999        iter.pos = 0;
18000        for attr in iter {
18001            if let FlowerAttrs::KeyPortDstMax(val) = attr? {
18002                return Ok(val);
18003            }
18004        }
18005        Err(ErrorContext::new_missing(
18006            "FlowerAttrs",
18007            "KeyPortDstMax",
18008            self.orig_loc,
18009            self.buf.as_ptr() as usize,
18010        ))
18011    }
18012    pub fn get_key_ct_state(&self) -> Result<u16, ErrorContext> {
18013        let mut iter = self.clone();
18014        iter.pos = 0;
18015        for attr in iter {
18016            if let FlowerAttrs::KeyCtState(val) = attr? {
18017                return Ok(val);
18018            }
18019        }
18020        Err(ErrorContext::new_missing(
18021            "FlowerAttrs",
18022            "KeyCtState",
18023            self.orig_loc,
18024            self.buf.as_ptr() as usize,
18025        ))
18026    }
18027    pub fn get_key_ct_state_mask(&self) -> Result<u16, ErrorContext> {
18028        let mut iter = self.clone();
18029        iter.pos = 0;
18030        for attr in iter {
18031            if let FlowerAttrs::KeyCtStateMask(val) = attr? {
18032                return Ok(val);
18033            }
18034        }
18035        Err(ErrorContext::new_missing(
18036            "FlowerAttrs",
18037            "KeyCtStateMask",
18038            self.orig_loc,
18039            self.buf.as_ptr() as usize,
18040        ))
18041    }
18042    pub fn get_key_ct_zone(&self) -> Result<u16, ErrorContext> {
18043        let mut iter = self.clone();
18044        iter.pos = 0;
18045        for attr in iter {
18046            if let FlowerAttrs::KeyCtZone(val) = attr? {
18047                return Ok(val);
18048            }
18049        }
18050        Err(ErrorContext::new_missing(
18051            "FlowerAttrs",
18052            "KeyCtZone",
18053            self.orig_loc,
18054            self.buf.as_ptr() as usize,
18055        ))
18056    }
18057    pub fn get_key_ct_zone_mask(&self) -> Result<u16, ErrorContext> {
18058        let mut iter = self.clone();
18059        iter.pos = 0;
18060        for attr in iter {
18061            if let FlowerAttrs::KeyCtZoneMask(val) = attr? {
18062                return Ok(val);
18063            }
18064        }
18065        Err(ErrorContext::new_missing(
18066            "FlowerAttrs",
18067            "KeyCtZoneMask",
18068            self.orig_loc,
18069            self.buf.as_ptr() as usize,
18070        ))
18071    }
18072    pub fn get_key_ct_mark(&self) -> Result<u32, ErrorContext> {
18073        let mut iter = self.clone();
18074        iter.pos = 0;
18075        for attr in iter {
18076            if let FlowerAttrs::KeyCtMark(val) = attr? {
18077                return Ok(val);
18078            }
18079        }
18080        Err(ErrorContext::new_missing(
18081            "FlowerAttrs",
18082            "KeyCtMark",
18083            self.orig_loc,
18084            self.buf.as_ptr() as usize,
18085        ))
18086    }
18087    pub fn get_key_ct_mark_mask(&self) -> Result<u32, ErrorContext> {
18088        let mut iter = self.clone();
18089        iter.pos = 0;
18090        for attr in iter {
18091            if let FlowerAttrs::KeyCtMarkMask(val) = attr? {
18092                return Ok(val);
18093            }
18094        }
18095        Err(ErrorContext::new_missing(
18096            "FlowerAttrs",
18097            "KeyCtMarkMask",
18098            self.orig_loc,
18099            self.buf.as_ptr() as usize,
18100        ))
18101    }
18102    pub fn get_key_ct_labels(&self) -> Result<&'a [u8], ErrorContext> {
18103        let mut iter = self.clone();
18104        iter.pos = 0;
18105        for attr in iter {
18106            if let FlowerAttrs::KeyCtLabels(val) = attr? {
18107                return Ok(val);
18108            }
18109        }
18110        Err(ErrorContext::new_missing(
18111            "FlowerAttrs",
18112            "KeyCtLabels",
18113            self.orig_loc,
18114            self.buf.as_ptr() as usize,
18115        ))
18116    }
18117    pub fn get_key_ct_labels_mask(&self) -> Result<&'a [u8], ErrorContext> {
18118        let mut iter = self.clone();
18119        iter.pos = 0;
18120        for attr in iter {
18121            if let FlowerAttrs::KeyCtLabelsMask(val) = attr? {
18122                return Ok(val);
18123            }
18124        }
18125        Err(ErrorContext::new_missing(
18126            "FlowerAttrs",
18127            "KeyCtLabelsMask",
18128            self.orig_loc,
18129            self.buf.as_ptr() as usize,
18130        ))
18131    }
18132    pub fn get_key_mpls_opts(&self) -> Result<IterableFlowerKeyMplsOptAttrs<'a>, ErrorContext> {
18133        let mut iter = self.clone();
18134        iter.pos = 0;
18135        for attr in iter {
18136            if let FlowerAttrs::KeyMplsOpts(val) = attr? {
18137                return Ok(val);
18138            }
18139        }
18140        Err(ErrorContext::new_missing(
18141            "FlowerAttrs",
18142            "KeyMplsOpts",
18143            self.orig_loc,
18144            self.buf.as_ptr() as usize,
18145        ))
18146    }
18147    pub fn get_key_hash(&self) -> Result<u32, ErrorContext> {
18148        let mut iter = self.clone();
18149        iter.pos = 0;
18150        for attr in iter {
18151            if let FlowerAttrs::KeyHash(val) = attr? {
18152                return Ok(val);
18153            }
18154        }
18155        Err(ErrorContext::new_missing(
18156            "FlowerAttrs",
18157            "KeyHash",
18158            self.orig_loc,
18159            self.buf.as_ptr() as usize,
18160        ))
18161    }
18162    pub fn get_key_hash_mask(&self) -> Result<u32, ErrorContext> {
18163        let mut iter = self.clone();
18164        iter.pos = 0;
18165        for attr in iter {
18166            if let FlowerAttrs::KeyHashMask(val) = attr? {
18167                return Ok(val);
18168            }
18169        }
18170        Err(ErrorContext::new_missing(
18171            "FlowerAttrs",
18172            "KeyHashMask",
18173            self.orig_loc,
18174            self.buf.as_ptr() as usize,
18175        ))
18176    }
18177    pub fn get_key_num_of_vlans(&self) -> Result<u8, ErrorContext> {
18178        let mut iter = self.clone();
18179        iter.pos = 0;
18180        for attr in iter {
18181            if let FlowerAttrs::KeyNumOfVlans(val) = attr? {
18182                return Ok(val);
18183            }
18184        }
18185        Err(ErrorContext::new_missing(
18186            "FlowerAttrs",
18187            "KeyNumOfVlans",
18188            self.orig_loc,
18189            self.buf.as_ptr() as usize,
18190        ))
18191    }
18192    pub fn get_key_pppoe_sid(&self) -> Result<u16, ErrorContext> {
18193        let mut iter = self.clone();
18194        iter.pos = 0;
18195        for attr in iter {
18196            if let FlowerAttrs::KeyPppoeSid(val) = attr? {
18197                return Ok(val);
18198            }
18199        }
18200        Err(ErrorContext::new_missing(
18201            "FlowerAttrs",
18202            "KeyPppoeSid",
18203            self.orig_loc,
18204            self.buf.as_ptr() as usize,
18205        ))
18206    }
18207    pub fn get_key_ppp_proto(&self) -> Result<u16, ErrorContext> {
18208        let mut iter = self.clone();
18209        iter.pos = 0;
18210        for attr in iter {
18211            if let FlowerAttrs::KeyPppProto(val) = attr? {
18212                return Ok(val);
18213            }
18214        }
18215        Err(ErrorContext::new_missing(
18216            "FlowerAttrs",
18217            "KeyPppProto",
18218            self.orig_loc,
18219            self.buf.as_ptr() as usize,
18220        ))
18221    }
18222    pub fn get_key_l2tpv3_sid(&self) -> Result<u32, ErrorContext> {
18223        let mut iter = self.clone();
18224        iter.pos = 0;
18225        for attr in iter {
18226            if let FlowerAttrs::KeyL2tpv3Sid(val) = attr? {
18227                return Ok(val);
18228            }
18229        }
18230        Err(ErrorContext::new_missing(
18231            "FlowerAttrs",
18232            "KeyL2tpv3Sid",
18233            self.orig_loc,
18234            self.buf.as_ptr() as usize,
18235        ))
18236    }
18237    pub fn get_l2_miss(&self) -> Result<u8, ErrorContext> {
18238        let mut iter = self.clone();
18239        iter.pos = 0;
18240        for attr in iter {
18241            if let FlowerAttrs::L2Miss(val) = attr? {
18242                return Ok(val);
18243            }
18244        }
18245        Err(ErrorContext::new_missing(
18246            "FlowerAttrs",
18247            "L2Miss",
18248            self.orig_loc,
18249            self.buf.as_ptr() as usize,
18250        ))
18251    }
18252    pub fn get_key_cfm(&self) -> Result<IterableFlowerKeyCfmAttrs<'a>, ErrorContext> {
18253        let mut iter = self.clone();
18254        iter.pos = 0;
18255        for attr in iter {
18256            if let FlowerAttrs::KeyCfm(val) = attr? {
18257                return Ok(val);
18258            }
18259        }
18260        Err(ErrorContext::new_missing(
18261            "FlowerAttrs",
18262            "KeyCfm",
18263            self.orig_loc,
18264            self.buf.as_ptr() as usize,
18265        ))
18266    }
18267    pub fn get_key_spi(&self) -> Result<u32, ErrorContext> {
18268        let mut iter = self.clone();
18269        iter.pos = 0;
18270        for attr in iter {
18271            if let FlowerAttrs::KeySpi(val) = attr? {
18272                return Ok(val);
18273            }
18274        }
18275        Err(ErrorContext::new_missing(
18276            "FlowerAttrs",
18277            "KeySpi",
18278            self.orig_loc,
18279            self.buf.as_ptr() as usize,
18280        ))
18281    }
18282    pub fn get_key_spi_mask(&self) -> Result<u32, ErrorContext> {
18283        let mut iter = self.clone();
18284        iter.pos = 0;
18285        for attr in iter {
18286            if let FlowerAttrs::KeySpiMask(val) = attr? {
18287                return Ok(val);
18288            }
18289        }
18290        Err(ErrorContext::new_missing(
18291            "FlowerAttrs",
18292            "KeySpiMask",
18293            self.orig_loc,
18294            self.buf.as_ptr() as usize,
18295        ))
18296    }
18297    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
18298    pub fn get_key_enc_flags(&self) -> Result<u32, ErrorContext> {
18299        let mut iter = self.clone();
18300        iter.pos = 0;
18301        for attr in iter {
18302            if let FlowerAttrs::KeyEncFlags(val) = attr? {
18303                return Ok(val);
18304            }
18305        }
18306        Err(ErrorContext::new_missing(
18307            "FlowerAttrs",
18308            "KeyEncFlags",
18309            self.orig_loc,
18310            self.buf.as_ptr() as usize,
18311        ))
18312    }
18313    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
18314    pub fn get_key_enc_flags_mask(&self) -> Result<u32, ErrorContext> {
18315        let mut iter = self.clone();
18316        iter.pos = 0;
18317        for attr in iter {
18318            if let FlowerAttrs::KeyEncFlagsMask(val) = attr? {
18319                return Ok(val);
18320            }
18321        }
18322        Err(ErrorContext::new_missing(
18323            "FlowerAttrs",
18324            "KeyEncFlagsMask",
18325            self.orig_loc,
18326            self.buf.as_ptr() as usize,
18327        ))
18328    }
18329}
18330impl FlowerAttrs<'_> {
18331    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowerAttrs<'a> {
18332        IterableFlowerAttrs::with_loc(buf, buf.as_ptr() as usize)
18333    }
18334    fn attr_from_type(r#type: u16) -> Option<&'static str> {
18335        let res = match r#type {
18336            1u16 => "Classid",
18337            2u16 => "Indev",
18338            3u16 => "Act",
18339            4u16 => "KeyEthDst",
18340            5u16 => "KeyEthDstMask",
18341            6u16 => "KeyEthSrc",
18342            7u16 => "KeyEthSrcMask",
18343            8u16 => "KeyEthType",
18344            9u16 => "KeyIpProto",
18345            10u16 => "KeyIpv4Src",
18346            11u16 => "KeyIpv4SrcMask",
18347            12u16 => "KeyIpv4Dst",
18348            13u16 => "KeyIpv4DstMask",
18349            14u16 => "KeyIpv6Src",
18350            15u16 => "KeyIpv6SrcMask",
18351            16u16 => "KeyIpv6Dst",
18352            17u16 => "KeyIpv6DstMask",
18353            18u16 => "KeyTcpSrc",
18354            19u16 => "KeyTcpDst",
18355            20u16 => "KeyUdpSrc",
18356            21u16 => "KeyUdpDst",
18357            22u16 => "Flags",
18358            23u16 => "KeyVlanId",
18359            24u16 => "KeyVlanPrio",
18360            25u16 => "KeyVlanEthType",
18361            26u16 => "KeyEncKeyId",
18362            27u16 => "KeyEncIpv4Src",
18363            28u16 => "KeyEncIpv4SrcMask",
18364            29u16 => "KeyEncIpv4Dst",
18365            30u16 => "KeyEncIpv4DstMask",
18366            31u16 => "KeyEncIpv6Src",
18367            32u16 => "KeyEncIpv6SrcMask",
18368            33u16 => "KeyEncIpv6Dst",
18369            34u16 => "KeyEncIpv6DstMask",
18370            35u16 => "KeyTcpSrcMask",
18371            36u16 => "KeyTcpDstMask",
18372            37u16 => "KeyUdpSrcMask",
18373            38u16 => "KeyUdpDstMask",
18374            39u16 => "KeySctpSrcMask",
18375            40u16 => "KeySctpDstMask",
18376            41u16 => "KeySctpSrc",
18377            42u16 => "KeySctpDst",
18378            43u16 => "KeyEncUdpSrcPort",
18379            44u16 => "KeyEncUdpSrcPortMask",
18380            45u16 => "KeyEncUdpDstPort",
18381            46u16 => "KeyEncUdpDstPortMask",
18382            47u16 => "KeyFlags",
18383            48u16 => "KeyFlagsMask",
18384            49u16 => "KeyIcmpv4Code",
18385            50u16 => "KeyIcmpv4CodeMask",
18386            51u16 => "KeyIcmpv4Type",
18387            52u16 => "KeyIcmpv4TypeMask",
18388            53u16 => "KeyIcmpv6Code",
18389            54u16 => "KeyIcmpv6CodeMask",
18390            55u16 => "KeyIcmpv6Type",
18391            56u16 => "KeyIcmpv6TypeMask",
18392            57u16 => "KeyArpSip",
18393            58u16 => "KeyArpSipMask",
18394            59u16 => "KeyArpTip",
18395            60u16 => "KeyArpTipMask",
18396            61u16 => "KeyArpOp",
18397            62u16 => "KeyArpOpMask",
18398            63u16 => "KeyArpSha",
18399            64u16 => "KeyArpShaMask",
18400            65u16 => "KeyArpTha",
18401            66u16 => "KeyArpThaMask",
18402            67u16 => "KeyMplsTtl",
18403            68u16 => "KeyMplsBos",
18404            69u16 => "KeyMplsTc",
18405            70u16 => "KeyMplsLabel",
18406            71u16 => "KeyTcpFlags",
18407            72u16 => "KeyTcpFlagsMask",
18408            73u16 => "KeyIpTos",
18409            74u16 => "KeyIpTosMask",
18410            75u16 => "KeyIpTtl",
18411            76u16 => "KeyIpTtlMask",
18412            77u16 => "KeyCvlanId",
18413            78u16 => "KeyCvlanPrio",
18414            79u16 => "KeyCvlanEthType",
18415            80u16 => "KeyEncIpTos",
18416            81u16 => "KeyEncIpTosMask",
18417            82u16 => "KeyEncIpTtl",
18418            83u16 => "KeyEncIpTtlMask",
18419            84u16 => "KeyEncOpts",
18420            85u16 => "KeyEncOptsMask",
18421            86u16 => "InHwCount",
18422            87u16 => "KeyPortSrcMin",
18423            88u16 => "KeyPortSrcMax",
18424            89u16 => "KeyPortDstMin",
18425            90u16 => "KeyPortDstMax",
18426            91u16 => "KeyCtState",
18427            92u16 => "KeyCtStateMask",
18428            93u16 => "KeyCtZone",
18429            94u16 => "KeyCtZoneMask",
18430            95u16 => "KeyCtMark",
18431            96u16 => "KeyCtMarkMask",
18432            97u16 => "KeyCtLabels",
18433            98u16 => "KeyCtLabelsMask",
18434            99u16 => "KeyMplsOpts",
18435            100u16 => "KeyHash",
18436            101u16 => "KeyHashMask",
18437            102u16 => "KeyNumOfVlans",
18438            103u16 => "KeyPppoeSid",
18439            104u16 => "KeyPppProto",
18440            105u16 => "KeyL2tpv3Sid",
18441            106u16 => "L2Miss",
18442            107u16 => "KeyCfm",
18443            108u16 => "KeySpi",
18444            109u16 => "KeySpiMask",
18445            110u16 => "KeyEncFlags",
18446            111u16 => "KeyEncFlagsMask",
18447            _ => return None,
18448        };
18449        Some(res)
18450    }
18451}
18452#[derive(Clone, Copy, Default)]
18453pub struct IterableFlowerAttrs<'a> {
18454    buf: &'a [u8],
18455    pos: usize,
18456    orig_loc: usize,
18457}
18458impl<'a> IterableFlowerAttrs<'a> {
18459    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
18460        Self {
18461            buf,
18462            pos: 0,
18463            orig_loc,
18464        }
18465    }
18466    pub fn get_buf(&self) -> &'a [u8] {
18467        self.buf
18468    }
18469}
18470impl<'a> Iterator for IterableFlowerAttrs<'a> {
18471    type Item = Result<FlowerAttrs<'a>, ErrorContext>;
18472    fn next(&mut self) -> Option<Self::Item> {
18473        let pos = self.pos;
18474        let mut r#type;
18475        loop {
18476            r#type = None;
18477            if self.buf.len() == self.pos {
18478                return None;
18479            }
18480            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
18481                break;
18482            };
18483            r#type = Some(header.r#type);
18484            let res = match header.r#type {
18485                1u16 => FlowerAttrs::Classid({
18486                    let res = parse_u32(next);
18487                    let Some(val) = res else { break };
18488                    val
18489                }),
18490                2u16 => FlowerAttrs::Indev({
18491                    let res = CStr::from_bytes_with_nul(next).ok();
18492                    let Some(val) = res else { break };
18493                    val
18494                }),
18495                3u16 => FlowerAttrs::Act({
18496                    let res = Some(IterableArrayActAttrs::with_loc(next, self.orig_loc));
18497                    let Some(val) = res else { break };
18498                    val
18499                }),
18500                4u16 => FlowerAttrs::KeyEthDst({
18501                    let res = Some(next);
18502                    let Some(val) = res else { break };
18503                    val
18504                }),
18505                5u16 => FlowerAttrs::KeyEthDstMask({
18506                    let res = Some(next);
18507                    let Some(val) = res else { break };
18508                    val
18509                }),
18510                6u16 => FlowerAttrs::KeyEthSrc({
18511                    let res = Some(next);
18512                    let Some(val) = res else { break };
18513                    val
18514                }),
18515                7u16 => FlowerAttrs::KeyEthSrcMask({
18516                    let res = Some(next);
18517                    let Some(val) = res else { break };
18518                    val
18519                }),
18520                8u16 => FlowerAttrs::KeyEthType({
18521                    let res = parse_be_u16(next);
18522                    let Some(val) = res else { break };
18523                    val
18524                }),
18525                9u16 => FlowerAttrs::KeyIpProto({
18526                    let res = parse_u8(next);
18527                    let Some(val) = res else { break };
18528                    val
18529                }),
18530                10u16 => FlowerAttrs::KeyIpv4Src({
18531                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
18532                    let Some(val) = res else { break };
18533                    val
18534                }),
18535                11u16 => FlowerAttrs::KeyIpv4SrcMask({
18536                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
18537                    let Some(val) = res else { break };
18538                    val
18539                }),
18540                12u16 => FlowerAttrs::KeyIpv4Dst({
18541                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
18542                    let Some(val) = res else { break };
18543                    val
18544                }),
18545                13u16 => FlowerAttrs::KeyIpv4DstMask({
18546                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
18547                    let Some(val) = res else { break };
18548                    val
18549                }),
18550                14u16 => FlowerAttrs::KeyIpv6Src({
18551                    let res = Some(next);
18552                    let Some(val) = res else { break };
18553                    val
18554                }),
18555                15u16 => FlowerAttrs::KeyIpv6SrcMask({
18556                    let res = Some(next);
18557                    let Some(val) = res else { break };
18558                    val
18559                }),
18560                16u16 => FlowerAttrs::KeyIpv6Dst({
18561                    let res = Some(next);
18562                    let Some(val) = res else { break };
18563                    val
18564                }),
18565                17u16 => FlowerAttrs::KeyIpv6DstMask({
18566                    let res = Some(next);
18567                    let Some(val) = res else { break };
18568                    val
18569                }),
18570                18u16 => FlowerAttrs::KeyTcpSrc({
18571                    let res = parse_be_u16(next);
18572                    let Some(val) = res else { break };
18573                    val
18574                }),
18575                19u16 => FlowerAttrs::KeyTcpDst({
18576                    let res = parse_be_u16(next);
18577                    let Some(val) = res else { break };
18578                    val
18579                }),
18580                20u16 => FlowerAttrs::KeyUdpSrc({
18581                    let res = parse_be_u16(next);
18582                    let Some(val) = res else { break };
18583                    val
18584                }),
18585                21u16 => FlowerAttrs::KeyUdpDst({
18586                    let res = parse_be_u16(next);
18587                    let Some(val) = res else { break };
18588                    val
18589                }),
18590                22u16 => FlowerAttrs::Flags({
18591                    let res = parse_u32(next);
18592                    let Some(val) = res else { break };
18593                    val
18594                }),
18595                23u16 => FlowerAttrs::KeyVlanId({
18596                    let res = parse_be_u16(next);
18597                    let Some(val) = res else { break };
18598                    val
18599                }),
18600                24u16 => FlowerAttrs::KeyVlanPrio({
18601                    let res = parse_u8(next);
18602                    let Some(val) = res else { break };
18603                    val
18604                }),
18605                25u16 => FlowerAttrs::KeyVlanEthType({
18606                    let res = parse_be_u16(next);
18607                    let Some(val) = res else { break };
18608                    val
18609                }),
18610                26u16 => FlowerAttrs::KeyEncKeyId({
18611                    let res = parse_be_u32(next);
18612                    let Some(val) = res else { break };
18613                    val
18614                }),
18615                27u16 => FlowerAttrs::KeyEncIpv4Src({
18616                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
18617                    let Some(val) = res else { break };
18618                    val
18619                }),
18620                28u16 => FlowerAttrs::KeyEncIpv4SrcMask({
18621                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
18622                    let Some(val) = res else { break };
18623                    val
18624                }),
18625                29u16 => FlowerAttrs::KeyEncIpv4Dst({
18626                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
18627                    let Some(val) = res else { break };
18628                    val
18629                }),
18630                30u16 => FlowerAttrs::KeyEncIpv4DstMask({
18631                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
18632                    let Some(val) = res else { break };
18633                    val
18634                }),
18635                31u16 => FlowerAttrs::KeyEncIpv6Src({
18636                    let res = Some(next);
18637                    let Some(val) = res else { break };
18638                    val
18639                }),
18640                32u16 => FlowerAttrs::KeyEncIpv6SrcMask({
18641                    let res = Some(next);
18642                    let Some(val) = res else { break };
18643                    val
18644                }),
18645                33u16 => FlowerAttrs::KeyEncIpv6Dst({
18646                    let res = Some(next);
18647                    let Some(val) = res else { break };
18648                    val
18649                }),
18650                34u16 => FlowerAttrs::KeyEncIpv6DstMask({
18651                    let res = Some(next);
18652                    let Some(val) = res else { break };
18653                    val
18654                }),
18655                35u16 => FlowerAttrs::KeyTcpSrcMask({
18656                    let res = parse_be_u16(next);
18657                    let Some(val) = res else { break };
18658                    val
18659                }),
18660                36u16 => FlowerAttrs::KeyTcpDstMask({
18661                    let res = parse_be_u16(next);
18662                    let Some(val) = res else { break };
18663                    val
18664                }),
18665                37u16 => FlowerAttrs::KeyUdpSrcMask({
18666                    let res = parse_be_u16(next);
18667                    let Some(val) = res else { break };
18668                    val
18669                }),
18670                38u16 => FlowerAttrs::KeyUdpDstMask({
18671                    let res = parse_be_u16(next);
18672                    let Some(val) = res else { break };
18673                    val
18674                }),
18675                39u16 => FlowerAttrs::KeySctpSrcMask({
18676                    let res = parse_be_u16(next);
18677                    let Some(val) = res else { break };
18678                    val
18679                }),
18680                40u16 => FlowerAttrs::KeySctpDstMask({
18681                    let res = parse_be_u16(next);
18682                    let Some(val) = res else { break };
18683                    val
18684                }),
18685                41u16 => FlowerAttrs::KeySctpSrc({
18686                    let res = parse_be_u16(next);
18687                    let Some(val) = res else { break };
18688                    val
18689                }),
18690                42u16 => FlowerAttrs::KeySctpDst({
18691                    let res = parse_be_u16(next);
18692                    let Some(val) = res else { break };
18693                    val
18694                }),
18695                43u16 => FlowerAttrs::KeyEncUdpSrcPort({
18696                    let res = parse_be_u16(next);
18697                    let Some(val) = res else { break };
18698                    val
18699                }),
18700                44u16 => FlowerAttrs::KeyEncUdpSrcPortMask({
18701                    let res = parse_be_u16(next);
18702                    let Some(val) = res else { break };
18703                    val
18704                }),
18705                45u16 => FlowerAttrs::KeyEncUdpDstPort({
18706                    let res = parse_be_u16(next);
18707                    let Some(val) = res else { break };
18708                    val
18709                }),
18710                46u16 => FlowerAttrs::KeyEncUdpDstPortMask({
18711                    let res = parse_be_u16(next);
18712                    let Some(val) = res else { break };
18713                    val
18714                }),
18715                47u16 => FlowerAttrs::KeyFlags({
18716                    let res = parse_be_u32(next);
18717                    let Some(val) = res else { break };
18718                    val
18719                }),
18720                48u16 => FlowerAttrs::KeyFlagsMask({
18721                    let res = parse_be_u32(next);
18722                    let Some(val) = res else { break };
18723                    val
18724                }),
18725                49u16 => FlowerAttrs::KeyIcmpv4Code({
18726                    let res = parse_u8(next);
18727                    let Some(val) = res else { break };
18728                    val
18729                }),
18730                50u16 => FlowerAttrs::KeyIcmpv4CodeMask({
18731                    let res = parse_u8(next);
18732                    let Some(val) = res else { break };
18733                    val
18734                }),
18735                51u16 => FlowerAttrs::KeyIcmpv4Type({
18736                    let res = parse_u8(next);
18737                    let Some(val) = res else { break };
18738                    val
18739                }),
18740                52u16 => FlowerAttrs::KeyIcmpv4TypeMask({
18741                    let res = parse_u8(next);
18742                    let Some(val) = res else { break };
18743                    val
18744                }),
18745                53u16 => FlowerAttrs::KeyIcmpv6Code({
18746                    let res = parse_u8(next);
18747                    let Some(val) = res else { break };
18748                    val
18749                }),
18750                54u16 => FlowerAttrs::KeyIcmpv6CodeMask({
18751                    let res = parse_u8(next);
18752                    let Some(val) = res else { break };
18753                    val
18754                }),
18755                55u16 => FlowerAttrs::KeyIcmpv6Type({
18756                    let res = parse_u8(next);
18757                    let Some(val) = res else { break };
18758                    val
18759                }),
18760                56u16 => FlowerAttrs::KeyIcmpv6TypeMask({
18761                    let res = parse_u8(next);
18762                    let Some(val) = res else { break };
18763                    val
18764                }),
18765                57u16 => FlowerAttrs::KeyArpSip({
18766                    let res = parse_be_u32(next);
18767                    let Some(val) = res else { break };
18768                    val
18769                }),
18770                58u16 => FlowerAttrs::KeyArpSipMask({
18771                    let res = parse_be_u32(next);
18772                    let Some(val) = res else { break };
18773                    val
18774                }),
18775                59u16 => FlowerAttrs::KeyArpTip({
18776                    let res = parse_be_u32(next);
18777                    let Some(val) = res else { break };
18778                    val
18779                }),
18780                60u16 => FlowerAttrs::KeyArpTipMask({
18781                    let res = parse_be_u32(next);
18782                    let Some(val) = res else { break };
18783                    val
18784                }),
18785                61u16 => FlowerAttrs::KeyArpOp({
18786                    let res = parse_u8(next);
18787                    let Some(val) = res else { break };
18788                    val
18789                }),
18790                62u16 => FlowerAttrs::KeyArpOpMask({
18791                    let res = parse_u8(next);
18792                    let Some(val) = res else { break };
18793                    val
18794                }),
18795                63u16 => FlowerAttrs::KeyArpSha({
18796                    let res = Some(next);
18797                    let Some(val) = res else { break };
18798                    val
18799                }),
18800                64u16 => FlowerAttrs::KeyArpShaMask({
18801                    let res = Some(next);
18802                    let Some(val) = res else { break };
18803                    val
18804                }),
18805                65u16 => FlowerAttrs::KeyArpTha({
18806                    let res = Some(next);
18807                    let Some(val) = res else { break };
18808                    val
18809                }),
18810                66u16 => FlowerAttrs::KeyArpThaMask({
18811                    let res = Some(next);
18812                    let Some(val) = res else { break };
18813                    val
18814                }),
18815                67u16 => FlowerAttrs::KeyMplsTtl({
18816                    let res = parse_u8(next);
18817                    let Some(val) = res else { break };
18818                    val
18819                }),
18820                68u16 => FlowerAttrs::KeyMplsBos({
18821                    let res = parse_u8(next);
18822                    let Some(val) = res else { break };
18823                    val
18824                }),
18825                69u16 => FlowerAttrs::KeyMplsTc({
18826                    let res = parse_u8(next);
18827                    let Some(val) = res else { break };
18828                    val
18829                }),
18830                70u16 => FlowerAttrs::KeyMplsLabel({
18831                    let res = parse_be_u32(next);
18832                    let Some(val) = res else { break };
18833                    val
18834                }),
18835                71u16 => FlowerAttrs::KeyTcpFlags({
18836                    let res = parse_be_u16(next);
18837                    let Some(val) = res else { break };
18838                    val
18839                }),
18840                72u16 => FlowerAttrs::KeyTcpFlagsMask({
18841                    let res = parse_be_u16(next);
18842                    let Some(val) = res else { break };
18843                    val
18844                }),
18845                73u16 => FlowerAttrs::KeyIpTos({
18846                    let res = parse_u8(next);
18847                    let Some(val) = res else { break };
18848                    val
18849                }),
18850                74u16 => FlowerAttrs::KeyIpTosMask({
18851                    let res = parse_u8(next);
18852                    let Some(val) = res else { break };
18853                    val
18854                }),
18855                75u16 => FlowerAttrs::KeyIpTtl({
18856                    let res = parse_u8(next);
18857                    let Some(val) = res else { break };
18858                    val
18859                }),
18860                76u16 => FlowerAttrs::KeyIpTtlMask({
18861                    let res = parse_u8(next);
18862                    let Some(val) = res else { break };
18863                    val
18864                }),
18865                77u16 => FlowerAttrs::KeyCvlanId({
18866                    let res = parse_be_u16(next);
18867                    let Some(val) = res else { break };
18868                    val
18869                }),
18870                78u16 => FlowerAttrs::KeyCvlanPrio({
18871                    let res = parse_u8(next);
18872                    let Some(val) = res else { break };
18873                    val
18874                }),
18875                79u16 => FlowerAttrs::KeyCvlanEthType({
18876                    let res = parse_be_u16(next);
18877                    let Some(val) = res else { break };
18878                    val
18879                }),
18880                80u16 => FlowerAttrs::KeyEncIpTos({
18881                    let res = parse_u8(next);
18882                    let Some(val) = res else { break };
18883                    val
18884                }),
18885                81u16 => FlowerAttrs::KeyEncIpTosMask({
18886                    let res = parse_u8(next);
18887                    let Some(val) = res else { break };
18888                    val
18889                }),
18890                82u16 => FlowerAttrs::KeyEncIpTtl({
18891                    let res = parse_u8(next);
18892                    let Some(val) = res else { break };
18893                    val
18894                }),
18895                83u16 => FlowerAttrs::KeyEncIpTtlMask({
18896                    let res = parse_u8(next);
18897                    let Some(val) = res else { break };
18898                    val
18899                }),
18900                84u16 => FlowerAttrs::KeyEncOpts({
18901                    let res = Some(IterableFlowerKeyEncOptsAttrs::with_loc(next, self.orig_loc));
18902                    let Some(val) = res else { break };
18903                    val
18904                }),
18905                85u16 => FlowerAttrs::KeyEncOptsMask({
18906                    let res = Some(IterableFlowerKeyEncOptsAttrs::with_loc(next, self.orig_loc));
18907                    let Some(val) = res else { break };
18908                    val
18909                }),
18910                86u16 => FlowerAttrs::InHwCount({
18911                    let res = parse_u32(next);
18912                    let Some(val) = res else { break };
18913                    val
18914                }),
18915                87u16 => FlowerAttrs::KeyPortSrcMin({
18916                    let res = parse_be_u16(next);
18917                    let Some(val) = res else { break };
18918                    val
18919                }),
18920                88u16 => FlowerAttrs::KeyPortSrcMax({
18921                    let res = parse_be_u16(next);
18922                    let Some(val) = res else { break };
18923                    val
18924                }),
18925                89u16 => FlowerAttrs::KeyPortDstMin({
18926                    let res = parse_be_u16(next);
18927                    let Some(val) = res else { break };
18928                    val
18929                }),
18930                90u16 => FlowerAttrs::KeyPortDstMax({
18931                    let res = parse_be_u16(next);
18932                    let Some(val) = res else { break };
18933                    val
18934                }),
18935                91u16 => FlowerAttrs::KeyCtState({
18936                    let res = parse_u16(next);
18937                    let Some(val) = res else { break };
18938                    val
18939                }),
18940                92u16 => FlowerAttrs::KeyCtStateMask({
18941                    let res = parse_u16(next);
18942                    let Some(val) = res else { break };
18943                    val
18944                }),
18945                93u16 => FlowerAttrs::KeyCtZone({
18946                    let res = parse_u16(next);
18947                    let Some(val) = res else { break };
18948                    val
18949                }),
18950                94u16 => FlowerAttrs::KeyCtZoneMask({
18951                    let res = parse_u16(next);
18952                    let Some(val) = res else { break };
18953                    val
18954                }),
18955                95u16 => FlowerAttrs::KeyCtMark({
18956                    let res = parse_u32(next);
18957                    let Some(val) = res else { break };
18958                    val
18959                }),
18960                96u16 => FlowerAttrs::KeyCtMarkMask({
18961                    let res = parse_u32(next);
18962                    let Some(val) = res else { break };
18963                    val
18964                }),
18965                97u16 => FlowerAttrs::KeyCtLabels({
18966                    let res = Some(next);
18967                    let Some(val) = res else { break };
18968                    val
18969                }),
18970                98u16 => FlowerAttrs::KeyCtLabelsMask({
18971                    let res = Some(next);
18972                    let Some(val) = res else { break };
18973                    val
18974                }),
18975                99u16 => FlowerAttrs::KeyMplsOpts({
18976                    let res = Some(IterableFlowerKeyMplsOptAttrs::with_loc(next, self.orig_loc));
18977                    let Some(val) = res else { break };
18978                    val
18979                }),
18980                100u16 => FlowerAttrs::KeyHash({
18981                    let res = parse_u32(next);
18982                    let Some(val) = res else { break };
18983                    val
18984                }),
18985                101u16 => FlowerAttrs::KeyHashMask({
18986                    let res = parse_u32(next);
18987                    let Some(val) = res else { break };
18988                    val
18989                }),
18990                102u16 => FlowerAttrs::KeyNumOfVlans({
18991                    let res = parse_u8(next);
18992                    let Some(val) = res else { break };
18993                    val
18994                }),
18995                103u16 => FlowerAttrs::KeyPppoeSid({
18996                    let res = parse_be_u16(next);
18997                    let Some(val) = res else { break };
18998                    val
18999                }),
19000                104u16 => FlowerAttrs::KeyPppProto({
19001                    let res = parse_be_u16(next);
19002                    let Some(val) = res else { break };
19003                    val
19004                }),
19005                105u16 => FlowerAttrs::KeyL2tpv3Sid({
19006                    let res = parse_be_u32(next);
19007                    let Some(val) = res else { break };
19008                    val
19009                }),
19010                106u16 => FlowerAttrs::L2Miss({
19011                    let res = parse_u8(next);
19012                    let Some(val) = res else { break };
19013                    val
19014                }),
19015                107u16 => FlowerAttrs::KeyCfm({
19016                    let res = Some(IterableFlowerKeyCfmAttrs::with_loc(next, self.orig_loc));
19017                    let Some(val) = res else { break };
19018                    val
19019                }),
19020                108u16 => FlowerAttrs::KeySpi({
19021                    let res = parse_be_u32(next);
19022                    let Some(val) = res else { break };
19023                    val
19024                }),
19025                109u16 => FlowerAttrs::KeySpiMask({
19026                    let res = parse_be_u32(next);
19027                    let Some(val) = res else { break };
19028                    val
19029                }),
19030                110u16 => FlowerAttrs::KeyEncFlags({
19031                    let res = parse_be_u32(next);
19032                    let Some(val) = res else { break };
19033                    val
19034                }),
19035                111u16 => FlowerAttrs::KeyEncFlagsMask({
19036                    let res = parse_be_u32(next);
19037                    let Some(val) = res else { break };
19038                    val
19039                }),
19040                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
19041                n => continue,
19042            };
19043            return Some(Ok(res));
19044        }
19045        Some(Err(ErrorContext::new(
19046            "FlowerAttrs",
19047            r#type.and_then(|t| FlowerAttrs::attr_from_type(t)),
19048            self.orig_loc,
19049            self.buf.as_ptr().wrapping_add(pos) as usize,
19050        )))
19051    }
19052}
19053impl<'a> std::fmt::Debug for IterableFlowerAttrs<'_> {
19054    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19055        let mut fmt = f.debug_struct("FlowerAttrs");
19056        for attr in self.clone() {
19057            let attr = match attr {
19058                Ok(a) => a,
19059                Err(err) => {
19060                    fmt.finish()?;
19061                    f.write_str("Err(")?;
19062                    err.fmt(f)?;
19063                    return f.write_str(")");
19064                }
19065            };
19066            match attr {
19067                FlowerAttrs::Classid(val) => fmt.field("Classid", &val),
19068                FlowerAttrs::Indev(val) => fmt.field("Indev", &val),
19069                FlowerAttrs::Act(val) => fmt.field("Act", &val),
19070                FlowerAttrs::KeyEthDst(val) => fmt.field("KeyEthDst", &FormatMac(val)),
19071                FlowerAttrs::KeyEthDstMask(val) => fmt.field("KeyEthDstMask", &FormatMac(val)),
19072                FlowerAttrs::KeyEthSrc(val) => fmt.field("KeyEthSrc", &FormatMac(val)),
19073                FlowerAttrs::KeyEthSrcMask(val) => fmt.field("KeyEthSrcMask", &FormatMac(val)),
19074                FlowerAttrs::KeyEthType(val) => fmt.field("KeyEthType", &val),
19075                FlowerAttrs::KeyIpProto(val) => fmt.field("KeyIpProto", &val),
19076                FlowerAttrs::KeyIpv4Src(val) => fmt.field("KeyIpv4Src", &val),
19077                FlowerAttrs::KeyIpv4SrcMask(val) => fmt.field("KeyIpv4SrcMask", &val),
19078                FlowerAttrs::KeyIpv4Dst(val) => fmt.field("KeyIpv4Dst", &val),
19079                FlowerAttrs::KeyIpv4DstMask(val) => fmt.field("KeyIpv4DstMask", &val),
19080                FlowerAttrs::KeyIpv6Src(val) => fmt.field("KeyIpv6Src", &val),
19081                FlowerAttrs::KeyIpv6SrcMask(val) => fmt.field("KeyIpv6SrcMask", &val),
19082                FlowerAttrs::KeyIpv6Dst(val) => fmt.field("KeyIpv6Dst", &val),
19083                FlowerAttrs::KeyIpv6DstMask(val) => fmt.field("KeyIpv6DstMask", &val),
19084                FlowerAttrs::KeyTcpSrc(val) => fmt.field("KeyTcpSrc", &val),
19085                FlowerAttrs::KeyTcpDst(val) => fmt.field("KeyTcpDst", &val),
19086                FlowerAttrs::KeyUdpSrc(val) => fmt.field("KeyUdpSrc", &val),
19087                FlowerAttrs::KeyUdpDst(val) => fmt.field("KeyUdpDst", &val),
19088                FlowerAttrs::Flags(val) => {
19089                    fmt.field("Flags", &FormatFlags(val.into(), ClsFlags::from_value))
19090                }
19091                FlowerAttrs::KeyVlanId(val) => fmt.field("KeyVlanId", &val),
19092                FlowerAttrs::KeyVlanPrio(val) => fmt.field("KeyVlanPrio", &val),
19093                FlowerAttrs::KeyVlanEthType(val) => fmt.field("KeyVlanEthType", &val),
19094                FlowerAttrs::KeyEncKeyId(val) => fmt.field("KeyEncKeyId", &val),
19095                FlowerAttrs::KeyEncIpv4Src(val) => fmt.field("KeyEncIpv4Src", &val),
19096                FlowerAttrs::KeyEncIpv4SrcMask(val) => fmt.field("KeyEncIpv4SrcMask", &val),
19097                FlowerAttrs::KeyEncIpv4Dst(val) => fmt.field("KeyEncIpv4Dst", &val),
19098                FlowerAttrs::KeyEncIpv4DstMask(val) => fmt.field("KeyEncIpv4DstMask", &val),
19099                FlowerAttrs::KeyEncIpv6Src(val) => fmt.field("KeyEncIpv6Src", &val),
19100                FlowerAttrs::KeyEncIpv6SrcMask(val) => fmt.field("KeyEncIpv6SrcMask", &val),
19101                FlowerAttrs::KeyEncIpv6Dst(val) => fmt.field("KeyEncIpv6Dst", &val),
19102                FlowerAttrs::KeyEncIpv6DstMask(val) => fmt.field("KeyEncIpv6DstMask", &val),
19103                FlowerAttrs::KeyTcpSrcMask(val) => fmt.field("KeyTcpSrcMask", &val),
19104                FlowerAttrs::KeyTcpDstMask(val) => fmt.field("KeyTcpDstMask", &val),
19105                FlowerAttrs::KeyUdpSrcMask(val) => fmt.field("KeyUdpSrcMask", &val),
19106                FlowerAttrs::KeyUdpDstMask(val) => fmt.field("KeyUdpDstMask", &val),
19107                FlowerAttrs::KeySctpSrcMask(val) => fmt.field("KeySctpSrcMask", &val),
19108                FlowerAttrs::KeySctpDstMask(val) => fmt.field("KeySctpDstMask", &val),
19109                FlowerAttrs::KeySctpSrc(val) => fmt.field("KeySctpSrc", &val),
19110                FlowerAttrs::KeySctpDst(val) => fmt.field("KeySctpDst", &val),
19111                FlowerAttrs::KeyEncUdpSrcPort(val) => fmt.field("KeyEncUdpSrcPort", &val),
19112                FlowerAttrs::KeyEncUdpSrcPortMask(val) => fmt.field("KeyEncUdpSrcPortMask", &val),
19113                FlowerAttrs::KeyEncUdpDstPort(val) => fmt.field("KeyEncUdpDstPort", &val),
19114                FlowerAttrs::KeyEncUdpDstPortMask(val) => fmt.field("KeyEncUdpDstPortMask", &val),
19115                FlowerAttrs::KeyFlags(val) => fmt.field(
19116                    "KeyFlags",
19117                    &FormatFlags(val.into(), FlowerKeyCtrlFlags::from_value),
19118                ),
19119                FlowerAttrs::KeyFlagsMask(val) => fmt.field(
19120                    "KeyFlagsMask",
19121                    &FormatFlags(val.into(), FlowerKeyCtrlFlags::from_value),
19122                ),
19123                FlowerAttrs::KeyIcmpv4Code(val) => fmt.field("KeyIcmpv4Code", &val),
19124                FlowerAttrs::KeyIcmpv4CodeMask(val) => fmt.field("KeyIcmpv4CodeMask", &val),
19125                FlowerAttrs::KeyIcmpv4Type(val) => fmt.field("KeyIcmpv4Type", &val),
19126                FlowerAttrs::KeyIcmpv4TypeMask(val) => fmt.field("KeyIcmpv4TypeMask", &val),
19127                FlowerAttrs::KeyIcmpv6Code(val) => fmt.field("KeyIcmpv6Code", &val),
19128                FlowerAttrs::KeyIcmpv6CodeMask(val) => fmt.field("KeyIcmpv6CodeMask", &val),
19129                FlowerAttrs::KeyIcmpv6Type(val) => fmt.field("KeyIcmpv6Type", &val),
19130                FlowerAttrs::KeyIcmpv6TypeMask(val) => fmt.field("KeyIcmpv6TypeMask", &val),
19131                FlowerAttrs::KeyArpSip(val) => fmt.field("KeyArpSip", &val),
19132                FlowerAttrs::KeyArpSipMask(val) => fmt.field("KeyArpSipMask", &val),
19133                FlowerAttrs::KeyArpTip(val) => fmt.field("KeyArpTip", &val),
19134                FlowerAttrs::KeyArpTipMask(val) => fmt.field("KeyArpTipMask", &val),
19135                FlowerAttrs::KeyArpOp(val) => fmt.field("KeyArpOp", &val),
19136                FlowerAttrs::KeyArpOpMask(val) => fmt.field("KeyArpOpMask", &val),
19137                FlowerAttrs::KeyArpSha(val) => fmt.field("KeyArpSha", &FormatMac(val)),
19138                FlowerAttrs::KeyArpShaMask(val) => fmt.field("KeyArpShaMask", &FormatMac(val)),
19139                FlowerAttrs::KeyArpTha(val) => fmt.field("KeyArpTha", &FormatMac(val)),
19140                FlowerAttrs::KeyArpThaMask(val) => fmt.field("KeyArpThaMask", &FormatMac(val)),
19141                FlowerAttrs::KeyMplsTtl(val) => fmt.field("KeyMplsTtl", &val),
19142                FlowerAttrs::KeyMplsBos(val) => fmt.field("KeyMplsBos", &val),
19143                FlowerAttrs::KeyMplsTc(val) => fmt.field("KeyMplsTc", &val),
19144                FlowerAttrs::KeyMplsLabel(val) => fmt.field("KeyMplsLabel", &val),
19145                FlowerAttrs::KeyTcpFlags(val) => fmt.field("KeyTcpFlags", &val),
19146                FlowerAttrs::KeyTcpFlagsMask(val) => fmt.field("KeyTcpFlagsMask", &val),
19147                FlowerAttrs::KeyIpTos(val) => fmt.field("KeyIpTos", &val),
19148                FlowerAttrs::KeyIpTosMask(val) => fmt.field("KeyIpTosMask", &val),
19149                FlowerAttrs::KeyIpTtl(val) => fmt.field("KeyIpTtl", &val),
19150                FlowerAttrs::KeyIpTtlMask(val) => fmt.field("KeyIpTtlMask", &val),
19151                FlowerAttrs::KeyCvlanId(val) => fmt.field("KeyCvlanId", &val),
19152                FlowerAttrs::KeyCvlanPrio(val) => fmt.field("KeyCvlanPrio", &val),
19153                FlowerAttrs::KeyCvlanEthType(val) => fmt.field("KeyCvlanEthType", &val),
19154                FlowerAttrs::KeyEncIpTos(val) => fmt.field("KeyEncIpTos", &val),
19155                FlowerAttrs::KeyEncIpTosMask(val) => fmt.field("KeyEncIpTosMask", &val),
19156                FlowerAttrs::KeyEncIpTtl(val) => fmt.field("KeyEncIpTtl", &val),
19157                FlowerAttrs::KeyEncIpTtlMask(val) => fmt.field("KeyEncIpTtlMask", &val),
19158                FlowerAttrs::KeyEncOpts(val) => fmt.field("KeyEncOpts", &val),
19159                FlowerAttrs::KeyEncOptsMask(val) => fmt.field("KeyEncOptsMask", &val),
19160                FlowerAttrs::InHwCount(val) => fmt.field("InHwCount", &val),
19161                FlowerAttrs::KeyPortSrcMin(val) => fmt.field("KeyPortSrcMin", &val),
19162                FlowerAttrs::KeyPortSrcMax(val) => fmt.field("KeyPortSrcMax", &val),
19163                FlowerAttrs::KeyPortDstMin(val) => fmt.field("KeyPortDstMin", &val),
19164                FlowerAttrs::KeyPortDstMax(val) => fmt.field("KeyPortDstMax", &val),
19165                FlowerAttrs::KeyCtState(val) => fmt.field("KeyCtState", &val),
19166                FlowerAttrs::KeyCtStateMask(val) => fmt.field("KeyCtStateMask", &val),
19167                FlowerAttrs::KeyCtZone(val) => fmt.field("KeyCtZone", &val),
19168                FlowerAttrs::KeyCtZoneMask(val) => fmt.field("KeyCtZoneMask", &val),
19169                FlowerAttrs::KeyCtMark(val) => fmt.field("KeyCtMark", &val),
19170                FlowerAttrs::KeyCtMarkMask(val) => fmt.field("KeyCtMarkMask", &val),
19171                FlowerAttrs::KeyCtLabels(val) => fmt.field("KeyCtLabels", &val),
19172                FlowerAttrs::KeyCtLabelsMask(val) => fmt.field("KeyCtLabelsMask", &val),
19173                FlowerAttrs::KeyMplsOpts(val) => fmt.field("KeyMplsOpts", &val),
19174                FlowerAttrs::KeyHash(val) => fmt.field("KeyHash", &val),
19175                FlowerAttrs::KeyHashMask(val) => fmt.field("KeyHashMask", &val),
19176                FlowerAttrs::KeyNumOfVlans(val) => fmt.field("KeyNumOfVlans", &val),
19177                FlowerAttrs::KeyPppoeSid(val) => fmt.field("KeyPppoeSid", &val),
19178                FlowerAttrs::KeyPppProto(val) => fmt.field("KeyPppProto", &val),
19179                FlowerAttrs::KeyL2tpv3Sid(val) => fmt.field("KeyL2tpv3Sid", &val),
19180                FlowerAttrs::L2Miss(val) => fmt.field("L2Miss", &val),
19181                FlowerAttrs::KeyCfm(val) => fmt.field("KeyCfm", &val),
19182                FlowerAttrs::KeySpi(val) => fmt.field("KeySpi", &val),
19183                FlowerAttrs::KeySpiMask(val) => fmt.field("KeySpiMask", &val),
19184                FlowerAttrs::KeyEncFlags(val) => fmt.field(
19185                    "KeyEncFlags",
19186                    &FormatFlags(val.into(), FlowerKeyCtrlFlags::from_value),
19187                ),
19188                FlowerAttrs::KeyEncFlagsMask(val) => fmt.field(
19189                    "KeyEncFlagsMask",
19190                    &FormatFlags(val.into(), FlowerKeyCtrlFlags::from_value),
19191                ),
19192            };
19193        }
19194        fmt.finish()
19195    }
19196}
19197impl IterableFlowerAttrs<'_> {
19198    pub fn lookup_attr(
19199        &self,
19200        offset: usize,
19201        missing_type: Option<u16>,
19202    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
19203        let mut stack = Vec::new();
19204        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
19205        if missing_type.is_some() && cur == offset {
19206            stack.push(("FlowerAttrs", offset));
19207            return (
19208                stack,
19209                missing_type.and_then(|t| FlowerAttrs::attr_from_type(t)),
19210            );
19211        }
19212        if cur > offset || cur + self.buf.len() < offset {
19213            return (stack, None);
19214        }
19215        let mut attrs = self.clone();
19216        let mut last_off = cur + attrs.pos;
19217        let mut missing = None;
19218        while let Some(attr) = attrs.next() {
19219            let Ok(attr) = attr else { break };
19220            match attr {
19221                FlowerAttrs::Classid(val) => {
19222                    if last_off == offset {
19223                        stack.push(("Classid", last_off));
19224                        break;
19225                    }
19226                }
19227                FlowerAttrs::Indev(val) => {
19228                    if last_off == offset {
19229                        stack.push(("Indev", last_off));
19230                        break;
19231                    }
19232                }
19233                FlowerAttrs::Act(val) => {
19234                    for entry in val {
19235                        let Ok(attr) = entry else { break };
19236                        (stack, missing) = attr.lookup_attr(offset, missing_type);
19237                        if !stack.is_empty() {
19238                            break;
19239                        }
19240                    }
19241                    if !stack.is_empty() {
19242                        stack.push(("Act", last_off));
19243                        break;
19244                    }
19245                }
19246                FlowerAttrs::KeyEthDst(val) => {
19247                    if last_off == offset {
19248                        stack.push(("KeyEthDst", last_off));
19249                        break;
19250                    }
19251                }
19252                FlowerAttrs::KeyEthDstMask(val) => {
19253                    if last_off == offset {
19254                        stack.push(("KeyEthDstMask", last_off));
19255                        break;
19256                    }
19257                }
19258                FlowerAttrs::KeyEthSrc(val) => {
19259                    if last_off == offset {
19260                        stack.push(("KeyEthSrc", last_off));
19261                        break;
19262                    }
19263                }
19264                FlowerAttrs::KeyEthSrcMask(val) => {
19265                    if last_off == offset {
19266                        stack.push(("KeyEthSrcMask", last_off));
19267                        break;
19268                    }
19269                }
19270                FlowerAttrs::KeyEthType(val) => {
19271                    if last_off == offset {
19272                        stack.push(("KeyEthType", last_off));
19273                        break;
19274                    }
19275                }
19276                FlowerAttrs::KeyIpProto(val) => {
19277                    if last_off == offset {
19278                        stack.push(("KeyIpProto", last_off));
19279                        break;
19280                    }
19281                }
19282                FlowerAttrs::KeyIpv4Src(val) => {
19283                    if last_off == offset {
19284                        stack.push(("KeyIpv4Src", last_off));
19285                        break;
19286                    }
19287                }
19288                FlowerAttrs::KeyIpv4SrcMask(val) => {
19289                    if last_off == offset {
19290                        stack.push(("KeyIpv4SrcMask", last_off));
19291                        break;
19292                    }
19293                }
19294                FlowerAttrs::KeyIpv4Dst(val) => {
19295                    if last_off == offset {
19296                        stack.push(("KeyIpv4Dst", last_off));
19297                        break;
19298                    }
19299                }
19300                FlowerAttrs::KeyIpv4DstMask(val) => {
19301                    if last_off == offset {
19302                        stack.push(("KeyIpv4DstMask", last_off));
19303                        break;
19304                    }
19305                }
19306                FlowerAttrs::KeyIpv6Src(val) => {
19307                    if last_off == offset {
19308                        stack.push(("KeyIpv6Src", last_off));
19309                        break;
19310                    }
19311                }
19312                FlowerAttrs::KeyIpv6SrcMask(val) => {
19313                    if last_off == offset {
19314                        stack.push(("KeyIpv6SrcMask", last_off));
19315                        break;
19316                    }
19317                }
19318                FlowerAttrs::KeyIpv6Dst(val) => {
19319                    if last_off == offset {
19320                        stack.push(("KeyIpv6Dst", last_off));
19321                        break;
19322                    }
19323                }
19324                FlowerAttrs::KeyIpv6DstMask(val) => {
19325                    if last_off == offset {
19326                        stack.push(("KeyIpv6DstMask", last_off));
19327                        break;
19328                    }
19329                }
19330                FlowerAttrs::KeyTcpSrc(val) => {
19331                    if last_off == offset {
19332                        stack.push(("KeyTcpSrc", last_off));
19333                        break;
19334                    }
19335                }
19336                FlowerAttrs::KeyTcpDst(val) => {
19337                    if last_off == offset {
19338                        stack.push(("KeyTcpDst", last_off));
19339                        break;
19340                    }
19341                }
19342                FlowerAttrs::KeyUdpSrc(val) => {
19343                    if last_off == offset {
19344                        stack.push(("KeyUdpSrc", last_off));
19345                        break;
19346                    }
19347                }
19348                FlowerAttrs::KeyUdpDst(val) => {
19349                    if last_off == offset {
19350                        stack.push(("KeyUdpDst", last_off));
19351                        break;
19352                    }
19353                }
19354                FlowerAttrs::Flags(val) => {
19355                    if last_off == offset {
19356                        stack.push(("Flags", last_off));
19357                        break;
19358                    }
19359                }
19360                FlowerAttrs::KeyVlanId(val) => {
19361                    if last_off == offset {
19362                        stack.push(("KeyVlanId", last_off));
19363                        break;
19364                    }
19365                }
19366                FlowerAttrs::KeyVlanPrio(val) => {
19367                    if last_off == offset {
19368                        stack.push(("KeyVlanPrio", last_off));
19369                        break;
19370                    }
19371                }
19372                FlowerAttrs::KeyVlanEthType(val) => {
19373                    if last_off == offset {
19374                        stack.push(("KeyVlanEthType", last_off));
19375                        break;
19376                    }
19377                }
19378                FlowerAttrs::KeyEncKeyId(val) => {
19379                    if last_off == offset {
19380                        stack.push(("KeyEncKeyId", last_off));
19381                        break;
19382                    }
19383                }
19384                FlowerAttrs::KeyEncIpv4Src(val) => {
19385                    if last_off == offset {
19386                        stack.push(("KeyEncIpv4Src", last_off));
19387                        break;
19388                    }
19389                }
19390                FlowerAttrs::KeyEncIpv4SrcMask(val) => {
19391                    if last_off == offset {
19392                        stack.push(("KeyEncIpv4SrcMask", last_off));
19393                        break;
19394                    }
19395                }
19396                FlowerAttrs::KeyEncIpv4Dst(val) => {
19397                    if last_off == offset {
19398                        stack.push(("KeyEncIpv4Dst", last_off));
19399                        break;
19400                    }
19401                }
19402                FlowerAttrs::KeyEncIpv4DstMask(val) => {
19403                    if last_off == offset {
19404                        stack.push(("KeyEncIpv4DstMask", last_off));
19405                        break;
19406                    }
19407                }
19408                FlowerAttrs::KeyEncIpv6Src(val) => {
19409                    if last_off == offset {
19410                        stack.push(("KeyEncIpv6Src", last_off));
19411                        break;
19412                    }
19413                }
19414                FlowerAttrs::KeyEncIpv6SrcMask(val) => {
19415                    if last_off == offset {
19416                        stack.push(("KeyEncIpv6SrcMask", last_off));
19417                        break;
19418                    }
19419                }
19420                FlowerAttrs::KeyEncIpv6Dst(val) => {
19421                    if last_off == offset {
19422                        stack.push(("KeyEncIpv6Dst", last_off));
19423                        break;
19424                    }
19425                }
19426                FlowerAttrs::KeyEncIpv6DstMask(val) => {
19427                    if last_off == offset {
19428                        stack.push(("KeyEncIpv6DstMask", last_off));
19429                        break;
19430                    }
19431                }
19432                FlowerAttrs::KeyTcpSrcMask(val) => {
19433                    if last_off == offset {
19434                        stack.push(("KeyTcpSrcMask", last_off));
19435                        break;
19436                    }
19437                }
19438                FlowerAttrs::KeyTcpDstMask(val) => {
19439                    if last_off == offset {
19440                        stack.push(("KeyTcpDstMask", last_off));
19441                        break;
19442                    }
19443                }
19444                FlowerAttrs::KeyUdpSrcMask(val) => {
19445                    if last_off == offset {
19446                        stack.push(("KeyUdpSrcMask", last_off));
19447                        break;
19448                    }
19449                }
19450                FlowerAttrs::KeyUdpDstMask(val) => {
19451                    if last_off == offset {
19452                        stack.push(("KeyUdpDstMask", last_off));
19453                        break;
19454                    }
19455                }
19456                FlowerAttrs::KeySctpSrcMask(val) => {
19457                    if last_off == offset {
19458                        stack.push(("KeySctpSrcMask", last_off));
19459                        break;
19460                    }
19461                }
19462                FlowerAttrs::KeySctpDstMask(val) => {
19463                    if last_off == offset {
19464                        stack.push(("KeySctpDstMask", last_off));
19465                        break;
19466                    }
19467                }
19468                FlowerAttrs::KeySctpSrc(val) => {
19469                    if last_off == offset {
19470                        stack.push(("KeySctpSrc", last_off));
19471                        break;
19472                    }
19473                }
19474                FlowerAttrs::KeySctpDst(val) => {
19475                    if last_off == offset {
19476                        stack.push(("KeySctpDst", last_off));
19477                        break;
19478                    }
19479                }
19480                FlowerAttrs::KeyEncUdpSrcPort(val) => {
19481                    if last_off == offset {
19482                        stack.push(("KeyEncUdpSrcPort", last_off));
19483                        break;
19484                    }
19485                }
19486                FlowerAttrs::KeyEncUdpSrcPortMask(val) => {
19487                    if last_off == offset {
19488                        stack.push(("KeyEncUdpSrcPortMask", last_off));
19489                        break;
19490                    }
19491                }
19492                FlowerAttrs::KeyEncUdpDstPort(val) => {
19493                    if last_off == offset {
19494                        stack.push(("KeyEncUdpDstPort", last_off));
19495                        break;
19496                    }
19497                }
19498                FlowerAttrs::KeyEncUdpDstPortMask(val) => {
19499                    if last_off == offset {
19500                        stack.push(("KeyEncUdpDstPortMask", last_off));
19501                        break;
19502                    }
19503                }
19504                FlowerAttrs::KeyFlags(val) => {
19505                    if last_off == offset {
19506                        stack.push(("KeyFlags", last_off));
19507                        break;
19508                    }
19509                }
19510                FlowerAttrs::KeyFlagsMask(val) => {
19511                    if last_off == offset {
19512                        stack.push(("KeyFlagsMask", last_off));
19513                        break;
19514                    }
19515                }
19516                FlowerAttrs::KeyIcmpv4Code(val) => {
19517                    if last_off == offset {
19518                        stack.push(("KeyIcmpv4Code", last_off));
19519                        break;
19520                    }
19521                }
19522                FlowerAttrs::KeyIcmpv4CodeMask(val) => {
19523                    if last_off == offset {
19524                        stack.push(("KeyIcmpv4CodeMask", last_off));
19525                        break;
19526                    }
19527                }
19528                FlowerAttrs::KeyIcmpv4Type(val) => {
19529                    if last_off == offset {
19530                        stack.push(("KeyIcmpv4Type", last_off));
19531                        break;
19532                    }
19533                }
19534                FlowerAttrs::KeyIcmpv4TypeMask(val) => {
19535                    if last_off == offset {
19536                        stack.push(("KeyIcmpv4TypeMask", last_off));
19537                        break;
19538                    }
19539                }
19540                FlowerAttrs::KeyIcmpv6Code(val) => {
19541                    if last_off == offset {
19542                        stack.push(("KeyIcmpv6Code", last_off));
19543                        break;
19544                    }
19545                }
19546                FlowerAttrs::KeyIcmpv6CodeMask(val) => {
19547                    if last_off == offset {
19548                        stack.push(("KeyIcmpv6CodeMask", last_off));
19549                        break;
19550                    }
19551                }
19552                FlowerAttrs::KeyIcmpv6Type(val) => {
19553                    if last_off == offset {
19554                        stack.push(("KeyIcmpv6Type", last_off));
19555                        break;
19556                    }
19557                }
19558                FlowerAttrs::KeyIcmpv6TypeMask(val) => {
19559                    if last_off == offset {
19560                        stack.push(("KeyIcmpv6TypeMask", last_off));
19561                        break;
19562                    }
19563                }
19564                FlowerAttrs::KeyArpSip(val) => {
19565                    if last_off == offset {
19566                        stack.push(("KeyArpSip", last_off));
19567                        break;
19568                    }
19569                }
19570                FlowerAttrs::KeyArpSipMask(val) => {
19571                    if last_off == offset {
19572                        stack.push(("KeyArpSipMask", last_off));
19573                        break;
19574                    }
19575                }
19576                FlowerAttrs::KeyArpTip(val) => {
19577                    if last_off == offset {
19578                        stack.push(("KeyArpTip", last_off));
19579                        break;
19580                    }
19581                }
19582                FlowerAttrs::KeyArpTipMask(val) => {
19583                    if last_off == offset {
19584                        stack.push(("KeyArpTipMask", last_off));
19585                        break;
19586                    }
19587                }
19588                FlowerAttrs::KeyArpOp(val) => {
19589                    if last_off == offset {
19590                        stack.push(("KeyArpOp", last_off));
19591                        break;
19592                    }
19593                }
19594                FlowerAttrs::KeyArpOpMask(val) => {
19595                    if last_off == offset {
19596                        stack.push(("KeyArpOpMask", last_off));
19597                        break;
19598                    }
19599                }
19600                FlowerAttrs::KeyArpSha(val) => {
19601                    if last_off == offset {
19602                        stack.push(("KeyArpSha", last_off));
19603                        break;
19604                    }
19605                }
19606                FlowerAttrs::KeyArpShaMask(val) => {
19607                    if last_off == offset {
19608                        stack.push(("KeyArpShaMask", last_off));
19609                        break;
19610                    }
19611                }
19612                FlowerAttrs::KeyArpTha(val) => {
19613                    if last_off == offset {
19614                        stack.push(("KeyArpTha", last_off));
19615                        break;
19616                    }
19617                }
19618                FlowerAttrs::KeyArpThaMask(val) => {
19619                    if last_off == offset {
19620                        stack.push(("KeyArpThaMask", last_off));
19621                        break;
19622                    }
19623                }
19624                FlowerAttrs::KeyMplsTtl(val) => {
19625                    if last_off == offset {
19626                        stack.push(("KeyMplsTtl", last_off));
19627                        break;
19628                    }
19629                }
19630                FlowerAttrs::KeyMplsBos(val) => {
19631                    if last_off == offset {
19632                        stack.push(("KeyMplsBos", last_off));
19633                        break;
19634                    }
19635                }
19636                FlowerAttrs::KeyMplsTc(val) => {
19637                    if last_off == offset {
19638                        stack.push(("KeyMplsTc", last_off));
19639                        break;
19640                    }
19641                }
19642                FlowerAttrs::KeyMplsLabel(val) => {
19643                    if last_off == offset {
19644                        stack.push(("KeyMplsLabel", last_off));
19645                        break;
19646                    }
19647                }
19648                FlowerAttrs::KeyTcpFlags(val) => {
19649                    if last_off == offset {
19650                        stack.push(("KeyTcpFlags", last_off));
19651                        break;
19652                    }
19653                }
19654                FlowerAttrs::KeyTcpFlagsMask(val) => {
19655                    if last_off == offset {
19656                        stack.push(("KeyTcpFlagsMask", last_off));
19657                        break;
19658                    }
19659                }
19660                FlowerAttrs::KeyIpTos(val) => {
19661                    if last_off == offset {
19662                        stack.push(("KeyIpTos", last_off));
19663                        break;
19664                    }
19665                }
19666                FlowerAttrs::KeyIpTosMask(val) => {
19667                    if last_off == offset {
19668                        stack.push(("KeyIpTosMask", last_off));
19669                        break;
19670                    }
19671                }
19672                FlowerAttrs::KeyIpTtl(val) => {
19673                    if last_off == offset {
19674                        stack.push(("KeyIpTtl", last_off));
19675                        break;
19676                    }
19677                }
19678                FlowerAttrs::KeyIpTtlMask(val) => {
19679                    if last_off == offset {
19680                        stack.push(("KeyIpTtlMask", last_off));
19681                        break;
19682                    }
19683                }
19684                FlowerAttrs::KeyCvlanId(val) => {
19685                    if last_off == offset {
19686                        stack.push(("KeyCvlanId", last_off));
19687                        break;
19688                    }
19689                }
19690                FlowerAttrs::KeyCvlanPrio(val) => {
19691                    if last_off == offset {
19692                        stack.push(("KeyCvlanPrio", last_off));
19693                        break;
19694                    }
19695                }
19696                FlowerAttrs::KeyCvlanEthType(val) => {
19697                    if last_off == offset {
19698                        stack.push(("KeyCvlanEthType", last_off));
19699                        break;
19700                    }
19701                }
19702                FlowerAttrs::KeyEncIpTos(val) => {
19703                    if last_off == offset {
19704                        stack.push(("KeyEncIpTos", last_off));
19705                        break;
19706                    }
19707                }
19708                FlowerAttrs::KeyEncIpTosMask(val) => {
19709                    if last_off == offset {
19710                        stack.push(("KeyEncIpTosMask", last_off));
19711                        break;
19712                    }
19713                }
19714                FlowerAttrs::KeyEncIpTtl(val) => {
19715                    if last_off == offset {
19716                        stack.push(("KeyEncIpTtl", last_off));
19717                        break;
19718                    }
19719                }
19720                FlowerAttrs::KeyEncIpTtlMask(val) => {
19721                    if last_off == offset {
19722                        stack.push(("KeyEncIpTtlMask", last_off));
19723                        break;
19724                    }
19725                }
19726                FlowerAttrs::KeyEncOpts(val) => {
19727                    (stack, missing) = val.lookup_attr(offset, missing_type);
19728                    if !stack.is_empty() {
19729                        break;
19730                    }
19731                }
19732                FlowerAttrs::KeyEncOptsMask(val) => {
19733                    (stack, missing) = val.lookup_attr(offset, missing_type);
19734                    if !stack.is_empty() {
19735                        break;
19736                    }
19737                }
19738                FlowerAttrs::InHwCount(val) => {
19739                    if last_off == offset {
19740                        stack.push(("InHwCount", last_off));
19741                        break;
19742                    }
19743                }
19744                FlowerAttrs::KeyPortSrcMin(val) => {
19745                    if last_off == offset {
19746                        stack.push(("KeyPortSrcMin", last_off));
19747                        break;
19748                    }
19749                }
19750                FlowerAttrs::KeyPortSrcMax(val) => {
19751                    if last_off == offset {
19752                        stack.push(("KeyPortSrcMax", last_off));
19753                        break;
19754                    }
19755                }
19756                FlowerAttrs::KeyPortDstMin(val) => {
19757                    if last_off == offset {
19758                        stack.push(("KeyPortDstMin", last_off));
19759                        break;
19760                    }
19761                }
19762                FlowerAttrs::KeyPortDstMax(val) => {
19763                    if last_off == offset {
19764                        stack.push(("KeyPortDstMax", last_off));
19765                        break;
19766                    }
19767                }
19768                FlowerAttrs::KeyCtState(val) => {
19769                    if last_off == offset {
19770                        stack.push(("KeyCtState", last_off));
19771                        break;
19772                    }
19773                }
19774                FlowerAttrs::KeyCtStateMask(val) => {
19775                    if last_off == offset {
19776                        stack.push(("KeyCtStateMask", last_off));
19777                        break;
19778                    }
19779                }
19780                FlowerAttrs::KeyCtZone(val) => {
19781                    if last_off == offset {
19782                        stack.push(("KeyCtZone", last_off));
19783                        break;
19784                    }
19785                }
19786                FlowerAttrs::KeyCtZoneMask(val) => {
19787                    if last_off == offset {
19788                        stack.push(("KeyCtZoneMask", last_off));
19789                        break;
19790                    }
19791                }
19792                FlowerAttrs::KeyCtMark(val) => {
19793                    if last_off == offset {
19794                        stack.push(("KeyCtMark", last_off));
19795                        break;
19796                    }
19797                }
19798                FlowerAttrs::KeyCtMarkMask(val) => {
19799                    if last_off == offset {
19800                        stack.push(("KeyCtMarkMask", last_off));
19801                        break;
19802                    }
19803                }
19804                FlowerAttrs::KeyCtLabels(val) => {
19805                    if last_off == offset {
19806                        stack.push(("KeyCtLabels", last_off));
19807                        break;
19808                    }
19809                }
19810                FlowerAttrs::KeyCtLabelsMask(val) => {
19811                    if last_off == offset {
19812                        stack.push(("KeyCtLabelsMask", last_off));
19813                        break;
19814                    }
19815                }
19816                FlowerAttrs::KeyMplsOpts(val) => {
19817                    (stack, missing) = val.lookup_attr(offset, missing_type);
19818                    if !stack.is_empty() {
19819                        break;
19820                    }
19821                }
19822                FlowerAttrs::KeyHash(val) => {
19823                    if last_off == offset {
19824                        stack.push(("KeyHash", last_off));
19825                        break;
19826                    }
19827                }
19828                FlowerAttrs::KeyHashMask(val) => {
19829                    if last_off == offset {
19830                        stack.push(("KeyHashMask", last_off));
19831                        break;
19832                    }
19833                }
19834                FlowerAttrs::KeyNumOfVlans(val) => {
19835                    if last_off == offset {
19836                        stack.push(("KeyNumOfVlans", last_off));
19837                        break;
19838                    }
19839                }
19840                FlowerAttrs::KeyPppoeSid(val) => {
19841                    if last_off == offset {
19842                        stack.push(("KeyPppoeSid", last_off));
19843                        break;
19844                    }
19845                }
19846                FlowerAttrs::KeyPppProto(val) => {
19847                    if last_off == offset {
19848                        stack.push(("KeyPppProto", last_off));
19849                        break;
19850                    }
19851                }
19852                FlowerAttrs::KeyL2tpv3Sid(val) => {
19853                    if last_off == offset {
19854                        stack.push(("KeyL2tpv3Sid", last_off));
19855                        break;
19856                    }
19857                }
19858                FlowerAttrs::L2Miss(val) => {
19859                    if last_off == offset {
19860                        stack.push(("L2Miss", last_off));
19861                        break;
19862                    }
19863                }
19864                FlowerAttrs::KeyCfm(val) => {
19865                    (stack, missing) = val.lookup_attr(offset, missing_type);
19866                    if !stack.is_empty() {
19867                        break;
19868                    }
19869                }
19870                FlowerAttrs::KeySpi(val) => {
19871                    if last_off == offset {
19872                        stack.push(("KeySpi", last_off));
19873                        break;
19874                    }
19875                }
19876                FlowerAttrs::KeySpiMask(val) => {
19877                    if last_off == offset {
19878                        stack.push(("KeySpiMask", last_off));
19879                        break;
19880                    }
19881                }
19882                FlowerAttrs::KeyEncFlags(val) => {
19883                    if last_off == offset {
19884                        stack.push(("KeyEncFlags", last_off));
19885                        break;
19886                    }
19887                }
19888                FlowerAttrs::KeyEncFlagsMask(val) => {
19889                    if last_off == offset {
19890                        stack.push(("KeyEncFlagsMask", last_off));
19891                        break;
19892                    }
19893                }
19894                _ => {}
19895            };
19896            last_off = cur + attrs.pos;
19897        }
19898        if !stack.is_empty() {
19899            stack.push(("FlowerAttrs", cur));
19900        }
19901        (stack, missing)
19902    }
19903}
19904#[derive(Clone)]
19905pub enum FlowerKeyEncOptsAttrs<'a> {
19906    Geneve(IterableFlowerKeyEncOptGeneveAttrs<'a>),
19907    Vxlan(IterableFlowerKeyEncOptVxlanAttrs<'a>),
19908    Erspan(IterableFlowerKeyEncOptErspanAttrs<'a>),
19909    Gtp(IterableFlowerKeyEncOptGtpAttrs<'a>),
19910}
19911impl<'a> IterableFlowerKeyEncOptsAttrs<'a> {
19912    pub fn get_geneve(&self) -> Result<IterableFlowerKeyEncOptGeneveAttrs<'a>, ErrorContext> {
19913        let mut iter = self.clone();
19914        iter.pos = 0;
19915        for attr in iter {
19916            if let FlowerKeyEncOptsAttrs::Geneve(val) = attr? {
19917                return Ok(val);
19918            }
19919        }
19920        Err(ErrorContext::new_missing(
19921            "FlowerKeyEncOptsAttrs",
19922            "Geneve",
19923            self.orig_loc,
19924            self.buf.as_ptr() as usize,
19925        ))
19926    }
19927    pub fn get_vxlan(&self) -> Result<IterableFlowerKeyEncOptVxlanAttrs<'a>, ErrorContext> {
19928        let mut iter = self.clone();
19929        iter.pos = 0;
19930        for attr in iter {
19931            if let FlowerKeyEncOptsAttrs::Vxlan(val) = attr? {
19932                return Ok(val);
19933            }
19934        }
19935        Err(ErrorContext::new_missing(
19936            "FlowerKeyEncOptsAttrs",
19937            "Vxlan",
19938            self.orig_loc,
19939            self.buf.as_ptr() as usize,
19940        ))
19941    }
19942    pub fn get_erspan(&self) -> Result<IterableFlowerKeyEncOptErspanAttrs<'a>, ErrorContext> {
19943        let mut iter = self.clone();
19944        iter.pos = 0;
19945        for attr in iter {
19946            if let FlowerKeyEncOptsAttrs::Erspan(val) = attr? {
19947                return Ok(val);
19948            }
19949        }
19950        Err(ErrorContext::new_missing(
19951            "FlowerKeyEncOptsAttrs",
19952            "Erspan",
19953            self.orig_loc,
19954            self.buf.as_ptr() as usize,
19955        ))
19956    }
19957    pub fn get_gtp(&self) -> Result<IterableFlowerKeyEncOptGtpAttrs<'a>, ErrorContext> {
19958        let mut iter = self.clone();
19959        iter.pos = 0;
19960        for attr in iter {
19961            if let FlowerKeyEncOptsAttrs::Gtp(val) = attr? {
19962                return Ok(val);
19963            }
19964        }
19965        Err(ErrorContext::new_missing(
19966            "FlowerKeyEncOptsAttrs",
19967            "Gtp",
19968            self.orig_loc,
19969            self.buf.as_ptr() as usize,
19970        ))
19971    }
19972}
19973impl FlowerKeyEncOptsAttrs<'_> {
19974    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowerKeyEncOptsAttrs<'a> {
19975        IterableFlowerKeyEncOptsAttrs::with_loc(buf, buf.as_ptr() as usize)
19976    }
19977    fn attr_from_type(r#type: u16) -> Option<&'static str> {
19978        let res = match r#type {
19979            1u16 => "Geneve",
19980            2u16 => "Vxlan",
19981            3u16 => "Erspan",
19982            4u16 => "Gtp",
19983            _ => return None,
19984        };
19985        Some(res)
19986    }
19987}
19988#[derive(Clone, Copy, Default)]
19989pub struct IterableFlowerKeyEncOptsAttrs<'a> {
19990    buf: &'a [u8],
19991    pos: usize,
19992    orig_loc: usize,
19993}
19994impl<'a> IterableFlowerKeyEncOptsAttrs<'a> {
19995    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
19996        Self {
19997            buf,
19998            pos: 0,
19999            orig_loc,
20000        }
20001    }
20002    pub fn get_buf(&self) -> &'a [u8] {
20003        self.buf
20004    }
20005}
20006impl<'a> Iterator for IterableFlowerKeyEncOptsAttrs<'a> {
20007    type Item = Result<FlowerKeyEncOptsAttrs<'a>, ErrorContext>;
20008    fn next(&mut self) -> Option<Self::Item> {
20009        let pos = self.pos;
20010        let mut r#type;
20011        loop {
20012            r#type = None;
20013            if self.buf.len() == self.pos {
20014                return None;
20015            }
20016            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
20017                break;
20018            };
20019            r#type = Some(header.r#type);
20020            let res = match header.r#type {
20021                1u16 => FlowerKeyEncOptsAttrs::Geneve({
20022                    let res = Some(IterableFlowerKeyEncOptGeneveAttrs::with_loc(
20023                        next,
20024                        self.orig_loc,
20025                    ));
20026                    let Some(val) = res else { break };
20027                    val
20028                }),
20029                2u16 => FlowerKeyEncOptsAttrs::Vxlan({
20030                    let res = Some(IterableFlowerKeyEncOptVxlanAttrs::with_loc(
20031                        next,
20032                        self.orig_loc,
20033                    ));
20034                    let Some(val) = res else { break };
20035                    val
20036                }),
20037                3u16 => FlowerKeyEncOptsAttrs::Erspan({
20038                    let res = Some(IterableFlowerKeyEncOptErspanAttrs::with_loc(
20039                        next,
20040                        self.orig_loc,
20041                    ));
20042                    let Some(val) = res else { break };
20043                    val
20044                }),
20045                4u16 => FlowerKeyEncOptsAttrs::Gtp({
20046                    let res = Some(IterableFlowerKeyEncOptGtpAttrs::with_loc(
20047                        next,
20048                        self.orig_loc,
20049                    ));
20050                    let Some(val) = res else { break };
20051                    val
20052                }),
20053                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
20054                n => continue,
20055            };
20056            return Some(Ok(res));
20057        }
20058        Some(Err(ErrorContext::new(
20059            "FlowerKeyEncOptsAttrs",
20060            r#type.and_then(|t| FlowerKeyEncOptsAttrs::attr_from_type(t)),
20061            self.orig_loc,
20062            self.buf.as_ptr().wrapping_add(pos) as usize,
20063        )))
20064    }
20065}
20066impl<'a> std::fmt::Debug for IterableFlowerKeyEncOptsAttrs<'_> {
20067    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20068        let mut fmt = f.debug_struct("FlowerKeyEncOptsAttrs");
20069        for attr in self.clone() {
20070            let attr = match attr {
20071                Ok(a) => a,
20072                Err(err) => {
20073                    fmt.finish()?;
20074                    f.write_str("Err(")?;
20075                    err.fmt(f)?;
20076                    return f.write_str(")");
20077                }
20078            };
20079            match attr {
20080                FlowerKeyEncOptsAttrs::Geneve(val) => fmt.field("Geneve", &val),
20081                FlowerKeyEncOptsAttrs::Vxlan(val) => fmt.field("Vxlan", &val),
20082                FlowerKeyEncOptsAttrs::Erspan(val) => fmt.field("Erspan", &val),
20083                FlowerKeyEncOptsAttrs::Gtp(val) => fmt.field("Gtp", &val),
20084            };
20085        }
20086        fmt.finish()
20087    }
20088}
20089impl IterableFlowerKeyEncOptsAttrs<'_> {
20090    pub fn lookup_attr(
20091        &self,
20092        offset: usize,
20093        missing_type: Option<u16>,
20094    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
20095        let mut stack = Vec::new();
20096        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
20097        if missing_type.is_some() && cur == offset {
20098            stack.push(("FlowerKeyEncOptsAttrs", offset));
20099            return (
20100                stack,
20101                missing_type.and_then(|t| FlowerKeyEncOptsAttrs::attr_from_type(t)),
20102            );
20103        }
20104        if cur > offset || cur + self.buf.len() < offset {
20105            return (stack, None);
20106        }
20107        let mut attrs = self.clone();
20108        let mut last_off = cur + attrs.pos;
20109        let mut missing = None;
20110        while let Some(attr) = attrs.next() {
20111            let Ok(attr) = attr else { break };
20112            match attr {
20113                FlowerKeyEncOptsAttrs::Geneve(val) => {
20114                    (stack, missing) = val.lookup_attr(offset, missing_type);
20115                    if !stack.is_empty() {
20116                        break;
20117                    }
20118                }
20119                FlowerKeyEncOptsAttrs::Vxlan(val) => {
20120                    (stack, missing) = val.lookup_attr(offset, missing_type);
20121                    if !stack.is_empty() {
20122                        break;
20123                    }
20124                }
20125                FlowerKeyEncOptsAttrs::Erspan(val) => {
20126                    (stack, missing) = val.lookup_attr(offset, missing_type);
20127                    if !stack.is_empty() {
20128                        break;
20129                    }
20130                }
20131                FlowerKeyEncOptsAttrs::Gtp(val) => {
20132                    (stack, missing) = val.lookup_attr(offset, missing_type);
20133                    if !stack.is_empty() {
20134                        break;
20135                    }
20136                }
20137                _ => {}
20138            };
20139            last_off = cur + attrs.pos;
20140        }
20141        if !stack.is_empty() {
20142            stack.push(("FlowerKeyEncOptsAttrs", cur));
20143        }
20144        (stack, missing)
20145    }
20146}
20147#[derive(Clone)]
20148pub enum FlowerKeyEncOptGeneveAttrs<'a> {
20149    Class(u16),
20150    Type(u8),
20151    Data(&'a [u8]),
20152}
20153impl<'a> IterableFlowerKeyEncOptGeneveAttrs<'a> {
20154    pub fn get_class(&self) -> Result<u16, ErrorContext> {
20155        let mut iter = self.clone();
20156        iter.pos = 0;
20157        for attr in iter {
20158            if let FlowerKeyEncOptGeneveAttrs::Class(val) = attr? {
20159                return Ok(val);
20160            }
20161        }
20162        Err(ErrorContext::new_missing(
20163            "FlowerKeyEncOptGeneveAttrs",
20164            "Class",
20165            self.orig_loc,
20166            self.buf.as_ptr() as usize,
20167        ))
20168    }
20169    pub fn get_type(&self) -> Result<u8, ErrorContext> {
20170        let mut iter = self.clone();
20171        iter.pos = 0;
20172        for attr in iter {
20173            if let FlowerKeyEncOptGeneveAttrs::Type(val) = attr? {
20174                return Ok(val);
20175            }
20176        }
20177        Err(ErrorContext::new_missing(
20178            "FlowerKeyEncOptGeneveAttrs",
20179            "Type",
20180            self.orig_loc,
20181            self.buf.as_ptr() as usize,
20182        ))
20183    }
20184    pub fn get_data(&self) -> Result<&'a [u8], ErrorContext> {
20185        let mut iter = self.clone();
20186        iter.pos = 0;
20187        for attr in iter {
20188            if let FlowerKeyEncOptGeneveAttrs::Data(val) = attr? {
20189                return Ok(val);
20190            }
20191        }
20192        Err(ErrorContext::new_missing(
20193            "FlowerKeyEncOptGeneveAttrs",
20194            "Data",
20195            self.orig_loc,
20196            self.buf.as_ptr() as usize,
20197        ))
20198    }
20199}
20200impl FlowerKeyEncOptGeneveAttrs<'_> {
20201    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowerKeyEncOptGeneveAttrs<'a> {
20202        IterableFlowerKeyEncOptGeneveAttrs::with_loc(buf, buf.as_ptr() as usize)
20203    }
20204    fn attr_from_type(r#type: u16) -> Option<&'static str> {
20205        let res = match r#type {
20206            1u16 => "Class",
20207            2u16 => "Type",
20208            3u16 => "Data",
20209            _ => return None,
20210        };
20211        Some(res)
20212    }
20213}
20214#[derive(Clone, Copy, Default)]
20215pub struct IterableFlowerKeyEncOptGeneveAttrs<'a> {
20216    buf: &'a [u8],
20217    pos: usize,
20218    orig_loc: usize,
20219}
20220impl<'a> IterableFlowerKeyEncOptGeneveAttrs<'a> {
20221    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
20222        Self {
20223            buf,
20224            pos: 0,
20225            orig_loc,
20226        }
20227    }
20228    pub fn get_buf(&self) -> &'a [u8] {
20229        self.buf
20230    }
20231}
20232impl<'a> Iterator for IterableFlowerKeyEncOptGeneveAttrs<'a> {
20233    type Item = Result<FlowerKeyEncOptGeneveAttrs<'a>, ErrorContext>;
20234    fn next(&mut self) -> Option<Self::Item> {
20235        let pos = self.pos;
20236        let mut r#type;
20237        loop {
20238            r#type = None;
20239            if self.buf.len() == self.pos {
20240                return None;
20241            }
20242            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
20243                break;
20244            };
20245            r#type = Some(header.r#type);
20246            let res = match header.r#type {
20247                1u16 => FlowerKeyEncOptGeneveAttrs::Class({
20248                    let res = parse_u16(next);
20249                    let Some(val) = res else { break };
20250                    val
20251                }),
20252                2u16 => FlowerKeyEncOptGeneveAttrs::Type({
20253                    let res = parse_u8(next);
20254                    let Some(val) = res else { break };
20255                    val
20256                }),
20257                3u16 => FlowerKeyEncOptGeneveAttrs::Data({
20258                    let res = Some(next);
20259                    let Some(val) = res else { break };
20260                    val
20261                }),
20262                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
20263                n => continue,
20264            };
20265            return Some(Ok(res));
20266        }
20267        Some(Err(ErrorContext::new(
20268            "FlowerKeyEncOptGeneveAttrs",
20269            r#type.and_then(|t| FlowerKeyEncOptGeneveAttrs::attr_from_type(t)),
20270            self.orig_loc,
20271            self.buf.as_ptr().wrapping_add(pos) as usize,
20272        )))
20273    }
20274}
20275impl<'a> std::fmt::Debug for IterableFlowerKeyEncOptGeneveAttrs<'_> {
20276    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20277        let mut fmt = f.debug_struct("FlowerKeyEncOptGeneveAttrs");
20278        for attr in self.clone() {
20279            let attr = match attr {
20280                Ok(a) => a,
20281                Err(err) => {
20282                    fmt.finish()?;
20283                    f.write_str("Err(")?;
20284                    err.fmt(f)?;
20285                    return f.write_str(")");
20286                }
20287            };
20288            match attr {
20289                FlowerKeyEncOptGeneveAttrs::Class(val) => fmt.field("Class", &val),
20290                FlowerKeyEncOptGeneveAttrs::Type(val) => fmt.field("Type", &val),
20291                FlowerKeyEncOptGeneveAttrs::Data(val) => fmt.field("Data", &val),
20292            };
20293        }
20294        fmt.finish()
20295    }
20296}
20297impl IterableFlowerKeyEncOptGeneveAttrs<'_> {
20298    pub fn lookup_attr(
20299        &self,
20300        offset: usize,
20301        missing_type: Option<u16>,
20302    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
20303        let mut stack = Vec::new();
20304        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
20305        if missing_type.is_some() && cur == offset {
20306            stack.push(("FlowerKeyEncOptGeneveAttrs", offset));
20307            return (
20308                stack,
20309                missing_type.and_then(|t| FlowerKeyEncOptGeneveAttrs::attr_from_type(t)),
20310            );
20311        }
20312        if cur > offset || cur + self.buf.len() < offset {
20313            return (stack, None);
20314        }
20315        let mut attrs = self.clone();
20316        let mut last_off = cur + attrs.pos;
20317        while let Some(attr) = attrs.next() {
20318            let Ok(attr) = attr else { break };
20319            match attr {
20320                FlowerKeyEncOptGeneveAttrs::Class(val) => {
20321                    if last_off == offset {
20322                        stack.push(("Class", last_off));
20323                        break;
20324                    }
20325                }
20326                FlowerKeyEncOptGeneveAttrs::Type(val) => {
20327                    if last_off == offset {
20328                        stack.push(("Type", last_off));
20329                        break;
20330                    }
20331                }
20332                FlowerKeyEncOptGeneveAttrs::Data(val) => {
20333                    if last_off == offset {
20334                        stack.push(("Data", last_off));
20335                        break;
20336                    }
20337                }
20338                _ => {}
20339            };
20340            last_off = cur + attrs.pos;
20341        }
20342        if !stack.is_empty() {
20343            stack.push(("FlowerKeyEncOptGeneveAttrs", cur));
20344        }
20345        (stack, None)
20346    }
20347}
20348#[derive(Clone)]
20349pub enum FlowerKeyEncOptVxlanAttrs {
20350    Gbp(u32),
20351}
20352impl<'a> IterableFlowerKeyEncOptVxlanAttrs<'a> {
20353    pub fn get_gbp(&self) -> Result<u32, ErrorContext> {
20354        let mut iter = self.clone();
20355        iter.pos = 0;
20356        for attr in iter {
20357            if let FlowerKeyEncOptVxlanAttrs::Gbp(val) = attr? {
20358                return Ok(val);
20359            }
20360        }
20361        Err(ErrorContext::new_missing(
20362            "FlowerKeyEncOptVxlanAttrs",
20363            "Gbp",
20364            self.orig_loc,
20365            self.buf.as_ptr() as usize,
20366        ))
20367    }
20368}
20369impl FlowerKeyEncOptVxlanAttrs {
20370    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowerKeyEncOptVxlanAttrs<'a> {
20371        IterableFlowerKeyEncOptVxlanAttrs::with_loc(buf, buf.as_ptr() as usize)
20372    }
20373    fn attr_from_type(r#type: u16) -> Option<&'static str> {
20374        let res = match r#type {
20375            1u16 => "Gbp",
20376            _ => return None,
20377        };
20378        Some(res)
20379    }
20380}
20381#[derive(Clone, Copy, Default)]
20382pub struct IterableFlowerKeyEncOptVxlanAttrs<'a> {
20383    buf: &'a [u8],
20384    pos: usize,
20385    orig_loc: usize,
20386}
20387impl<'a> IterableFlowerKeyEncOptVxlanAttrs<'a> {
20388    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
20389        Self {
20390            buf,
20391            pos: 0,
20392            orig_loc,
20393        }
20394    }
20395    pub fn get_buf(&self) -> &'a [u8] {
20396        self.buf
20397    }
20398}
20399impl<'a> Iterator for IterableFlowerKeyEncOptVxlanAttrs<'a> {
20400    type Item = Result<FlowerKeyEncOptVxlanAttrs, ErrorContext>;
20401    fn next(&mut self) -> Option<Self::Item> {
20402        let pos = self.pos;
20403        let mut r#type;
20404        loop {
20405            r#type = None;
20406            if self.buf.len() == self.pos {
20407                return None;
20408            }
20409            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
20410                break;
20411            };
20412            r#type = Some(header.r#type);
20413            let res = match header.r#type {
20414                1u16 => FlowerKeyEncOptVxlanAttrs::Gbp({
20415                    let res = parse_u32(next);
20416                    let Some(val) = res else { break };
20417                    val
20418                }),
20419                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
20420                n => continue,
20421            };
20422            return Some(Ok(res));
20423        }
20424        Some(Err(ErrorContext::new(
20425            "FlowerKeyEncOptVxlanAttrs",
20426            r#type.and_then(|t| FlowerKeyEncOptVxlanAttrs::attr_from_type(t)),
20427            self.orig_loc,
20428            self.buf.as_ptr().wrapping_add(pos) as usize,
20429        )))
20430    }
20431}
20432impl std::fmt::Debug for IterableFlowerKeyEncOptVxlanAttrs<'_> {
20433    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20434        let mut fmt = f.debug_struct("FlowerKeyEncOptVxlanAttrs");
20435        for attr in self.clone() {
20436            let attr = match attr {
20437                Ok(a) => a,
20438                Err(err) => {
20439                    fmt.finish()?;
20440                    f.write_str("Err(")?;
20441                    err.fmt(f)?;
20442                    return f.write_str(")");
20443                }
20444            };
20445            match attr {
20446                FlowerKeyEncOptVxlanAttrs::Gbp(val) => fmt.field("Gbp", &val),
20447            };
20448        }
20449        fmt.finish()
20450    }
20451}
20452impl IterableFlowerKeyEncOptVxlanAttrs<'_> {
20453    pub fn lookup_attr(
20454        &self,
20455        offset: usize,
20456        missing_type: Option<u16>,
20457    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
20458        let mut stack = Vec::new();
20459        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
20460        if missing_type.is_some() && cur == offset {
20461            stack.push(("FlowerKeyEncOptVxlanAttrs", offset));
20462            return (
20463                stack,
20464                missing_type.and_then(|t| FlowerKeyEncOptVxlanAttrs::attr_from_type(t)),
20465            );
20466        }
20467        if cur > offset || cur + self.buf.len() < offset {
20468            return (stack, None);
20469        }
20470        let mut attrs = self.clone();
20471        let mut last_off = cur + attrs.pos;
20472        while let Some(attr) = attrs.next() {
20473            let Ok(attr) = attr else { break };
20474            match attr {
20475                FlowerKeyEncOptVxlanAttrs::Gbp(val) => {
20476                    if last_off == offset {
20477                        stack.push(("Gbp", last_off));
20478                        break;
20479                    }
20480                }
20481                _ => {}
20482            };
20483            last_off = cur + attrs.pos;
20484        }
20485        if !stack.is_empty() {
20486            stack.push(("FlowerKeyEncOptVxlanAttrs", cur));
20487        }
20488        (stack, None)
20489    }
20490}
20491#[derive(Clone)]
20492pub enum FlowerKeyEncOptErspanAttrs {
20493    Ver(u8),
20494    Index(u32),
20495    Dir(u8),
20496    Hwid(u8),
20497}
20498impl<'a> IterableFlowerKeyEncOptErspanAttrs<'a> {
20499    pub fn get_ver(&self) -> Result<u8, ErrorContext> {
20500        let mut iter = self.clone();
20501        iter.pos = 0;
20502        for attr in iter {
20503            if let FlowerKeyEncOptErspanAttrs::Ver(val) = attr? {
20504                return Ok(val);
20505            }
20506        }
20507        Err(ErrorContext::new_missing(
20508            "FlowerKeyEncOptErspanAttrs",
20509            "Ver",
20510            self.orig_loc,
20511            self.buf.as_ptr() as usize,
20512        ))
20513    }
20514    pub fn get_index(&self) -> Result<u32, ErrorContext> {
20515        let mut iter = self.clone();
20516        iter.pos = 0;
20517        for attr in iter {
20518            if let FlowerKeyEncOptErspanAttrs::Index(val) = attr? {
20519                return Ok(val);
20520            }
20521        }
20522        Err(ErrorContext::new_missing(
20523            "FlowerKeyEncOptErspanAttrs",
20524            "Index",
20525            self.orig_loc,
20526            self.buf.as_ptr() as usize,
20527        ))
20528    }
20529    pub fn get_dir(&self) -> Result<u8, ErrorContext> {
20530        let mut iter = self.clone();
20531        iter.pos = 0;
20532        for attr in iter {
20533            if let FlowerKeyEncOptErspanAttrs::Dir(val) = attr? {
20534                return Ok(val);
20535            }
20536        }
20537        Err(ErrorContext::new_missing(
20538            "FlowerKeyEncOptErspanAttrs",
20539            "Dir",
20540            self.orig_loc,
20541            self.buf.as_ptr() as usize,
20542        ))
20543    }
20544    pub fn get_hwid(&self) -> Result<u8, ErrorContext> {
20545        let mut iter = self.clone();
20546        iter.pos = 0;
20547        for attr in iter {
20548            if let FlowerKeyEncOptErspanAttrs::Hwid(val) = attr? {
20549                return Ok(val);
20550            }
20551        }
20552        Err(ErrorContext::new_missing(
20553            "FlowerKeyEncOptErspanAttrs",
20554            "Hwid",
20555            self.orig_loc,
20556            self.buf.as_ptr() as usize,
20557        ))
20558    }
20559}
20560impl FlowerKeyEncOptErspanAttrs {
20561    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowerKeyEncOptErspanAttrs<'a> {
20562        IterableFlowerKeyEncOptErspanAttrs::with_loc(buf, buf.as_ptr() as usize)
20563    }
20564    fn attr_from_type(r#type: u16) -> Option<&'static str> {
20565        let res = match r#type {
20566            1u16 => "Ver",
20567            2u16 => "Index",
20568            3u16 => "Dir",
20569            4u16 => "Hwid",
20570            _ => return None,
20571        };
20572        Some(res)
20573    }
20574}
20575#[derive(Clone, Copy, Default)]
20576pub struct IterableFlowerKeyEncOptErspanAttrs<'a> {
20577    buf: &'a [u8],
20578    pos: usize,
20579    orig_loc: usize,
20580}
20581impl<'a> IterableFlowerKeyEncOptErspanAttrs<'a> {
20582    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
20583        Self {
20584            buf,
20585            pos: 0,
20586            orig_loc,
20587        }
20588    }
20589    pub fn get_buf(&self) -> &'a [u8] {
20590        self.buf
20591    }
20592}
20593impl<'a> Iterator for IterableFlowerKeyEncOptErspanAttrs<'a> {
20594    type Item = Result<FlowerKeyEncOptErspanAttrs, ErrorContext>;
20595    fn next(&mut self) -> Option<Self::Item> {
20596        let pos = self.pos;
20597        let mut r#type;
20598        loop {
20599            r#type = None;
20600            if self.buf.len() == self.pos {
20601                return None;
20602            }
20603            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
20604                break;
20605            };
20606            r#type = Some(header.r#type);
20607            let res = match header.r#type {
20608                1u16 => FlowerKeyEncOptErspanAttrs::Ver({
20609                    let res = parse_u8(next);
20610                    let Some(val) = res else { break };
20611                    val
20612                }),
20613                2u16 => FlowerKeyEncOptErspanAttrs::Index({
20614                    let res = parse_u32(next);
20615                    let Some(val) = res else { break };
20616                    val
20617                }),
20618                3u16 => FlowerKeyEncOptErspanAttrs::Dir({
20619                    let res = parse_u8(next);
20620                    let Some(val) = res else { break };
20621                    val
20622                }),
20623                4u16 => FlowerKeyEncOptErspanAttrs::Hwid({
20624                    let res = parse_u8(next);
20625                    let Some(val) = res else { break };
20626                    val
20627                }),
20628                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
20629                n => continue,
20630            };
20631            return Some(Ok(res));
20632        }
20633        Some(Err(ErrorContext::new(
20634            "FlowerKeyEncOptErspanAttrs",
20635            r#type.and_then(|t| FlowerKeyEncOptErspanAttrs::attr_from_type(t)),
20636            self.orig_loc,
20637            self.buf.as_ptr().wrapping_add(pos) as usize,
20638        )))
20639    }
20640}
20641impl std::fmt::Debug for IterableFlowerKeyEncOptErspanAttrs<'_> {
20642    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20643        let mut fmt = f.debug_struct("FlowerKeyEncOptErspanAttrs");
20644        for attr in self.clone() {
20645            let attr = match attr {
20646                Ok(a) => a,
20647                Err(err) => {
20648                    fmt.finish()?;
20649                    f.write_str("Err(")?;
20650                    err.fmt(f)?;
20651                    return f.write_str(")");
20652                }
20653            };
20654            match attr {
20655                FlowerKeyEncOptErspanAttrs::Ver(val) => fmt.field("Ver", &val),
20656                FlowerKeyEncOptErspanAttrs::Index(val) => fmt.field("Index", &val),
20657                FlowerKeyEncOptErspanAttrs::Dir(val) => fmt.field("Dir", &val),
20658                FlowerKeyEncOptErspanAttrs::Hwid(val) => fmt.field("Hwid", &val),
20659            };
20660        }
20661        fmt.finish()
20662    }
20663}
20664impl IterableFlowerKeyEncOptErspanAttrs<'_> {
20665    pub fn lookup_attr(
20666        &self,
20667        offset: usize,
20668        missing_type: Option<u16>,
20669    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
20670        let mut stack = Vec::new();
20671        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
20672        if missing_type.is_some() && cur == offset {
20673            stack.push(("FlowerKeyEncOptErspanAttrs", offset));
20674            return (
20675                stack,
20676                missing_type.and_then(|t| FlowerKeyEncOptErspanAttrs::attr_from_type(t)),
20677            );
20678        }
20679        if cur > offset || cur + self.buf.len() < offset {
20680            return (stack, None);
20681        }
20682        let mut attrs = self.clone();
20683        let mut last_off = cur + attrs.pos;
20684        while let Some(attr) = attrs.next() {
20685            let Ok(attr) = attr else { break };
20686            match attr {
20687                FlowerKeyEncOptErspanAttrs::Ver(val) => {
20688                    if last_off == offset {
20689                        stack.push(("Ver", last_off));
20690                        break;
20691                    }
20692                }
20693                FlowerKeyEncOptErspanAttrs::Index(val) => {
20694                    if last_off == offset {
20695                        stack.push(("Index", last_off));
20696                        break;
20697                    }
20698                }
20699                FlowerKeyEncOptErspanAttrs::Dir(val) => {
20700                    if last_off == offset {
20701                        stack.push(("Dir", last_off));
20702                        break;
20703                    }
20704                }
20705                FlowerKeyEncOptErspanAttrs::Hwid(val) => {
20706                    if last_off == offset {
20707                        stack.push(("Hwid", last_off));
20708                        break;
20709                    }
20710                }
20711                _ => {}
20712            };
20713            last_off = cur + attrs.pos;
20714        }
20715        if !stack.is_empty() {
20716            stack.push(("FlowerKeyEncOptErspanAttrs", cur));
20717        }
20718        (stack, None)
20719    }
20720}
20721#[derive(Clone)]
20722pub enum FlowerKeyEncOptGtpAttrs {
20723    PduType(u8),
20724    Qfi(u8),
20725}
20726impl<'a> IterableFlowerKeyEncOptGtpAttrs<'a> {
20727    pub fn get_pdu_type(&self) -> Result<u8, ErrorContext> {
20728        let mut iter = self.clone();
20729        iter.pos = 0;
20730        for attr in iter {
20731            if let FlowerKeyEncOptGtpAttrs::PduType(val) = attr? {
20732                return Ok(val);
20733            }
20734        }
20735        Err(ErrorContext::new_missing(
20736            "FlowerKeyEncOptGtpAttrs",
20737            "PduType",
20738            self.orig_loc,
20739            self.buf.as_ptr() as usize,
20740        ))
20741    }
20742    pub fn get_qfi(&self) -> Result<u8, ErrorContext> {
20743        let mut iter = self.clone();
20744        iter.pos = 0;
20745        for attr in iter {
20746            if let FlowerKeyEncOptGtpAttrs::Qfi(val) = attr? {
20747                return Ok(val);
20748            }
20749        }
20750        Err(ErrorContext::new_missing(
20751            "FlowerKeyEncOptGtpAttrs",
20752            "Qfi",
20753            self.orig_loc,
20754            self.buf.as_ptr() as usize,
20755        ))
20756    }
20757}
20758impl FlowerKeyEncOptGtpAttrs {
20759    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowerKeyEncOptGtpAttrs<'a> {
20760        IterableFlowerKeyEncOptGtpAttrs::with_loc(buf, buf.as_ptr() as usize)
20761    }
20762    fn attr_from_type(r#type: u16) -> Option<&'static str> {
20763        let res = match r#type {
20764            1u16 => "PduType",
20765            2u16 => "Qfi",
20766            _ => return None,
20767        };
20768        Some(res)
20769    }
20770}
20771#[derive(Clone, Copy, Default)]
20772pub struct IterableFlowerKeyEncOptGtpAttrs<'a> {
20773    buf: &'a [u8],
20774    pos: usize,
20775    orig_loc: usize,
20776}
20777impl<'a> IterableFlowerKeyEncOptGtpAttrs<'a> {
20778    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
20779        Self {
20780            buf,
20781            pos: 0,
20782            orig_loc,
20783        }
20784    }
20785    pub fn get_buf(&self) -> &'a [u8] {
20786        self.buf
20787    }
20788}
20789impl<'a> Iterator for IterableFlowerKeyEncOptGtpAttrs<'a> {
20790    type Item = Result<FlowerKeyEncOptGtpAttrs, ErrorContext>;
20791    fn next(&mut self) -> Option<Self::Item> {
20792        let pos = self.pos;
20793        let mut r#type;
20794        loop {
20795            r#type = None;
20796            if self.buf.len() == self.pos {
20797                return None;
20798            }
20799            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
20800                break;
20801            };
20802            r#type = Some(header.r#type);
20803            let res = match header.r#type {
20804                1u16 => FlowerKeyEncOptGtpAttrs::PduType({
20805                    let res = parse_u8(next);
20806                    let Some(val) = res else { break };
20807                    val
20808                }),
20809                2u16 => FlowerKeyEncOptGtpAttrs::Qfi({
20810                    let res = parse_u8(next);
20811                    let Some(val) = res else { break };
20812                    val
20813                }),
20814                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
20815                n => continue,
20816            };
20817            return Some(Ok(res));
20818        }
20819        Some(Err(ErrorContext::new(
20820            "FlowerKeyEncOptGtpAttrs",
20821            r#type.and_then(|t| FlowerKeyEncOptGtpAttrs::attr_from_type(t)),
20822            self.orig_loc,
20823            self.buf.as_ptr().wrapping_add(pos) as usize,
20824        )))
20825    }
20826}
20827impl std::fmt::Debug for IterableFlowerKeyEncOptGtpAttrs<'_> {
20828    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20829        let mut fmt = f.debug_struct("FlowerKeyEncOptGtpAttrs");
20830        for attr in self.clone() {
20831            let attr = match attr {
20832                Ok(a) => a,
20833                Err(err) => {
20834                    fmt.finish()?;
20835                    f.write_str("Err(")?;
20836                    err.fmt(f)?;
20837                    return f.write_str(")");
20838                }
20839            };
20840            match attr {
20841                FlowerKeyEncOptGtpAttrs::PduType(val) => fmt.field("PduType", &val),
20842                FlowerKeyEncOptGtpAttrs::Qfi(val) => fmt.field("Qfi", &val),
20843            };
20844        }
20845        fmt.finish()
20846    }
20847}
20848impl IterableFlowerKeyEncOptGtpAttrs<'_> {
20849    pub fn lookup_attr(
20850        &self,
20851        offset: usize,
20852        missing_type: Option<u16>,
20853    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
20854        let mut stack = Vec::new();
20855        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
20856        if missing_type.is_some() && cur == offset {
20857            stack.push(("FlowerKeyEncOptGtpAttrs", offset));
20858            return (
20859                stack,
20860                missing_type.and_then(|t| FlowerKeyEncOptGtpAttrs::attr_from_type(t)),
20861            );
20862        }
20863        if cur > offset || cur + self.buf.len() < offset {
20864            return (stack, None);
20865        }
20866        let mut attrs = self.clone();
20867        let mut last_off = cur + attrs.pos;
20868        while let Some(attr) = attrs.next() {
20869            let Ok(attr) = attr else { break };
20870            match attr {
20871                FlowerKeyEncOptGtpAttrs::PduType(val) => {
20872                    if last_off == offset {
20873                        stack.push(("PduType", last_off));
20874                        break;
20875                    }
20876                }
20877                FlowerKeyEncOptGtpAttrs::Qfi(val) => {
20878                    if last_off == offset {
20879                        stack.push(("Qfi", last_off));
20880                        break;
20881                    }
20882                }
20883                _ => {}
20884            };
20885            last_off = cur + attrs.pos;
20886        }
20887        if !stack.is_empty() {
20888            stack.push(("FlowerKeyEncOptGtpAttrs", cur));
20889        }
20890        (stack, None)
20891    }
20892}
20893#[derive(Clone)]
20894pub enum FlowerKeyMplsOptAttrs {
20895    LseDepth(u8),
20896    LseTtl(u8),
20897    LseBos(u8),
20898    LseTc(u8),
20899    LseLabel(u32),
20900}
20901impl<'a> IterableFlowerKeyMplsOptAttrs<'a> {
20902    pub fn get_lse_depth(&self) -> Result<u8, ErrorContext> {
20903        let mut iter = self.clone();
20904        iter.pos = 0;
20905        for attr in iter {
20906            if let FlowerKeyMplsOptAttrs::LseDepth(val) = attr? {
20907                return Ok(val);
20908            }
20909        }
20910        Err(ErrorContext::new_missing(
20911            "FlowerKeyMplsOptAttrs",
20912            "LseDepth",
20913            self.orig_loc,
20914            self.buf.as_ptr() as usize,
20915        ))
20916    }
20917    pub fn get_lse_ttl(&self) -> Result<u8, ErrorContext> {
20918        let mut iter = self.clone();
20919        iter.pos = 0;
20920        for attr in iter {
20921            if let FlowerKeyMplsOptAttrs::LseTtl(val) = attr? {
20922                return Ok(val);
20923            }
20924        }
20925        Err(ErrorContext::new_missing(
20926            "FlowerKeyMplsOptAttrs",
20927            "LseTtl",
20928            self.orig_loc,
20929            self.buf.as_ptr() as usize,
20930        ))
20931    }
20932    pub fn get_lse_bos(&self) -> Result<u8, ErrorContext> {
20933        let mut iter = self.clone();
20934        iter.pos = 0;
20935        for attr in iter {
20936            if let FlowerKeyMplsOptAttrs::LseBos(val) = attr? {
20937                return Ok(val);
20938            }
20939        }
20940        Err(ErrorContext::new_missing(
20941            "FlowerKeyMplsOptAttrs",
20942            "LseBos",
20943            self.orig_loc,
20944            self.buf.as_ptr() as usize,
20945        ))
20946    }
20947    pub fn get_lse_tc(&self) -> Result<u8, ErrorContext> {
20948        let mut iter = self.clone();
20949        iter.pos = 0;
20950        for attr in iter {
20951            if let FlowerKeyMplsOptAttrs::LseTc(val) = attr? {
20952                return Ok(val);
20953            }
20954        }
20955        Err(ErrorContext::new_missing(
20956            "FlowerKeyMplsOptAttrs",
20957            "LseTc",
20958            self.orig_loc,
20959            self.buf.as_ptr() as usize,
20960        ))
20961    }
20962    pub fn get_lse_label(&self) -> Result<u32, ErrorContext> {
20963        let mut iter = self.clone();
20964        iter.pos = 0;
20965        for attr in iter {
20966            if let FlowerKeyMplsOptAttrs::LseLabel(val) = attr? {
20967                return Ok(val);
20968            }
20969        }
20970        Err(ErrorContext::new_missing(
20971            "FlowerKeyMplsOptAttrs",
20972            "LseLabel",
20973            self.orig_loc,
20974            self.buf.as_ptr() as usize,
20975        ))
20976    }
20977}
20978impl FlowerKeyMplsOptAttrs {
20979    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowerKeyMplsOptAttrs<'a> {
20980        IterableFlowerKeyMplsOptAttrs::with_loc(buf, buf.as_ptr() as usize)
20981    }
20982    fn attr_from_type(r#type: u16) -> Option<&'static str> {
20983        let res = match r#type {
20984            1u16 => "LseDepth",
20985            2u16 => "LseTtl",
20986            3u16 => "LseBos",
20987            4u16 => "LseTc",
20988            5u16 => "LseLabel",
20989            _ => return None,
20990        };
20991        Some(res)
20992    }
20993}
20994#[derive(Clone, Copy, Default)]
20995pub struct IterableFlowerKeyMplsOptAttrs<'a> {
20996    buf: &'a [u8],
20997    pos: usize,
20998    orig_loc: usize,
20999}
21000impl<'a> IterableFlowerKeyMplsOptAttrs<'a> {
21001    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
21002        Self {
21003            buf,
21004            pos: 0,
21005            orig_loc,
21006        }
21007    }
21008    pub fn get_buf(&self) -> &'a [u8] {
21009        self.buf
21010    }
21011}
21012impl<'a> Iterator for IterableFlowerKeyMplsOptAttrs<'a> {
21013    type Item = Result<FlowerKeyMplsOptAttrs, ErrorContext>;
21014    fn next(&mut self) -> Option<Self::Item> {
21015        let pos = self.pos;
21016        let mut r#type;
21017        loop {
21018            r#type = None;
21019            if self.buf.len() == self.pos {
21020                return None;
21021            }
21022            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
21023                break;
21024            };
21025            r#type = Some(header.r#type);
21026            let res = match header.r#type {
21027                1u16 => FlowerKeyMplsOptAttrs::LseDepth({
21028                    let res = parse_u8(next);
21029                    let Some(val) = res else { break };
21030                    val
21031                }),
21032                2u16 => FlowerKeyMplsOptAttrs::LseTtl({
21033                    let res = parse_u8(next);
21034                    let Some(val) = res else { break };
21035                    val
21036                }),
21037                3u16 => FlowerKeyMplsOptAttrs::LseBos({
21038                    let res = parse_u8(next);
21039                    let Some(val) = res else { break };
21040                    val
21041                }),
21042                4u16 => FlowerKeyMplsOptAttrs::LseTc({
21043                    let res = parse_u8(next);
21044                    let Some(val) = res else { break };
21045                    val
21046                }),
21047                5u16 => FlowerKeyMplsOptAttrs::LseLabel({
21048                    let res = parse_u32(next);
21049                    let Some(val) = res else { break };
21050                    val
21051                }),
21052                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
21053                n => continue,
21054            };
21055            return Some(Ok(res));
21056        }
21057        Some(Err(ErrorContext::new(
21058            "FlowerKeyMplsOptAttrs",
21059            r#type.and_then(|t| FlowerKeyMplsOptAttrs::attr_from_type(t)),
21060            self.orig_loc,
21061            self.buf.as_ptr().wrapping_add(pos) as usize,
21062        )))
21063    }
21064}
21065impl std::fmt::Debug for IterableFlowerKeyMplsOptAttrs<'_> {
21066    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21067        let mut fmt = f.debug_struct("FlowerKeyMplsOptAttrs");
21068        for attr in self.clone() {
21069            let attr = match attr {
21070                Ok(a) => a,
21071                Err(err) => {
21072                    fmt.finish()?;
21073                    f.write_str("Err(")?;
21074                    err.fmt(f)?;
21075                    return f.write_str(")");
21076                }
21077            };
21078            match attr {
21079                FlowerKeyMplsOptAttrs::LseDepth(val) => fmt.field("LseDepth", &val),
21080                FlowerKeyMplsOptAttrs::LseTtl(val) => fmt.field("LseTtl", &val),
21081                FlowerKeyMplsOptAttrs::LseBos(val) => fmt.field("LseBos", &val),
21082                FlowerKeyMplsOptAttrs::LseTc(val) => fmt.field("LseTc", &val),
21083                FlowerKeyMplsOptAttrs::LseLabel(val) => fmt.field("LseLabel", &val),
21084            };
21085        }
21086        fmt.finish()
21087    }
21088}
21089impl IterableFlowerKeyMplsOptAttrs<'_> {
21090    pub fn lookup_attr(
21091        &self,
21092        offset: usize,
21093        missing_type: Option<u16>,
21094    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
21095        let mut stack = Vec::new();
21096        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
21097        if missing_type.is_some() && cur == offset {
21098            stack.push(("FlowerKeyMplsOptAttrs", offset));
21099            return (
21100                stack,
21101                missing_type.and_then(|t| FlowerKeyMplsOptAttrs::attr_from_type(t)),
21102            );
21103        }
21104        if cur > offset || cur + self.buf.len() < offset {
21105            return (stack, None);
21106        }
21107        let mut attrs = self.clone();
21108        let mut last_off = cur + attrs.pos;
21109        while let Some(attr) = attrs.next() {
21110            let Ok(attr) = attr else { break };
21111            match attr {
21112                FlowerKeyMplsOptAttrs::LseDepth(val) => {
21113                    if last_off == offset {
21114                        stack.push(("LseDepth", last_off));
21115                        break;
21116                    }
21117                }
21118                FlowerKeyMplsOptAttrs::LseTtl(val) => {
21119                    if last_off == offset {
21120                        stack.push(("LseTtl", last_off));
21121                        break;
21122                    }
21123                }
21124                FlowerKeyMplsOptAttrs::LseBos(val) => {
21125                    if last_off == offset {
21126                        stack.push(("LseBos", last_off));
21127                        break;
21128                    }
21129                }
21130                FlowerKeyMplsOptAttrs::LseTc(val) => {
21131                    if last_off == offset {
21132                        stack.push(("LseTc", last_off));
21133                        break;
21134                    }
21135                }
21136                FlowerKeyMplsOptAttrs::LseLabel(val) => {
21137                    if last_off == offset {
21138                        stack.push(("LseLabel", last_off));
21139                        break;
21140                    }
21141                }
21142                _ => {}
21143            };
21144            last_off = cur + attrs.pos;
21145        }
21146        if !stack.is_empty() {
21147            stack.push(("FlowerKeyMplsOptAttrs", cur));
21148        }
21149        (stack, None)
21150    }
21151}
21152#[derive(Clone)]
21153pub enum FlowerKeyCfmAttrs {
21154    MdLevel(u8),
21155    Opcode(u8),
21156}
21157impl<'a> IterableFlowerKeyCfmAttrs<'a> {
21158    pub fn get_md_level(&self) -> Result<u8, ErrorContext> {
21159        let mut iter = self.clone();
21160        iter.pos = 0;
21161        for attr in iter {
21162            if let FlowerKeyCfmAttrs::MdLevel(val) = attr? {
21163                return Ok(val);
21164            }
21165        }
21166        Err(ErrorContext::new_missing(
21167            "FlowerKeyCfmAttrs",
21168            "MdLevel",
21169            self.orig_loc,
21170            self.buf.as_ptr() as usize,
21171        ))
21172    }
21173    pub fn get_opcode(&self) -> Result<u8, ErrorContext> {
21174        let mut iter = self.clone();
21175        iter.pos = 0;
21176        for attr in iter {
21177            if let FlowerKeyCfmAttrs::Opcode(val) = attr? {
21178                return Ok(val);
21179            }
21180        }
21181        Err(ErrorContext::new_missing(
21182            "FlowerKeyCfmAttrs",
21183            "Opcode",
21184            self.orig_loc,
21185            self.buf.as_ptr() as usize,
21186        ))
21187    }
21188}
21189impl FlowerKeyCfmAttrs {
21190    pub fn new<'a>(buf: &'a [u8]) -> IterableFlowerKeyCfmAttrs<'a> {
21191        IterableFlowerKeyCfmAttrs::with_loc(buf, buf.as_ptr() as usize)
21192    }
21193    fn attr_from_type(r#type: u16) -> Option<&'static str> {
21194        let res = match r#type {
21195            1u16 => "MdLevel",
21196            2u16 => "Opcode",
21197            _ => return None,
21198        };
21199        Some(res)
21200    }
21201}
21202#[derive(Clone, Copy, Default)]
21203pub struct IterableFlowerKeyCfmAttrs<'a> {
21204    buf: &'a [u8],
21205    pos: usize,
21206    orig_loc: usize,
21207}
21208impl<'a> IterableFlowerKeyCfmAttrs<'a> {
21209    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
21210        Self {
21211            buf,
21212            pos: 0,
21213            orig_loc,
21214        }
21215    }
21216    pub fn get_buf(&self) -> &'a [u8] {
21217        self.buf
21218    }
21219}
21220impl<'a> Iterator for IterableFlowerKeyCfmAttrs<'a> {
21221    type Item = Result<FlowerKeyCfmAttrs, ErrorContext>;
21222    fn next(&mut self) -> Option<Self::Item> {
21223        let pos = self.pos;
21224        let mut r#type;
21225        loop {
21226            r#type = None;
21227            if self.buf.len() == self.pos {
21228                return None;
21229            }
21230            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
21231                break;
21232            };
21233            r#type = Some(header.r#type);
21234            let res = match header.r#type {
21235                1u16 => FlowerKeyCfmAttrs::MdLevel({
21236                    let res = parse_u8(next);
21237                    let Some(val) = res else { break };
21238                    val
21239                }),
21240                2u16 => FlowerKeyCfmAttrs::Opcode({
21241                    let res = parse_u8(next);
21242                    let Some(val) = res else { break };
21243                    val
21244                }),
21245                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
21246                n => continue,
21247            };
21248            return Some(Ok(res));
21249        }
21250        Some(Err(ErrorContext::new(
21251            "FlowerKeyCfmAttrs",
21252            r#type.and_then(|t| FlowerKeyCfmAttrs::attr_from_type(t)),
21253            self.orig_loc,
21254            self.buf.as_ptr().wrapping_add(pos) as usize,
21255        )))
21256    }
21257}
21258impl std::fmt::Debug for IterableFlowerKeyCfmAttrs<'_> {
21259    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21260        let mut fmt = f.debug_struct("FlowerKeyCfmAttrs");
21261        for attr in self.clone() {
21262            let attr = match attr {
21263                Ok(a) => a,
21264                Err(err) => {
21265                    fmt.finish()?;
21266                    f.write_str("Err(")?;
21267                    err.fmt(f)?;
21268                    return f.write_str(")");
21269                }
21270            };
21271            match attr {
21272                FlowerKeyCfmAttrs::MdLevel(val) => fmt.field("MdLevel", &val),
21273                FlowerKeyCfmAttrs::Opcode(val) => fmt.field("Opcode", &val),
21274            };
21275        }
21276        fmt.finish()
21277    }
21278}
21279impl IterableFlowerKeyCfmAttrs<'_> {
21280    pub fn lookup_attr(
21281        &self,
21282        offset: usize,
21283        missing_type: Option<u16>,
21284    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
21285        let mut stack = Vec::new();
21286        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
21287        if missing_type.is_some() && cur == offset {
21288            stack.push(("FlowerKeyCfmAttrs", offset));
21289            return (
21290                stack,
21291                missing_type.and_then(|t| FlowerKeyCfmAttrs::attr_from_type(t)),
21292            );
21293        }
21294        if cur > offset || cur + self.buf.len() < offset {
21295            return (stack, None);
21296        }
21297        let mut attrs = self.clone();
21298        let mut last_off = cur + attrs.pos;
21299        while let Some(attr) = attrs.next() {
21300            let Ok(attr) = attr else { break };
21301            match attr {
21302                FlowerKeyCfmAttrs::MdLevel(val) => {
21303                    if last_off == offset {
21304                        stack.push(("MdLevel", last_off));
21305                        break;
21306                    }
21307                }
21308                FlowerKeyCfmAttrs::Opcode(val) => {
21309                    if last_off == offset {
21310                        stack.push(("Opcode", last_off));
21311                        break;
21312                    }
21313                }
21314                _ => {}
21315            };
21316            last_off = cur + attrs.pos;
21317        }
21318        if !stack.is_empty() {
21319            stack.push(("FlowerKeyCfmAttrs", cur));
21320        }
21321        (stack, None)
21322    }
21323}
21324#[derive(Clone)]
21325pub enum FwAttrs<'a> {
21326    Classid(u32),
21327    Police(IterablePoliceAttrs<'a>),
21328    Indev(&'a CStr),
21329    Act(IterableArrayActAttrs<'a>),
21330    Mask(u32),
21331}
21332impl<'a> IterableFwAttrs<'a> {
21333    pub fn get_classid(&self) -> Result<u32, ErrorContext> {
21334        let mut iter = self.clone();
21335        iter.pos = 0;
21336        for attr in iter {
21337            if let FwAttrs::Classid(val) = attr? {
21338                return Ok(val);
21339            }
21340        }
21341        Err(ErrorContext::new_missing(
21342            "FwAttrs",
21343            "Classid",
21344            self.orig_loc,
21345            self.buf.as_ptr() as usize,
21346        ))
21347    }
21348    pub fn get_police(&self) -> Result<IterablePoliceAttrs<'a>, ErrorContext> {
21349        let mut iter = self.clone();
21350        iter.pos = 0;
21351        for attr in iter {
21352            if let FwAttrs::Police(val) = attr? {
21353                return Ok(val);
21354            }
21355        }
21356        Err(ErrorContext::new_missing(
21357            "FwAttrs",
21358            "Police",
21359            self.orig_loc,
21360            self.buf.as_ptr() as usize,
21361        ))
21362    }
21363    pub fn get_indev(&self) -> Result<&'a CStr, ErrorContext> {
21364        let mut iter = self.clone();
21365        iter.pos = 0;
21366        for attr in iter {
21367            if let FwAttrs::Indev(val) = attr? {
21368                return Ok(val);
21369            }
21370        }
21371        Err(ErrorContext::new_missing(
21372            "FwAttrs",
21373            "Indev",
21374            self.orig_loc,
21375            self.buf.as_ptr() as usize,
21376        ))
21377    }
21378    pub fn get_act(
21379        &self,
21380    ) -> Result<ArrayIterable<IterableArrayActAttrs<'a>, IterableActAttrs<'a>>, ErrorContext> {
21381        for attr in self.clone() {
21382            if let FwAttrs::Act(val) = attr? {
21383                return Ok(ArrayIterable::new(val));
21384            }
21385        }
21386        Err(ErrorContext::new_missing(
21387            "FwAttrs",
21388            "Act",
21389            self.orig_loc,
21390            self.buf.as_ptr() as usize,
21391        ))
21392    }
21393    pub fn get_mask(&self) -> Result<u32, ErrorContext> {
21394        let mut iter = self.clone();
21395        iter.pos = 0;
21396        for attr in iter {
21397            if let FwAttrs::Mask(val) = attr? {
21398                return Ok(val);
21399            }
21400        }
21401        Err(ErrorContext::new_missing(
21402            "FwAttrs",
21403            "Mask",
21404            self.orig_loc,
21405            self.buf.as_ptr() as usize,
21406        ))
21407    }
21408}
21409impl FwAttrs<'_> {
21410    pub fn new<'a>(buf: &'a [u8]) -> IterableFwAttrs<'a> {
21411        IterableFwAttrs::with_loc(buf, buf.as_ptr() as usize)
21412    }
21413    fn attr_from_type(r#type: u16) -> Option<&'static str> {
21414        let res = match r#type {
21415            1u16 => "Classid",
21416            2u16 => "Police",
21417            3u16 => "Indev",
21418            4u16 => "Act",
21419            5u16 => "Mask",
21420            _ => return None,
21421        };
21422        Some(res)
21423    }
21424}
21425#[derive(Clone, Copy, Default)]
21426pub struct IterableFwAttrs<'a> {
21427    buf: &'a [u8],
21428    pos: usize,
21429    orig_loc: usize,
21430}
21431impl<'a> IterableFwAttrs<'a> {
21432    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
21433        Self {
21434            buf,
21435            pos: 0,
21436            orig_loc,
21437        }
21438    }
21439    pub fn get_buf(&self) -> &'a [u8] {
21440        self.buf
21441    }
21442}
21443impl<'a> Iterator for IterableFwAttrs<'a> {
21444    type Item = Result<FwAttrs<'a>, ErrorContext>;
21445    fn next(&mut self) -> Option<Self::Item> {
21446        let pos = self.pos;
21447        let mut r#type;
21448        loop {
21449            r#type = None;
21450            if self.buf.len() == self.pos {
21451                return None;
21452            }
21453            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
21454                break;
21455            };
21456            r#type = Some(header.r#type);
21457            let res = match header.r#type {
21458                1u16 => FwAttrs::Classid({
21459                    let res = parse_u32(next);
21460                    let Some(val) = res else { break };
21461                    val
21462                }),
21463                2u16 => FwAttrs::Police({
21464                    let res = Some(IterablePoliceAttrs::with_loc(next, self.orig_loc));
21465                    let Some(val) = res else { break };
21466                    val
21467                }),
21468                3u16 => FwAttrs::Indev({
21469                    let res = CStr::from_bytes_with_nul(next).ok();
21470                    let Some(val) = res else { break };
21471                    val
21472                }),
21473                4u16 => FwAttrs::Act({
21474                    let res = Some(IterableArrayActAttrs::with_loc(next, self.orig_loc));
21475                    let Some(val) = res else { break };
21476                    val
21477                }),
21478                5u16 => FwAttrs::Mask({
21479                    let res = parse_u32(next);
21480                    let Some(val) = res else { break };
21481                    val
21482                }),
21483                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
21484                n => continue,
21485            };
21486            return Some(Ok(res));
21487        }
21488        Some(Err(ErrorContext::new(
21489            "FwAttrs",
21490            r#type.and_then(|t| FwAttrs::attr_from_type(t)),
21491            self.orig_loc,
21492            self.buf.as_ptr().wrapping_add(pos) as usize,
21493        )))
21494    }
21495}
21496impl<'a> std::fmt::Debug for IterableFwAttrs<'_> {
21497    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21498        let mut fmt = f.debug_struct("FwAttrs");
21499        for attr in self.clone() {
21500            let attr = match attr {
21501                Ok(a) => a,
21502                Err(err) => {
21503                    fmt.finish()?;
21504                    f.write_str("Err(")?;
21505                    err.fmt(f)?;
21506                    return f.write_str(")");
21507                }
21508            };
21509            match attr {
21510                FwAttrs::Classid(val) => fmt.field("Classid", &val),
21511                FwAttrs::Police(val) => fmt.field("Police", &val),
21512                FwAttrs::Indev(val) => fmt.field("Indev", &val),
21513                FwAttrs::Act(val) => fmt.field("Act", &val),
21514                FwAttrs::Mask(val) => fmt.field("Mask", &val),
21515            };
21516        }
21517        fmt.finish()
21518    }
21519}
21520impl IterableFwAttrs<'_> {
21521    pub fn lookup_attr(
21522        &self,
21523        offset: usize,
21524        missing_type: Option<u16>,
21525    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
21526        let mut stack = Vec::new();
21527        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
21528        if missing_type.is_some() && cur == offset {
21529            stack.push(("FwAttrs", offset));
21530            return (stack, missing_type.and_then(|t| FwAttrs::attr_from_type(t)));
21531        }
21532        if cur > offset || cur + self.buf.len() < offset {
21533            return (stack, None);
21534        }
21535        let mut attrs = self.clone();
21536        let mut last_off = cur + attrs.pos;
21537        let mut missing = None;
21538        while let Some(attr) = attrs.next() {
21539            let Ok(attr) = attr else { break };
21540            match attr {
21541                FwAttrs::Classid(val) => {
21542                    if last_off == offset {
21543                        stack.push(("Classid", last_off));
21544                        break;
21545                    }
21546                }
21547                FwAttrs::Police(val) => {
21548                    (stack, missing) = val.lookup_attr(offset, missing_type);
21549                    if !stack.is_empty() {
21550                        break;
21551                    }
21552                }
21553                FwAttrs::Indev(val) => {
21554                    if last_off == offset {
21555                        stack.push(("Indev", last_off));
21556                        break;
21557                    }
21558                }
21559                FwAttrs::Act(val) => {
21560                    for entry in val {
21561                        let Ok(attr) = entry else { break };
21562                        (stack, missing) = attr.lookup_attr(offset, missing_type);
21563                        if !stack.is_empty() {
21564                            break;
21565                        }
21566                    }
21567                    if !stack.is_empty() {
21568                        stack.push(("Act", last_off));
21569                        break;
21570                    }
21571                }
21572                FwAttrs::Mask(val) => {
21573                    if last_off == offset {
21574                        stack.push(("Mask", last_off));
21575                        break;
21576                    }
21577                }
21578                _ => {}
21579            };
21580            last_off = cur + attrs.pos;
21581        }
21582        if !stack.is_empty() {
21583            stack.push(("FwAttrs", cur));
21584        }
21585        (stack, missing)
21586    }
21587}
21588#[derive(Clone)]
21589pub enum GredAttrs<'a> {
21590    Parms(&'a [u8]),
21591    Stab(&'a [u8]),
21592    Dps(TcGredSopt),
21593    MaxP(&'a [u8]),
21594    Limit(u32),
21595    VqList(IterableTcaGredVqListAttrs<'a>),
21596}
21597impl<'a> IterableGredAttrs<'a> {
21598    pub fn get_parms(&self) -> Result<&'a [u8], ErrorContext> {
21599        let mut iter = self.clone();
21600        iter.pos = 0;
21601        for attr in iter {
21602            if let GredAttrs::Parms(val) = attr? {
21603                return Ok(val);
21604            }
21605        }
21606        Err(ErrorContext::new_missing(
21607            "GredAttrs",
21608            "Parms",
21609            self.orig_loc,
21610            self.buf.as_ptr() as usize,
21611        ))
21612    }
21613    pub fn get_stab(&self) -> Result<&'a [u8], ErrorContext> {
21614        let mut iter = self.clone();
21615        iter.pos = 0;
21616        for attr in iter {
21617            if let GredAttrs::Stab(val) = attr? {
21618                return Ok(val);
21619            }
21620        }
21621        Err(ErrorContext::new_missing(
21622            "GredAttrs",
21623            "Stab",
21624            self.orig_loc,
21625            self.buf.as_ptr() as usize,
21626        ))
21627    }
21628    pub fn get_dps(&self) -> Result<TcGredSopt, ErrorContext> {
21629        let mut iter = self.clone();
21630        iter.pos = 0;
21631        for attr in iter {
21632            if let GredAttrs::Dps(val) = attr? {
21633                return Ok(val);
21634            }
21635        }
21636        Err(ErrorContext::new_missing(
21637            "GredAttrs",
21638            "Dps",
21639            self.orig_loc,
21640            self.buf.as_ptr() as usize,
21641        ))
21642    }
21643    pub fn get_max_p(&self) -> Result<&'a [u8], ErrorContext> {
21644        let mut iter = self.clone();
21645        iter.pos = 0;
21646        for attr in iter {
21647            if let GredAttrs::MaxP(val) = attr? {
21648                return Ok(val);
21649            }
21650        }
21651        Err(ErrorContext::new_missing(
21652            "GredAttrs",
21653            "MaxP",
21654            self.orig_loc,
21655            self.buf.as_ptr() as usize,
21656        ))
21657    }
21658    pub fn get_limit(&self) -> Result<u32, ErrorContext> {
21659        let mut iter = self.clone();
21660        iter.pos = 0;
21661        for attr in iter {
21662            if let GredAttrs::Limit(val) = attr? {
21663                return Ok(val);
21664            }
21665        }
21666        Err(ErrorContext::new_missing(
21667            "GredAttrs",
21668            "Limit",
21669            self.orig_loc,
21670            self.buf.as_ptr() as usize,
21671        ))
21672    }
21673    pub fn get_vq_list(&self) -> Result<IterableTcaGredVqListAttrs<'a>, ErrorContext> {
21674        let mut iter = self.clone();
21675        iter.pos = 0;
21676        for attr in iter {
21677            if let GredAttrs::VqList(val) = attr? {
21678                return Ok(val);
21679            }
21680        }
21681        Err(ErrorContext::new_missing(
21682            "GredAttrs",
21683            "VqList",
21684            self.orig_loc,
21685            self.buf.as_ptr() as usize,
21686        ))
21687    }
21688}
21689impl GredAttrs<'_> {
21690    pub fn new<'a>(buf: &'a [u8]) -> IterableGredAttrs<'a> {
21691        IterableGredAttrs::with_loc(buf, buf.as_ptr() as usize)
21692    }
21693    fn attr_from_type(r#type: u16) -> Option<&'static str> {
21694        let res = match r#type {
21695            1u16 => "Parms",
21696            2u16 => "Stab",
21697            3u16 => "Dps",
21698            4u16 => "MaxP",
21699            5u16 => "Limit",
21700            6u16 => "VqList",
21701            _ => return None,
21702        };
21703        Some(res)
21704    }
21705}
21706#[derive(Clone, Copy, Default)]
21707pub struct IterableGredAttrs<'a> {
21708    buf: &'a [u8],
21709    pos: usize,
21710    orig_loc: usize,
21711}
21712impl<'a> IterableGredAttrs<'a> {
21713    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
21714        Self {
21715            buf,
21716            pos: 0,
21717            orig_loc,
21718        }
21719    }
21720    pub fn get_buf(&self) -> &'a [u8] {
21721        self.buf
21722    }
21723}
21724impl<'a> Iterator for IterableGredAttrs<'a> {
21725    type Item = Result<GredAttrs<'a>, ErrorContext>;
21726    fn next(&mut self) -> Option<Self::Item> {
21727        let pos = self.pos;
21728        let mut r#type;
21729        loop {
21730            r#type = None;
21731            if self.buf.len() == self.pos {
21732                return None;
21733            }
21734            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
21735                break;
21736            };
21737            r#type = Some(header.r#type);
21738            let res = match header.r#type {
21739                1u16 => GredAttrs::Parms({
21740                    let res = Some(next);
21741                    let Some(val) = res else { break };
21742                    val
21743                }),
21744                2u16 => GredAttrs::Stab({
21745                    let res = Some(next);
21746                    let Some(val) = res else { break };
21747                    val
21748                }),
21749                3u16 => GredAttrs::Dps({
21750                    let res = Some(TcGredSopt::new_from_zeroed(next));
21751                    let Some(val) = res else { break };
21752                    val
21753                }),
21754                4u16 => GredAttrs::MaxP({
21755                    let res = Some(next);
21756                    let Some(val) = res else { break };
21757                    val
21758                }),
21759                5u16 => GredAttrs::Limit({
21760                    let res = parse_u32(next);
21761                    let Some(val) = res else { break };
21762                    val
21763                }),
21764                6u16 => GredAttrs::VqList({
21765                    let res = Some(IterableTcaGredVqListAttrs::with_loc(next, self.orig_loc));
21766                    let Some(val) = res else { break };
21767                    val
21768                }),
21769                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
21770                n => continue,
21771            };
21772            return Some(Ok(res));
21773        }
21774        Some(Err(ErrorContext::new(
21775            "GredAttrs",
21776            r#type.and_then(|t| GredAttrs::attr_from_type(t)),
21777            self.orig_loc,
21778            self.buf.as_ptr().wrapping_add(pos) as usize,
21779        )))
21780    }
21781}
21782impl<'a> std::fmt::Debug for IterableGredAttrs<'_> {
21783    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21784        let mut fmt = f.debug_struct("GredAttrs");
21785        for attr in self.clone() {
21786            let attr = match attr {
21787                Ok(a) => a,
21788                Err(err) => {
21789                    fmt.finish()?;
21790                    f.write_str("Err(")?;
21791                    err.fmt(f)?;
21792                    return f.write_str(")");
21793                }
21794            };
21795            match attr {
21796                GredAttrs::Parms(val) => fmt.field("Parms", &val),
21797                GredAttrs::Stab(val) => fmt.field("Stab", &val),
21798                GredAttrs::Dps(val) => fmt.field("Dps", &val),
21799                GredAttrs::MaxP(val) => fmt.field("MaxP", &val),
21800                GredAttrs::Limit(val) => fmt.field("Limit", &val),
21801                GredAttrs::VqList(val) => fmt.field("VqList", &val),
21802            };
21803        }
21804        fmt.finish()
21805    }
21806}
21807impl IterableGredAttrs<'_> {
21808    pub fn lookup_attr(
21809        &self,
21810        offset: usize,
21811        missing_type: Option<u16>,
21812    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
21813        let mut stack = Vec::new();
21814        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
21815        if missing_type.is_some() && cur == offset {
21816            stack.push(("GredAttrs", offset));
21817            return (
21818                stack,
21819                missing_type.and_then(|t| GredAttrs::attr_from_type(t)),
21820            );
21821        }
21822        if cur > offset || cur + self.buf.len() < offset {
21823            return (stack, None);
21824        }
21825        let mut attrs = self.clone();
21826        let mut last_off = cur + attrs.pos;
21827        let mut missing = None;
21828        while let Some(attr) = attrs.next() {
21829            let Ok(attr) = attr else { break };
21830            match attr {
21831                GredAttrs::Parms(val) => {
21832                    if last_off == offset {
21833                        stack.push(("Parms", last_off));
21834                        break;
21835                    }
21836                }
21837                GredAttrs::Stab(val) => {
21838                    if last_off == offset {
21839                        stack.push(("Stab", last_off));
21840                        break;
21841                    }
21842                }
21843                GredAttrs::Dps(val) => {
21844                    if last_off == offset {
21845                        stack.push(("Dps", last_off));
21846                        break;
21847                    }
21848                }
21849                GredAttrs::MaxP(val) => {
21850                    if last_off == offset {
21851                        stack.push(("MaxP", last_off));
21852                        break;
21853                    }
21854                }
21855                GredAttrs::Limit(val) => {
21856                    if last_off == offset {
21857                        stack.push(("Limit", last_off));
21858                        break;
21859                    }
21860                }
21861                GredAttrs::VqList(val) => {
21862                    (stack, missing) = val.lookup_attr(offset, missing_type);
21863                    if !stack.is_empty() {
21864                        break;
21865                    }
21866                }
21867                _ => {}
21868            };
21869            last_off = cur + attrs.pos;
21870        }
21871        if !stack.is_empty() {
21872            stack.push(("GredAttrs", cur));
21873        }
21874        (stack, missing)
21875    }
21876}
21877#[derive(Clone)]
21878pub enum TcaGredVqListAttrs<'a> {
21879    #[doc = "Attribute may repeat multiple times (treat it as array)"]
21880    Entry(IterableTcaGredVqEntryAttrs<'a>),
21881}
21882impl<'a> IterableTcaGredVqListAttrs<'a> {
21883    #[doc = "Attribute may repeat multiple times (treat it as array)"]
21884    pub fn get_entry(
21885        &self,
21886    ) -> MultiAttrIterable<Self, TcaGredVqListAttrs<'a>, IterableTcaGredVqEntryAttrs<'a>> {
21887        MultiAttrIterable::new(self.clone(), |variant| {
21888            if let TcaGredVqListAttrs::Entry(val) = variant {
21889                Some(val)
21890            } else {
21891                None
21892            }
21893        })
21894    }
21895}
21896impl TcaGredVqListAttrs<'_> {
21897    pub fn new<'a>(buf: &'a [u8]) -> IterableTcaGredVqListAttrs<'a> {
21898        IterableTcaGredVqListAttrs::with_loc(buf, buf.as_ptr() as usize)
21899    }
21900    fn attr_from_type(r#type: u16) -> Option<&'static str> {
21901        let res = match r#type {
21902            1u16 => "Entry",
21903            _ => return None,
21904        };
21905        Some(res)
21906    }
21907}
21908#[derive(Clone, Copy, Default)]
21909pub struct IterableTcaGredVqListAttrs<'a> {
21910    buf: &'a [u8],
21911    pos: usize,
21912    orig_loc: usize,
21913}
21914impl<'a> IterableTcaGredVqListAttrs<'a> {
21915    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
21916        Self {
21917            buf,
21918            pos: 0,
21919            orig_loc,
21920        }
21921    }
21922    pub fn get_buf(&self) -> &'a [u8] {
21923        self.buf
21924    }
21925}
21926impl<'a> Iterator for IterableTcaGredVqListAttrs<'a> {
21927    type Item = Result<TcaGredVqListAttrs<'a>, ErrorContext>;
21928    fn next(&mut self) -> Option<Self::Item> {
21929        let pos = self.pos;
21930        let mut r#type;
21931        loop {
21932            r#type = None;
21933            if self.buf.len() == self.pos {
21934                return None;
21935            }
21936            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
21937                break;
21938            };
21939            r#type = Some(header.r#type);
21940            let res = match header.r#type {
21941                1u16 => TcaGredVqListAttrs::Entry({
21942                    let res = Some(IterableTcaGredVqEntryAttrs::with_loc(next, self.orig_loc));
21943                    let Some(val) = res else { break };
21944                    val
21945                }),
21946                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
21947                n => continue,
21948            };
21949            return Some(Ok(res));
21950        }
21951        Some(Err(ErrorContext::new(
21952            "TcaGredVqListAttrs",
21953            r#type.and_then(|t| TcaGredVqListAttrs::attr_from_type(t)),
21954            self.orig_loc,
21955            self.buf.as_ptr().wrapping_add(pos) as usize,
21956        )))
21957    }
21958}
21959impl<'a> std::fmt::Debug for IterableTcaGredVqListAttrs<'_> {
21960    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21961        let mut fmt = f.debug_struct("TcaGredVqListAttrs");
21962        for attr in self.clone() {
21963            let attr = match attr {
21964                Ok(a) => a,
21965                Err(err) => {
21966                    fmt.finish()?;
21967                    f.write_str("Err(")?;
21968                    err.fmt(f)?;
21969                    return f.write_str(")");
21970                }
21971            };
21972            match attr {
21973                TcaGredVqListAttrs::Entry(val) => fmt.field("Entry", &val),
21974            };
21975        }
21976        fmt.finish()
21977    }
21978}
21979impl IterableTcaGredVqListAttrs<'_> {
21980    pub fn lookup_attr(
21981        &self,
21982        offset: usize,
21983        missing_type: Option<u16>,
21984    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
21985        let mut stack = Vec::new();
21986        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
21987        if missing_type.is_some() && cur == offset {
21988            stack.push(("TcaGredVqListAttrs", offset));
21989            return (
21990                stack,
21991                missing_type.and_then(|t| TcaGredVqListAttrs::attr_from_type(t)),
21992            );
21993        }
21994        if cur > offset || cur + self.buf.len() < offset {
21995            return (stack, None);
21996        }
21997        let mut attrs = self.clone();
21998        let mut last_off = cur + attrs.pos;
21999        let mut missing = None;
22000        while let Some(attr) = attrs.next() {
22001            let Ok(attr) = attr else { break };
22002            match attr {
22003                TcaGredVqListAttrs::Entry(val) => {
22004                    (stack, missing) = val.lookup_attr(offset, missing_type);
22005                    if !stack.is_empty() {
22006                        break;
22007                    }
22008                }
22009                _ => {}
22010            };
22011            last_off = cur + attrs.pos;
22012        }
22013        if !stack.is_empty() {
22014            stack.push(("TcaGredVqListAttrs", cur));
22015        }
22016        (stack, missing)
22017    }
22018}
22019#[derive(Clone)]
22020pub enum TcaGredVqEntryAttrs<'a> {
22021    Pad(&'a [u8]),
22022    Dp(u32),
22023    StatBytes(u64),
22024    StatPackets(u32),
22025    StatBacklog(u32),
22026    StatProbDrop(u32),
22027    StatProbMark(u32),
22028    StatForcedDrop(u32),
22029    StatForcedMark(u32),
22030    StatPdrop(u32),
22031    StatOther(u32),
22032    Flags(u32),
22033}
22034impl<'a> IterableTcaGredVqEntryAttrs<'a> {
22035    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
22036        let mut iter = self.clone();
22037        iter.pos = 0;
22038        for attr in iter {
22039            if let TcaGredVqEntryAttrs::Pad(val) = attr? {
22040                return Ok(val);
22041            }
22042        }
22043        Err(ErrorContext::new_missing(
22044            "TcaGredVqEntryAttrs",
22045            "Pad",
22046            self.orig_loc,
22047            self.buf.as_ptr() as usize,
22048        ))
22049    }
22050    pub fn get_dp(&self) -> Result<u32, ErrorContext> {
22051        let mut iter = self.clone();
22052        iter.pos = 0;
22053        for attr in iter {
22054            if let TcaGredVqEntryAttrs::Dp(val) = attr? {
22055                return Ok(val);
22056            }
22057        }
22058        Err(ErrorContext::new_missing(
22059            "TcaGredVqEntryAttrs",
22060            "Dp",
22061            self.orig_loc,
22062            self.buf.as_ptr() as usize,
22063        ))
22064    }
22065    pub fn get_stat_bytes(&self) -> Result<u64, ErrorContext> {
22066        let mut iter = self.clone();
22067        iter.pos = 0;
22068        for attr in iter {
22069            if let TcaGredVqEntryAttrs::StatBytes(val) = attr? {
22070                return Ok(val);
22071            }
22072        }
22073        Err(ErrorContext::new_missing(
22074            "TcaGredVqEntryAttrs",
22075            "StatBytes",
22076            self.orig_loc,
22077            self.buf.as_ptr() as usize,
22078        ))
22079    }
22080    pub fn get_stat_packets(&self) -> Result<u32, ErrorContext> {
22081        let mut iter = self.clone();
22082        iter.pos = 0;
22083        for attr in iter {
22084            if let TcaGredVqEntryAttrs::StatPackets(val) = attr? {
22085                return Ok(val);
22086            }
22087        }
22088        Err(ErrorContext::new_missing(
22089            "TcaGredVqEntryAttrs",
22090            "StatPackets",
22091            self.orig_loc,
22092            self.buf.as_ptr() as usize,
22093        ))
22094    }
22095    pub fn get_stat_backlog(&self) -> Result<u32, ErrorContext> {
22096        let mut iter = self.clone();
22097        iter.pos = 0;
22098        for attr in iter {
22099            if let TcaGredVqEntryAttrs::StatBacklog(val) = attr? {
22100                return Ok(val);
22101            }
22102        }
22103        Err(ErrorContext::new_missing(
22104            "TcaGredVqEntryAttrs",
22105            "StatBacklog",
22106            self.orig_loc,
22107            self.buf.as_ptr() as usize,
22108        ))
22109    }
22110    pub fn get_stat_prob_drop(&self) -> Result<u32, ErrorContext> {
22111        let mut iter = self.clone();
22112        iter.pos = 0;
22113        for attr in iter {
22114            if let TcaGredVqEntryAttrs::StatProbDrop(val) = attr? {
22115                return Ok(val);
22116            }
22117        }
22118        Err(ErrorContext::new_missing(
22119            "TcaGredVqEntryAttrs",
22120            "StatProbDrop",
22121            self.orig_loc,
22122            self.buf.as_ptr() as usize,
22123        ))
22124    }
22125    pub fn get_stat_prob_mark(&self) -> Result<u32, ErrorContext> {
22126        let mut iter = self.clone();
22127        iter.pos = 0;
22128        for attr in iter {
22129            if let TcaGredVqEntryAttrs::StatProbMark(val) = attr? {
22130                return Ok(val);
22131            }
22132        }
22133        Err(ErrorContext::new_missing(
22134            "TcaGredVqEntryAttrs",
22135            "StatProbMark",
22136            self.orig_loc,
22137            self.buf.as_ptr() as usize,
22138        ))
22139    }
22140    pub fn get_stat_forced_drop(&self) -> Result<u32, ErrorContext> {
22141        let mut iter = self.clone();
22142        iter.pos = 0;
22143        for attr in iter {
22144            if let TcaGredVqEntryAttrs::StatForcedDrop(val) = attr? {
22145                return Ok(val);
22146            }
22147        }
22148        Err(ErrorContext::new_missing(
22149            "TcaGredVqEntryAttrs",
22150            "StatForcedDrop",
22151            self.orig_loc,
22152            self.buf.as_ptr() as usize,
22153        ))
22154    }
22155    pub fn get_stat_forced_mark(&self) -> Result<u32, ErrorContext> {
22156        let mut iter = self.clone();
22157        iter.pos = 0;
22158        for attr in iter {
22159            if let TcaGredVqEntryAttrs::StatForcedMark(val) = attr? {
22160                return Ok(val);
22161            }
22162        }
22163        Err(ErrorContext::new_missing(
22164            "TcaGredVqEntryAttrs",
22165            "StatForcedMark",
22166            self.orig_loc,
22167            self.buf.as_ptr() as usize,
22168        ))
22169    }
22170    pub fn get_stat_pdrop(&self) -> Result<u32, ErrorContext> {
22171        let mut iter = self.clone();
22172        iter.pos = 0;
22173        for attr in iter {
22174            if let TcaGredVqEntryAttrs::StatPdrop(val) = attr? {
22175                return Ok(val);
22176            }
22177        }
22178        Err(ErrorContext::new_missing(
22179            "TcaGredVqEntryAttrs",
22180            "StatPdrop",
22181            self.orig_loc,
22182            self.buf.as_ptr() as usize,
22183        ))
22184    }
22185    pub fn get_stat_other(&self) -> Result<u32, ErrorContext> {
22186        let mut iter = self.clone();
22187        iter.pos = 0;
22188        for attr in iter {
22189            if let TcaGredVqEntryAttrs::StatOther(val) = attr? {
22190                return Ok(val);
22191            }
22192        }
22193        Err(ErrorContext::new_missing(
22194            "TcaGredVqEntryAttrs",
22195            "StatOther",
22196            self.orig_loc,
22197            self.buf.as_ptr() as usize,
22198        ))
22199    }
22200    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
22201        let mut iter = self.clone();
22202        iter.pos = 0;
22203        for attr in iter {
22204            if let TcaGredVqEntryAttrs::Flags(val) = attr? {
22205                return Ok(val);
22206            }
22207        }
22208        Err(ErrorContext::new_missing(
22209            "TcaGredVqEntryAttrs",
22210            "Flags",
22211            self.orig_loc,
22212            self.buf.as_ptr() as usize,
22213        ))
22214    }
22215}
22216impl TcaGredVqEntryAttrs<'_> {
22217    pub fn new<'a>(buf: &'a [u8]) -> IterableTcaGredVqEntryAttrs<'a> {
22218        IterableTcaGredVqEntryAttrs::with_loc(buf, buf.as_ptr() as usize)
22219    }
22220    fn attr_from_type(r#type: u16) -> Option<&'static str> {
22221        let res = match r#type {
22222            1u16 => "Pad",
22223            2u16 => "Dp",
22224            3u16 => "StatBytes",
22225            4u16 => "StatPackets",
22226            5u16 => "StatBacklog",
22227            6u16 => "StatProbDrop",
22228            7u16 => "StatProbMark",
22229            8u16 => "StatForcedDrop",
22230            9u16 => "StatForcedMark",
22231            10u16 => "StatPdrop",
22232            11u16 => "StatOther",
22233            12u16 => "Flags",
22234            _ => return None,
22235        };
22236        Some(res)
22237    }
22238}
22239#[derive(Clone, Copy, Default)]
22240pub struct IterableTcaGredVqEntryAttrs<'a> {
22241    buf: &'a [u8],
22242    pos: usize,
22243    orig_loc: usize,
22244}
22245impl<'a> IterableTcaGredVqEntryAttrs<'a> {
22246    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
22247        Self {
22248            buf,
22249            pos: 0,
22250            orig_loc,
22251        }
22252    }
22253    pub fn get_buf(&self) -> &'a [u8] {
22254        self.buf
22255    }
22256}
22257impl<'a> Iterator for IterableTcaGredVqEntryAttrs<'a> {
22258    type Item = Result<TcaGredVqEntryAttrs<'a>, ErrorContext>;
22259    fn next(&mut self) -> Option<Self::Item> {
22260        let pos = self.pos;
22261        let mut r#type;
22262        loop {
22263            r#type = None;
22264            if self.buf.len() == self.pos {
22265                return None;
22266            }
22267            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
22268                break;
22269            };
22270            r#type = Some(header.r#type);
22271            let res = match header.r#type {
22272                1u16 => TcaGredVqEntryAttrs::Pad({
22273                    let res = Some(next);
22274                    let Some(val) = res else { break };
22275                    val
22276                }),
22277                2u16 => TcaGredVqEntryAttrs::Dp({
22278                    let res = parse_u32(next);
22279                    let Some(val) = res else { break };
22280                    val
22281                }),
22282                3u16 => TcaGredVqEntryAttrs::StatBytes({
22283                    let res = parse_u64(next);
22284                    let Some(val) = res else { break };
22285                    val
22286                }),
22287                4u16 => TcaGredVqEntryAttrs::StatPackets({
22288                    let res = parse_u32(next);
22289                    let Some(val) = res else { break };
22290                    val
22291                }),
22292                5u16 => TcaGredVqEntryAttrs::StatBacklog({
22293                    let res = parse_u32(next);
22294                    let Some(val) = res else { break };
22295                    val
22296                }),
22297                6u16 => TcaGredVqEntryAttrs::StatProbDrop({
22298                    let res = parse_u32(next);
22299                    let Some(val) = res else { break };
22300                    val
22301                }),
22302                7u16 => TcaGredVqEntryAttrs::StatProbMark({
22303                    let res = parse_u32(next);
22304                    let Some(val) = res else { break };
22305                    val
22306                }),
22307                8u16 => TcaGredVqEntryAttrs::StatForcedDrop({
22308                    let res = parse_u32(next);
22309                    let Some(val) = res else { break };
22310                    val
22311                }),
22312                9u16 => TcaGredVqEntryAttrs::StatForcedMark({
22313                    let res = parse_u32(next);
22314                    let Some(val) = res else { break };
22315                    val
22316                }),
22317                10u16 => TcaGredVqEntryAttrs::StatPdrop({
22318                    let res = parse_u32(next);
22319                    let Some(val) = res else { break };
22320                    val
22321                }),
22322                11u16 => TcaGredVqEntryAttrs::StatOther({
22323                    let res = parse_u32(next);
22324                    let Some(val) = res else { break };
22325                    val
22326                }),
22327                12u16 => TcaGredVqEntryAttrs::Flags({
22328                    let res = parse_u32(next);
22329                    let Some(val) = res else { break };
22330                    val
22331                }),
22332                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
22333                n => continue,
22334            };
22335            return Some(Ok(res));
22336        }
22337        Some(Err(ErrorContext::new(
22338            "TcaGredVqEntryAttrs",
22339            r#type.and_then(|t| TcaGredVqEntryAttrs::attr_from_type(t)),
22340            self.orig_loc,
22341            self.buf.as_ptr().wrapping_add(pos) as usize,
22342        )))
22343    }
22344}
22345impl<'a> std::fmt::Debug for IterableTcaGredVqEntryAttrs<'_> {
22346    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22347        let mut fmt = f.debug_struct("TcaGredVqEntryAttrs");
22348        for attr in self.clone() {
22349            let attr = match attr {
22350                Ok(a) => a,
22351                Err(err) => {
22352                    fmt.finish()?;
22353                    f.write_str("Err(")?;
22354                    err.fmt(f)?;
22355                    return f.write_str(")");
22356                }
22357            };
22358            match attr {
22359                TcaGredVqEntryAttrs::Pad(val) => fmt.field("Pad", &val),
22360                TcaGredVqEntryAttrs::Dp(val) => fmt.field("Dp", &val),
22361                TcaGredVqEntryAttrs::StatBytes(val) => fmt.field("StatBytes", &val),
22362                TcaGredVqEntryAttrs::StatPackets(val) => fmt.field("StatPackets", &val),
22363                TcaGredVqEntryAttrs::StatBacklog(val) => fmt.field("StatBacklog", &val),
22364                TcaGredVqEntryAttrs::StatProbDrop(val) => fmt.field("StatProbDrop", &val),
22365                TcaGredVqEntryAttrs::StatProbMark(val) => fmt.field("StatProbMark", &val),
22366                TcaGredVqEntryAttrs::StatForcedDrop(val) => fmt.field("StatForcedDrop", &val),
22367                TcaGredVqEntryAttrs::StatForcedMark(val) => fmt.field("StatForcedMark", &val),
22368                TcaGredVqEntryAttrs::StatPdrop(val) => fmt.field("StatPdrop", &val),
22369                TcaGredVqEntryAttrs::StatOther(val) => fmt.field("StatOther", &val),
22370                TcaGredVqEntryAttrs::Flags(val) => fmt.field("Flags", &val),
22371            };
22372        }
22373        fmt.finish()
22374    }
22375}
22376impl IterableTcaGredVqEntryAttrs<'_> {
22377    pub fn lookup_attr(
22378        &self,
22379        offset: usize,
22380        missing_type: Option<u16>,
22381    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
22382        let mut stack = Vec::new();
22383        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
22384        if missing_type.is_some() && cur == offset {
22385            stack.push(("TcaGredVqEntryAttrs", offset));
22386            return (
22387                stack,
22388                missing_type.and_then(|t| TcaGredVqEntryAttrs::attr_from_type(t)),
22389            );
22390        }
22391        if cur > offset || cur + self.buf.len() < offset {
22392            return (stack, None);
22393        }
22394        let mut attrs = self.clone();
22395        let mut last_off = cur + attrs.pos;
22396        while let Some(attr) = attrs.next() {
22397            let Ok(attr) = attr else { break };
22398            match attr {
22399                TcaGredVqEntryAttrs::Pad(val) => {
22400                    if last_off == offset {
22401                        stack.push(("Pad", last_off));
22402                        break;
22403                    }
22404                }
22405                TcaGredVqEntryAttrs::Dp(val) => {
22406                    if last_off == offset {
22407                        stack.push(("Dp", last_off));
22408                        break;
22409                    }
22410                }
22411                TcaGredVqEntryAttrs::StatBytes(val) => {
22412                    if last_off == offset {
22413                        stack.push(("StatBytes", last_off));
22414                        break;
22415                    }
22416                }
22417                TcaGredVqEntryAttrs::StatPackets(val) => {
22418                    if last_off == offset {
22419                        stack.push(("StatPackets", last_off));
22420                        break;
22421                    }
22422                }
22423                TcaGredVqEntryAttrs::StatBacklog(val) => {
22424                    if last_off == offset {
22425                        stack.push(("StatBacklog", last_off));
22426                        break;
22427                    }
22428                }
22429                TcaGredVqEntryAttrs::StatProbDrop(val) => {
22430                    if last_off == offset {
22431                        stack.push(("StatProbDrop", last_off));
22432                        break;
22433                    }
22434                }
22435                TcaGredVqEntryAttrs::StatProbMark(val) => {
22436                    if last_off == offset {
22437                        stack.push(("StatProbMark", last_off));
22438                        break;
22439                    }
22440                }
22441                TcaGredVqEntryAttrs::StatForcedDrop(val) => {
22442                    if last_off == offset {
22443                        stack.push(("StatForcedDrop", last_off));
22444                        break;
22445                    }
22446                }
22447                TcaGredVqEntryAttrs::StatForcedMark(val) => {
22448                    if last_off == offset {
22449                        stack.push(("StatForcedMark", last_off));
22450                        break;
22451                    }
22452                }
22453                TcaGredVqEntryAttrs::StatPdrop(val) => {
22454                    if last_off == offset {
22455                        stack.push(("StatPdrop", last_off));
22456                        break;
22457                    }
22458                }
22459                TcaGredVqEntryAttrs::StatOther(val) => {
22460                    if last_off == offset {
22461                        stack.push(("StatOther", last_off));
22462                        break;
22463                    }
22464                }
22465                TcaGredVqEntryAttrs::Flags(val) => {
22466                    if last_off == offset {
22467                        stack.push(("Flags", last_off));
22468                        break;
22469                    }
22470                }
22471                _ => {}
22472            };
22473            last_off = cur + attrs.pos;
22474        }
22475        if !stack.is_empty() {
22476            stack.push(("TcaGredVqEntryAttrs", cur));
22477        }
22478        (stack, None)
22479    }
22480}
22481#[derive(Clone)]
22482pub enum HfscAttrs<'a> {
22483    Rsc(&'a [u8]),
22484    Fsc(&'a [u8]),
22485    Usc(&'a [u8]),
22486}
22487impl<'a> IterableHfscAttrs<'a> {
22488    pub fn get_rsc(&self) -> Result<&'a [u8], ErrorContext> {
22489        let mut iter = self.clone();
22490        iter.pos = 0;
22491        for attr in iter {
22492            if let HfscAttrs::Rsc(val) = attr? {
22493                return Ok(val);
22494            }
22495        }
22496        Err(ErrorContext::new_missing(
22497            "HfscAttrs",
22498            "Rsc",
22499            self.orig_loc,
22500            self.buf.as_ptr() as usize,
22501        ))
22502    }
22503    pub fn get_fsc(&self) -> Result<&'a [u8], ErrorContext> {
22504        let mut iter = self.clone();
22505        iter.pos = 0;
22506        for attr in iter {
22507            if let HfscAttrs::Fsc(val) = attr? {
22508                return Ok(val);
22509            }
22510        }
22511        Err(ErrorContext::new_missing(
22512            "HfscAttrs",
22513            "Fsc",
22514            self.orig_loc,
22515            self.buf.as_ptr() as usize,
22516        ))
22517    }
22518    pub fn get_usc(&self) -> Result<&'a [u8], ErrorContext> {
22519        let mut iter = self.clone();
22520        iter.pos = 0;
22521        for attr in iter {
22522            if let HfscAttrs::Usc(val) = attr? {
22523                return Ok(val);
22524            }
22525        }
22526        Err(ErrorContext::new_missing(
22527            "HfscAttrs",
22528            "Usc",
22529            self.orig_loc,
22530            self.buf.as_ptr() as usize,
22531        ))
22532    }
22533}
22534impl HfscAttrs<'_> {
22535    pub fn new<'a>(buf: &'a [u8]) -> IterableHfscAttrs<'a> {
22536        IterableHfscAttrs::with_loc(buf, buf.as_ptr() as usize)
22537    }
22538    fn attr_from_type(r#type: u16) -> Option<&'static str> {
22539        let res = match r#type {
22540            1u16 => "Rsc",
22541            2u16 => "Fsc",
22542            3u16 => "Usc",
22543            _ => return None,
22544        };
22545        Some(res)
22546    }
22547}
22548#[derive(Clone, Copy, Default)]
22549pub struct IterableHfscAttrs<'a> {
22550    buf: &'a [u8],
22551    pos: usize,
22552    orig_loc: usize,
22553}
22554impl<'a> IterableHfscAttrs<'a> {
22555    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
22556        Self {
22557            buf,
22558            pos: 0,
22559            orig_loc,
22560        }
22561    }
22562    pub fn get_buf(&self) -> &'a [u8] {
22563        self.buf
22564    }
22565}
22566impl<'a> Iterator for IterableHfscAttrs<'a> {
22567    type Item = Result<HfscAttrs<'a>, ErrorContext>;
22568    fn next(&mut self) -> Option<Self::Item> {
22569        let pos = self.pos;
22570        let mut r#type;
22571        loop {
22572            r#type = None;
22573            if self.buf.len() == self.pos {
22574                return None;
22575            }
22576            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
22577                break;
22578            };
22579            r#type = Some(header.r#type);
22580            let res = match header.r#type {
22581                1u16 => HfscAttrs::Rsc({
22582                    let res = Some(next);
22583                    let Some(val) = res else { break };
22584                    val
22585                }),
22586                2u16 => HfscAttrs::Fsc({
22587                    let res = Some(next);
22588                    let Some(val) = res else { break };
22589                    val
22590                }),
22591                3u16 => HfscAttrs::Usc({
22592                    let res = Some(next);
22593                    let Some(val) = res else { break };
22594                    val
22595                }),
22596                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
22597                n => continue,
22598            };
22599            return Some(Ok(res));
22600        }
22601        Some(Err(ErrorContext::new(
22602            "HfscAttrs",
22603            r#type.and_then(|t| HfscAttrs::attr_from_type(t)),
22604            self.orig_loc,
22605            self.buf.as_ptr().wrapping_add(pos) as usize,
22606        )))
22607    }
22608}
22609impl<'a> std::fmt::Debug for IterableHfscAttrs<'_> {
22610    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22611        let mut fmt = f.debug_struct("HfscAttrs");
22612        for attr in self.clone() {
22613            let attr = match attr {
22614                Ok(a) => a,
22615                Err(err) => {
22616                    fmt.finish()?;
22617                    f.write_str("Err(")?;
22618                    err.fmt(f)?;
22619                    return f.write_str(")");
22620                }
22621            };
22622            match attr {
22623                HfscAttrs::Rsc(val) => fmt.field("Rsc", &val),
22624                HfscAttrs::Fsc(val) => fmt.field("Fsc", &val),
22625                HfscAttrs::Usc(val) => fmt.field("Usc", &val),
22626            };
22627        }
22628        fmt.finish()
22629    }
22630}
22631impl IterableHfscAttrs<'_> {
22632    pub fn lookup_attr(
22633        &self,
22634        offset: usize,
22635        missing_type: Option<u16>,
22636    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
22637        let mut stack = Vec::new();
22638        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
22639        if missing_type.is_some() && cur == offset {
22640            stack.push(("HfscAttrs", offset));
22641            return (
22642                stack,
22643                missing_type.and_then(|t| HfscAttrs::attr_from_type(t)),
22644            );
22645        }
22646        if cur > offset || cur + self.buf.len() < offset {
22647            return (stack, None);
22648        }
22649        let mut attrs = self.clone();
22650        let mut last_off = cur + attrs.pos;
22651        while let Some(attr) = attrs.next() {
22652            let Ok(attr) = attr else { break };
22653            match attr {
22654                HfscAttrs::Rsc(val) => {
22655                    if last_off == offset {
22656                        stack.push(("Rsc", last_off));
22657                        break;
22658                    }
22659                }
22660                HfscAttrs::Fsc(val) => {
22661                    if last_off == offset {
22662                        stack.push(("Fsc", last_off));
22663                        break;
22664                    }
22665                }
22666                HfscAttrs::Usc(val) => {
22667                    if last_off == offset {
22668                        stack.push(("Usc", last_off));
22669                        break;
22670                    }
22671                }
22672                _ => {}
22673            };
22674            last_off = cur + attrs.pos;
22675        }
22676        if !stack.is_empty() {
22677            stack.push(("HfscAttrs", cur));
22678        }
22679        (stack, None)
22680    }
22681}
22682#[derive(Clone)]
22683pub enum HhfAttrs {
22684    BacklogLimit(u32),
22685    Quantum(u32),
22686    HhFlowsLimit(u32),
22687    ResetTimeout(u32),
22688    AdmitBytes(u32),
22689    EvictTimeout(u32),
22690    NonHhWeight(u32),
22691}
22692impl<'a> IterableHhfAttrs<'a> {
22693    pub fn get_backlog_limit(&self) -> Result<u32, ErrorContext> {
22694        let mut iter = self.clone();
22695        iter.pos = 0;
22696        for attr in iter {
22697            if let HhfAttrs::BacklogLimit(val) = attr? {
22698                return Ok(val);
22699            }
22700        }
22701        Err(ErrorContext::new_missing(
22702            "HhfAttrs",
22703            "BacklogLimit",
22704            self.orig_loc,
22705            self.buf.as_ptr() as usize,
22706        ))
22707    }
22708    pub fn get_quantum(&self) -> Result<u32, ErrorContext> {
22709        let mut iter = self.clone();
22710        iter.pos = 0;
22711        for attr in iter {
22712            if let HhfAttrs::Quantum(val) = attr? {
22713                return Ok(val);
22714            }
22715        }
22716        Err(ErrorContext::new_missing(
22717            "HhfAttrs",
22718            "Quantum",
22719            self.orig_loc,
22720            self.buf.as_ptr() as usize,
22721        ))
22722    }
22723    pub fn get_hh_flows_limit(&self) -> Result<u32, ErrorContext> {
22724        let mut iter = self.clone();
22725        iter.pos = 0;
22726        for attr in iter {
22727            if let HhfAttrs::HhFlowsLimit(val) = attr? {
22728                return Ok(val);
22729            }
22730        }
22731        Err(ErrorContext::new_missing(
22732            "HhfAttrs",
22733            "HhFlowsLimit",
22734            self.orig_loc,
22735            self.buf.as_ptr() as usize,
22736        ))
22737    }
22738    pub fn get_reset_timeout(&self) -> Result<u32, ErrorContext> {
22739        let mut iter = self.clone();
22740        iter.pos = 0;
22741        for attr in iter {
22742            if let HhfAttrs::ResetTimeout(val) = attr? {
22743                return Ok(val);
22744            }
22745        }
22746        Err(ErrorContext::new_missing(
22747            "HhfAttrs",
22748            "ResetTimeout",
22749            self.orig_loc,
22750            self.buf.as_ptr() as usize,
22751        ))
22752    }
22753    pub fn get_admit_bytes(&self) -> Result<u32, ErrorContext> {
22754        let mut iter = self.clone();
22755        iter.pos = 0;
22756        for attr in iter {
22757            if let HhfAttrs::AdmitBytes(val) = attr? {
22758                return Ok(val);
22759            }
22760        }
22761        Err(ErrorContext::new_missing(
22762            "HhfAttrs",
22763            "AdmitBytes",
22764            self.orig_loc,
22765            self.buf.as_ptr() as usize,
22766        ))
22767    }
22768    pub fn get_evict_timeout(&self) -> Result<u32, ErrorContext> {
22769        let mut iter = self.clone();
22770        iter.pos = 0;
22771        for attr in iter {
22772            if let HhfAttrs::EvictTimeout(val) = attr? {
22773                return Ok(val);
22774            }
22775        }
22776        Err(ErrorContext::new_missing(
22777            "HhfAttrs",
22778            "EvictTimeout",
22779            self.orig_loc,
22780            self.buf.as_ptr() as usize,
22781        ))
22782    }
22783    pub fn get_non_hh_weight(&self) -> Result<u32, ErrorContext> {
22784        let mut iter = self.clone();
22785        iter.pos = 0;
22786        for attr in iter {
22787            if let HhfAttrs::NonHhWeight(val) = attr? {
22788                return Ok(val);
22789            }
22790        }
22791        Err(ErrorContext::new_missing(
22792            "HhfAttrs",
22793            "NonHhWeight",
22794            self.orig_loc,
22795            self.buf.as_ptr() as usize,
22796        ))
22797    }
22798}
22799impl HhfAttrs {
22800    pub fn new<'a>(buf: &'a [u8]) -> IterableHhfAttrs<'a> {
22801        IterableHhfAttrs::with_loc(buf, buf.as_ptr() as usize)
22802    }
22803    fn attr_from_type(r#type: u16) -> Option<&'static str> {
22804        let res = match r#type {
22805            1u16 => "BacklogLimit",
22806            2u16 => "Quantum",
22807            3u16 => "HhFlowsLimit",
22808            4u16 => "ResetTimeout",
22809            5u16 => "AdmitBytes",
22810            6u16 => "EvictTimeout",
22811            7u16 => "NonHhWeight",
22812            _ => return None,
22813        };
22814        Some(res)
22815    }
22816}
22817#[derive(Clone, Copy, Default)]
22818pub struct IterableHhfAttrs<'a> {
22819    buf: &'a [u8],
22820    pos: usize,
22821    orig_loc: usize,
22822}
22823impl<'a> IterableHhfAttrs<'a> {
22824    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
22825        Self {
22826            buf,
22827            pos: 0,
22828            orig_loc,
22829        }
22830    }
22831    pub fn get_buf(&self) -> &'a [u8] {
22832        self.buf
22833    }
22834}
22835impl<'a> Iterator for IterableHhfAttrs<'a> {
22836    type Item = Result<HhfAttrs, ErrorContext>;
22837    fn next(&mut self) -> Option<Self::Item> {
22838        let pos = self.pos;
22839        let mut r#type;
22840        loop {
22841            r#type = None;
22842            if self.buf.len() == self.pos {
22843                return None;
22844            }
22845            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
22846                break;
22847            };
22848            r#type = Some(header.r#type);
22849            let res = match header.r#type {
22850                1u16 => HhfAttrs::BacklogLimit({
22851                    let res = parse_u32(next);
22852                    let Some(val) = res else { break };
22853                    val
22854                }),
22855                2u16 => HhfAttrs::Quantum({
22856                    let res = parse_u32(next);
22857                    let Some(val) = res else { break };
22858                    val
22859                }),
22860                3u16 => HhfAttrs::HhFlowsLimit({
22861                    let res = parse_u32(next);
22862                    let Some(val) = res else { break };
22863                    val
22864                }),
22865                4u16 => HhfAttrs::ResetTimeout({
22866                    let res = parse_u32(next);
22867                    let Some(val) = res else { break };
22868                    val
22869                }),
22870                5u16 => HhfAttrs::AdmitBytes({
22871                    let res = parse_u32(next);
22872                    let Some(val) = res else { break };
22873                    val
22874                }),
22875                6u16 => HhfAttrs::EvictTimeout({
22876                    let res = parse_u32(next);
22877                    let Some(val) = res else { break };
22878                    val
22879                }),
22880                7u16 => HhfAttrs::NonHhWeight({
22881                    let res = parse_u32(next);
22882                    let Some(val) = res else { break };
22883                    val
22884                }),
22885                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
22886                n => continue,
22887            };
22888            return Some(Ok(res));
22889        }
22890        Some(Err(ErrorContext::new(
22891            "HhfAttrs",
22892            r#type.and_then(|t| HhfAttrs::attr_from_type(t)),
22893            self.orig_loc,
22894            self.buf.as_ptr().wrapping_add(pos) as usize,
22895        )))
22896    }
22897}
22898impl std::fmt::Debug for IterableHhfAttrs<'_> {
22899    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22900        let mut fmt = f.debug_struct("HhfAttrs");
22901        for attr in self.clone() {
22902            let attr = match attr {
22903                Ok(a) => a,
22904                Err(err) => {
22905                    fmt.finish()?;
22906                    f.write_str("Err(")?;
22907                    err.fmt(f)?;
22908                    return f.write_str(")");
22909                }
22910            };
22911            match attr {
22912                HhfAttrs::BacklogLimit(val) => fmt.field("BacklogLimit", &val),
22913                HhfAttrs::Quantum(val) => fmt.field("Quantum", &val),
22914                HhfAttrs::HhFlowsLimit(val) => fmt.field("HhFlowsLimit", &val),
22915                HhfAttrs::ResetTimeout(val) => fmt.field("ResetTimeout", &val),
22916                HhfAttrs::AdmitBytes(val) => fmt.field("AdmitBytes", &val),
22917                HhfAttrs::EvictTimeout(val) => fmt.field("EvictTimeout", &val),
22918                HhfAttrs::NonHhWeight(val) => fmt.field("NonHhWeight", &val),
22919            };
22920        }
22921        fmt.finish()
22922    }
22923}
22924impl IterableHhfAttrs<'_> {
22925    pub fn lookup_attr(
22926        &self,
22927        offset: usize,
22928        missing_type: Option<u16>,
22929    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
22930        let mut stack = Vec::new();
22931        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
22932        if missing_type.is_some() && cur == offset {
22933            stack.push(("HhfAttrs", offset));
22934            return (
22935                stack,
22936                missing_type.and_then(|t| HhfAttrs::attr_from_type(t)),
22937            );
22938        }
22939        if cur > offset || cur + self.buf.len() < offset {
22940            return (stack, None);
22941        }
22942        let mut attrs = self.clone();
22943        let mut last_off = cur + attrs.pos;
22944        while let Some(attr) = attrs.next() {
22945            let Ok(attr) = attr else { break };
22946            match attr {
22947                HhfAttrs::BacklogLimit(val) => {
22948                    if last_off == offset {
22949                        stack.push(("BacklogLimit", last_off));
22950                        break;
22951                    }
22952                }
22953                HhfAttrs::Quantum(val) => {
22954                    if last_off == offset {
22955                        stack.push(("Quantum", last_off));
22956                        break;
22957                    }
22958                }
22959                HhfAttrs::HhFlowsLimit(val) => {
22960                    if last_off == offset {
22961                        stack.push(("HhFlowsLimit", last_off));
22962                        break;
22963                    }
22964                }
22965                HhfAttrs::ResetTimeout(val) => {
22966                    if last_off == offset {
22967                        stack.push(("ResetTimeout", last_off));
22968                        break;
22969                    }
22970                }
22971                HhfAttrs::AdmitBytes(val) => {
22972                    if last_off == offset {
22973                        stack.push(("AdmitBytes", last_off));
22974                        break;
22975                    }
22976                }
22977                HhfAttrs::EvictTimeout(val) => {
22978                    if last_off == offset {
22979                        stack.push(("EvictTimeout", last_off));
22980                        break;
22981                    }
22982                }
22983                HhfAttrs::NonHhWeight(val) => {
22984                    if last_off == offset {
22985                        stack.push(("NonHhWeight", last_off));
22986                        break;
22987                    }
22988                }
22989                _ => {}
22990            };
22991            last_off = cur + attrs.pos;
22992        }
22993        if !stack.is_empty() {
22994            stack.push(("HhfAttrs", cur));
22995        }
22996        (stack, None)
22997    }
22998}
22999#[derive(Clone)]
23000pub enum HtbAttrs<'a> {
23001    Parms(TcHtbOpt),
23002    Init(TcHtbGlob),
23003    Ctab(&'a [u8]),
23004    Rtab(&'a [u8]),
23005    DirectQlen(u32),
23006    Rate64(u64),
23007    Ceil64(u64),
23008    Pad(&'a [u8]),
23009    Offload(()),
23010}
23011impl<'a> IterableHtbAttrs<'a> {
23012    pub fn get_parms(&self) -> Result<TcHtbOpt, ErrorContext> {
23013        let mut iter = self.clone();
23014        iter.pos = 0;
23015        for attr in iter {
23016            if let HtbAttrs::Parms(val) = attr? {
23017                return Ok(val);
23018            }
23019        }
23020        Err(ErrorContext::new_missing(
23021            "HtbAttrs",
23022            "Parms",
23023            self.orig_loc,
23024            self.buf.as_ptr() as usize,
23025        ))
23026    }
23027    pub fn get_init(&self) -> Result<TcHtbGlob, ErrorContext> {
23028        let mut iter = self.clone();
23029        iter.pos = 0;
23030        for attr in iter {
23031            if let HtbAttrs::Init(val) = attr? {
23032                return Ok(val);
23033            }
23034        }
23035        Err(ErrorContext::new_missing(
23036            "HtbAttrs",
23037            "Init",
23038            self.orig_loc,
23039            self.buf.as_ptr() as usize,
23040        ))
23041    }
23042    pub fn get_ctab(&self) -> Result<&'a [u8], ErrorContext> {
23043        let mut iter = self.clone();
23044        iter.pos = 0;
23045        for attr in iter {
23046            if let HtbAttrs::Ctab(val) = attr? {
23047                return Ok(val);
23048            }
23049        }
23050        Err(ErrorContext::new_missing(
23051            "HtbAttrs",
23052            "Ctab",
23053            self.orig_loc,
23054            self.buf.as_ptr() as usize,
23055        ))
23056    }
23057    pub fn get_rtab(&self) -> Result<&'a [u8], ErrorContext> {
23058        let mut iter = self.clone();
23059        iter.pos = 0;
23060        for attr in iter {
23061            if let HtbAttrs::Rtab(val) = attr? {
23062                return Ok(val);
23063            }
23064        }
23065        Err(ErrorContext::new_missing(
23066            "HtbAttrs",
23067            "Rtab",
23068            self.orig_loc,
23069            self.buf.as_ptr() as usize,
23070        ))
23071    }
23072    pub fn get_direct_qlen(&self) -> Result<u32, ErrorContext> {
23073        let mut iter = self.clone();
23074        iter.pos = 0;
23075        for attr in iter {
23076            if let HtbAttrs::DirectQlen(val) = attr? {
23077                return Ok(val);
23078            }
23079        }
23080        Err(ErrorContext::new_missing(
23081            "HtbAttrs",
23082            "DirectQlen",
23083            self.orig_loc,
23084            self.buf.as_ptr() as usize,
23085        ))
23086    }
23087    pub fn get_rate64(&self) -> Result<u64, ErrorContext> {
23088        let mut iter = self.clone();
23089        iter.pos = 0;
23090        for attr in iter {
23091            if let HtbAttrs::Rate64(val) = attr? {
23092                return Ok(val);
23093            }
23094        }
23095        Err(ErrorContext::new_missing(
23096            "HtbAttrs",
23097            "Rate64",
23098            self.orig_loc,
23099            self.buf.as_ptr() as usize,
23100        ))
23101    }
23102    pub fn get_ceil64(&self) -> Result<u64, ErrorContext> {
23103        let mut iter = self.clone();
23104        iter.pos = 0;
23105        for attr in iter {
23106            if let HtbAttrs::Ceil64(val) = attr? {
23107                return Ok(val);
23108            }
23109        }
23110        Err(ErrorContext::new_missing(
23111            "HtbAttrs",
23112            "Ceil64",
23113            self.orig_loc,
23114            self.buf.as_ptr() as usize,
23115        ))
23116    }
23117    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
23118        let mut iter = self.clone();
23119        iter.pos = 0;
23120        for attr in iter {
23121            if let HtbAttrs::Pad(val) = attr? {
23122                return Ok(val);
23123            }
23124        }
23125        Err(ErrorContext::new_missing(
23126            "HtbAttrs",
23127            "Pad",
23128            self.orig_loc,
23129            self.buf.as_ptr() as usize,
23130        ))
23131    }
23132    pub fn get_offload(&self) -> Result<(), ErrorContext> {
23133        let mut iter = self.clone();
23134        iter.pos = 0;
23135        for attr in iter {
23136            if let HtbAttrs::Offload(val) = attr? {
23137                return Ok(val);
23138            }
23139        }
23140        Err(ErrorContext::new_missing(
23141            "HtbAttrs",
23142            "Offload",
23143            self.orig_loc,
23144            self.buf.as_ptr() as usize,
23145        ))
23146    }
23147}
23148impl HtbAttrs<'_> {
23149    pub fn new<'a>(buf: &'a [u8]) -> IterableHtbAttrs<'a> {
23150        IterableHtbAttrs::with_loc(buf, buf.as_ptr() as usize)
23151    }
23152    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23153        let res = match r#type {
23154            1u16 => "Parms",
23155            2u16 => "Init",
23156            3u16 => "Ctab",
23157            4u16 => "Rtab",
23158            5u16 => "DirectQlen",
23159            6u16 => "Rate64",
23160            7u16 => "Ceil64",
23161            8u16 => "Pad",
23162            9u16 => "Offload",
23163            _ => return None,
23164        };
23165        Some(res)
23166    }
23167}
23168#[derive(Clone, Copy, Default)]
23169pub struct IterableHtbAttrs<'a> {
23170    buf: &'a [u8],
23171    pos: usize,
23172    orig_loc: usize,
23173}
23174impl<'a> IterableHtbAttrs<'a> {
23175    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23176        Self {
23177            buf,
23178            pos: 0,
23179            orig_loc,
23180        }
23181    }
23182    pub fn get_buf(&self) -> &'a [u8] {
23183        self.buf
23184    }
23185}
23186impl<'a> Iterator for IterableHtbAttrs<'a> {
23187    type Item = Result<HtbAttrs<'a>, ErrorContext>;
23188    fn next(&mut self) -> Option<Self::Item> {
23189        let pos = self.pos;
23190        let mut r#type;
23191        loop {
23192            r#type = None;
23193            if self.buf.len() == self.pos {
23194                return None;
23195            }
23196            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
23197                break;
23198            };
23199            r#type = Some(header.r#type);
23200            let res = match header.r#type {
23201                1u16 => HtbAttrs::Parms({
23202                    let res = Some(TcHtbOpt::new_from_zeroed(next));
23203                    let Some(val) = res else { break };
23204                    val
23205                }),
23206                2u16 => HtbAttrs::Init({
23207                    let res = Some(TcHtbGlob::new_from_zeroed(next));
23208                    let Some(val) = res else { break };
23209                    val
23210                }),
23211                3u16 => HtbAttrs::Ctab({
23212                    let res = Some(next);
23213                    let Some(val) = res else { break };
23214                    val
23215                }),
23216                4u16 => HtbAttrs::Rtab({
23217                    let res = Some(next);
23218                    let Some(val) = res else { break };
23219                    val
23220                }),
23221                5u16 => HtbAttrs::DirectQlen({
23222                    let res = parse_u32(next);
23223                    let Some(val) = res else { break };
23224                    val
23225                }),
23226                6u16 => HtbAttrs::Rate64({
23227                    let res = parse_u64(next);
23228                    let Some(val) = res else { break };
23229                    val
23230                }),
23231                7u16 => HtbAttrs::Ceil64({
23232                    let res = parse_u64(next);
23233                    let Some(val) = res else { break };
23234                    val
23235                }),
23236                8u16 => HtbAttrs::Pad({
23237                    let res = Some(next);
23238                    let Some(val) = res else { break };
23239                    val
23240                }),
23241                9u16 => HtbAttrs::Offload(()),
23242                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
23243                n => continue,
23244            };
23245            return Some(Ok(res));
23246        }
23247        Some(Err(ErrorContext::new(
23248            "HtbAttrs",
23249            r#type.and_then(|t| HtbAttrs::attr_from_type(t)),
23250            self.orig_loc,
23251            self.buf.as_ptr().wrapping_add(pos) as usize,
23252        )))
23253    }
23254}
23255impl<'a> std::fmt::Debug for IterableHtbAttrs<'_> {
23256    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23257        let mut fmt = f.debug_struct("HtbAttrs");
23258        for attr in self.clone() {
23259            let attr = match attr {
23260                Ok(a) => a,
23261                Err(err) => {
23262                    fmt.finish()?;
23263                    f.write_str("Err(")?;
23264                    err.fmt(f)?;
23265                    return f.write_str(")");
23266                }
23267            };
23268            match attr {
23269                HtbAttrs::Parms(val) => fmt.field("Parms", &val),
23270                HtbAttrs::Init(val) => fmt.field("Init", &val),
23271                HtbAttrs::Ctab(val) => fmt.field("Ctab", &val),
23272                HtbAttrs::Rtab(val) => fmt.field("Rtab", &val),
23273                HtbAttrs::DirectQlen(val) => fmt.field("DirectQlen", &val),
23274                HtbAttrs::Rate64(val) => fmt.field("Rate64", &val),
23275                HtbAttrs::Ceil64(val) => fmt.field("Ceil64", &val),
23276                HtbAttrs::Pad(val) => fmt.field("Pad", &val),
23277                HtbAttrs::Offload(val) => fmt.field("Offload", &val),
23278            };
23279        }
23280        fmt.finish()
23281    }
23282}
23283impl IterableHtbAttrs<'_> {
23284    pub fn lookup_attr(
23285        &self,
23286        offset: usize,
23287        missing_type: Option<u16>,
23288    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23289        let mut stack = Vec::new();
23290        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23291        if missing_type.is_some() && cur == offset {
23292            stack.push(("HtbAttrs", offset));
23293            return (
23294                stack,
23295                missing_type.and_then(|t| HtbAttrs::attr_from_type(t)),
23296            );
23297        }
23298        if cur > offset || cur + self.buf.len() < offset {
23299            return (stack, None);
23300        }
23301        let mut attrs = self.clone();
23302        let mut last_off = cur + attrs.pos;
23303        while let Some(attr) = attrs.next() {
23304            let Ok(attr) = attr else { break };
23305            match attr {
23306                HtbAttrs::Parms(val) => {
23307                    if last_off == offset {
23308                        stack.push(("Parms", last_off));
23309                        break;
23310                    }
23311                }
23312                HtbAttrs::Init(val) => {
23313                    if last_off == offset {
23314                        stack.push(("Init", last_off));
23315                        break;
23316                    }
23317                }
23318                HtbAttrs::Ctab(val) => {
23319                    if last_off == offset {
23320                        stack.push(("Ctab", last_off));
23321                        break;
23322                    }
23323                }
23324                HtbAttrs::Rtab(val) => {
23325                    if last_off == offset {
23326                        stack.push(("Rtab", last_off));
23327                        break;
23328                    }
23329                }
23330                HtbAttrs::DirectQlen(val) => {
23331                    if last_off == offset {
23332                        stack.push(("DirectQlen", last_off));
23333                        break;
23334                    }
23335                }
23336                HtbAttrs::Rate64(val) => {
23337                    if last_off == offset {
23338                        stack.push(("Rate64", last_off));
23339                        break;
23340                    }
23341                }
23342                HtbAttrs::Ceil64(val) => {
23343                    if last_off == offset {
23344                        stack.push(("Ceil64", last_off));
23345                        break;
23346                    }
23347                }
23348                HtbAttrs::Pad(val) => {
23349                    if last_off == offset {
23350                        stack.push(("Pad", last_off));
23351                        break;
23352                    }
23353                }
23354                HtbAttrs::Offload(val) => {
23355                    if last_off == offset {
23356                        stack.push(("Offload", last_off));
23357                        break;
23358                    }
23359                }
23360                _ => {}
23361            };
23362            last_off = cur + attrs.pos;
23363        }
23364        if !stack.is_empty() {
23365            stack.push(("HtbAttrs", cur));
23366        }
23367        (stack, None)
23368    }
23369}
23370#[derive(Clone)]
23371pub enum MatchallAttrs<'a> {
23372    Classid(u32),
23373    Act(IterableArrayActAttrs<'a>),
23374    Flags(u32),
23375    Pcnt(TcMatchallPcnt),
23376    Pad(&'a [u8]),
23377}
23378impl<'a> IterableMatchallAttrs<'a> {
23379    pub fn get_classid(&self) -> Result<u32, ErrorContext> {
23380        let mut iter = self.clone();
23381        iter.pos = 0;
23382        for attr in iter {
23383            if let MatchallAttrs::Classid(val) = attr? {
23384                return Ok(val);
23385            }
23386        }
23387        Err(ErrorContext::new_missing(
23388            "MatchallAttrs",
23389            "Classid",
23390            self.orig_loc,
23391            self.buf.as_ptr() as usize,
23392        ))
23393    }
23394    pub fn get_act(
23395        &self,
23396    ) -> Result<ArrayIterable<IterableArrayActAttrs<'a>, IterableActAttrs<'a>>, ErrorContext> {
23397        for attr in self.clone() {
23398            if let MatchallAttrs::Act(val) = attr? {
23399                return Ok(ArrayIterable::new(val));
23400            }
23401        }
23402        Err(ErrorContext::new_missing(
23403            "MatchallAttrs",
23404            "Act",
23405            self.orig_loc,
23406            self.buf.as_ptr() as usize,
23407        ))
23408    }
23409    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
23410        let mut iter = self.clone();
23411        iter.pos = 0;
23412        for attr in iter {
23413            if let MatchallAttrs::Flags(val) = attr? {
23414                return Ok(val);
23415            }
23416        }
23417        Err(ErrorContext::new_missing(
23418            "MatchallAttrs",
23419            "Flags",
23420            self.orig_loc,
23421            self.buf.as_ptr() as usize,
23422        ))
23423    }
23424    pub fn get_pcnt(&self) -> Result<TcMatchallPcnt, ErrorContext> {
23425        let mut iter = self.clone();
23426        iter.pos = 0;
23427        for attr in iter {
23428            if let MatchallAttrs::Pcnt(val) = attr? {
23429                return Ok(val);
23430            }
23431        }
23432        Err(ErrorContext::new_missing(
23433            "MatchallAttrs",
23434            "Pcnt",
23435            self.orig_loc,
23436            self.buf.as_ptr() as usize,
23437        ))
23438    }
23439    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
23440        let mut iter = self.clone();
23441        iter.pos = 0;
23442        for attr in iter {
23443            if let MatchallAttrs::Pad(val) = attr? {
23444                return Ok(val);
23445            }
23446        }
23447        Err(ErrorContext::new_missing(
23448            "MatchallAttrs",
23449            "Pad",
23450            self.orig_loc,
23451            self.buf.as_ptr() as usize,
23452        ))
23453    }
23454}
23455impl MatchallAttrs<'_> {
23456    pub fn new<'a>(buf: &'a [u8]) -> IterableMatchallAttrs<'a> {
23457        IterableMatchallAttrs::with_loc(buf, buf.as_ptr() as usize)
23458    }
23459    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23460        let res = match r#type {
23461            1u16 => "Classid",
23462            2u16 => "Act",
23463            3u16 => "Flags",
23464            4u16 => "Pcnt",
23465            5u16 => "Pad",
23466            _ => return None,
23467        };
23468        Some(res)
23469    }
23470}
23471#[derive(Clone, Copy, Default)]
23472pub struct IterableMatchallAttrs<'a> {
23473    buf: &'a [u8],
23474    pos: usize,
23475    orig_loc: usize,
23476}
23477impl<'a> IterableMatchallAttrs<'a> {
23478    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23479        Self {
23480            buf,
23481            pos: 0,
23482            orig_loc,
23483        }
23484    }
23485    pub fn get_buf(&self) -> &'a [u8] {
23486        self.buf
23487    }
23488}
23489impl<'a> Iterator for IterableMatchallAttrs<'a> {
23490    type Item = Result<MatchallAttrs<'a>, ErrorContext>;
23491    fn next(&mut self) -> Option<Self::Item> {
23492        let pos = self.pos;
23493        let mut r#type;
23494        loop {
23495            r#type = None;
23496            if self.buf.len() == self.pos {
23497                return None;
23498            }
23499            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
23500                break;
23501            };
23502            r#type = Some(header.r#type);
23503            let res = match header.r#type {
23504                1u16 => MatchallAttrs::Classid({
23505                    let res = parse_u32(next);
23506                    let Some(val) = res else { break };
23507                    val
23508                }),
23509                2u16 => MatchallAttrs::Act({
23510                    let res = Some(IterableArrayActAttrs::with_loc(next, self.orig_loc));
23511                    let Some(val) = res else { break };
23512                    val
23513                }),
23514                3u16 => MatchallAttrs::Flags({
23515                    let res = parse_u32(next);
23516                    let Some(val) = res else { break };
23517                    val
23518                }),
23519                4u16 => MatchallAttrs::Pcnt({
23520                    let res = Some(TcMatchallPcnt::new_from_zeroed(next));
23521                    let Some(val) = res else { break };
23522                    val
23523                }),
23524                5u16 => MatchallAttrs::Pad({
23525                    let res = Some(next);
23526                    let Some(val) = res else { break };
23527                    val
23528                }),
23529                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
23530                n => continue,
23531            };
23532            return Some(Ok(res));
23533        }
23534        Some(Err(ErrorContext::new(
23535            "MatchallAttrs",
23536            r#type.and_then(|t| MatchallAttrs::attr_from_type(t)),
23537            self.orig_loc,
23538            self.buf.as_ptr().wrapping_add(pos) as usize,
23539        )))
23540    }
23541}
23542impl<'a> std::fmt::Debug for IterableMatchallAttrs<'_> {
23543    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23544        let mut fmt = f.debug_struct("MatchallAttrs");
23545        for attr in self.clone() {
23546            let attr = match attr {
23547                Ok(a) => a,
23548                Err(err) => {
23549                    fmt.finish()?;
23550                    f.write_str("Err(")?;
23551                    err.fmt(f)?;
23552                    return f.write_str(")");
23553                }
23554            };
23555            match attr {
23556                MatchallAttrs::Classid(val) => fmt.field("Classid", &val),
23557                MatchallAttrs::Act(val) => fmt.field("Act", &val),
23558                MatchallAttrs::Flags(val) => fmt.field("Flags", &val),
23559                MatchallAttrs::Pcnt(val) => fmt.field("Pcnt", &val),
23560                MatchallAttrs::Pad(val) => fmt.field("Pad", &val),
23561            };
23562        }
23563        fmt.finish()
23564    }
23565}
23566impl IterableMatchallAttrs<'_> {
23567    pub fn lookup_attr(
23568        &self,
23569        offset: usize,
23570        missing_type: Option<u16>,
23571    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23572        let mut stack = Vec::new();
23573        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23574        if missing_type.is_some() && cur == offset {
23575            stack.push(("MatchallAttrs", offset));
23576            return (
23577                stack,
23578                missing_type.and_then(|t| MatchallAttrs::attr_from_type(t)),
23579            );
23580        }
23581        if cur > offset || cur + self.buf.len() < offset {
23582            return (stack, None);
23583        }
23584        let mut attrs = self.clone();
23585        let mut last_off = cur + attrs.pos;
23586        let mut missing = None;
23587        while let Some(attr) = attrs.next() {
23588            let Ok(attr) = attr else { break };
23589            match attr {
23590                MatchallAttrs::Classid(val) => {
23591                    if last_off == offset {
23592                        stack.push(("Classid", last_off));
23593                        break;
23594                    }
23595                }
23596                MatchallAttrs::Act(val) => {
23597                    for entry in val {
23598                        let Ok(attr) = entry else { break };
23599                        (stack, missing) = attr.lookup_attr(offset, missing_type);
23600                        if !stack.is_empty() {
23601                            break;
23602                        }
23603                    }
23604                    if !stack.is_empty() {
23605                        stack.push(("Act", last_off));
23606                        break;
23607                    }
23608                }
23609                MatchallAttrs::Flags(val) => {
23610                    if last_off == offset {
23611                        stack.push(("Flags", last_off));
23612                        break;
23613                    }
23614                }
23615                MatchallAttrs::Pcnt(val) => {
23616                    if last_off == offset {
23617                        stack.push(("Pcnt", last_off));
23618                        break;
23619                    }
23620                }
23621                MatchallAttrs::Pad(val) => {
23622                    if last_off == offset {
23623                        stack.push(("Pad", last_off));
23624                        break;
23625                    }
23626                }
23627                _ => {}
23628            };
23629            last_off = cur + attrs.pos;
23630        }
23631        if !stack.is_empty() {
23632            stack.push(("MatchallAttrs", cur));
23633        }
23634        (stack, missing)
23635    }
23636}
23637#[derive(Clone)]
23638pub enum EtfAttrs {
23639    Parms(TcEtfQopt),
23640}
23641impl<'a> IterableEtfAttrs<'a> {
23642    pub fn get_parms(&self) -> Result<TcEtfQopt, ErrorContext> {
23643        let mut iter = self.clone();
23644        iter.pos = 0;
23645        for attr in iter {
23646            if let EtfAttrs::Parms(val) = attr? {
23647                return Ok(val);
23648            }
23649        }
23650        Err(ErrorContext::new_missing(
23651            "EtfAttrs",
23652            "Parms",
23653            self.orig_loc,
23654            self.buf.as_ptr() as usize,
23655        ))
23656    }
23657}
23658impl EtfAttrs {
23659    pub fn new<'a>(buf: &'a [u8]) -> IterableEtfAttrs<'a> {
23660        IterableEtfAttrs::with_loc(buf, buf.as_ptr() as usize)
23661    }
23662    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23663        let res = match r#type {
23664            1u16 => "Parms",
23665            _ => return None,
23666        };
23667        Some(res)
23668    }
23669}
23670#[derive(Clone, Copy, Default)]
23671pub struct IterableEtfAttrs<'a> {
23672    buf: &'a [u8],
23673    pos: usize,
23674    orig_loc: usize,
23675}
23676impl<'a> IterableEtfAttrs<'a> {
23677    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23678        Self {
23679            buf,
23680            pos: 0,
23681            orig_loc,
23682        }
23683    }
23684    pub fn get_buf(&self) -> &'a [u8] {
23685        self.buf
23686    }
23687}
23688impl<'a> Iterator for IterableEtfAttrs<'a> {
23689    type Item = Result<EtfAttrs, ErrorContext>;
23690    fn next(&mut self) -> Option<Self::Item> {
23691        let pos = self.pos;
23692        let mut r#type;
23693        loop {
23694            r#type = None;
23695            if self.buf.len() == self.pos {
23696                return None;
23697            }
23698            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
23699                break;
23700            };
23701            r#type = Some(header.r#type);
23702            let res = match header.r#type {
23703                1u16 => EtfAttrs::Parms({
23704                    let res = Some(TcEtfQopt::new_from_zeroed(next));
23705                    let Some(val) = res else { break };
23706                    val
23707                }),
23708                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
23709                n => continue,
23710            };
23711            return Some(Ok(res));
23712        }
23713        Some(Err(ErrorContext::new(
23714            "EtfAttrs",
23715            r#type.and_then(|t| EtfAttrs::attr_from_type(t)),
23716            self.orig_loc,
23717            self.buf.as_ptr().wrapping_add(pos) as usize,
23718        )))
23719    }
23720}
23721impl std::fmt::Debug for IterableEtfAttrs<'_> {
23722    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23723        let mut fmt = f.debug_struct("EtfAttrs");
23724        for attr in self.clone() {
23725            let attr = match attr {
23726                Ok(a) => a,
23727                Err(err) => {
23728                    fmt.finish()?;
23729                    f.write_str("Err(")?;
23730                    err.fmt(f)?;
23731                    return f.write_str(")");
23732                }
23733            };
23734            match attr {
23735                EtfAttrs::Parms(val) => fmt.field("Parms", &val),
23736            };
23737        }
23738        fmt.finish()
23739    }
23740}
23741impl IterableEtfAttrs<'_> {
23742    pub fn lookup_attr(
23743        &self,
23744        offset: usize,
23745        missing_type: Option<u16>,
23746    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23747        let mut stack = Vec::new();
23748        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23749        if missing_type.is_some() && cur == offset {
23750            stack.push(("EtfAttrs", offset));
23751            return (
23752                stack,
23753                missing_type.and_then(|t| EtfAttrs::attr_from_type(t)),
23754            );
23755        }
23756        if cur > offset || cur + self.buf.len() < offset {
23757            return (stack, None);
23758        }
23759        let mut attrs = self.clone();
23760        let mut last_off = cur + attrs.pos;
23761        while let Some(attr) = attrs.next() {
23762            let Ok(attr) = attr else { break };
23763            match attr {
23764                EtfAttrs::Parms(val) => {
23765                    if last_off == offset {
23766                        stack.push(("Parms", last_off));
23767                        break;
23768                    }
23769                }
23770                _ => {}
23771            };
23772            last_off = cur + attrs.pos;
23773        }
23774        if !stack.is_empty() {
23775            stack.push(("EtfAttrs", cur));
23776        }
23777        (stack, None)
23778    }
23779}
23780#[derive(Clone)]
23781pub enum EtsAttrs<'a> {
23782    Nbands(u8),
23783    Nstrict(u8),
23784    Quanta(IterableEtsAttrs<'a>),
23785    #[doc = "Attribute may repeat multiple times (treat it as array)"]
23786    QuantaBand(u32),
23787    Priomap(IterableEtsAttrs<'a>),
23788    #[doc = "Attribute may repeat multiple times (treat it as array)"]
23789    PriomapBand(u8),
23790}
23791impl<'a> IterableEtsAttrs<'a> {
23792    pub fn get_nbands(&self) -> Result<u8, ErrorContext> {
23793        let mut iter = self.clone();
23794        iter.pos = 0;
23795        for attr in iter {
23796            if let EtsAttrs::Nbands(val) = attr? {
23797                return Ok(val);
23798            }
23799        }
23800        Err(ErrorContext::new_missing(
23801            "EtsAttrs",
23802            "Nbands",
23803            self.orig_loc,
23804            self.buf.as_ptr() as usize,
23805        ))
23806    }
23807    pub fn get_nstrict(&self) -> Result<u8, ErrorContext> {
23808        let mut iter = self.clone();
23809        iter.pos = 0;
23810        for attr in iter {
23811            if let EtsAttrs::Nstrict(val) = attr? {
23812                return Ok(val);
23813            }
23814        }
23815        Err(ErrorContext::new_missing(
23816            "EtsAttrs",
23817            "Nstrict",
23818            self.orig_loc,
23819            self.buf.as_ptr() as usize,
23820        ))
23821    }
23822    pub fn get_quanta(&self) -> Result<IterableEtsAttrs<'a>, ErrorContext> {
23823        let mut iter = self.clone();
23824        iter.pos = 0;
23825        for attr in iter {
23826            if let EtsAttrs::Quanta(val) = attr? {
23827                return Ok(val);
23828            }
23829        }
23830        Err(ErrorContext::new_missing(
23831            "EtsAttrs",
23832            "Quanta",
23833            self.orig_loc,
23834            self.buf.as_ptr() as usize,
23835        ))
23836    }
23837    #[doc = "Attribute may repeat multiple times (treat it as array)"]
23838    pub fn get_quanta_band(&self) -> MultiAttrIterable<Self, EtsAttrs<'a>, u32> {
23839        MultiAttrIterable::new(self.clone(), |variant| {
23840            if let EtsAttrs::QuantaBand(val) = variant {
23841                Some(val)
23842            } else {
23843                None
23844            }
23845        })
23846    }
23847    pub fn get_priomap(&self) -> Result<IterableEtsAttrs<'a>, ErrorContext> {
23848        let mut iter = self.clone();
23849        iter.pos = 0;
23850        for attr in iter {
23851            if let EtsAttrs::Priomap(val) = attr? {
23852                return Ok(val);
23853            }
23854        }
23855        Err(ErrorContext::new_missing(
23856            "EtsAttrs",
23857            "Priomap",
23858            self.orig_loc,
23859            self.buf.as_ptr() as usize,
23860        ))
23861    }
23862    #[doc = "Attribute may repeat multiple times (treat it as array)"]
23863    pub fn get_priomap_band(&self) -> MultiAttrIterable<Self, EtsAttrs<'a>, u8> {
23864        MultiAttrIterable::new(self.clone(), |variant| {
23865            if let EtsAttrs::PriomapBand(val) = variant {
23866                Some(val)
23867            } else {
23868                None
23869            }
23870        })
23871    }
23872}
23873impl EtsAttrs<'_> {
23874    pub fn new<'a>(buf: &'a [u8]) -> IterableEtsAttrs<'a> {
23875        IterableEtsAttrs::with_loc(buf, buf.as_ptr() as usize)
23876    }
23877    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23878        let res = match r#type {
23879            1u16 => "Nbands",
23880            2u16 => "Nstrict",
23881            3u16 => "Quanta",
23882            4u16 => "QuantaBand",
23883            5u16 => "Priomap",
23884            6u16 => "PriomapBand",
23885            _ => return None,
23886        };
23887        Some(res)
23888    }
23889}
23890#[derive(Clone, Copy, Default)]
23891pub struct IterableEtsAttrs<'a> {
23892    buf: &'a [u8],
23893    pos: usize,
23894    orig_loc: usize,
23895}
23896impl<'a> IterableEtsAttrs<'a> {
23897    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23898        Self {
23899            buf,
23900            pos: 0,
23901            orig_loc,
23902        }
23903    }
23904    pub fn get_buf(&self) -> &'a [u8] {
23905        self.buf
23906    }
23907}
23908impl<'a> Iterator for IterableEtsAttrs<'a> {
23909    type Item = Result<EtsAttrs<'a>, ErrorContext>;
23910    fn next(&mut self) -> Option<Self::Item> {
23911        let pos = self.pos;
23912        let mut r#type;
23913        loop {
23914            r#type = None;
23915            if self.buf.len() == self.pos {
23916                return None;
23917            }
23918            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
23919                break;
23920            };
23921            r#type = Some(header.r#type);
23922            let res = match header.r#type {
23923                1u16 => EtsAttrs::Nbands({
23924                    let res = parse_u8(next);
23925                    let Some(val) = res else { break };
23926                    val
23927                }),
23928                2u16 => EtsAttrs::Nstrict({
23929                    let res = parse_u8(next);
23930                    let Some(val) = res else { break };
23931                    val
23932                }),
23933                3u16 => EtsAttrs::Quanta({
23934                    let res = Some(IterableEtsAttrs::with_loc(next, self.orig_loc));
23935                    let Some(val) = res else { break };
23936                    val
23937                }),
23938                4u16 => EtsAttrs::QuantaBand({
23939                    let res = parse_u32(next);
23940                    let Some(val) = res else { break };
23941                    val
23942                }),
23943                5u16 => EtsAttrs::Priomap({
23944                    let res = Some(IterableEtsAttrs::with_loc(next, self.orig_loc));
23945                    let Some(val) = res else { break };
23946                    val
23947                }),
23948                6u16 => EtsAttrs::PriomapBand({
23949                    let res = parse_u8(next);
23950                    let Some(val) = res else { break };
23951                    val
23952                }),
23953                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
23954                n => continue,
23955            };
23956            return Some(Ok(res));
23957        }
23958        Some(Err(ErrorContext::new(
23959            "EtsAttrs",
23960            r#type.and_then(|t| EtsAttrs::attr_from_type(t)),
23961            self.orig_loc,
23962            self.buf.as_ptr().wrapping_add(pos) as usize,
23963        )))
23964    }
23965}
23966impl<'a> std::fmt::Debug for IterableEtsAttrs<'_> {
23967    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23968        let mut fmt = f.debug_struct("EtsAttrs");
23969        for attr in self.clone() {
23970            let attr = match attr {
23971                Ok(a) => a,
23972                Err(err) => {
23973                    fmt.finish()?;
23974                    f.write_str("Err(")?;
23975                    err.fmt(f)?;
23976                    return f.write_str(")");
23977                }
23978            };
23979            match attr {
23980                EtsAttrs::Nbands(val) => fmt.field("Nbands", &val),
23981                EtsAttrs::Nstrict(val) => fmt.field("Nstrict", &val),
23982                EtsAttrs::Quanta(val) => fmt.field("Quanta", &val),
23983                EtsAttrs::QuantaBand(val) => fmt.field("QuantaBand", &val),
23984                EtsAttrs::Priomap(val) => fmt.field("Priomap", &val),
23985                EtsAttrs::PriomapBand(val) => fmt.field("PriomapBand", &val),
23986            };
23987        }
23988        fmt.finish()
23989    }
23990}
23991impl IterableEtsAttrs<'_> {
23992    pub fn lookup_attr(
23993        &self,
23994        offset: usize,
23995        missing_type: Option<u16>,
23996    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23997        let mut stack = Vec::new();
23998        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23999        if missing_type.is_some() && cur == offset {
24000            stack.push(("EtsAttrs", offset));
24001            return (
24002                stack,
24003                missing_type.and_then(|t| EtsAttrs::attr_from_type(t)),
24004            );
24005        }
24006        if cur > offset || cur + self.buf.len() < offset {
24007            return (stack, None);
24008        }
24009        let mut attrs = self.clone();
24010        let mut last_off = cur + attrs.pos;
24011        let mut missing = None;
24012        while let Some(attr) = attrs.next() {
24013            let Ok(attr) = attr else { break };
24014            match attr {
24015                EtsAttrs::Nbands(val) => {
24016                    if last_off == offset {
24017                        stack.push(("Nbands", last_off));
24018                        break;
24019                    }
24020                }
24021                EtsAttrs::Nstrict(val) => {
24022                    if last_off == offset {
24023                        stack.push(("Nstrict", last_off));
24024                        break;
24025                    }
24026                }
24027                EtsAttrs::Quanta(val) => {
24028                    (stack, missing) = val.lookup_attr(offset, missing_type);
24029                    if !stack.is_empty() {
24030                        break;
24031                    }
24032                }
24033                EtsAttrs::QuantaBand(val) => {
24034                    if last_off == offset {
24035                        stack.push(("QuantaBand", last_off));
24036                        break;
24037                    }
24038                }
24039                EtsAttrs::Priomap(val) => {
24040                    (stack, missing) = val.lookup_attr(offset, missing_type);
24041                    if !stack.is_empty() {
24042                        break;
24043                    }
24044                }
24045                EtsAttrs::PriomapBand(val) => {
24046                    if last_off == offset {
24047                        stack.push(("PriomapBand", last_off));
24048                        break;
24049                    }
24050                }
24051                _ => {}
24052            };
24053            last_off = cur + attrs.pos;
24054        }
24055        if !stack.is_empty() {
24056            stack.push(("EtsAttrs", cur));
24057        }
24058        (stack, missing)
24059    }
24060}
24061#[derive(Clone)]
24062pub enum FqAttrs<'a> {
24063    #[doc = "Limit of total number of packets in queue"]
24064    Plimit(u32),
24065    #[doc = "Limit of packets per flow"]
24066    FlowPlimit(u32),
24067    #[doc = "RR quantum"]
24068    Quantum(u32),
24069    #[doc = "RR quantum for new flow"]
24070    InitialQuantum(u32),
24071    #[doc = "Enable / disable rate limiting"]
24072    RateEnable(u32),
24073    #[doc = "Obsolete, do not use"]
24074    FlowDefaultRate(u32),
24075    #[doc = "Per flow max rate"]
24076    FlowMaxRate(u32),
24077    #[doc = "log2(number of buckets)"]
24078    BucketsLog(u32),
24079    #[doc = "Flow credit refill delay in usec"]
24080    FlowRefillDelay(u32),
24081    #[doc = "Mask applied to orphaned skb hashes"]
24082    OrphanMask(u32),
24083    #[doc = "Per packet delay under this rate"]
24084    LowRateThreshold(u32),
24085    #[doc = "DCTCP\\-like CE marking threshold"]
24086    CeThreshold(u32),
24087    TimerSlack(u32),
24088    #[doc = "Time horizon in usec"]
24089    Horizon(u32),
24090    #[doc = "Drop packets beyond horizon, or cap their EDT"]
24091    HorizonDrop(u8),
24092    Priomap(TcPrioQopt),
24093    #[doc = "Weights for each band"]
24094    Weights(&'a [u8]),
24095}
24096impl<'a> IterableFqAttrs<'a> {
24097    #[doc = "Limit of total number of packets in queue"]
24098    pub fn get_plimit(&self) -> Result<u32, ErrorContext> {
24099        let mut iter = self.clone();
24100        iter.pos = 0;
24101        for attr in iter {
24102            if let FqAttrs::Plimit(val) = attr? {
24103                return Ok(val);
24104            }
24105        }
24106        Err(ErrorContext::new_missing(
24107            "FqAttrs",
24108            "Plimit",
24109            self.orig_loc,
24110            self.buf.as_ptr() as usize,
24111        ))
24112    }
24113    #[doc = "Limit of packets per flow"]
24114    pub fn get_flow_plimit(&self) -> Result<u32, ErrorContext> {
24115        let mut iter = self.clone();
24116        iter.pos = 0;
24117        for attr in iter {
24118            if let FqAttrs::FlowPlimit(val) = attr? {
24119                return Ok(val);
24120            }
24121        }
24122        Err(ErrorContext::new_missing(
24123            "FqAttrs",
24124            "FlowPlimit",
24125            self.orig_loc,
24126            self.buf.as_ptr() as usize,
24127        ))
24128    }
24129    #[doc = "RR quantum"]
24130    pub fn get_quantum(&self) -> Result<u32, ErrorContext> {
24131        let mut iter = self.clone();
24132        iter.pos = 0;
24133        for attr in iter {
24134            if let FqAttrs::Quantum(val) = attr? {
24135                return Ok(val);
24136            }
24137        }
24138        Err(ErrorContext::new_missing(
24139            "FqAttrs",
24140            "Quantum",
24141            self.orig_loc,
24142            self.buf.as_ptr() as usize,
24143        ))
24144    }
24145    #[doc = "RR quantum for new flow"]
24146    pub fn get_initial_quantum(&self) -> Result<u32, ErrorContext> {
24147        let mut iter = self.clone();
24148        iter.pos = 0;
24149        for attr in iter {
24150            if let FqAttrs::InitialQuantum(val) = attr? {
24151                return Ok(val);
24152            }
24153        }
24154        Err(ErrorContext::new_missing(
24155            "FqAttrs",
24156            "InitialQuantum",
24157            self.orig_loc,
24158            self.buf.as_ptr() as usize,
24159        ))
24160    }
24161    #[doc = "Enable / disable rate limiting"]
24162    pub fn get_rate_enable(&self) -> Result<u32, ErrorContext> {
24163        let mut iter = self.clone();
24164        iter.pos = 0;
24165        for attr in iter {
24166            if let FqAttrs::RateEnable(val) = attr? {
24167                return Ok(val);
24168            }
24169        }
24170        Err(ErrorContext::new_missing(
24171            "FqAttrs",
24172            "RateEnable",
24173            self.orig_loc,
24174            self.buf.as_ptr() as usize,
24175        ))
24176    }
24177    #[doc = "Obsolete, do not use"]
24178    pub fn get_flow_default_rate(&self) -> Result<u32, ErrorContext> {
24179        let mut iter = self.clone();
24180        iter.pos = 0;
24181        for attr in iter {
24182            if let FqAttrs::FlowDefaultRate(val) = attr? {
24183                return Ok(val);
24184            }
24185        }
24186        Err(ErrorContext::new_missing(
24187            "FqAttrs",
24188            "FlowDefaultRate",
24189            self.orig_loc,
24190            self.buf.as_ptr() as usize,
24191        ))
24192    }
24193    #[doc = "Per flow max rate"]
24194    pub fn get_flow_max_rate(&self) -> Result<u32, ErrorContext> {
24195        let mut iter = self.clone();
24196        iter.pos = 0;
24197        for attr in iter {
24198            if let FqAttrs::FlowMaxRate(val) = attr? {
24199                return Ok(val);
24200            }
24201        }
24202        Err(ErrorContext::new_missing(
24203            "FqAttrs",
24204            "FlowMaxRate",
24205            self.orig_loc,
24206            self.buf.as_ptr() as usize,
24207        ))
24208    }
24209    #[doc = "log2(number of buckets)"]
24210    pub fn get_buckets_log(&self) -> Result<u32, ErrorContext> {
24211        let mut iter = self.clone();
24212        iter.pos = 0;
24213        for attr in iter {
24214            if let FqAttrs::BucketsLog(val) = attr? {
24215                return Ok(val);
24216            }
24217        }
24218        Err(ErrorContext::new_missing(
24219            "FqAttrs",
24220            "BucketsLog",
24221            self.orig_loc,
24222            self.buf.as_ptr() as usize,
24223        ))
24224    }
24225    #[doc = "Flow credit refill delay in usec"]
24226    pub fn get_flow_refill_delay(&self) -> Result<u32, ErrorContext> {
24227        let mut iter = self.clone();
24228        iter.pos = 0;
24229        for attr in iter {
24230            if let FqAttrs::FlowRefillDelay(val) = attr? {
24231                return Ok(val);
24232            }
24233        }
24234        Err(ErrorContext::new_missing(
24235            "FqAttrs",
24236            "FlowRefillDelay",
24237            self.orig_loc,
24238            self.buf.as_ptr() as usize,
24239        ))
24240    }
24241    #[doc = "Mask applied to orphaned skb hashes"]
24242    pub fn get_orphan_mask(&self) -> Result<u32, ErrorContext> {
24243        let mut iter = self.clone();
24244        iter.pos = 0;
24245        for attr in iter {
24246            if let FqAttrs::OrphanMask(val) = attr? {
24247                return Ok(val);
24248            }
24249        }
24250        Err(ErrorContext::new_missing(
24251            "FqAttrs",
24252            "OrphanMask",
24253            self.orig_loc,
24254            self.buf.as_ptr() as usize,
24255        ))
24256    }
24257    #[doc = "Per packet delay under this rate"]
24258    pub fn get_low_rate_threshold(&self) -> Result<u32, ErrorContext> {
24259        let mut iter = self.clone();
24260        iter.pos = 0;
24261        for attr in iter {
24262            if let FqAttrs::LowRateThreshold(val) = attr? {
24263                return Ok(val);
24264            }
24265        }
24266        Err(ErrorContext::new_missing(
24267            "FqAttrs",
24268            "LowRateThreshold",
24269            self.orig_loc,
24270            self.buf.as_ptr() as usize,
24271        ))
24272    }
24273    #[doc = "DCTCP\\-like CE marking threshold"]
24274    pub fn get_ce_threshold(&self) -> Result<u32, ErrorContext> {
24275        let mut iter = self.clone();
24276        iter.pos = 0;
24277        for attr in iter {
24278            if let FqAttrs::CeThreshold(val) = attr? {
24279                return Ok(val);
24280            }
24281        }
24282        Err(ErrorContext::new_missing(
24283            "FqAttrs",
24284            "CeThreshold",
24285            self.orig_loc,
24286            self.buf.as_ptr() as usize,
24287        ))
24288    }
24289    pub fn get_timer_slack(&self) -> Result<u32, ErrorContext> {
24290        let mut iter = self.clone();
24291        iter.pos = 0;
24292        for attr in iter {
24293            if let FqAttrs::TimerSlack(val) = attr? {
24294                return Ok(val);
24295            }
24296        }
24297        Err(ErrorContext::new_missing(
24298            "FqAttrs",
24299            "TimerSlack",
24300            self.orig_loc,
24301            self.buf.as_ptr() as usize,
24302        ))
24303    }
24304    #[doc = "Time horizon in usec"]
24305    pub fn get_horizon(&self) -> Result<u32, ErrorContext> {
24306        let mut iter = self.clone();
24307        iter.pos = 0;
24308        for attr in iter {
24309            if let FqAttrs::Horizon(val) = attr? {
24310                return Ok(val);
24311            }
24312        }
24313        Err(ErrorContext::new_missing(
24314            "FqAttrs",
24315            "Horizon",
24316            self.orig_loc,
24317            self.buf.as_ptr() as usize,
24318        ))
24319    }
24320    #[doc = "Drop packets beyond horizon, or cap their EDT"]
24321    pub fn get_horizon_drop(&self) -> Result<u8, ErrorContext> {
24322        let mut iter = self.clone();
24323        iter.pos = 0;
24324        for attr in iter {
24325            if let FqAttrs::HorizonDrop(val) = attr? {
24326                return Ok(val);
24327            }
24328        }
24329        Err(ErrorContext::new_missing(
24330            "FqAttrs",
24331            "HorizonDrop",
24332            self.orig_loc,
24333            self.buf.as_ptr() as usize,
24334        ))
24335    }
24336    pub fn get_priomap(&self) -> Result<TcPrioQopt, ErrorContext> {
24337        let mut iter = self.clone();
24338        iter.pos = 0;
24339        for attr in iter {
24340            if let FqAttrs::Priomap(val) = attr? {
24341                return Ok(val);
24342            }
24343        }
24344        Err(ErrorContext::new_missing(
24345            "FqAttrs",
24346            "Priomap",
24347            self.orig_loc,
24348            self.buf.as_ptr() as usize,
24349        ))
24350    }
24351    #[doc = "Weights for each band"]
24352    pub fn get_weights(&self) -> Result<&'a [u8], ErrorContext> {
24353        let mut iter = self.clone();
24354        iter.pos = 0;
24355        for attr in iter {
24356            if let FqAttrs::Weights(val) = attr? {
24357                return Ok(val);
24358            }
24359        }
24360        Err(ErrorContext::new_missing(
24361            "FqAttrs",
24362            "Weights",
24363            self.orig_loc,
24364            self.buf.as_ptr() as usize,
24365        ))
24366    }
24367}
24368impl FqAttrs<'_> {
24369    pub fn new<'a>(buf: &'a [u8]) -> IterableFqAttrs<'a> {
24370        IterableFqAttrs::with_loc(buf, buf.as_ptr() as usize)
24371    }
24372    fn attr_from_type(r#type: u16) -> Option<&'static str> {
24373        let res = match r#type {
24374            1u16 => "Plimit",
24375            2u16 => "FlowPlimit",
24376            3u16 => "Quantum",
24377            4u16 => "InitialQuantum",
24378            5u16 => "RateEnable",
24379            6u16 => "FlowDefaultRate",
24380            7u16 => "FlowMaxRate",
24381            8u16 => "BucketsLog",
24382            9u16 => "FlowRefillDelay",
24383            10u16 => "OrphanMask",
24384            11u16 => "LowRateThreshold",
24385            12u16 => "CeThreshold",
24386            13u16 => "TimerSlack",
24387            14u16 => "Horizon",
24388            15u16 => "HorizonDrop",
24389            16u16 => "Priomap",
24390            17u16 => "Weights",
24391            _ => return None,
24392        };
24393        Some(res)
24394    }
24395}
24396#[derive(Clone, Copy, Default)]
24397pub struct IterableFqAttrs<'a> {
24398    buf: &'a [u8],
24399    pos: usize,
24400    orig_loc: usize,
24401}
24402impl<'a> IterableFqAttrs<'a> {
24403    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
24404        Self {
24405            buf,
24406            pos: 0,
24407            orig_loc,
24408        }
24409    }
24410    pub fn get_buf(&self) -> &'a [u8] {
24411        self.buf
24412    }
24413}
24414impl<'a> Iterator for IterableFqAttrs<'a> {
24415    type Item = Result<FqAttrs<'a>, ErrorContext>;
24416    fn next(&mut self) -> Option<Self::Item> {
24417        let pos = self.pos;
24418        let mut r#type;
24419        loop {
24420            r#type = None;
24421            if self.buf.len() == self.pos {
24422                return None;
24423            }
24424            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
24425                break;
24426            };
24427            r#type = Some(header.r#type);
24428            let res = match header.r#type {
24429                1u16 => FqAttrs::Plimit({
24430                    let res = parse_u32(next);
24431                    let Some(val) = res else { break };
24432                    val
24433                }),
24434                2u16 => FqAttrs::FlowPlimit({
24435                    let res = parse_u32(next);
24436                    let Some(val) = res else { break };
24437                    val
24438                }),
24439                3u16 => FqAttrs::Quantum({
24440                    let res = parse_u32(next);
24441                    let Some(val) = res else { break };
24442                    val
24443                }),
24444                4u16 => FqAttrs::InitialQuantum({
24445                    let res = parse_u32(next);
24446                    let Some(val) = res else { break };
24447                    val
24448                }),
24449                5u16 => FqAttrs::RateEnable({
24450                    let res = parse_u32(next);
24451                    let Some(val) = res else { break };
24452                    val
24453                }),
24454                6u16 => FqAttrs::FlowDefaultRate({
24455                    let res = parse_u32(next);
24456                    let Some(val) = res else { break };
24457                    val
24458                }),
24459                7u16 => FqAttrs::FlowMaxRate({
24460                    let res = parse_u32(next);
24461                    let Some(val) = res else { break };
24462                    val
24463                }),
24464                8u16 => FqAttrs::BucketsLog({
24465                    let res = parse_u32(next);
24466                    let Some(val) = res else { break };
24467                    val
24468                }),
24469                9u16 => FqAttrs::FlowRefillDelay({
24470                    let res = parse_u32(next);
24471                    let Some(val) = res else { break };
24472                    val
24473                }),
24474                10u16 => FqAttrs::OrphanMask({
24475                    let res = parse_u32(next);
24476                    let Some(val) = res else { break };
24477                    val
24478                }),
24479                11u16 => FqAttrs::LowRateThreshold({
24480                    let res = parse_u32(next);
24481                    let Some(val) = res else { break };
24482                    val
24483                }),
24484                12u16 => FqAttrs::CeThreshold({
24485                    let res = parse_u32(next);
24486                    let Some(val) = res else { break };
24487                    val
24488                }),
24489                13u16 => FqAttrs::TimerSlack({
24490                    let res = parse_u32(next);
24491                    let Some(val) = res else { break };
24492                    val
24493                }),
24494                14u16 => FqAttrs::Horizon({
24495                    let res = parse_u32(next);
24496                    let Some(val) = res else { break };
24497                    val
24498                }),
24499                15u16 => FqAttrs::HorizonDrop({
24500                    let res = parse_u8(next);
24501                    let Some(val) = res else { break };
24502                    val
24503                }),
24504                16u16 => FqAttrs::Priomap({
24505                    let res = Some(TcPrioQopt::new_from_zeroed(next));
24506                    let Some(val) = res else { break };
24507                    val
24508                }),
24509                17u16 => FqAttrs::Weights({
24510                    let res = Some(next);
24511                    let Some(val) = res else { break };
24512                    val
24513                }),
24514                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
24515                n => continue,
24516            };
24517            return Some(Ok(res));
24518        }
24519        Some(Err(ErrorContext::new(
24520            "FqAttrs",
24521            r#type.and_then(|t| FqAttrs::attr_from_type(t)),
24522            self.orig_loc,
24523            self.buf.as_ptr().wrapping_add(pos) as usize,
24524        )))
24525    }
24526}
24527impl<'a> std::fmt::Debug for IterableFqAttrs<'_> {
24528    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24529        let mut fmt = f.debug_struct("FqAttrs");
24530        for attr in self.clone() {
24531            let attr = match attr {
24532                Ok(a) => a,
24533                Err(err) => {
24534                    fmt.finish()?;
24535                    f.write_str("Err(")?;
24536                    err.fmt(f)?;
24537                    return f.write_str(")");
24538                }
24539            };
24540            match attr {
24541                FqAttrs::Plimit(val) => fmt.field("Plimit", &val),
24542                FqAttrs::FlowPlimit(val) => fmt.field("FlowPlimit", &val),
24543                FqAttrs::Quantum(val) => fmt.field("Quantum", &val),
24544                FqAttrs::InitialQuantum(val) => fmt.field("InitialQuantum", &val),
24545                FqAttrs::RateEnable(val) => fmt.field("RateEnable", &val),
24546                FqAttrs::FlowDefaultRate(val) => fmt.field("FlowDefaultRate", &val),
24547                FqAttrs::FlowMaxRate(val) => fmt.field("FlowMaxRate", &val),
24548                FqAttrs::BucketsLog(val) => fmt.field("BucketsLog", &val),
24549                FqAttrs::FlowRefillDelay(val) => fmt.field("FlowRefillDelay", &val),
24550                FqAttrs::OrphanMask(val) => fmt.field("OrphanMask", &val),
24551                FqAttrs::LowRateThreshold(val) => fmt.field("LowRateThreshold", &val),
24552                FqAttrs::CeThreshold(val) => fmt.field("CeThreshold", &val),
24553                FqAttrs::TimerSlack(val) => fmt.field("TimerSlack", &val),
24554                FqAttrs::Horizon(val) => fmt.field("Horizon", &val),
24555                FqAttrs::HorizonDrop(val) => fmt.field("HorizonDrop", &val),
24556                FqAttrs::Priomap(val) => fmt.field("Priomap", &val),
24557                FqAttrs::Weights(val) => fmt.field("Weights", &val),
24558            };
24559        }
24560        fmt.finish()
24561    }
24562}
24563impl IterableFqAttrs<'_> {
24564    pub fn lookup_attr(
24565        &self,
24566        offset: usize,
24567        missing_type: Option<u16>,
24568    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
24569        let mut stack = Vec::new();
24570        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
24571        if missing_type.is_some() && cur == offset {
24572            stack.push(("FqAttrs", offset));
24573            return (stack, missing_type.and_then(|t| FqAttrs::attr_from_type(t)));
24574        }
24575        if cur > offset || cur + self.buf.len() < offset {
24576            return (stack, None);
24577        }
24578        let mut attrs = self.clone();
24579        let mut last_off = cur + attrs.pos;
24580        while let Some(attr) = attrs.next() {
24581            let Ok(attr) = attr else { break };
24582            match attr {
24583                FqAttrs::Plimit(val) => {
24584                    if last_off == offset {
24585                        stack.push(("Plimit", last_off));
24586                        break;
24587                    }
24588                }
24589                FqAttrs::FlowPlimit(val) => {
24590                    if last_off == offset {
24591                        stack.push(("FlowPlimit", last_off));
24592                        break;
24593                    }
24594                }
24595                FqAttrs::Quantum(val) => {
24596                    if last_off == offset {
24597                        stack.push(("Quantum", last_off));
24598                        break;
24599                    }
24600                }
24601                FqAttrs::InitialQuantum(val) => {
24602                    if last_off == offset {
24603                        stack.push(("InitialQuantum", last_off));
24604                        break;
24605                    }
24606                }
24607                FqAttrs::RateEnable(val) => {
24608                    if last_off == offset {
24609                        stack.push(("RateEnable", last_off));
24610                        break;
24611                    }
24612                }
24613                FqAttrs::FlowDefaultRate(val) => {
24614                    if last_off == offset {
24615                        stack.push(("FlowDefaultRate", last_off));
24616                        break;
24617                    }
24618                }
24619                FqAttrs::FlowMaxRate(val) => {
24620                    if last_off == offset {
24621                        stack.push(("FlowMaxRate", last_off));
24622                        break;
24623                    }
24624                }
24625                FqAttrs::BucketsLog(val) => {
24626                    if last_off == offset {
24627                        stack.push(("BucketsLog", last_off));
24628                        break;
24629                    }
24630                }
24631                FqAttrs::FlowRefillDelay(val) => {
24632                    if last_off == offset {
24633                        stack.push(("FlowRefillDelay", last_off));
24634                        break;
24635                    }
24636                }
24637                FqAttrs::OrphanMask(val) => {
24638                    if last_off == offset {
24639                        stack.push(("OrphanMask", last_off));
24640                        break;
24641                    }
24642                }
24643                FqAttrs::LowRateThreshold(val) => {
24644                    if last_off == offset {
24645                        stack.push(("LowRateThreshold", last_off));
24646                        break;
24647                    }
24648                }
24649                FqAttrs::CeThreshold(val) => {
24650                    if last_off == offset {
24651                        stack.push(("CeThreshold", last_off));
24652                        break;
24653                    }
24654                }
24655                FqAttrs::TimerSlack(val) => {
24656                    if last_off == offset {
24657                        stack.push(("TimerSlack", last_off));
24658                        break;
24659                    }
24660                }
24661                FqAttrs::Horizon(val) => {
24662                    if last_off == offset {
24663                        stack.push(("Horizon", last_off));
24664                        break;
24665                    }
24666                }
24667                FqAttrs::HorizonDrop(val) => {
24668                    if last_off == offset {
24669                        stack.push(("HorizonDrop", last_off));
24670                        break;
24671                    }
24672                }
24673                FqAttrs::Priomap(val) => {
24674                    if last_off == offset {
24675                        stack.push(("Priomap", last_off));
24676                        break;
24677                    }
24678                }
24679                FqAttrs::Weights(val) => {
24680                    if last_off == offset {
24681                        stack.push(("Weights", last_off));
24682                        break;
24683                    }
24684                }
24685                _ => {}
24686            };
24687            last_off = cur + attrs.pos;
24688        }
24689        if !stack.is_empty() {
24690            stack.push(("FqAttrs", cur));
24691        }
24692        (stack, None)
24693    }
24694}
24695#[derive(Clone)]
24696pub enum FqCodelAttrs {
24697    Target(u32),
24698    Limit(u32),
24699    Interval(u32),
24700    Ecn(u32),
24701    Flows(u32),
24702    Quantum(u32),
24703    CeThreshold(u32),
24704    DropBatchSize(u32),
24705    MemoryLimit(u32),
24706    CeThresholdSelector(u8),
24707    CeThresholdMask(u8),
24708}
24709impl<'a> IterableFqCodelAttrs<'a> {
24710    pub fn get_target(&self) -> Result<u32, ErrorContext> {
24711        let mut iter = self.clone();
24712        iter.pos = 0;
24713        for attr in iter {
24714            if let FqCodelAttrs::Target(val) = attr? {
24715                return Ok(val);
24716            }
24717        }
24718        Err(ErrorContext::new_missing(
24719            "FqCodelAttrs",
24720            "Target",
24721            self.orig_loc,
24722            self.buf.as_ptr() as usize,
24723        ))
24724    }
24725    pub fn get_limit(&self) -> Result<u32, ErrorContext> {
24726        let mut iter = self.clone();
24727        iter.pos = 0;
24728        for attr in iter {
24729            if let FqCodelAttrs::Limit(val) = attr? {
24730                return Ok(val);
24731            }
24732        }
24733        Err(ErrorContext::new_missing(
24734            "FqCodelAttrs",
24735            "Limit",
24736            self.orig_loc,
24737            self.buf.as_ptr() as usize,
24738        ))
24739    }
24740    pub fn get_interval(&self) -> Result<u32, ErrorContext> {
24741        let mut iter = self.clone();
24742        iter.pos = 0;
24743        for attr in iter {
24744            if let FqCodelAttrs::Interval(val) = attr? {
24745                return Ok(val);
24746            }
24747        }
24748        Err(ErrorContext::new_missing(
24749            "FqCodelAttrs",
24750            "Interval",
24751            self.orig_loc,
24752            self.buf.as_ptr() as usize,
24753        ))
24754    }
24755    pub fn get_ecn(&self) -> Result<u32, ErrorContext> {
24756        let mut iter = self.clone();
24757        iter.pos = 0;
24758        for attr in iter {
24759            if let FqCodelAttrs::Ecn(val) = attr? {
24760                return Ok(val);
24761            }
24762        }
24763        Err(ErrorContext::new_missing(
24764            "FqCodelAttrs",
24765            "Ecn",
24766            self.orig_loc,
24767            self.buf.as_ptr() as usize,
24768        ))
24769    }
24770    pub fn get_flows(&self) -> Result<u32, ErrorContext> {
24771        let mut iter = self.clone();
24772        iter.pos = 0;
24773        for attr in iter {
24774            if let FqCodelAttrs::Flows(val) = attr? {
24775                return Ok(val);
24776            }
24777        }
24778        Err(ErrorContext::new_missing(
24779            "FqCodelAttrs",
24780            "Flows",
24781            self.orig_loc,
24782            self.buf.as_ptr() as usize,
24783        ))
24784    }
24785    pub fn get_quantum(&self) -> Result<u32, ErrorContext> {
24786        let mut iter = self.clone();
24787        iter.pos = 0;
24788        for attr in iter {
24789            if let FqCodelAttrs::Quantum(val) = attr? {
24790                return Ok(val);
24791            }
24792        }
24793        Err(ErrorContext::new_missing(
24794            "FqCodelAttrs",
24795            "Quantum",
24796            self.orig_loc,
24797            self.buf.as_ptr() as usize,
24798        ))
24799    }
24800    pub fn get_ce_threshold(&self) -> Result<u32, ErrorContext> {
24801        let mut iter = self.clone();
24802        iter.pos = 0;
24803        for attr in iter {
24804            if let FqCodelAttrs::CeThreshold(val) = attr? {
24805                return Ok(val);
24806            }
24807        }
24808        Err(ErrorContext::new_missing(
24809            "FqCodelAttrs",
24810            "CeThreshold",
24811            self.orig_loc,
24812            self.buf.as_ptr() as usize,
24813        ))
24814    }
24815    pub fn get_drop_batch_size(&self) -> Result<u32, ErrorContext> {
24816        let mut iter = self.clone();
24817        iter.pos = 0;
24818        for attr in iter {
24819            if let FqCodelAttrs::DropBatchSize(val) = attr? {
24820                return Ok(val);
24821            }
24822        }
24823        Err(ErrorContext::new_missing(
24824            "FqCodelAttrs",
24825            "DropBatchSize",
24826            self.orig_loc,
24827            self.buf.as_ptr() as usize,
24828        ))
24829    }
24830    pub fn get_memory_limit(&self) -> Result<u32, ErrorContext> {
24831        let mut iter = self.clone();
24832        iter.pos = 0;
24833        for attr in iter {
24834            if let FqCodelAttrs::MemoryLimit(val) = attr? {
24835                return Ok(val);
24836            }
24837        }
24838        Err(ErrorContext::new_missing(
24839            "FqCodelAttrs",
24840            "MemoryLimit",
24841            self.orig_loc,
24842            self.buf.as_ptr() as usize,
24843        ))
24844    }
24845    pub fn get_ce_threshold_selector(&self) -> Result<u8, ErrorContext> {
24846        let mut iter = self.clone();
24847        iter.pos = 0;
24848        for attr in iter {
24849            if let FqCodelAttrs::CeThresholdSelector(val) = attr? {
24850                return Ok(val);
24851            }
24852        }
24853        Err(ErrorContext::new_missing(
24854            "FqCodelAttrs",
24855            "CeThresholdSelector",
24856            self.orig_loc,
24857            self.buf.as_ptr() as usize,
24858        ))
24859    }
24860    pub fn get_ce_threshold_mask(&self) -> Result<u8, ErrorContext> {
24861        let mut iter = self.clone();
24862        iter.pos = 0;
24863        for attr in iter {
24864            if let FqCodelAttrs::CeThresholdMask(val) = attr? {
24865                return Ok(val);
24866            }
24867        }
24868        Err(ErrorContext::new_missing(
24869            "FqCodelAttrs",
24870            "CeThresholdMask",
24871            self.orig_loc,
24872            self.buf.as_ptr() as usize,
24873        ))
24874    }
24875}
24876impl FqCodelAttrs {
24877    pub fn new<'a>(buf: &'a [u8]) -> IterableFqCodelAttrs<'a> {
24878        IterableFqCodelAttrs::with_loc(buf, buf.as_ptr() as usize)
24879    }
24880    fn attr_from_type(r#type: u16) -> Option<&'static str> {
24881        let res = match r#type {
24882            1u16 => "Target",
24883            2u16 => "Limit",
24884            3u16 => "Interval",
24885            4u16 => "Ecn",
24886            5u16 => "Flows",
24887            6u16 => "Quantum",
24888            7u16 => "CeThreshold",
24889            8u16 => "DropBatchSize",
24890            9u16 => "MemoryLimit",
24891            10u16 => "CeThresholdSelector",
24892            11u16 => "CeThresholdMask",
24893            _ => return None,
24894        };
24895        Some(res)
24896    }
24897}
24898#[derive(Clone, Copy, Default)]
24899pub struct IterableFqCodelAttrs<'a> {
24900    buf: &'a [u8],
24901    pos: usize,
24902    orig_loc: usize,
24903}
24904impl<'a> IterableFqCodelAttrs<'a> {
24905    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
24906        Self {
24907            buf,
24908            pos: 0,
24909            orig_loc,
24910        }
24911    }
24912    pub fn get_buf(&self) -> &'a [u8] {
24913        self.buf
24914    }
24915}
24916impl<'a> Iterator for IterableFqCodelAttrs<'a> {
24917    type Item = Result<FqCodelAttrs, ErrorContext>;
24918    fn next(&mut self) -> Option<Self::Item> {
24919        let pos = self.pos;
24920        let mut r#type;
24921        loop {
24922            r#type = None;
24923            if self.buf.len() == self.pos {
24924                return None;
24925            }
24926            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
24927                break;
24928            };
24929            r#type = Some(header.r#type);
24930            let res = match header.r#type {
24931                1u16 => FqCodelAttrs::Target({
24932                    let res = parse_u32(next);
24933                    let Some(val) = res else { break };
24934                    val
24935                }),
24936                2u16 => FqCodelAttrs::Limit({
24937                    let res = parse_u32(next);
24938                    let Some(val) = res else { break };
24939                    val
24940                }),
24941                3u16 => FqCodelAttrs::Interval({
24942                    let res = parse_u32(next);
24943                    let Some(val) = res else { break };
24944                    val
24945                }),
24946                4u16 => FqCodelAttrs::Ecn({
24947                    let res = parse_u32(next);
24948                    let Some(val) = res else { break };
24949                    val
24950                }),
24951                5u16 => FqCodelAttrs::Flows({
24952                    let res = parse_u32(next);
24953                    let Some(val) = res else { break };
24954                    val
24955                }),
24956                6u16 => FqCodelAttrs::Quantum({
24957                    let res = parse_u32(next);
24958                    let Some(val) = res else { break };
24959                    val
24960                }),
24961                7u16 => FqCodelAttrs::CeThreshold({
24962                    let res = parse_u32(next);
24963                    let Some(val) = res else { break };
24964                    val
24965                }),
24966                8u16 => FqCodelAttrs::DropBatchSize({
24967                    let res = parse_u32(next);
24968                    let Some(val) = res else { break };
24969                    val
24970                }),
24971                9u16 => FqCodelAttrs::MemoryLimit({
24972                    let res = parse_u32(next);
24973                    let Some(val) = res else { break };
24974                    val
24975                }),
24976                10u16 => FqCodelAttrs::CeThresholdSelector({
24977                    let res = parse_u8(next);
24978                    let Some(val) = res else { break };
24979                    val
24980                }),
24981                11u16 => FqCodelAttrs::CeThresholdMask({
24982                    let res = parse_u8(next);
24983                    let Some(val) = res else { break };
24984                    val
24985                }),
24986                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
24987                n => continue,
24988            };
24989            return Some(Ok(res));
24990        }
24991        Some(Err(ErrorContext::new(
24992            "FqCodelAttrs",
24993            r#type.and_then(|t| FqCodelAttrs::attr_from_type(t)),
24994            self.orig_loc,
24995            self.buf.as_ptr().wrapping_add(pos) as usize,
24996        )))
24997    }
24998}
24999impl std::fmt::Debug for IterableFqCodelAttrs<'_> {
25000    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25001        let mut fmt = f.debug_struct("FqCodelAttrs");
25002        for attr in self.clone() {
25003            let attr = match attr {
25004                Ok(a) => a,
25005                Err(err) => {
25006                    fmt.finish()?;
25007                    f.write_str("Err(")?;
25008                    err.fmt(f)?;
25009                    return f.write_str(")");
25010                }
25011            };
25012            match attr {
25013                FqCodelAttrs::Target(val) => fmt.field("Target", &val),
25014                FqCodelAttrs::Limit(val) => fmt.field("Limit", &val),
25015                FqCodelAttrs::Interval(val) => fmt.field("Interval", &val),
25016                FqCodelAttrs::Ecn(val) => fmt.field("Ecn", &val),
25017                FqCodelAttrs::Flows(val) => fmt.field("Flows", &val),
25018                FqCodelAttrs::Quantum(val) => fmt.field("Quantum", &val),
25019                FqCodelAttrs::CeThreshold(val) => fmt.field("CeThreshold", &val),
25020                FqCodelAttrs::DropBatchSize(val) => fmt.field("DropBatchSize", &val),
25021                FqCodelAttrs::MemoryLimit(val) => fmt.field("MemoryLimit", &val),
25022                FqCodelAttrs::CeThresholdSelector(val) => fmt.field("CeThresholdSelector", &val),
25023                FqCodelAttrs::CeThresholdMask(val) => fmt.field("CeThresholdMask", &val),
25024            };
25025        }
25026        fmt.finish()
25027    }
25028}
25029impl IterableFqCodelAttrs<'_> {
25030    pub fn lookup_attr(
25031        &self,
25032        offset: usize,
25033        missing_type: Option<u16>,
25034    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
25035        let mut stack = Vec::new();
25036        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
25037        if missing_type.is_some() && cur == offset {
25038            stack.push(("FqCodelAttrs", offset));
25039            return (
25040                stack,
25041                missing_type.and_then(|t| FqCodelAttrs::attr_from_type(t)),
25042            );
25043        }
25044        if cur > offset || cur + self.buf.len() < offset {
25045            return (stack, None);
25046        }
25047        let mut attrs = self.clone();
25048        let mut last_off = cur + attrs.pos;
25049        while let Some(attr) = attrs.next() {
25050            let Ok(attr) = attr else { break };
25051            match attr {
25052                FqCodelAttrs::Target(val) => {
25053                    if last_off == offset {
25054                        stack.push(("Target", last_off));
25055                        break;
25056                    }
25057                }
25058                FqCodelAttrs::Limit(val) => {
25059                    if last_off == offset {
25060                        stack.push(("Limit", last_off));
25061                        break;
25062                    }
25063                }
25064                FqCodelAttrs::Interval(val) => {
25065                    if last_off == offset {
25066                        stack.push(("Interval", last_off));
25067                        break;
25068                    }
25069                }
25070                FqCodelAttrs::Ecn(val) => {
25071                    if last_off == offset {
25072                        stack.push(("Ecn", last_off));
25073                        break;
25074                    }
25075                }
25076                FqCodelAttrs::Flows(val) => {
25077                    if last_off == offset {
25078                        stack.push(("Flows", last_off));
25079                        break;
25080                    }
25081                }
25082                FqCodelAttrs::Quantum(val) => {
25083                    if last_off == offset {
25084                        stack.push(("Quantum", last_off));
25085                        break;
25086                    }
25087                }
25088                FqCodelAttrs::CeThreshold(val) => {
25089                    if last_off == offset {
25090                        stack.push(("CeThreshold", last_off));
25091                        break;
25092                    }
25093                }
25094                FqCodelAttrs::DropBatchSize(val) => {
25095                    if last_off == offset {
25096                        stack.push(("DropBatchSize", last_off));
25097                        break;
25098                    }
25099                }
25100                FqCodelAttrs::MemoryLimit(val) => {
25101                    if last_off == offset {
25102                        stack.push(("MemoryLimit", last_off));
25103                        break;
25104                    }
25105                }
25106                FqCodelAttrs::CeThresholdSelector(val) => {
25107                    if last_off == offset {
25108                        stack.push(("CeThresholdSelector", last_off));
25109                        break;
25110                    }
25111                }
25112                FqCodelAttrs::CeThresholdMask(val) => {
25113                    if last_off == offset {
25114                        stack.push(("CeThresholdMask", last_off));
25115                        break;
25116                    }
25117                }
25118                _ => {}
25119            };
25120            last_off = cur + attrs.pos;
25121        }
25122        if !stack.is_empty() {
25123            stack.push(("FqCodelAttrs", cur));
25124        }
25125        (stack, None)
25126    }
25127}
25128#[derive(Clone)]
25129pub enum FqPieAttrs {
25130    Limit(u32),
25131    Flows(u32),
25132    Target(u32),
25133    Tupdate(u32),
25134    Alpha(u32),
25135    Beta(u32),
25136    Quantum(u32),
25137    MemoryLimit(u32),
25138    EcnProb(u32),
25139    Ecn(u32),
25140    Bytemode(u32),
25141    DqRateEstimator(u32),
25142}
25143impl<'a> IterableFqPieAttrs<'a> {
25144    pub fn get_limit(&self) -> Result<u32, ErrorContext> {
25145        let mut iter = self.clone();
25146        iter.pos = 0;
25147        for attr in iter {
25148            if let FqPieAttrs::Limit(val) = attr? {
25149                return Ok(val);
25150            }
25151        }
25152        Err(ErrorContext::new_missing(
25153            "FqPieAttrs",
25154            "Limit",
25155            self.orig_loc,
25156            self.buf.as_ptr() as usize,
25157        ))
25158    }
25159    pub fn get_flows(&self) -> Result<u32, ErrorContext> {
25160        let mut iter = self.clone();
25161        iter.pos = 0;
25162        for attr in iter {
25163            if let FqPieAttrs::Flows(val) = attr? {
25164                return Ok(val);
25165            }
25166        }
25167        Err(ErrorContext::new_missing(
25168            "FqPieAttrs",
25169            "Flows",
25170            self.orig_loc,
25171            self.buf.as_ptr() as usize,
25172        ))
25173    }
25174    pub fn get_target(&self) -> Result<u32, ErrorContext> {
25175        let mut iter = self.clone();
25176        iter.pos = 0;
25177        for attr in iter {
25178            if let FqPieAttrs::Target(val) = attr? {
25179                return Ok(val);
25180            }
25181        }
25182        Err(ErrorContext::new_missing(
25183            "FqPieAttrs",
25184            "Target",
25185            self.orig_loc,
25186            self.buf.as_ptr() as usize,
25187        ))
25188    }
25189    pub fn get_tupdate(&self) -> Result<u32, ErrorContext> {
25190        let mut iter = self.clone();
25191        iter.pos = 0;
25192        for attr in iter {
25193            if let FqPieAttrs::Tupdate(val) = attr? {
25194                return Ok(val);
25195            }
25196        }
25197        Err(ErrorContext::new_missing(
25198            "FqPieAttrs",
25199            "Tupdate",
25200            self.orig_loc,
25201            self.buf.as_ptr() as usize,
25202        ))
25203    }
25204    pub fn get_alpha(&self) -> Result<u32, ErrorContext> {
25205        let mut iter = self.clone();
25206        iter.pos = 0;
25207        for attr in iter {
25208            if let FqPieAttrs::Alpha(val) = attr? {
25209                return Ok(val);
25210            }
25211        }
25212        Err(ErrorContext::new_missing(
25213            "FqPieAttrs",
25214            "Alpha",
25215            self.orig_loc,
25216            self.buf.as_ptr() as usize,
25217        ))
25218    }
25219    pub fn get_beta(&self) -> Result<u32, ErrorContext> {
25220        let mut iter = self.clone();
25221        iter.pos = 0;
25222        for attr in iter {
25223            if let FqPieAttrs::Beta(val) = attr? {
25224                return Ok(val);
25225            }
25226        }
25227        Err(ErrorContext::new_missing(
25228            "FqPieAttrs",
25229            "Beta",
25230            self.orig_loc,
25231            self.buf.as_ptr() as usize,
25232        ))
25233    }
25234    pub fn get_quantum(&self) -> Result<u32, ErrorContext> {
25235        let mut iter = self.clone();
25236        iter.pos = 0;
25237        for attr in iter {
25238            if let FqPieAttrs::Quantum(val) = attr? {
25239                return Ok(val);
25240            }
25241        }
25242        Err(ErrorContext::new_missing(
25243            "FqPieAttrs",
25244            "Quantum",
25245            self.orig_loc,
25246            self.buf.as_ptr() as usize,
25247        ))
25248    }
25249    pub fn get_memory_limit(&self) -> Result<u32, ErrorContext> {
25250        let mut iter = self.clone();
25251        iter.pos = 0;
25252        for attr in iter {
25253            if let FqPieAttrs::MemoryLimit(val) = attr? {
25254                return Ok(val);
25255            }
25256        }
25257        Err(ErrorContext::new_missing(
25258            "FqPieAttrs",
25259            "MemoryLimit",
25260            self.orig_loc,
25261            self.buf.as_ptr() as usize,
25262        ))
25263    }
25264    pub fn get_ecn_prob(&self) -> Result<u32, ErrorContext> {
25265        let mut iter = self.clone();
25266        iter.pos = 0;
25267        for attr in iter {
25268            if let FqPieAttrs::EcnProb(val) = attr? {
25269                return Ok(val);
25270            }
25271        }
25272        Err(ErrorContext::new_missing(
25273            "FqPieAttrs",
25274            "EcnProb",
25275            self.orig_loc,
25276            self.buf.as_ptr() as usize,
25277        ))
25278    }
25279    pub fn get_ecn(&self) -> Result<u32, ErrorContext> {
25280        let mut iter = self.clone();
25281        iter.pos = 0;
25282        for attr in iter {
25283            if let FqPieAttrs::Ecn(val) = attr? {
25284                return Ok(val);
25285            }
25286        }
25287        Err(ErrorContext::new_missing(
25288            "FqPieAttrs",
25289            "Ecn",
25290            self.orig_loc,
25291            self.buf.as_ptr() as usize,
25292        ))
25293    }
25294    pub fn get_bytemode(&self) -> Result<u32, ErrorContext> {
25295        let mut iter = self.clone();
25296        iter.pos = 0;
25297        for attr in iter {
25298            if let FqPieAttrs::Bytemode(val) = attr? {
25299                return Ok(val);
25300            }
25301        }
25302        Err(ErrorContext::new_missing(
25303            "FqPieAttrs",
25304            "Bytemode",
25305            self.orig_loc,
25306            self.buf.as_ptr() as usize,
25307        ))
25308    }
25309    pub fn get_dq_rate_estimator(&self) -> Result<u32, ErrorContext> {
25310        let mut iter = self.clone();
25311        iter.pos = 0;
25312        for attr in iter {
25313            if let FqPieAttrs::DqRateEstimator(val) = attr? {
25314                return Ok(val);
25315            }
25316        }
25317        Err(ErrorContext::new_missing(
25318            "FqPieAttrs",
25319            "DqRateEstimator",
25320            self.orig_loc,
25321            self.buf.as_ptr() as usize,
25322        ))
25323    }
25324}
25325impl FqPieAttrs {
25326    pub fn new<'a>(buf: &'a [u8]) -> IterableFqPieAttrs<'a> {
25327        IterableFqPieAttrs::with_loc(buf, buf.as_ptr() as usize)
25328    }
25329    fn attr_from_type(r#type: u16) -> Option<&'static str> {
25330        let res = match r#type {
25331            1u16 => "Limit",
25332            2u16 => "Flows",
25333            3u16 => "Target",
25334            4u16 => "Tupdate",
25335            5u16 => "Alpha",
25336            6u16 => "Beta",
25337            7u16 => "Quantum",
25338            8u16 => "MemoryLimit",
25339            9u16 => "EcnProb",
25340            10u16 => "Ecn",
25341            11u16 => "Bytemode",
25342            12u16 => "DqRateEstimator",
25343            _ => return None,
25344        };
25345        Some(res)
25346    }
25347}
25348#[derive(Clone, Copy, Default)]
25349pub struct IterableFqPieAttrs<'a> {
25350    buf: &'a [u8],
25351    pos: usize,
25352    orig_loc: usize,
25353}
25354impl<'a> IterableFqPieAttrs<'a> {
25355    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
25356        Self {
25357            buf,
25358            pos: 0,
25359            orig_loc,
25360        }
25361    }
25362    pub fn get_buf(&self) -> &'a [u8] {
25363        self.buf
25364    }
25365}
25366impl<'a> Iterator for IterableFqPieAttrs<'a> {
25367    type Item = Result<FqPieAttrs, ErrorContext>;
25368    fn next(&mut self) -> Option<Self::Item> {
25369        let pos = self.pos;
25370        let mut r#type;
25371        loop {
25372            r#type = None;
25373            if self.buf.len() == self.pos {
25374                return None;
25375            }
25376            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
25377                break;
25378            };
25379            r#type = Some(header.r#type);
25380            let res = match header.r#type {
25381                1u16 => FqPieAttrs::Limit({
25382                    let res = parse_u32(next);
25383                    let Some(val) = res else { break };
25384                    val
25385                }),
25386                2u16 => FqPieAttrs::Flows({
25387                    let res = parse_u32(next);
25388                    let Some(val) = res else { break };
25389                    val
25390                }),
25391                3u16 => FqPieAttrs::Target({
25392                    let res = parse_u32(next);
25393                    let Some(val) = res else { break };
25394                    val
25395                }),
25396                4u16 => FqPieAttrs::Tupdate({
25397                    let res = parse_u32(next);
25398                    let Some(val) = res else { break };
25399                    val
25400                }),
25401                5u16 => FqPieAttrs::Alpha({
25402                    let res = parse_u32(next);
25403                    let Some(val) = res else { break };
25404                    val
25405                }),
25406                6u16 => FqPieAttrs::Beta({
25407                    let res = parse_u32(next);
25408                    let Some(val) = res else { break };
25409                    val
25410                }),
25411                7u16 => FqPieAttrs::Quantum({
25412                    let res = parse_u32(next);
25413                    let Some(val) = res else { break };
25414                    val
25415                }),
25416                8u16 => FqPieAttrs::MemoryLimit({
25417                    let res = parse_u32(next);
25418                    let Some(val) = res else { break };
25419                    val
25420                }),
25421                9u16 => FqPieAttrs::EcnProb({
25422                    let res = parse_u32(next);
25423                    let Some(val) = res else { break };
25424                    val
25425                }),
25426                10u16 => FqPieAttrs::Ecn({
25427                    let res = parse_u32(next);
25428                    let Some(val) = res else { break };
25429                    val
25430                }),
25431                11u16 => FqPieAttrs::Bytemode({
25432                    let res = parse_u32(next);
25433                    let Some(val) = res else { break };
25434                    val
25435                }),
25436                12u16 => FqPieAttrs::DqRateEstimator({
25437                    let res = parse_u32(next);
25438                    let Some(val) = res else { break };
25439                    val
25440                }),
25441                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
25442                n => continue,
25443            };
25444            return Some(Ok(res));
25445        }
25446        Some(Err(ErrorContext::new(
25447            "FqPieAttrs",
25448            r#type.and_then(|t| FqPieAttrs::attr_from_type(t)),
25449            self.orig_loc,
25450            self.buf.as_ptr().wrapping_add(pos) as usize,
25451        )))
25452    }
25453}
25454impl std::fmt::Debug for IterableFqPieAttrs<'_> {
25455    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25456        let mut fmt = f.debug_struct("FqPieAttrs");
25457        for attr in self.clone() {
25458            let attr = match attr {
25459                Ok(a) => a,
25460                Err(err) => {
25461                    fmt.finish()?;
25462                    f.write_str("Err(")?;
25463                    err.fmt(f)?;
25464                    return f.write_str(")");
25465                }
25466            };
25467            match attr {
25468                FqPieAttrs::Limit(val) => fmt.field("Limit", &val),
25469                FqPieAttrs::Flows(val) => fmt.field("Flows", &val),
25470                FqPieAttrs::Target(val) => fmt.field("Target", &val),
25471                FqPieAttrs::Tupdate(val) => fmt.field("Tupdate", &val),
25472                FqPieAttrs::Alpha(val) => fmt.field("Alpha", &val),
25473                FqPieAttrs::Beta(val) => fmt.field("Beta", &val),
25474                FqPieAttrs::Quantum(val) => fmt.field("Quantum", &val),
25475                FqPieAttrs::MemoryLimit(val) => fmt.field("MemoryLimit", &val),
25476                FqPieAttrs::EcnProb(val) => fmt.field("EcnProb", &val),
25477                FqPieAttrs::Ecn(val) => fmt.field("Ecn", &val),
25478                FqPieAttrs::Bytemode(val) => fmt.field("Bytemode", &val),
25479                FqPieAttrs::DqRateEstimator(val) => fmt.field("DqRateEstimator", &val),
25480            };
25481        }
25482        fmt.finish()
25483    }
25484}
25485impl IterableFqPieAttrs<'_> {
25486    pub fn lookup_attr(
25487        &self,
25488        offset: usize,
25489        missing_type: Option<u16>,
25490    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
25491        let mut stack = Vec::new();
25492        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
25493        if missing_type.is_some() && cur == offset {
25494            stack.push(("FqPieAttrs", offset));
25495            return (
25496                stack,
25497                missing_type.and_then(|t| FqPieAttrs::attr_from_type(t)),
25498            );
25499        }
25500        if cur > offset || cur + self.buf.len() < offset {
25501            return (stack, None);
25502        }
25503        let mut attrs = self.clone();
25504        let mut last_off = cur + attrs.pos;
25505        while let Some(attr) = attrs.next() {
25506            let Ok(attr) = attr else { break };
25507            match attr {
25508                FqPieAttrs::Limit(val) => {
25509                    if last_off == offset {
25510                        stack.push(("Limit", last_off));
25511                        break;
25512                    }
25513                }
25514                FqPieAttrs::Flows(val) => {
25515                    if last_off == offset {
25516                        stack.push(("Flows", last_off));
25517                        break;
25518                    }
25519                }
25520                FqPieAttrs::Target(val) => {
25521                    if last_off == offset {
25522                        stack.push(("Target", last_off));
25523                        break;
25524                    }
25525                }
25526                FqPieAttrs::Tupdate(val) => {
25527                    if last_off == offset {
25528                        stack.push(("Tupdate", last_off));
25529                        break;
25530                    }
25531                }
25532                FqPieAttrs::Alpha(val) => {
25533                    if last_off == offset {
25534                        stack.push(("Alpha", last_off));
25535                        break;
25536                    }
25537                }
25538                FqPieAttrs::Beta(val) => {
25539                    if last_off == offset {
25540                        stack.push(("Beta", last_off));
25541                        break;
25542                    }
25543                }
25544                FqPieAttrs::Quantum(val) => {
25545                    if last_off == offset {
25546                        stack.push(("Quantum", last_off));
25547                        break;
25548                    }
25549                }
25550                FqPieAttrs::MemoryLimit(val) => {
25551                    if last_off == offset {
25552                        stack.push(("MemoryLimit", last_off));
25553                        break;
25554                    }
25555                }
25556                FqPieAttrs::EcnProb(val) => {
25557                    if last_off == offset {
25558                        stack.push(("EcnProb", last_off));
25559                        break;
25560                    }
25561                }
25562                FqPieAttrs::Ecn(val) => {
25563                    if last_off == offset {
25564                        stack.push(("Ecn", last_off));
25565                        break;
25566                    }
25567                }
25568                FqPieAttrs::Bytemode(val) => {
25569                    if last_off == offset {
25570                        stack.push(("Bytemode", last_off));
25571                        break;
25572                    }
25573                }
25574                FqPieAttrs::DqRateEstimator(val) => {
25575                    if last_off == offset {
25576                        stack.push(("DqRateEstimator", last_off));
25577                        break;
25578                    }
25579                }
25580                _ => {}
25581            };
25582            last_off = cur + attrs.pos;
25583        }
25584        if !stack.is_empty() {
25585            stack.push(("FqPieAttrs", cur));
25586        }
25587        (stack, None)
25588    }
25589}
25590#[derive(Clone)]
25591pub enum NetemAttrs<'a> {
25592    Corr(TcNetemCorr),
25593    DelayDist(&'a [u8]),
25594    Reorder(TcNetemReorder),
25595    Corrupt(TcNetemCorrupt),
25596    Loss(IterableNetemLossAttrs<'a>),
25597    Rate(TcNetemRate),
25598    Ecn(u32),
25599    Rate64(u64),
25600    Pad(u32),
25601    Latency64(i64),
25602    Jitter64(i64),
25603    Slot(TcNetemSlot),
25604    SlotDist(&'a [u8]),
25605    PrngSeed(u64),
25606}
25607impl<'a> IterableNetemAttrs<'a> {
25608    pub fn get_corr(&self) -> Result<TcNetemCorr, ErrorContext> {
25609        let mut iter = self.clone();
25610        iter.pos = 0;
25611        for attr in iter {
25612            if let NetemAttrs::Corr(val) = attr? {
25613                return Ok(val);
25614            }
25615        }
25616        Err(ErrorContext::new_missing(
25617            "NetemAttrs",
25618            "Corr",
25619            self.orig_loc,
25620            self.buf.as_ptr() as usize,
25621        ))
25622    }
25623    pub fn get_delay_dist(&self) -> Result<&'a [u8], ErrorContext> {
25624        let mut iter = self.clone();
25625        iter.pos = 0;
25626        for attr in iter {
25627            if let NetemAttrs::DelayDist(val) = attr? {
25628                return Ok(val);
25629            }
25630        }
25631        Err(ErrorContext::new_missing(
25632            "NetemAttrs",
25633            "DelayDist",
25634            self.orig_loc,
25635            self.buf.as_ptr() as usize,
25636        ))
25637    }
25638    pub fn get_reorder(&self) -> Result<TcNetemReorder, ErrorContext> {
25639        let mut iter = self.clone();
25640        iter.pos = 0;
25641        for attr in iter {
25642            if let NetemAttrs::Reorder(val) = attr? {
25643                return Ok(val);
25644            }
25645        }
25646        Err(ErrorContext::new_missing(
25647            "NetemAttrs",
25648            "Reorder",
25649            self.orig_loc,
25650            self.buf.as_ptr() as usize,
25651        ))
25652    }
25653    pub fn get_corrupt(&self) -> Result<TcNetemCorrupt, ErrorContext> {
25654        let mut iter = self.clone();
25655        iter.pos = 0;
25656        for attr in iter {
25657            if let NetemAttrs::Corrupt(val) = attr? {
25658                return Ok(val);
25659            }
25660        }
25661        Err(ErrorContext::new_missing(
25662            "NetemAttrs",
25663            "Corrupt",
25664            self.orig_loc,
25665            self.buf.as_ptr() as usize,
25666        ))
25667    }
25668    pub fn get_loss(&self) -> Result<IterableNetemLossAttrs<'a>, ErrorContext> {
25669        let mut iter = self.clone();
25670        iter.pos = 0;
25671        for attr in iter {
25672            if let NetemAttrs::Loss(val) = attr? {
25673                return Ok(val);
25674            }
25675        }
25676        Err(ErrorContext::new_missing(
25677            "NetemAttrs",
25678            "Loss",
25679            self.orig_loc,
25680            self.buf.as_ptr() as usize,
25681        ))
25682    }
25683    pub fn get_rate(&self) -> Result<TcNetemRate, ErrorContext> {
25684        let mut iter = self.clone();
25685        iter.pos = 0;
25686        for attr in iter {
25687            if let NetemAttrs::Rate(val) = attr? {
25688                return Ok(val);
25689            }
25690        }
25691        Err(ErrorContext::new_missing(
25692            "NetemAttrs",
25693            "Rate",
25694            self.orig_loc,
25695            self.buf.as_ptr() as usize,
25696        ))
25697    }
25698    pub fn get_ecn(&self) -> Result<u32, ErrorContext> {
25699        let mut iter = self.clone();
25700        iter.pos = 0;
25701        for attr in iter {
25702            if let NetemAttrs::Ecn(val) = attr? {
25703                return Ok(val);
25704            }
25705        }
25706        Err(ErrorContext::new_missing(
25707            "NetemAttrs",
25708            "Ecn",
25709            self.orig_loc,
25710            self.buf.as_ptr() as usize,
25711        ))
25712    }
25713    pub fn get_rate64(&self) -> Result<u64, ErrorContext> {
25714        let mut iter = self.clone();
25715        iter.pos = 0;
25716        for attr in iter {
25717            if let NetemAttrs::Rate64(val) = attr? {
25718                return Ok(val);
25719            }
25720        }
25721        Err(ErrorContext::new_missing(
25722            "NetemAttrs",
25723            "Rate64",
25724            self.orig_loc,
25725            self.buf.as_ptr() as usize,
25726        ))
25727    }
25728    pub fn get_pad(&self) -> Result<u32, ErrorContext> {
25729        let mut iter = self.clone();
25730        iter.pos = 0;
25731        for attr in iter {
25732            if let NetemAttrs::Pad(val) = attr? {
25733                return Ok(val);
25734            }
25735        }
25736        Err(ErrorContext::new_missing(
25737            "NetemAttrs",
25738            "Pad",
25739            self.orig_loc,
25740            self.buf.as_ptr() as usize,
25741        ))
25742    }
25743    pub fn get_latency64(&self) -> Result<i64, ErrorContext> {
25744        let mut iter = self.clone();
25745        iter.pos = 0;
25746        for attr in iter {
25747            if let NetemAttrs::Latency64(val) = attr? {
25748                return Ok(val);
25749            }
25750        }
25751        Err(ErrorContext::new_missing(
25752            "NetemAttrs",
25753            "Latency64",
25754            self.orig_loc,
25755            self.buf.as_ptr() as usize,
25756        ))
25757    }
25758    pub fn get_jitter64(&self) -> Result<i64, ErrorContext> {
25759        let mut iter = self.clone();
25760        iter.pos = 0;
25761        for attr in iter {
25762            if let NetemAttrs::Jitter64(val) = attr? {
25763                return Ok(val);
25764            }
25765        }
25766        Err(ErrorContext::new_missing(
25767            "NetemAttrs",
25768            "Jitter64",
25769            self.orig_loc,
25770            self.buf.as_ptr() as usize,
25771        ))
25772    }
25773    pub fn get_slot(&self) -> Result<TcNetemSlot, ErrorContext> {
25774        let mut iter = self.clone();
25775        iter.pos = 0;
25776        for attr in iter {
25777            if let NetemAttrs::Slot(val) = attr? {
25778                return Ok(val);
25779            }
25780        }
25781        Err(ErrorContext::new_missing(
25782            "NetemAttrs",
25783            "Slot",
25784            self.orig_loc,
25785            self.buf.as_ptr() as usize,
25786        ))
25787    }
25788    pub fn get_slot_dist(&self) -> Result<&'a [u8], ErrorContext> {
25789        let mut iter = self.clone();
25790        iter.pos = 0;
25791        for attr in iter {
25792            if let NetemAttrs::SlotDist(val) = attr? {
25793                return Ok(val);
25794            }
25795        }
25796        Err(ErrorContext::new_missing(
25797            "NetemAttrs",
25798            "SlotDist",
25799            self.orig_loc,
25800            self.buf.as_ptr() as usize,
25801        ))
25802    }
25803    pub fn get_prng_seed(&self) -> Result<u64, ErrorContext> {
25804        let mut iter = self.clone();
25805        iter.pos = 0;
25806        for attr in iter {
25807            if let NetemAttrs::PrngSeed(val) = attr? {
25808                return Ok(val);
25809            }
25810        }
25811        Err(ErrorContext::new_missing(
25812            "NetemAttrs",
25813            "PrngSeed",
25814            self.orig_loc,
25815            self.buf.as_ptr() as usize,
25816        ))
25817    }
25818}
25819impl NetemAttrs<'_> {
25820    pub fn new<'a>(buf: &'a [u8]) -> IterableNetemAttrs<'a> {
25821        IterableNetemAttrs::with_loc(buf, buf.as_ptr() as usize)
25822    }
25823    fn attr_from_type(r#type: u16) -> Option<&'static str> {
25824        let res = match r#type {
25825            1u16 => "Corr",
25826            2u16 => "DelayDist",
25827            3u16 => "Reorder",
25828            4u16 => "Corrupt",
25829            5u16 => "Loss",
25830            6u16 => "Rate",
25831            7u16 => "Ecn",
25832            8u16 => "Rate64",
25833            9u16 => "Pad",
25834            10u16 => "Latency64",
25835            11u16 => "Jitter64",
25836            12u16 => "Slot",
25837            13u16 => "SlotDist",
25838            14u16 => "PrngSeed",
25839            _ => return None,
25840        };
25841        Some(res)
25842    }
25843}
25844#[derive(Clone, Copy, Default)]
25845pub struct IterableNetemAttrs<'a> {
25846    buf: &'a [u8],
25847    pos: usize,
25848    orig_loc: usize,
25849}
25850impl<'a> IterableNetemAttrs<'a> {
25851    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
25852        Self {
25853            buf,
25854            pos: 0,
25855            orig_loc,
25856        }
25857    }
25858    pub fn get_buf(&self) -> &'a [u8] {
25859        self.buf
25860    }
25861}
25862impl<'a> Iterator for IterableNetemAttrs<'a> {
25863    type Item = Result<NetemAttrs<'a>, ErrorContext>;
25864    fn next(&mut self) -> Option<Self::Item> {
25865        let pos = self.pos;
25866        let mut r#type;
25867        loop {
25868            r#type = None;
25869            if self.buf.len() == self.pos {
25870                return None;
25871            }
25872            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
25873                break;
25874            };
25875            r#type = Some(header.r#type);
25876            let res = match header.r#type {
25877                1u16 => NetemAttrs::Corr({
25878                    let res = Some(TcNetemCorr::new_from_zeroed(next));
25879                    let Some(val) = res else { break };
25880                    val
25881                }),
25882                2u16 => NetemAttrs::DelayDist({
25883                    let res = Some(next);
25884                    let Some(val) = res else { break };
25885                    val
25886                }),
25887                3u16 => NetemAttrs::Reorder({
25888                    let res = Some(TcNetemReorder::new_from_zeroed(next));
25889                    let Some(val) = res else { break };
25890                    val
25891                }),
25892                4u16 => NetemAttrs::Corrupt({
25893                    let res = Some(TcNetemCorrupt::new_from_zeroed(next));
25894                    let Some(val) = res else { break };
25895                    val
25896                }),
25897                5u16 => NetemAttrs::Loss({
25898                    let res = Some(IterableNetemLossAttrs::with_loc(next, self.orig_loc));
25899                    let Some(val) = res else { break };
25900                    val
25901                }),
25902                6u16 => NetemAttrs::Rate({
25903                    let res = Some(TcNetemRate::new_from_zeroed(next));
25904                    let Some(val) = res else { break };
25905                    val
25906                }),
25907                7u16 => NetemAttrs::Ecn({
25908                    let res = parse_u32(next);
25909                    let Some(val) = res else { break };
25910                    val
25911                }),
25912                8u16 => NetemAttrs::Rate64({
25913                    let res = parse_u64(next);
25914                    let Some(val) = res else { break };
25915                    val
25916                }),
25917                9u16 => NetemAttrs::Pad({
25918                    let res = parse_u32(next);
25919                    let Some(val) = res else { break };
25920                    val
25921                }),
25922                10u16 => NetemAttrs::Latency64({
25923                    let res = parse_i64(next);
25924                    let Some(val) = res else { break };
25925                    val
25926                }),
25927                11u16 => NetemAttrs::Jitter64({
25928                    let res = parse_i64(next);
25929                    let Some(val) = res else { break };
25930                    val
25931                }),
25932                12u16 => NetemAttrs::Slot({
25933                    let res = Some(TcNetemSlot::new_from_zeroed(next));
25934                    let Some(val) = res else { break };
25935                    val
25936                }),
25937                13u16 => NetemAttrs::SlotDist({
25938                    let res = Some(next);
25939                    let Some(val) = res else { break };
25940                    val
25941                }),
25942                14u16 => NetemAttrs::PrngSeed({
25943                    let res = parse_u64(next);
25944                    let Some(val) = res else { break };
25945                    val
25946                }),
25947                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
25948                n => continue,
25949            };
25950            return Some(Ok(res));
25951        }
25952        Some(Err(ErrorContext::new(
25953            "NetemAttrs",
25954            r#type.and_then(|t| NetemAttrs::attr_from_type(t)),
25955            self.orig_loc,
25956            self.buf.as_ptr().wrapping_add(pos) as usize,
25957        )))
25958    }
25959}
25960impl<'a> std::fmt::Debug for IterableNetemAttrs<'_> {
25961    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25962        let mut fmt = f.debug_struct("NetemAttrs");
25963        for attr in self.clone() {
25964            let attr = match attr {
25965                Ok(a) => a,
25966                Err(err) => {
25967                    fmt.finish()?;
25968                    f.write_str("Err(")?;
25969                    err.fmt(f)?;
25970                    return f.write_str(")");
25971                }
25972            };
25973            match attr {
25974                NetemAttrs::Corr(val) => fmt.field("Corr", &val),
25975                NetemAttrs::DelayDist(val) => fmt.field("DelayDist", &val),
25976                NetemAttrs::Reorder(val) => fmt.field("Reorder", &val),
25977                NetemAttrs::Corrupt(val) => fmt.field("Corrupt", &val),
25978                NetemAttrs::Loss(val) => fmt.field("Loss", &val),
25979                NetemAttrs::Rate(val) => fmt.field("Rate", &val),
25980                NetemAttrs::Ecn(val) => fmt.field("Ecn", &val),
25981                NetemAttrs::Rate64(val) => fmt.field("Rate64", &val),
25982                NetemAttrs::Pad(val) => fmt.field("Pad", &val),
25983                NetemAttrs::Latency64(val) => fmt.field("Latency64", &val),
25984                NetemAttrs::Jitter64(val) => fmt.field("Jitter64", &val),
25985                NetemAttrs::Slot(val) => fmt.field("Slot", &val),
25986                NetemAttrs::SlotDist(val) => fmt.field("SlotDist", &val),
25987                NetemAttrs::PrngSeed(val) => fmt.field("PrngSeed", &val),
25988            };
25989        }
25990        fmt.finish()
25991    }
25992}
25993impl IterableNetemAttrs<'_> {
25994    pub fn lookup_attr(
25995        &self,
25996        offset: usize,
25997        missing_type: Option<u16>,
25998    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
25999        let mut stack = Vec::new();
26000        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
26001        if missing_type.is_some() && cur == offset {
26002            stack.push(("NetemAttrs", offset));
26003            return (
26004                stack,
26005                missing_type.and_then(|t| NetemAttrs::attr_from_type(t)),
26006            );
26007        }
26008        if cur > offset || cur + self.buf.len() < offset {
26009            return (stack, None);
26010        }
26011        let mut attrs = self.clone();
26012        let mut last_off = cur + attrs.pos;
26013        let mut missing = None;
26014        while let Some(attr) = attrs.next() {
26015            let Ok(attr) = attr else { break };
26016            match attr {
26017                NetemAttrs::Corr(val) => {
26018                    if last_off == offset {
26019                        stack.push(("Corr", last_off));
26020                        break;
26021                    }
26022                }
26023                NetemAttrs::DelayDist(val) => {
26024                    if last_off == offset {
26025                        stack.push(("DelayDist", last_off));
26026                        break;
26027                    }
26028                }
26029                NetemAttrs::Reorder(val) => {
26030                    if last_off == offset {
26031                        stack.push(("Reorder", last_off));
26032                        break;
26033                    }
26034                }
26035                NetemAttrs::Corrupt(val) => {
26036                    if last_off == offset {
26037                        stack.push(("Corrupt", last_off));
26038                        break;
26039                    }
26040                }
26041                NetemAttrs::Loss(val) => {
26042                    (stack, missing) = val.lookup_attr(offset, missing_type);
26043                    if !stack.is_empty() {
26044                        break;
26045                    }
26046                }
26047                NetemAttrs::Rate(val) => {
26048                    if last_off == offset {
26049                        stack.push(("Rate", last_off));
26050                        break;
26051                    }
26052                }
26053                NetemAttrs::Ecn(val) => {
26054                    if last_off == offset {
26055                        stack.push(("Ecn", last_off));
26056                        break;
26057                    }
26058                }
26059                NetemAttrs::Rate64(val) => {
26060                    if last_off == offset {
26061                        stack.push(("Rate64", last_off));
26062                        break;
26063                    }
26064                }
26065                NetemAttrs::Pad(val) => {
26066                    if last_off == offset {
26067                        stack.push(("Pad", last_off));
26068                        break;
26069                    }
26070                }
26071                NetemAttrs::Latency64(val) => {
26072                    if last_off == offset {
26073                        stack.push(("Latency64", last_off));
26074                        break;
26075                    }
26076                }
26077                NetemAttrs::Jitter64(val) => {
26078                    if last_off == offset {
26079                        stack.push(("Jitter64", last_off));
26080                        break;
26081                    }
26082                }
26083                NetemAttrs::Slot(val) => {
26084                    if last_off == offset {
26085                        stack.push(("Slot", last_off));
26086                        break;
26087                    }
26088                }
26089                NetemAttrs::SlotDist(val) => {
26090                    if last_off == offset {
26091                        stack.push(("SlotDist", last_off));
26092                        break;
26093                    }
26094                }
26095                NetemAttrs::PrngSeed(val) => {
26096                    if last_off == offset {
26097                        stack.push(("PrngSeed", last_off));
26098                        break;
26099                    }
26100                }
26101                _ => {}
26102            };
26103            last_off = cur + attrs.pos;
26104        }
26105        if !stack.is_empty() {
26106            stack.push(("NetemAttrs", cur));
26107        }
26108        (stack, missing)
26109    }
26110}
26111#[derive(Clone)]
26112pub enum NetemLossAttrs {
26113    #[doc = "General Intuitive \\- 4 state model"]
26114    Gi(TcNetemGimodel),
26115    #[doc = "Gilbert Elliot models"]
26116    Ge(TcNetemGemodel),
26117}
26118impl<'a> IterableNetemLossAttrs<'a> {
26119    #[doc = "General Intuitive \\- 4 state model"]
26120    pub fn get_gi(&self) -> Result<TcNetemGimodel, ErrorContext> {
26121        let mut iter = self.clone();
26122        iter.pos = 0;
26123        for attr in iter {
26124            if let NetemLossAttrs::Gi(val) = attr? {
26125                return Ok(val);
26126            }
26127        }
26128        Err(ErrorContext::new_missing(
26129            "NetemLossAttrs",
26130            "Gi",
26131            self.orig_loc,
26132            self.buf.as_ptr() as usize,
26133        ))
26134    }
26135    #[doc = "Gilbert Elliot models"]
26136    pub fn get_ge(&self) -> Result<TcNetemGemodel, ErrorContext> {
26137        let mut iter = self.clone();
26138        iter.pos = 0;
26139        for attr in iter {
26140            if let NetemLossAttrs::Ge(val) = attr? {
26141                return Ok(val);
26142            }
26143        }
26144        Err(ErrorContext::new_missing(
26145            "NetemLossAttrs",
26146            "Ge",
26147            self.orig_loc,
26148            self.buf.as_ptr() as usize,
26149        ))
26150    }
26151}
26152impl NetemLossAttrs {
26153    pub fn new<'a>(buf: &'a [u8]) -> IterableNetemLossAttrs<'a> {
26154        IterableNetemLossAttrs::with_loc(buf, buf.as_ptr() as usize)
26155    }
26156    fn attr_from_type(r#type: u16) -> Option<&'static str> {
26157        let res = match r#type {
26158            1u16 => "Gi",
26159            2u16 => "Ge",
26160            _ => return None,
26161        };
26162        Some(res)
26163    }
26164}
26165#[derive(Clone, Copy, Default)]
26166pub struct IterableNetemLossAttrs<'a> {
26167    buf: &'a [u8],
26168    pos: usize,
26169    orig_loc: usize,
26170}
26171impl<'a> IterableNetemLossAttrs<'a> {
26172    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
26173        Self {
26174            buf,
26175            pos: 0,
26176            orig_loc,
26177        }
26178    }
26179    pub fn get_buf(&self) -> &'a [u8] {
26180        self.buf
26181    }
26182}
26183impl<'a> Iterator for IterableNetemLossAttrs<'a> {
26184    type Item = Result<NetemLossAttrs, ErrorContext>;
26185    fn next(&mut self) -> Option<Self::Item> {
26186        let pos = self.pos;
26187        let mut r#type;
26188        loop {
26189            r#type = None;
26190            if self.buf.len() == self.pos {
26191                return None;
26192            }
26193            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
26194                break;
26195            };
26196            r#type = Some(header.r#type);
26197            let res = match header.r#type {
26198                1u16 => NetemLossAttrs::Gi({
26199                    let res = Some(TcNetemGimodel::new_from_zeroed(next));
26200                    let Some(val) = res else { break };
26201                    val
26202                }),
26203                2u16 => NetemLossAttrs::Ge({
26204                    let res = Some(TcNetemGemodel::new_from_zeroed(next));
26205                    let Some(val) = res else { break };
26206                    val
26207                }),
26208                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
26209                n => continue,
26210            };
26211            return Some(Ok(res));
26212        }
26213        Some(Err(ErrorContext::new(
26214            "NetemLossAttrs",
26215            r#type.and_then(|t| NetemLossAttrs::attr_from_type(t)),
26216            self.orig_loc,
26217            self.buf.as_ptr().wrapping_add(pos) as usize,
26218        )))
26219    }
26220}
26221impl std::fmt::Debug for IterableNetemLossAttrs<'_> {
26222    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26223        let mut fmt = f.debug_struct("NetemLossAttrs");
26224        for attr in self.clone() {
26225            let attr = match attr {
26226                Ok(a) => a,
26227                Err(err) => {
26228                    fmt.finish()?;
26229                    f.write_str("Err(")?;
26230                    err.fmt(f)?;
26231                    return f.write_str(")");
26232                }
26233            };
26234            match attr {
26235                NetemLossAttrs::Gi(val) => fmt.field("Gi", &val),
26236                NetemLossAttrs::Ge(val) => fmt.field("Ge", &val),
26237            };
26238        }
26239        fmt.finish()
26240    }
26241}
26242impl IterableNetemLossAttrs<'_> {
26243    pub fn lookup_attr(
26244        &self,
26245        offset: usize,
26246        missing_type: Option<u16>,
26247    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
26248        let mut stack = Vec::new();
26249        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
26250        if missing_type.is_some() && cur == offset {
26251            stack.push(("NetemLossAttrs", offset));
26252            return (
26253                stack,
26254                missing_type.and_then(|t| NetemLossAttrs::attr_from_type(t)),
26255            );
26256        }
26257        if cur > offset || cur + self.buf.len() < offset {
26258            return (stack, None);
26259        }
26260        let mut attrs = self.clone();
26261        let mut last_off = cur + attrs.pos;
26262        while let Some(attr) = attrs.next() {
26263            let Ok(attr) = attr else { break };
26264            match attr {
26265                NetemLossAttrs::Gi(val) => {
26266                    if last_off == offset {
26267                        stack.push(("Gi", last_off));
26268                        break;
26269                    }
26270                }
26271                NetemLossAttrs::Ge(val) => {
26272                    if last_off == offset {
26273                        stack.push(("Ge", last_off));
26274                        break;
26275                    }
26276                }
26277                _ => {}
26278            };
26279            last_off = cur + attrs.pos;
26280        }
26281        if !stack.is_empty() {
26282            stack.push(("NetemLossAttrs", cur));
26283        }
26284        (stack, None)
26285    }
26286}
26287#[derive(Clone)]
26288pub enum PieAttrs {
26289    Target(u32),
26290    Limit(u32),
26291    Tupdate(u32),
26292    Alpha(u32),
26293    Beta(u32),
26294    Ecn(u32),
26295    Bytemode(u32),
26296    DqRateEstimator(u32),
26297}
26298impl<'a> IterablePieAttrs<'a> {
26299    pub fn get_target(&self) -> Result<u32, ErrorContext> {
26300        let mut iter = self.clone();
26301        iter.pos = 0;
26302        for attr in iter {
26303            if let PieAttrs::Target(val) = attr? {
26304                return Ok(val);
26305            }
26306        }
26307        Err(ErrorContext::new_missing(
26308            "PieAttrs",
26309            "Target",
26310            self.orig_loc,
26311            self.buf.as_ptr() as usize,
26312        ))
26313    }
26314    pub fn get_limit(&self) -> Result<u32, ErrorContext> {
26315        let mut iter = self.clone();
26316        iter.pos = 0;
26317        for attr in iter {
26318            if let PieAttrs::Limit(val) = attr? {
26319                return Ok(val);
26320            }
26321        }
26322        Err(ErrorContext::new_missing(
26323            "PieAttrs",
26324            "Limit",
26325            self.orig_loc,
26326            self.buf.as_ptr() as usize,
26327        ))
26328    }
26329    pub fn get_tupdate(&self) -> Result<u32, ErrorContext> {
26330        let mut iter = self.clone();
26331        iter.pos = 0;
26332        for attr in iter {
26333            if let PieAttrs::Tupdate(val) = attr? {
26334                return Ok(val);
26335            }
26336        }
26337        Err(ErrorContext::new_missing(
26338            "PieAttrs",
26339            "Tupdate",
26340            self.orig_loc,
26341            self.buf.as_ptr() as usize,
26342        ))
26343    }
26344    pub fn get_alpha(&self) -> Result<u32, ErrorContext> {
26345        let mut iter = self.clone();
26346        iter.pos = 0;
26347        for attr in iter {
26348            if let PieAttrs::Alpha(val) = attr? {
26349                return Ok(val);
26350            }
26351        }
26352        Err(ErrorContext::new_missing(
26353            "PieAttrs",
26354            "Alpha",
26355            self.orig_loc,
26356            self.buf.as_ptr() as usize,
26357        ))
26358    }
26359    pub fn get_beta(&self) -> Result<u32, ErrorContext> {
26360        let mut iter = self.clone();
26361        iter.pos = 0;
26362        for attr in iter {
26363            if let PieAttrs::Beta(val) = attr? {
26364                return Ok(val);
26365            }
26366        }
26367        Err(ErrorContext::new_missing(
26368            "PieAttrs",
26369            "Beta",
26370            self.orig_loc,
26371            self.buf.as_ptr() as usize,
26372        ))
26373    }
26374    pub fn get_ecn(&self) -> Result<u32, ErrorContext> {
26375        let mut iter = self.clone();
26376        iter.pos = 0;
26377        for attr in iter {
26378            if let PieAttrs::Ecn(val) = attr? {
26379                return Ok(val);
26380            }
26381        }
26382        Err(ErrorContext::new_missing(
26383            "PieAttrs",
26384            "Ecn",
26385            self.orig_loc,
26386            self.buf.as_ptr() as usize,
26387        ))
26388    }
26389    pub fn get_bytemode(&self) -> Result<u32, ErrorContext> {
26390        let mut iter = self.clone();
26391        iter.pos = 0;
26392        for attr in iter {
26393            if let PieAttrs::Bytemode(val) = attr? {
26394                return Ok(val);
26395            }
26396        }
26397        Err(ErrorContext::new_missing(
26398            "PieAttrs",
26399            "Bytemode",
26400            self.orig_loc,
26401            self.buf.as_ptr() as usize,
26402        ))
26403    }
26404    pub fn get_dq_rate_estimator(&self) -> Result<u32, ErrorContext> {
26405        let mut iter = self.clone();
26406        iter.pos = 0;
26407        for attr in iter {
26408            if let PieAttrs::DqRateEstimator(val) = attr? {
26409                return Ok(val);
26410            }
26411        }
26412        Err(ErrorContext::new_missing(
26413            "PieAttrs",
26414            "DqRateEstimator",
26415            self.orig_loc,
26416            self.buf.as_ptr() as usize,
26417        ))
26418    }
26419}
26420impl PieAttrs {
26421    pub fn new<'a>(buf: &'a [u8]) -> IterablePieAttrs<'a> {
26422        IterablePieAttrs::with_loc(buf, buf.as_ptr() as usize)
26423    }
26424    fn attr_from_type(r#type: u16) -> Option<&'static str> {
26425        let res = match r#type {
26426            1u16 => "Target",
26427            2u16 => "Limit",
26428            3u16 => "Tupdate",
26429            4u16 => "Alpha",
26430            5u16 => "Beta",
26431            6u16 => "Ecn",
26432            7u16 => "Bytemode",
26433            8u16 => "DqRateEstimator",
26434            _ => return None,
26435        };
26436        Some(res)
26437    }
26438}
26439#[derive(Clone, Copy, Default)]
26440pub struct IterablePieAttrs<'a> {
26441    buf: &'a [u8],
26442    pos: usize,
26443    orig_loc: usize,
26444}
26445impl<'a> IterablePieAttrs<'a> {
26446    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
26447        Self {
26448            buf,
26449            pos: 0,
26450            orig_loc,
26451        }
26452    }
26453    pub fn get_buf(&self) -> &'a [u8] {
26454        self.buf
26455    }
26456}
26457impl<'a> Iterator for IterablePieAttrs<'a> {
26458    type Item = Result<PieAttrs, ErrorContext>;
26459    fn next(&mut self) -> Option<Self::Item> {
26460        let pos = self.pos;
26461        let mut r#type;
26462        loop {
26463            r#type = None;
26464            if self.buf.len() == self.pos {
26465                return None;
26466            }
26467            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
26468                break;
26469            };
26470            r#type = Some(header.r#type);
26471            let res = match header.r#type {
26472                1u16 => PieAttrs::Target({
26473                    let res = parse_u32(next);
26474                    let Some(val) = res else { break };
26475                    val
26476                }),
26477                2u16 => PieAttrs::Limit({
26478                    let res = parse_u32(next);
26479                    let Some(val) = res else { break };
26480                    val
26481                }),
26482                3u16 => PieAttrs::Tupdate({
26483                    let res = parse_u32(next);
26484                    let Some(val) = res else { break };
26485                    val
26486                }),
26487                4u16 => PieAttrs::Alpha({
26488                    let res = parse_u32(next);
26489                    let Some(val) = res else { break };
26490                    val
26491                }),
26492                5u16 => PieAttrs::Beta({
26493                    let res = parse_u32(next);
26494                    let Some(val) = res else { break };
26495                    val
26496                }),
26497                6u16 => PieAttrs::Ecn({
26498                    let res = parse_u32(next);
26499                    let Some(val) = res else { break };
26500                    val
26501                }),
26502                7u16 => PieAttrs::Bytemode({
26503                    let res = parse_u32(next);
26504                    let Some(val) = res else { break };
26505                    val
26506                }),
26507                8u16 => PieAttrs::DqRateEstimator({
26508                    let res = parse_u32(next);
26509                    let Some(val) = res else { break };
26510                    val
26511                }),
26512                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
26513                n => continue,
26514            };
26515            return Some(Ok(res));
26516        }
26517        Some(Err(ErrorContext::new(
26518            "PieAttrs",
26519            r#type.and_then(|t| PieAttrs::attr_from_type(t)),
26520            self.orig_loc,
26521            self.buf.as_ptr().wrapping_add(pos) as usize,
26522        )))
26523    }
26524}
26525impl std::fmt::Debug for IterablePieAttrs<'_> {
26526    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26527        let mut fmt = f.debug_struct("PieAttrs");
26528        for attr in self.clone() {
26529            let attr = match attr {
26530                Ok(a) => a,
26531                Err(err) => {
26532                    fmt.finish()?;
26533                    f.write_str("Err(")?;
26534                    err.fmt(f)?;
26535                    return f.write_str(")");
26536                }
26537            };
26538            match attr {
26539                PieAttrs::Target(val) => fmt.field("Target", &val),
26540                PieAttrs::Limit(val) => fmt.field("Limit", &val),
26541                PieAttrs::Tupdate(val) => fmt.field("Tupdate", &val),
26542                PieAttrs::Alpha(val) => fmt.field("Alpha", &val),
26543                PieAttrs::Beta(val) => fmt.field("Beta", &val),
26544                PieAttrs::Ecn(val) => fmt.field("Ecn", &val),
26545                PieAttrs::Bytemode(val) => fmt.field("Bytemode", &val),
26546                PieAttrs::DqRateEstimator(val) => fmt.field("DqRateEstimator", &val),
26547            };
26548        }
26549        fmt.finish()
26550    }
26551}
26552impl IterablePieAttrs<'_> {
26553    pub fn lookup_attr(
26554        &self,
26555        offset: usize,
26556        missing_type: Option<u16>,
26557    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
26558        let mut stack = Vec::new();
26559        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
26560        if missing_type.is_some() && cur == offset {
26561            stack.push(("PieAttrs", offset));
26562            return (
26563                stack,
26564                missing_type.and_then(|t| PieAttrs::attr_from_type(t)),
26565            );
26566        }
26567        if cur > offset || cur + self.buf.len() < offset {
26568            return (stack, None);
26569        }
26570        let mut attrs = self.clone();
26571        let mut last_off = cur + attrs.pos;
26572        while let Some(attr) = attrs.next() {
26573            let Ok(attr) = attr else { break };
26574            match attr {
26575                PieAttrs::Target(val) => {
26576                    if last_off == offset {
26577                        stack.push(("Target", last_off));
26578                        break;
26579                    }
26580                }
26581                PieAttrs::Limit(val) => {
26582                    if last_off == offset {
26583                        stack.push(("Limit", last_off));
26584                        break;
26585                    }
26586                }
26587                PieAttrs::Tupdate(val) => {
26588                    if last_off == offset {
26589                        stack.push(("Tupdate", last_off));
26590                        break;
26591                    }
26592                }
26593                PieAttrs::Alpha(val) => {
26594                    if last_off == offset {
26595                        stack.push(("Alpha", last_off));
26596                        break;
26597                    }
26598                }
26599                PieAttrs::Beta(val) => {
26600                    if last_off == offset {
26601                        stack.push(("Beta", last_off));
26602                        break;
26603                    }
26604                }
26605                PieAttrs::Ecn(val) => {
26606                    if last_off == offset {
26607                        stack.push(("Ecn", last_off));
26608                        break;
26609                    }
26610                }
26611                PieAttrs::Bytemode(val) => {
26612                    if last_off == offset {
26613                        stack.push(("Bytemode", last_off));
26614                        break;
26615                    }
26616                }
26617                PieAttrs::DqRateEstimator(val) => {
26618                    if last_off == offset {
26619                        stack.push(("DqRateEstimator", last_off));
26620                        break;
26621                    }
26622                }
26623                _ => {}
26624            };
26625            last_off = cur + attrs.pos;
26626        }
26627        if !stack.is_empty() {
26628            stack.push(("PieAttrs", cur));
26629        }
26630        (stack, None)
26631    }
26632}
26633#[derive(Clone)]
26634pub enum PoliceAttrs<'a> {
26635    Tbf(TcPolice),
26636    Rate(&'a [u8]),
26637    Peakrate(&'a [u8]),
26638    Avrate(u32),
26639    Result(u32),
26640    Tm(TcfT),
26641    Pad(&'a [u8]),
26642    Rate64(u64),
26643    Peakrate64(u64),
26644    Pktrate64(u64),
26645    Pktburst64(u64),
26646}
26647impl<'a> IterablePoliceAttrs<'a> {
26648    pub fn get_tbf(&self) -> Result<TcPolice, ErrorContext> {
26649        let mut iter = self.clone();
26650        iter.pos = 0;
26651        for attr in iter {
26652            if let PoliceAttrs::Tbf(val) = attr? {
26653                return Ok(val);
26654            }
26655        }
26656        Err(ErrorContext::new_missing(
26657            "PoliceAttrs",
26658            "Tbf",
26659            self.orig_loc,
26660            self.buf.as_ptr() as usize,
26661        ))
26662    }
26663    pub fn get_rate(&self) -> Result<&'a [u8], ErrorContext> {
26664        let mut iter = self.clone();
26665        iter.pos = 0;
26666        for attr in iter {
26667            if let PoliceAttrs::Rate(val) = attr? {
26668                return Ok(val);
26669            }
26670        }
26671        Err(ErrorContext::new_missing(
26672            "PoliceAttrs",
26673            "Rate",
26674            self.orig_loc,
26675            self.buf.as_ptr() as usize,
26676        ))
26677    }
26678    pub fn get_peakrate(&self) -> Result<&'a [u8], ErrorContext> {
26679        let mut iter = self.clone();
26680        iter.pos = 0;
26681        for attr in iter {
26682            if let PoliceAttrs::Peakrate(val) = attr? {
26683                return Ok(val);
26684            }
26685        }
26686        Err(ErrorContext::new_missing(
26687            "PoliceAttrs",
26688            "Peakrate",
26689            self.orig_loc,
26690            self.buf.as_ptr() as usize,
26691        ))
26692    }
26693    pub fn get_avrate(&self) -> Result<u32, ErrorContext> {
26694        let mut iter = self.clone();
26695        iter.pos = 0;
26696        for attr in iter {
26697            if let PoliceAttrs::Avrate(val) = attr? {
26698                return Ok(val);
26699            }
26700        }
26701        Err(ErrorContext::new_missing(
26702            "PoliceAttrs",
26703            "Avrate",
26704            self.orig_loc,
26705            self.buf.as_ptr() as usize,
26706        ))
26707    }
26708    pub fn get_result(&self) -> Result<u32, ErrorContext> {
26709        let mut iter = self.clone();
26710        iter.pos = 0;
26711        for attr in iter {
26712            if let PoliceAttrs::Result(val) = attr? {
26713                return Ok(val);
26714            }
26715        }
26716        Err(ErrorContext::new_missing(
26717            "PoliceAttrs",
26718            "Result",
26719            self.orig_loc,
26720            self.buf.as_ptr() as usize,
26721        ))
26722    }
26723    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
26724        let mut iter = self.clone();
26725        iter.pos = 0;
26726        for attr in iter {
26727            if let PoliceAttrs::Tm(val) = attr? {
26728                return Ok(val);
26729            }
26730        }
26731        Err(ErrorContext::new_missing(
26732            "PoliceAttrs",
26733            "Tm",
26734            self.orig_loc,
26735            self.buf.as_ptr() as usize,
26736        ))
26737    }
26738    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
26739        let mut iter = self.clone();
26740        iter.pos = 0;
26741        for attr in iter {
26742            if let PoliceAttrs::Pad(val) = attr? {
26743                return Ok(val);
26744            }
26745        }
26746        Err(ErrorContext::new_missing(
26747            "PoliceAttrs",
26748            "Pad",
26749            self.orig_loc,
26750            self.buf.as_ptr() as usize,
26751        ))
26752    }
26753    pub fn get_rate64(&self) -> Result<u64, ErrorContext> {
26754        let mut iter = self.clone();
26755        iter.pos = 0;
26756        for attr in iter {
26757            if let PoliceAttrs::Rate64(val) = attr? {
26758                return Ok(val);
26759            }
26760        }
26761        Err(ErrorContext::new_missing(
26762            "PoliceAttrs",
26763            "Rate64",
26764            self.orig_loc,
26765            self.buf.as_ptr() as usize,
26766        ))
26767    }
26768    pub fn get_peakrate64(&self) -> Result<u64, ErrorContext> {
26769        let mut iter = self.clone();
26770        iter.pos = 0;
26771        for attr in iter {
26772            if let PoliceAttrs::Peakrate64(val) = attr? {
26773                return Ok(val);
26774            }
26775        }
26776        Err(ErrorContext::new_missing(
26777            "PoliceAttrs",
26778            "Peakrate64",
26779            self.orig_loc,
26780            self.buf.as_ptr() as usize,
26781        ))
26782    }
26783    pub fn get_pktrate64(&self) -> Result<u64, ErrorContext> {
26784        let mut iter = self.clone();
26785        iter.pos = 0;
26786        for attr in iter {
26787            if let PoliceAttrs::Pktrate64(val) = attr? {
26788                return Ok(val);
26789            }
26790        }
26791        Err(ErrorContext::new_missing(
26792            "PoliceAttrs",
26793            "Pktrate64",
26794            self.orig_loc,
26795            self.buf.as_ptr() as usize,
26796        ))
26797    }
26798    pub fn get_pktburst64(&self) -> Result<u64, ErrorContext> {
26799        let mut iter = self.clone();
26800        iter.pos = 0;
26801        for attr in iter {
26802            if let PoliceAttrs::Pktburst64(val) = attr? {
26803                return Ok(val);
26804            }
26805        }
26806        Err(ErrorContext::new_missing(
26807            "PoliceAttrs",
26808            "Pktburst64",
26809            self.orig_loc,
26810            self.buf.as_ptr() as usize,
26811        ))
26812    }
26813}
26814impl PoliceAttrs<'_> {
26815    pub fn new<'a>(buf: &'a [u8]) -> IterablePoliceAttrs<'a> {
26816        IterablePoliceAttrs::with_loc(buf, buf.as_ptr() as usize)
26817    }
26818    fn attr_from_type(r#type: u16) -> Option<&'static str> {
26819        let res = match r#type {
26820            1u16 => "Tbf",
26821            2u16 => "Rate",
26822            3u16 => "Peakrate",
26823            4u16 => "Avrate",
26824            5u16 => "Result",
26825            6u16 => "Tm",
26826            7u16 => "Pad",
26827            8u16 => "Rate64",
26828            9u16 => "Peakrate64",
26829            10u16 => "Pktrate64",
26830            11u16 => "Pktburst64",
26831            _ => return None,
26832        };
26833        Some(res)
26834    }
26835}
26836#[derive(Clone, Copy, Default)]
26837pub struct IterablePoliceAttrs<'a> {
26838    buf: &'a [u8],
26839    pos: usize,
26840    orig_loc: usize,
26841}
26842impl<'a> IterablePoliceAttrs<'a> {
26843    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
26844        Self {
26845            buf,
26846            pos: 0,
26847            orig_loc,
26848        }
26849    }
26850    pub fn get_buf(&self) -> &'a [u8] {
26851        self.buf
26852    }
26853}
26854impl<'a> Iterator for IterablePoliceAttrs<'a> {
26855    type Item = Result<PoliceAttrs<'a>, ErrorContext>;
26856    fn next(&mut self) -> Option<Self::Item> {
26857        let pos = self.pos;
26858        let mut r#type;
26859        loop {
26860            r#type = None;
26861            if self.buf.len() == self.pos {
26862                return None;
26863            }
26864            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
26865                break;
26866            };
26867            r#type = Some(header.r#type);
26868            let res = match header.r#type {
26869                1u16 => PoliceAttrs::Tbf({
26870                    let res = Some(TcPolice::new_from_zeroed(next));
26871                    let Some(val) = res else { break };
26872                    val
26873                }),
26874                2u16 => PoliceAttrs::Rate({
26875                    let res = Some(next);
26876                    let Some(val) = res else { break };
26877                    val
26878                }),
26879                3u16 => PoliceAttrs::Peakrate({
26880                    let res = Some(next);
26881                    let Some(val) = res else { break };
26882                    val
26883                }),
26884                4u16 => PoliceAttrs::Avrate({
26885                    let res = parse_u32(next);
26886                    let Some(val) = res else { break };
26887                    val
26888                }),
26889                5u16 => PoliceAttrs::Result({
26890                    let res = parse_u32(next);
26891                    let Some(val) = res else { break };
26892                    val
26893                }),
26894                6u16 => PoliceAttrs::Tm({
26895                    let res = Some(TcfT::new_from_zeroed(next));
26896                    let Some(val) = res else { break };
26897                    val
26898                }),
26899                7u16 => PoliceAttrs::Pad({
26900                    let res = Some(next);
26901                    let Some(val) = res else { break };
26902                    val
26903                }),
26904                8u16 => PoliceAttrs::Rate64({
26905                    let res = parse_u64(next);
26906                    let Some(val) = res else { break };
26907                    val
26908                }),
26909                9u16 => PoliceAttrs::Peakrate64({
26910                    let res = parse_u64(next);
26911                    let Some(val) = res else { break };
26912                    val
26913                }),
26914                10u16 => PoliceAttrs::Pktrate64({
26915                    let res = parse_u64(next);
26916                    let Some(val) = res else { break };
26917                    val
26918                }),
26919                11u16 => PoliceAttrs::Pktburst64({
26920                    let res = parse_u64(next);
26921                    let Some(val) = res else { break };
26922                    val
26923                }),
26924                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
26925                n => continue,
26926            };
26927            return Some(Ok(res));
26928        }
26929        Some(Err(ErrorContext::new(
26930            "PoliceAttrs",
26931            r#type.and_then(|t| PoliceAttrs::attr_from_type(t)),
26932            self.orig_loc,
26933            self.buf.as_ptr().wrapping_add(pos) as usize,
26934        )))
26935    }
26936}
26937impl<'a> std::fmt::Debug for IterablePoliceAttrs<'_> {
26938    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26939        let mut fmt = f.debug_struct("PoliceAttrs");
26940        for attr in self.clone() {
26941            let attr = match attr {
26942                Ok(a) => a,
26943                Err(err) => {
26944                    fmt.finish()?;
26945                    f.write_str("Err(")?;
26946                    err.fmt(f)?;
26947                    return f.write_str(")");
26948                }
26949            };
26950            match attr {
26951                PoliceAttrs::Tbf(val) => fmt.field("Tbf", &val),
26952                PoliceAttrs::Rate(val) => fmt.field("Rate", &val),
26953                PoliceAttrs::Peakrate(val) => fmt.field("Peakrate", &val),
26954                PoliceAttrs::Avrate(val) => fmt.field("Avrate", &val),
26955                PoliceAttrs::Result(val) => fmt.field("Result", &val),
26956                PoliceAttrs::Tm(val) => fmt.field("Tm", &val),
26957                PoliceAttrs::Pad(val) => fmt.field("Pad", &val),
26958                PoliceAttrs::Rate64(val) => fmt.field("Rate64", &val),
26959                PoliceAttrs::Peakrate64(val) => fmt.field("Peakrate64", &val),
26960                PoliceAttrs::Pktrate64(val) => fmt.field("Pktrate64", &val),
26961                PoliceAttrs::Pktburst64(val) => fmt.field("Pktburst64", &val),
26962            };
26963        }
26964        fmt.finish()
26965    }
26966}
26967impl IterablePoliceAttrs<'_> {
26968    pub fn lookup_attr(
26969        &self,
26970        offset: usize,
26971        missing_type: Option<u16>,
26972    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
26973        let mut stack = Vec::new();
26974        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
26975        if missing_type.is_some() && cur == offset {
26976            stack.push(("PoliceAttrs", offset));
26977            return (
26978                stack,
26979                missing_type.and_then(|t| PoliceAttrs::attr_from_type(t)),
26980            );
26981        }
26982        if cur > offset || cur + self.buf.len() < offset {
26983            return (stack, None);
26984        }
26985        let mut attrs = self.clone();
26986        let mut last_off = cur + attrs.pos;
26987        while let Some(attr) = attrs.next() {
26988            let Ok(attr) = attr else { break };
26989            match attr {
26990                PoliceAttrs::Tbf(val) => {
26991                    if last_off == offset {
26992                        stack.push(("Tbf", last_off));
26993                        break;
26994                    }
26995                }
26996                PoliceAttrs::Rate(val) => {
26997                    if last_off == offset {
26998                        stack.push(("Rate", last_off));
26999                        break;
27000                    }
27001                }
27002                PoliceAttrs::Peakrate(val) => {
27003                    if last_off == offset {
27004                        stack.push(("Peakrate", last_off));
27005                        break;
27006                    }
27007                }
27008                PoliceAttrs::Avrate(val) => {
27009                    if last_off == offset {
27010                        stack.push(("Avrate", last_off));
27011                        break;
27012                    }
27013                }
27014                PoliceAttrs::Result(val) => {
27015                    if last_off == offset {
27016                        stack.push(("Result", last_off));
27017                        break;
27018                    }
27019                }
27020                PoliceAttrs::Tm(val) => {
27021                    if last_off == offset {
27022                        stack.push(("Tm", last_off));
27023                        break;
27024                    }
27025                }
27026                PoliceAttrs::Pad(val) => {
27027                    if last_off == offset {
27028                        stack.push(("Pad", last_off));
27029                        break;
27030                    }
27031                }
27032                PoliceAttrs::Rate64(val) => {
27033                    if last_off == offset {
27034                        stack.push(("Rate64", last_off));
27035                        break;
27036                    }
27037                }
27038                PoliceAttrs::Peakrate64(val) => {
27039                    if last_off == offset {
27040                        stack.push(("Peakrate64", last_off));
27041                        break;
27042                    }
27043                }
27044                PoliceAttrs::Pktrate64(val) => {
27045                    if last_off == offset {
27046                        stack.push(("Pktrate64", last_off));
27047                        break;
27048                    }
27049                }
27050                PoliceAttrs::Pktburst64(val) => {
27051                    if last_off == offset {
27052                        stack.push(("Pktburst64", last_off));
27053                        break;
27054                    }
27055                }
27056                _ => {}
27057            };
27058            last_off = cur + attrs.pos;
27059        }
27060        if !stack.is_empty() {
27061            stack.push(("PoliceAttrs", cur));
27062        }
27063        (stack, None)
27064    }
27065}
27066#[derive(Clone)]
27067pub enum QfqAttrs {
27068    Weight(u32),
27069    Lmax(u32),
27070}
27071impl<'a> IterableQfqAttrs<'a> {
27072    pub fn get_weight(&self) -> Result<u32, ErrorContext> {
27073        let mut iter = self.clone();
27074        iter.pos = 0;
27075        for attr in iter {
27076            if let QfqAttrs::Weight(val) = attr? {
27077                return Ok(val);
27078            }
27079        }
27080        Err(ErrorContext::new_missing(
27081            "QfqAttrs",
27082            "Weight",
27083            self.orig_loc,
27084            self.buf.as_ptr() as usize,
27085        ))
27086    }
27087    pub fn get_lmax(&self) -> Result<u32, ErrorContext> {
27088        let mut iter = self.clone();
27089        iter.pos = 0;
27090        for attr in iter {
27091            if let QfqAttrs::Lmax(val) = attr? {
27092                return Ok(val);
27093            }
27094        }
27095        Err(ErrorContext::new_missing(
27096            "QfqAttrs",
27097            "Lmax",
27098            self.orig_loc,
27099            self.buf.as_ptr() as usize,
27100        ))
27101    }
27102}
27103impl QfqAttrs {
27104    pub fn new<'a>(buf: &'a [u8]) -> IterableQfqAttrs<'a> {
27105        IterableQfqAttrs::with_loc(buf, buf.as_ptr() as usize)
27106    }
27107    fn attr_from_type(r#type: u16) -> Option<&'static str> {
27108        let res = match r#type {
27109            1u16 => "Weight",
27110            2u16 => "Lmax",
27111            _ => return None,
27112        };
27113        Some(res)
27114    }
27115}
27116#[derive(Clone, Copy, Default)]
27117pub struct IterableQfqAttrs<'a> {
27118    buf: &'a [u8],
27119    pos: usize,
27120    orig_loc: usize,
27121}
27122impl<'a> IterableQfqAttrs<'a> {
27123    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
27124        Self {
27125            buf,
27126            pos: 0,
27127            orig_loc,
27128        }
27129    }
27130    pub fn get_buf(&self) -> &'a [u8] {
27131        self.buf
27132    }
27133}
27134impl<'a> Iterator for IterableQfqAttrs<'a> {
27135    type Item = Result<QfqAttrs, ErrorContext>;
27136    fn next(&mut self) -> Option<Self::Item> {
27137        let pos = self.pos;
27138        let mut r#type;
27139        loop {
27140            r#type = None;
27141            if self.buf.len() == self.pos {
27142                return None;
27143            }
27144            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
27145                break;
27146            };
27147            r#type = Some(header.r#type);
27148            let res = match header.r#type {
27149                1u16 => QfqAttrs::Weight({
27150                    let res = parse_u32(next);
27151                    let Some(val) = res else { break };
27152                    val
27153                }),
27154                2u16 => QfqAttrs::Lmax({
27155                    let res = parse_u32(next);
27156                    let Some(val) = res else { break };
27157                    val
27158                }),
27159                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
27160                n => continue,
27161            };
27162            return Some(Ok(res));
27163        }
27164        Some(Err(ErrorContext::new(
27165            "QfqAttrs",
27166            r#type.and_then(|t| QfqAttrs::attr_from_type(t)),
27167            self.orig_loc,
27168            self.buf.as_ptr().wrapping_add(pos) as usize,
27169        )))
27170    }
27171}
27172impl std::fmt::Debug for IterableQfqAttrs<'_> {
27173    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27174        let mut fmt = f.debug_struct("QfqAttrs");
27175        for attr in self.clone() {
27176            let attr = match attr {
27177                Ok(a) => a,
27178                Err(err) => {
27179                    fmt.finish()?;
27180                    f.write_str("Err(")?;
27181                    err.fmt(f)?;
27182                    return f.write_str(")");
27183                }
27184            };
27185            match attr {
27186                QfqAttrs::Weight(val) => fmt.field("Weight", &val),
27187                QfqAttrs::Lmax(val) => fmt.field("Lmax", &val),
27188            };
27189        }
27190        fmt.finish()
27191    }
27192}
27193impl IterableQfqAttrs<'_> {
27194    pub fn lookup_attr(
27195        &self,
27196        offset: usize,
27197        missing_type: Option<u16>,
27198    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
27199        let mut stack = Vec::new();
27200        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
27201        if missing_type.is_some() && cur == offset {
27202            stack.push(("QfqAttrs", offset));
27203            return (
27204                stack,
27205                missing_type.and_then(|t| QfqAttrs::attr_from_type(t)),
27206            );
27207        }
27208        if cur > offset || cur + self.buf.len() < offset {
27209            return (stack, None);
27210        }
27211        let mut attrs = self.clone();
27212        let mut last_off = cur + attrs.pos;
27213        while let Some(attr) = attrs.next() {
27214            let Ok(attr) = attr else { break };
27215            match attr {
27216                QfqAttrs::Weight(val) => {
27217                    if last_off == offset {
27218                        stack.push(("Weight", last_off));
27219                        break;
27220                    }
27221                }
27222                QfqAttrs::Lmax(val) => {
27223                    if last_off == offset {
27224                        stack.push(("Lmax", last_off));
27225                        break;
27226                    }
27227                }
27228                _ => {}
27229            };
27230            last_off = cur + attrs.pos;
27231        }
27232        if !stack.is_empty() {
27233            stack.push(("QfqAttrs", cur));
27234        }
27235        (stack, None)
27236    }
27237}
27238#[derive(Clone)]
27239pub enum RedAttrs<'a> {
27240    Parms(TcRedQopt),
27241    Stab(&'a [u8]),
27242    MaxP(u32),
27243    Flags(BuiltinBitfield32),
27244    EarlyDropBlock(u32),
27245    MarkBlock(u32),
27246}
27247impl<'a> IterableRedAttrs<'a> {
27248    pub fn get_parms(&self) -> Result<TcRedQopt, ErrorContext> {
27249        let mut iter = self.clone();
27250        iter.pos = 0;
27251        for attr in iter {
27252            if let RedAttrs::Parms(val) = attr? {
27253                return Ok(val);
27254            }
27255        }
27256        Err(ErrorContext::new_missing(
27257            "RedAttrs",
27258            "Parms",
27259            self.orig_loc,
27260            self.buf.as_ptr() as usize,
27261        ))
27262    }
27263    pub fn get_stab(&self) -> Result<&'a [u8], ErrorContext> {
27264        let mut iter = self.clone();
27265        iter.pos = 0;
27266        for attr in iter {
27267            if let RedAttrs::Stab(val) = attr? {
27268                return Ok(val);
27269            }
27270        }
27271        Err(ErrorContext::new_missing(
27272            "RedAttrs",
27273            "Stab",
27274            self.orig_loc,
27275            self.buf.as_ptr() as usize,
27276        ))
27277    }
27278    pub fn get_max_p(&self) -> Result<u32, ErrorContext> {
27279        let mut iter = self.clone();
27280        iter.pos = 0;
27281        for attr in iter {
27282            if let RedAttrs::MaxP(val) = attr? {
27283                return Ok(val);
27284            }
27285        }
27286        Err(ErrorContext::new_missing(
27287            "RedAttrs",
27288            "MaxP",
27289            self.orig_loc,
27290            self.buf.as_ptr() as usize,
27291        ))
27292    }
27293    pub fn get_flags(&self) -> Result<BuiltinBitfield32, ErrorContext> {
27294        let mut iter = self.clone();
27295        iter.pos = 0;
27296        for attr in iter {
27297            if let RedAttrs::Flags(val) = attr? {
27298                return Ok(val);
27299            }
27300        }
27301        Err(ErrorContext::new_missing(
27302            "RedAttrs",
27303            "Flags",
27304            self.orig_loc,
27305            self.buf.as_ptr() as usize,
27306        ))
27307    }
27308    pub fn get_early_drop_block(&self) -> Result<u32, ErrorContext> {
27309        let mut iter = self.clone();
27310        iter.pos = 0;
27311        for attr in iter {
27312            if let RedAttrs::EarlyDropBlock(val) = attr? {
27313                return Ok(val);
27314            }
27315        }
27316        Err(ErrorContext::new_missing(
27317            "RedAttrs",
27318            "EarlyDropBlock",
27319            self.orig_loc,
27320            self.buf.as_ptr() as usize,
27321        ))
27322    }
27323    pub fn get_mark_block(&self) -> Result<u32, ErrorContext> {
27324        let mut iter = self.clone();
27325        iter.pos = 0;
27326        for attr in iter {
27327            if let RedAttrs::MarkBlock(val) = attr? {
27328                return Ok(val);
27329            }
27330        }
27331        Err(ErrorContext::new_missing(
27332            "RedAttrs",
27333            "MarkBlock",
27334            self.orig_loc,
27335            self.buf.as_ptr() as usize,
27336        ))
27337    }
27338}
27339impl RedAttrs<'_> {
27340    pub fn new<'a>(buf: &'a [u8]) -> IterableRedAttrs<'a> {
27341        IterableRedAttrs::with_loc(buf, buf.as_ptr() as usize)
27342    }
27343    fn attr_from_type(r#type: u16) -> Option<&'static str> {
27344        let res = match r#type {
27345            1u16 => "Parms",
27346            2u16 => "Stab",
27347            3u16 => "MaxP",
27348            4u16 => "Flags",
27349            5u16 => "EarlyDropBlock",
27350            6u16 => "MarkBlock",
27351            _ => return None,
27352        };
27353        Some(res)
27354    }
27355}
27356#[derive(Clone, Copy, Default)]
27357pub struct IterableRedAttrs<'a> {
27358    buf: &'a [u8],
27359    pos: usize,
27360    orig_loc: usize,
27361}
27362impl<'a> IterableRedAttrs<'a> {
27363    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
27364        Self {
27365            buf,
27366            pos: 0,
27367            orig_loc,
27368        }
27369    }
27370    pub fn get_buf(&self) -> &'a [u8] {
27371        self.buf
27372    }
27373}
27374impl<'a> Iterator for IterableRedAttrs<'a> {
27375    type Item = Result<RedAttrs<'a>, ErrorContext>;
27376    fn next(&mut self) -> Option<Self::Item> {
27377        let pos = self.pos;
27378        let mut r#type;
27379        loop {
27380            r#type = None;
27381            if self.buf.len() == self.pos {
27382                return None;
27383            }
27384            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
27385                break;
27386            };
27387            r#type = Some(header.r#type);
27388            let res = match header.r#type {
27389                1u16 => RedAttrs::Parms({
27390                    let res = Some(TcRedQopt::new_from_zeroed(next));
27391                    let Some(val) = res else { break };
27392                    val
27393                }),
27394                2u16 => RedAttrs::Stab({
27395                    let res = Some(next);
27396                    let Some(val) = res else { break };
27397                    val
27398                }),
27399                3u16 => RedAttrs::MaxP({
27400                    let res = parse_u32(next);
27401                    let Some(val) = res else { break };
27402                    val
27403                }),
27404                4u16 => RedAttrs::Flags({
27405                    let res = BuiltinBitfield32::new_from_slice(next);
27406                    let Some(val) = res else { break };
27407                    val
27408                }),
27409                5u16 => RedAttrs::EarlyDropBlock({
27410                    let res = parse_u32(next);
27411                    let Some(val) = res else { break };
27412                    val
27413                }),
27414                6u16 => RedAttrs::MarkBlock({
27415                    let res = parse_u32(next);
27416                    let Some(val) = res else { break };
27417                    val
27418                }),
27419                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
27420                n => continue,
27421            };
27422            return Some(Ok(res));
27423        }
27424        Some(Err(ErrorContext::new(
27425            "RedAttrs",
27426            r#type.and_then(|t| RedAttrs::attr_from_type(t)),
27427            self.orig_loc,
27428            self.buf.as_ptr().wrapping_add(pos) as usize,
27429        )))
27430    }
27431}
27432impl<'a> std::fmt::Debug for IterableRedAttrs<'_> {
27433    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27434        let mut fmt = f.debug_struct("RedAttrs");
27435        for attr in self.clone() {
27436            let attr = match attr {
27437                Ok(a) => a,
27438                Err(err) => {
27439                    fmt.finish()?;
27440                    f.write_str("Err(")?;
27441                    err.fmt(f)?;
27442                    return f.write_str(")");
27443                }
27444            };
27445            match attr {
27446                RedAttrs::Parms(val) => fmt.field("Parms", &val),
27447                RedAttrs::Stab(val) => fmt.field("Stab", &val),
27448                RedAttrs::MaxP(val) => fmt.field("MaxP", &val),
27449                RedAttrs::Flags(val) => fmt.field("Flags", &val),
27450                RedAttrs::EarlyDropBlock(val) => fmt.field("EarlyDropBlock", &val),
27451                RedAttrs::MarkBlock(val) => fmt.field("MarkBlock", &val),
27452            };
27453        }
27454        fmt.finish()
27455    }
27456}
27457impl IterableRedAttrs<'_> {
27458    pub fn lookup_attr(
27459        &self,
27460        offset: usize,
27461        missing_type: Option<u16>,
27462    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
27463        let mut stack = Vec::new();
27464        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
27465        if missing_type.is_some() && cur == offset {
27466            stack.push(("RedAttrs", offset));
27467            return (
27468                stack,
27469                missing_type.and_then(|t| RedAttrs::attr_from_type(t)),
27470            );
27471        }
27472        if cur > offset || cur + self.buf.len() < offset {
27473            return (stack, None);
27474        }
27475        let mut attrs = self.clone();
27476        let mut last_off = cur + attrs.pos;
27477        while let Some(attr) = attrs.next() {
27478            let Ok(attr) = attr else { break };
27479            match attr {
27480                RedAttrs::Parms(val) => {
27481                    if last_off == offset {
27482                        stack.push(("Parms", last_off));
27483                        break;
27484                    }
27485                }
27486                RedAttrs::Stab(val) => {
27487                    if last_off == offset {
27488                        stack.push(("Stab", last_off));
27489                        break;
27490                    }
27491                }
27492                RedAttrs::MaxP(val) => {
27493                    if last_off == offset {
27494                        stack.push(("MaxP", last_off));
27495                        break;
27496                    }
27497                }
27498                RedAttrs::Flags(val) => {
27499                    if last_off == offset {
27500                        stack.push(("Flags", last_off));
27501                        break;
27502                    }
27503                }
27504                RedAttrs::EarlyDropBlock(val) => {
27505                    if last_off == offset {
27506                        stack.push(("EarlyDropBlock", last_off));
27507                        break;
27508                    }
27509                }
27510                RedAttrs::MarkBlock(val) => {
27511                    if last_off == offset {
27512                        stack.push(("MarkBlock", last_off));
27513                        break;
27514                    }
27515                }
27516                _ => {}
27517            };
27518            last_off = cur + attrs.pos;
27519        }
27520        if !stack.is_empty() {
27521            stack.push(("RedAttrs", cur));
27522        }
27523        (stack, None)
27524    }
27525}
27526#[derive(Clone)]
27527pub enum RouteAttrs<'a> {
27528    Classid(u32),
27529    To(u32),
27530    From(u32),
27531    Iif(u32),
27532    Police(IterablePoliceAttrs<'a>),
27533    Act(IterableArrayActAttrs<'a>),
27534}
27535impl<'a> IterableRouteAttrs<'a> {
27536    pub fn get_classid(&self) -> Result<u32, ErrorContext> {
27537        let mut iter = self.clone();
27538        iter.pos = 0;
27539        for attr in iter {
27540            if let RouteAttrs::Classid(val) = attr? {
27541                return Ok(val);
27542            }
27543        }
27544        Err(ErrorContext::new_missing(
27545            "RouteAttrs",
27546            "Classid",
27547            self.orig_loc,
27548            self.buf.as_ptr() as usize,
27549        ))
27550    }
27551    pub fn get_to(&self) -> Result<u32, ErrorContext> {
27552        let mut iter = self.clone();
27553        iter.pos = 0;
27554        for attr in iter {
27555            if let RouteAttrs::To(val) = attr? {
27556                return Ok(val);
27557            }
27558        }
27559        Err(ErrorContext::new_missing(
27560            "RouteAttrs",
27561            "To",
27562            self.orig_loc,
27563            self.buf.as_ptr() as usize,
27564        ))
27565    }
27566    pub fn get_from(&self) -> Result<u32, ErrorContext> {
27567        let mut iter = self.clone();
27568        iter.pos = 0;
27569        for attr in iter {
27570            if let RouteAttrs::From(val) = attr? {
27571                return Ok(val);
27572            }
27573        }
27574        Err(ErrorContext::new_missing(
27575            "RouteAttrs",
27576            "From",
27577            self.orig_loc,
27578            self.buf.as_ptr() as usize,
27579        ))
27580    }
27581    pub fn get_iif(&self) -> Result<u32, ErrorContext> {
27582        let mut iter = self.clone();
27583        iter.pos = 0;
27584        for attr in iter {
27585            if let RouteAttrs::Iif(val) = attr? {
27586                return Ok(val);
27587            }
27588        }
27589        Err(ErrorContext::new_missing(
27590            "RouteAttrs",
27591            "Iif",
27592            self.orig_loc,
27593            self.buf.as_ptr() as usize,
27594        ))
27595    }
27596    pub fn get_police(&self) -> Result<IterablePoliceAttrs<'a>, ErrorContext> {
27597        let mut iter = self.clone();
27598        iter.pos = 0;
27599        for attr in iter {
27600            if let RouteAttrs::Police(val) = attr? {
27601                return Ok(val);
27602            }
27603        }
27604        Err(ErrorContext::new_missing(
27605            "RouteAttrs",
27606            "Police",
27607            self.orig_loc,
27608            self.buf.as_ptr() as usize,
27609        ))
27610    }
27611    pub fn get_act(
27612        &self,
27613    ) -> Result<ArrayIterable<IterableArrayActAttrs<'a>, IterableActAttrs<'a>>, ErrorContext> {
27614        for attr in self.clone() {
27615            if let RouteAttrs::Act(val) = attr? {
27616                return Ok(ArrayIterable::new(val));
27617            }
27618        }
27619        Err(ErrorContext::new_missing(
27620            "RouteAttrs",
27621            "Act",
27622            self.orig_loc,
27623            self.buf.as_ptr() as usize,
27624        ))
27625    }
27626}
27627impl RouteAttrs<'_> {
27628    pub fn new<'a>(buf: &'a [u8]) -> IterableRouteAttrs<'a> {
27629        IterableRouteAttrs::with_loc(buf, buf.as_ptr() as usize)
27630    }
27631    fn attr_from_type(r#type: u16) -> Option<&'static str> {
27632        let res = match r#type {
27633            1u16 => "Classid",
27634            2u16 => "To",
27635            3u16 => "From",
27636            4u16 => "Iif",
27637            5u16 => "Police",
27638            6u16 => "Act",
27639            _ => return None,
27640        };
27641        Some(res)
27642    }
27643}
27644#[derive(Clone, Copy, Default)]
27645pub struct IterableRouteAttrs<'a> {
27646    buf: &'a [u8],
27647    pos: usize,
27648    orig_loc: usize,
27649}
27650impl<'a> IterableRouteAttrs<'a> {
27651    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
27652        Self {
27653            buf,
27654            pos: 0,
27655            orig_loc,
27656        }
27657    }
27658    pub fn get_buf(&self) -> &'a [u8] {
27659        self.buf
27660    }
27661}
27662impl<'a> Iterator for IterableRouteAttrs<'a> {
27663    type Item = Result<RouteAttrs<'a>, ErrorContext>;
27664    fn next(&mut self) -> Option<Self::Item> {
27665        let pos = self.pos;
27666        let mut r#type;
27667        loop {
27668            r#type = None;
27669            if self.buf.len() == self.pos {
27670                return None;
27671            }
27672            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
27673                break;
27674            };
27675            r#type = Some(header.r#type);
27676            let res = match header.r#type {
27677                1u16 => RouteAttrs::Classid({
27678                    let res = parse_u32(next);
27679                    let Some(val) = res else { break };
27680                    val
27681                }),
27682                2u16 => RouteAttrs::To({
27683                    let res = parse_u32(next);
27684                    let Some(val) = res else { break };
27685                    val
27686                }),
27687                3u16 => RouteAttrs::From({
27688                    let res = parse_u32(next);
27689                    let Some(val) = res else { break };
27690                    val
27691                }),
27692                4u16 => RouteAttrs::Iif({
27693                    let res = parse_u32(next);
27694                    let Some(val) = res else { break };
27695                    val
27696                }),
27697                5u16 => RouteAttrs::Police({
27698                    let res = Some(IterablePoliceAttrs::with_loc(next, self.orig_loc));
27699                    let Some(val) = res else { break };
27700                    val
27701                }),
27702                6u16 => RouteAttrs::Act({
27703                    let res = Some(IterableArrayActAttrs::with_loc(next, self.orig_loc));
27704                    let Some(val) = res else { break };
27705                    val
27706                }),
27707                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
27708                n => continue,
27709            };
27710            return Some(Ok(res));
27711        }
27712        Some(Err(ErrorContext::new(
27713            "RouteAttrs",
27714            r#type.and_then(|t| RouteAttrs::attr_from_type(t)),
27715            self.orig_loc,
27716            self.buf.as_ptr().wrapping_add(pos) as usize,
27717        )))
27718    }
27719}
27720impl<'a> std::fmt::Debug for IterableRouteAttrs<'_> {
27721    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27722        let mut fmt = f.debug_struct("RouteAttrs");
27723        for attr in self.clone() {
27724            let attr = match attr {
27725                Ok(a) => a,
27726                Err(err) => {
27727                    fmt.finish()?;
27728                    f.write_str("Err(")?;
27729                    err.fmt(f)?;
27730                    return f.write_str(")");
27731                }
27732            };
27733            match attr {
27734                RouteAttrs::Classid(val) => fmt.field("Classid", &val),
27735                RouteAttrs::To(val) => fmt.field("To", &val),
27736                RouteAttrs::From(val) => fmt.field("From", &val),
27737                RouteAttrs::Iif(val) => fmt.field("Iif", &val),
27738                RouteAttrs::Police(val) => fmt.field("Police", &val),
27739                RouteAttrs::Act(val) => fmt.field("Act", &val),
27740            };
27741        }
27742        fmt.finish()
27743    }
27744}
27745impl IterableRouteAttrs<'_> {
27746    pub fn lookup_attr(
27747        &self,
27748        offset: usize,
27749        missing_type: Option<u16>,
27750    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
27751        let mut stack = Vec::new();
27752        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
27753        if missing_type.is_some() && cur == offset {
27754            stack.push(("RouteAttrs", offset));
27755            return (
27756                stack,
27757                missing_type.and_then(|t| RouteAttrs::attr_from_type(t)),
27758            );
27759        }
27760        if cur > offset || cur + self.buf.len() < offset {
27761            return (stack, None);
27762        }
27763        let mut attrs = self.clone();
27764        let mut last_off = cur + attrs.pos;
27765        let mut missing = None;
27766        while let Some(attr) = attrs.next() {
27767            let Ok(attr) = attr else { break };
27768            match attr {
27769                RouteAttrs::Classid(val) => {
27770                    if last_off == offset {
27771                        stack.push(("Classid", last_off));
27772                        break;
27773                    }
27774                }
27775                RouteAttrs::To(val) => {
27776                    if last_off == offset {
27777                        stack.push(("To", last_off));
27778                        break;
27779                    }
27780                }
27781                RouteAttrs::From(val) => {
27782                    if last_off == offset {
27783                        stack.push(("From", last_off));
27784                        break;
27785                    }
27786                }
27787                RouteAttrs::Iif(val) => {
27788                    if last_off == offset {
27789                        stack.push(("Iif", last_off));
27790                        break;
27791                    }
27792                }
27793                RouteAttrs::Police(val) => {
27794                    (stack, missing) = val.lookup_attr(offset, missing_type);
27795                    if !stack.is_empty() {
27796                        break;
27797                    }
27798                }
27799                RouteAttrs::Act(val) => {
27800                    for entry in val {
27801                        let Ok(attr) = entry else { break };
27802                        (stack, missing) = attr.lookup_attr(offset, missing_type);
27803                        if !stack.is_empty() {
27804                            break;
27805                        }
27806                    }
27807                    if !stack.is_empty() {
27808                        stack.push(("Act", last_off));
27809                        break;
27810                    }
27811                }
27812                _ => {}
27813            };
27814            last_off = cur + attrs.pos;
27815        }
27816        if !stack.is_empty() {
27817            stack.push(("RouteAttrs", cur));
27818        }
27819        (stack, missing)
27820    }
27821}
27822#[derive(Clone)]
27823pub enum TaprioAttrs<'a> {
27824    Priomap(TcMqprioQopt),
27825    SchedEntryList(IterableTaprioSchedEntryList<'a>),
27826    SchedBaseTime(i64),
27827    SchedSingleEntry(IterableTaprioSchedEntry<'a>),
27828    SchedClockid(i32),
27829    Pad(&'a [u8]),
27830    AdminSched(&'a [u8]),
27831    SchedCycleTime(i64),
27832    SchedCycleTimeExtension(i64),
27833    Flags(u32),
27834    TxtimeDelay(u32),
27835    TcEntry(IterableTaprioTcEntryAttrs<'a>),
27836}
27837impl<'a> IterableTaprioAttrs<'a> {
27838    pub fn get_priomap(&self) -> Result<TcMqprioQopt, ErrorContext> {
27839        let mut iter = self.clone();
27840        iter.pos = 0;
27841        for attr in iter {
27842            if let TaprioAttrs::Priomap(val) = attr? {
27843                return Ok(val);
27844            }
27845        }
27846        Err(ErrorContext::new_missing(
27847            "TaprioAttrs",
27848            "Priomap",
27849            self.orig_loc,
27850            self.buf.as_ptr() as usize,
27851        ))
27852    }
27853    pub fn get_sched_entry_list(&self) -> Result<IterableTaprioSchedEntryList<'a>, ErrorContext> {
27854        let mut iter = self.clone();
27855        iter.pos = 0;
27856        for attr in iter {
27857            if let TaprioAttrs::SchedEntryList(val) = attr? {
27858                return Ok(val);
27859            }
27860        }
27861        Err(ErrorContext::new_missing(
27862            "TaprioAttrs",
27863            "SchedEntryList",
27864            self.orig_loc,
27865            self.buf.as_ptr() as usize,
27866        ))
27867    }
27868    pub fn get_sched_base_time(&self) -> Result<i64, ErrorContext> {
27869        let mut iter = self.clone();
27870        iter.pos = 0;
27871        for attr in iter {
27872            if let TaprioAttrs::SchedBaseTime(val) = attr? {
27873                return Ok(val);
27874            }
27875        }
27876        Err(ErrorContext::new_missing(
27877            "TaprioAttrs",
27878            "SchedBaseTime",
27879            self.orig_loc,
27880            self.buf.as_ptr() as usize,
27881        ))
27882    }
27883    pub fn get_sched_single_entry(&self) -> Result<IterableTaprioSchedEntry<'a>, ErrorContext> {
27884        let mut iter = self.clone();
27885        iter.pos = 0;
27886        for attr in iter {
27887            if let TaprioAttrs::SchedSingleEntry(val) = attr? {
27888                return Ok(val);
27889            }
27890        }
27891        Err(ErrorContext::new_missing(
27892            "TaprioAttrs",
27893            "SchedSingleEntry",
27894            self.orig_loc,
27895            self.buf.as_ptr() as usize,
27896        ))
27897    }
27898    pub fn get_sched_clockid(&self) -> Result<i32, ErrorContext> {
27899        let mut iter = self.clone();
27900        iter.pos = 0;
27901        for attr in iter {
27902            if let TaprioAttrs::SchedClockid(val) = attr? {
27903                return Ok(val);
27904            }
27905        }
27906        Err(ErrorContext::new_missing(
27907            "TaprioAttrs",
27908            "SchedClockid",
27909            self.orig_loc,
27910            self.buf.as_ptr() as usize,
27911        ))
27912    }
27913    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
27914        let mut iter = self.clone();
27915        iter.pos = 0;
27916        for attr in iter {
27917            if let TaprioAttrs::Pad(val) = attr? {
27918                return Ok(val);
27919            }
27920        }
27921        Err(ErrorContext::new_missing(
27922            "TaprioAttrs",
27923            "Pad",
27924            self.orig_loc,
27925            self.buf.as_ptr() as usize,
27926        ))
27927    }
27928    pub fn get_admin_sched(&self) -> Result<&'a [u8], ErrorContext> {
27929        let mut iter = self.clone();
27930        iter.pos = 0;
27931        for attr in iter {
27932            if let TaprioAttrs::AdminSched(val) = attr? {
27933                return Ok(val);
27934            }
27935        }
27936        Err(ErrorContext::new_missing(
27937            "TaprioAttrs",
27938            "AdminSched",
27939            self.orig_loc,
27940            self.buf.as_ptr() as usize,
27941        ))
27942    }
27943    pub fn get_sched_cycle_time(&self) -> Result<i64, ErrorContext> {
27944        let mut iter = self.clone();
27945        iter.pos = 0;
27946        for attr in iter {
27947            if let TaprioAttrs::SchedCycleTime(val) = attr? {
27948                return Ok(val);
27949            }
27950        }
27951        Err(ErrorContext::new_missing(
27952            "TaprioAttrs",
27953            "SchedCycleTime",
27954            self.orig_loc,
27955            self.buf.as_ptr() as usize,
27956        ))
27957    }
27958    pub fn get_sched_cycle_time_extension(&self) -> Result<i64, ErrorContext> {
27959        let mut iter = self.clone();
27960        iter.pos = 0;
27961        for attr in iter {
27962            if let TaprioAttrs::SchedCycleTimeExtension(val) = attr? {
27963                return Ok(val);
27964            }
27965        }
27966        Err(ErrorContext::new_missing(
27967            "TaprioAttrs",
27968            "SchedCycleTimeExtension",
27969            self.orig_loc,
27970            self.buf.as_ptr() as usize,
27971        ))
27972    }
27973    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
27974        let mut iter = self.clone();
27975        iter.pos = 0;
27976        for attr in iter {
27977            if let TaprioAttrs::Flags(val) = attr? {
27978                return Ok(val);
27979            }
27980        }
27981        Err(ErrorContext::new_missing(
27982            "TaprioAttrs",
27983            "Flags",
27984            self.orig_loc,
27985            self.buf.as_ptr() as usize,
27986        ))
27987    }
27988    pub fn get_txtime_delay(&self) -> Result<u32, ErrorContext> {
27989        let mut iter = self.clone();
27990        iter.pos = 0;
27991        for attr in iter {
27992            if let TaprioAttrs::TxtimeDelay(val) = attr? {
27993                return Ok(val);
27994            }
27995        }
27996        Err(ErrorContext::new_missing(
27997            "TaprioAttrs",
27998            "TxtimeDelay",
27999            self.orig_loc,
28000            self.buf.as_ptr() as usize,
28001        ))
28002    }
28003    pub fn get_tc_entry(&self) -> Result<IterableTaprioTcEntryAttrs<'a>, ErrorContext> {
28004        let mut iter = self.clone();
28005        iter.pos = 0;
28006        for attr in iter {
28007            if let TaprioAttrs::TcEntry(val) = attr? {
28008                return Ok(val);
28009            }
28010        }
28011        Err(ErrorContext::new_missing(
28012            "TaprioAttrs",
28013            "TcEntry",
28014            self.orig_loc,
28015            self.buf.as_ptr() as usize,
28016        ))
28017    }
28018}
28019impl TaprioAttrs<'_> {
28020    pub fn new<'a>(buf: &'a [u8]) -> IterableTaprioAttrs<'a> {
28021        IterableTaprioAttrs::with_loc(buf, buf.as_ptr() as usize)
28022    }
28023    fn attr_from_type(r#type: u16) -> Option<&'static str> {
28024        let res = match r#type {
28025            1u16 => "Priomap",
28026            2u16 => "SchedEntryList",
28027            3u16 => "SchedBaseTime",
28028            4u16 => "SchedSingleEntry",
28029            5u16 => "SchedClockid",
28030            6u16 => "Pad",
28031            7u16 => "AdminSched",
28032            8u16 => "SchedCycleTime",
28033            9u16 => "SchedCycleTimeExtension",
28034            10u16 => "Flags",
28035            11u16 => "TxtimeDelay",
28036            12u16 => "TcEntry",
28037            _ => return None,
28038        };
28039        Some(res)
28040    }
28041}
28042#[derive(Clone, Copy, Default)]
28043pub struct IterableTaprioAttrs<'a> {
28044    buf: &'a [u8],
28045    pos: usize,
28046    orig_loc: usize,
28047}
28048impl<'a> IterableTaprioAttrs<'a> {
28049    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
28050        Self {
28051            buf,
28052            pos: 0,
28053            orig_loc,
28054        }
28055    }
28056    pub fn get_buf(&self) -> &'a [u8] {
28057        self.buf
28058    }
28059}
28060impl<'a> Iterator for IterableTaprioAttrs<'a> {
28061    type Item = Result<TaprioAttrs<'a>, ErrorContext>;
28062    fn next(&mut self) -> Option<Self::Item> {
28063        let pos = self.pos;
28064        let mut r#type;
28065        loop {
28066            r#type = None;
28067            if self.buf.len() == self.pos {
28068                return None;
28069            }
28070            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
28071                break;
28072            };
28073            r#type = Some(header.r#type);
28074            let res = match header.r#type {
28075                1u16 => TaprioAttrs::Priomap({
28076                    let res = Some(TcMqprioQopt::new_from_zeroed(next));
28077                    let Some(val) = res else { break };
28078                    val
28079                }),
28080                2u16 => TaprioAttrs::SchedEntryList({
28081                    let res = Some(IterableTaprioSchedEntryList::with_loc(next, self.orig_loc));
28082                    let Some(val) = res else { break };
28083                    val
28084                }),
28085                3u16 => TaprioAttrs::SchedBaseTime({
28086                    let res = parse_i64(next);
28087                    let Some(val) = res else { break };
28088                    val
28089                }),
28090                4u16 => TaprioAttrs::SchedSingleEntry({
28091                    let res = Some(IterableTaprioSchedEntry::with_loc(next, self.orig_loc));
28092                    let Some(val) = res else { break };
28093                    val
28094                }),
28095                5u16 => TaprioAttrs::SchedClockid({
28096                    let res = parse_i32(next);
28097                    let Some(val) = res else { break };
28098                    val
28099                }),
28100                6u16 => TaprioAttrs::Pad({
28101                    let res = Some(next);
28102                    let Some(val) = res else { break };
28103                    val
28104                }),
28105                7u16 => TaprioAttrs::AdminSched({
28106                    let res = Some(next);
28107                    let Some(val) = res else { break };
28108                    val
28109                }),
28110                8u16 => TaprioAttrs::SchedCycleTime({
28111                    let res = parse_i64(next);
28112                    let Some(val) = res else { break };
28113                    val
28114                }),
28115                9u16 => TaprioAttrs::SchedCycleTimeExtension({
28116                    let res = parse_i64(next);
28117                    let Some(val) = res else { break };
28118                    val
28119                }),
28120                10u16 => TaprioAttrs::Flags({
28121                    let res = parse_u32(next);
28122                    let Some(val) = res else { break };
28123                    val
28124                }),
28125                11u16 => TaprioAttrs::TxtimeDelay({
28126                    let res = parse_u32(next);
28127                    let Some(val) = res else { break };
28128                    val
28129                }),
28130                12u16 => TaprioAttrs::TcEntry({
28131                    let res = Some(IterableTaprioTcEntryAttrs::with_loc(next, self.orig_loc));
28132                    let Some(val) = res else { break };
28133                    val
28134                }),
28135                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
28136                n => continue,
28137            };
28138            return Some(Ok(res));
28139        }
28140        Some(Err(ErrorContext::new(
28141            "TaprioAttrs",
28142            r#type.and_then(|t| TaprioAttrs::attr_from_type(t)),
28143            self.orig_loc,
28144            self.buf.as_ptr().wrapping_add(pos) as usize,
28145        )))
28146    }
28147}
28148impl<'a> std::fmt::Debug for IterableTaprioAttrs<'_> {
28149    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28150        let mut fmt = f.debug_struct("TaprioAttrs");
28151        for attr in self.clone() {
28152            let attr = match attr {
28153                Ok(a) => a,
28154                Err(err) => {
28155                    fmt.finish()?;
28156                    f.write_str("Err(")?;
28157                    err.fmt(f)?;
28158                    return f.write_str(")");
28159                }
28160            };
28161            match attr {
28162                TaprioAttrs::Priomap(val) => fmt.field("Priomap", &val),
28163                TaprioAttrs::SchedEntryList(val) => fmt.field("SchedEntryList", &val),
28164                TaprioAttrs::SchedBaseTime(val) => fmt.field("SchedBaseTime", &val),
28165                TaprioAttrs::SchedSingleEntry(val) => fmt.field("SchedSingleEntry", &val),
28166                TaprioAttrs::SchedClockid(val) => fmt.field("SchedClockid", &val),
28167                TaprioAttrs::Pad(val) => fmt.field("Pad", &val),
28168                TaprioAttrs::AdminSched(val) => fmt.field("AdminSched", &val),
28169                TaprioAttrs::SchedCycleTime(val) => fmt.field("SchedCycleTime", &val),
28170                TaprioAttrs::SchedCycleTimeExtension(val) => {
28171                    fmt.field("SchedCycleTimeExtension", &val)
28172                }
28173                TaprioAttrs::Flags(val) => fmt.field("Flags", &val),
28174                TaprioAttrs::TxtimeDelay(val) => fmt.field("TxtimeDelay", &val),
28175                TaprioAttrs::TcEntry(val) => fmt.field("TcEntry", &val),
28176            };
28177        }
28178        fmt.finish()
28179    }
28180}
28181impl IterableTaprioAttrs<'_> {
28182    pub fn lookup_attr(
28183        &self,
28184        offset: usize,
28185        missing_type: Option<u16>,
28186    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
28187        let mut stack = Vec::new();
28188        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
28189        if missing_type.is_some() && cur == offset {
28190            stack.push(("TaprioAttrs", offset));
28191            return (
28192                stack,
28193                missing_type.and_then(|t| TaprioAttrs::attr_from_type(t)),
28194            );
28195        }
28196        if cur > offset || cur + self.buf.len() < offset {
28197            return (stack, None);
28198        }
28199        let mut attrs = self.clone();
28200        let mut last_off = cur + attrs.pos;
28201        let mut missing = None;
28202        while let Some(attr) = attrs.next() {
28203            let Ok(attr) = attr else { break };
28204            match attr {
28205                TaprioAttrs::Priomap(val) => {
28206                    if last_off == offset {
28207                        stack.push(("Priomap", last_off));
28208                        break;
28209                    }
28210                }
28211                TaprioAttrs::SchedEntryList(val) => {
28212                    (stack, missing) = val.lookup_attr(offset, missing_type);
28213                    if !stack.is_empty() {
28214                        break;
28215                    }
28216                }
28217                TaprioAttrs::SchedBaseTime(val) => {
28218                    if last_off == offset {
28219                        stack.push(("SchedBaseTime", last_off));
28220                        break;
28221                    }
28222                }
28223                TaprioAttrs::SchedSingleEntry(val) => {
28224                    (stack, missing) = val.lookup_attr(offset, missing_type);
28225                    if !stack.is_empty() {
28226                        break;
28227                    }
28228                }
28229                TaprioAttrs::SchedClockid(val) => {
28230                    if last_off == offset {
28231                        stack.push(("SchedClockid", last_off));
28232                        break;
28233                    }
28234                }
28235                TaprioAttrs::Pad(val) => {
28236                    if last_off == offset {
28237                        stack.push(("Pad", last_off));
28238                        break;
28239                    }
28240                }
28241                TaprioAttrs::AdminSched(val) => {
28242                    if last_off == offset {
28243                        stack.push(("AdminSched", last_off));
28244                        break;
28245                    }
28246                }
28247                TaprioAttrs::SchedCycleTime(val) => {
28248                    if last_off == offset {
28249                        stack.push(("SchedCycleTime", last_off));
28250                        break;
28251                    }
28252                }
28253                TaprioAttrs::SchedCycleTimeExtension(val) => {
28254                    if last_off == offset {
28255                        stack.push(("SchedCycleTimeExtension", last_off));
28256                        break;
28257                    }
28258                }
28259                TaprioAttrs::Flags(val) => {
28260                    if last_off == offset {
28261                        stack.push(("Flags", last_off));
28262                        break;
28263                    }
28264                }
28265                TaprioAttrs::TxtimeDelay(val) => {
28266                    if last_off == offset {
28267                        stack.push(("TxtimeDelay", last_off));
28268                        break;
28269                    }
28270                }
28271                TaprioAttrs::TcEntry(val) => {
28272                    (stack, missing) = val.lookup_attr(offset, missing_type);
28273                    if !stack.is_empty() {
28274                        break;
28275                    }
28276                }
28277                _ => {}
28278            };
28279            last_off = cur + attrs.pos;
28280        }
28281        if !stack.is_empty() {
28282            stack.push(("TaprioAttrs", cur));
28283        }
28284        (stack, missing)
28285    }
28286}
28287#[derive(Clone)]
28288pub enum TaprioSchedEntryList<'a> {
28289    #[doc = "Attribute may repeat multiple times (treat it as array)"]
28290    Entry(IterableTaprioSchedEntry<'a>),
28291}
28292impl<'a> IterableTaprioSchedEntryList<'a> {
28293    #[doc = "Attribute may repeat multiple times (treat it as array)"]
28294    pub fn get_entry(
28295        &self,
28296    ) -> MultiAttrIterable<Self, TaprioSchedEntryList<'a>, IterableTaprioSchedEntry<'a>> {
28297        MultiAttrIterable::new(self.clone(), |variant| {
28298            if let TaprioSchedEntryList::Entry(val) = variant {
28299                Some(val)
28300            } else {
28301                None
28302            }
28303        })
28304    }
28305}
28306impl TaprioSchedEntryList<'_> {
28307    pub fn new<'a>(buf: &'a [u8]) -> IterableTaprioSchedEntryList<'a> {
28308        IterableTaprioSchedEntryList::with_loc(buf, buf.as_ptr() as usize)
28309    }
28310    fn attr_from_type(r#type: u16) -> Option<&'static str> {
28311        let res = match r#type {
28312            1u16 => "Entry",
28313            _ => return None,
28314        };
28315        Some(res)
28316    }
28317}
28318#[derive(Clone, Copy, Default)]
28319pub struct IterableTaprioSchedEntryList<'a> {
28320    buf: &'a [u8],
28321    pos: usize,
28322    orig_loc: usize,
28323}
28324impl<'a> IterableTaprioSchedEntryList<'a> {
28325    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
28326        Self {
28327            buf,
28328            pos: 0,
28329            orig_loc,
28330        }
28331    }
28332    pub fn get_buf(&self) -> &'a [u8] {
28333        self.buf
28334    }
28335}
28336impl<'a> Iterator for IterableTaprioSchedEntryList<'a> {
28337    type Item = Result<TaprioSchedEntryList<'a>, ErrorContext>;
28338    fn next(&mut self) -> Option<Self::Item> {
28339        let pos = self.pos;
28340        let mut r#type;
28341        loop {
28342            r#type = None;
28343            if self.buf.len() == self.pos {
28344                return None;
28345            }
28346            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
28347                break;
28348            };
28349            r#type = Some(header.r#type);
28350            let res = match header.r#type {
28351                1u16 => TaprioSchedEntryList::Entry({
28352                    let res = Some(IterableTaprioSchedEntry::with_loc(next, self.orig_loc));
28353                    let Some(val) = res else { break };
28354                    val
28355                }),
28356                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
28357                n => continue,
28358            };
28359            return Some(Ok(res));
28360        }
28361        Some(Err(ErrorContext::new(
28362            "TaprioSchedEntryList",
28363            r#type.and_then(|t| TaprioSchedEntryList::attr_from_type(t)),
28364            self.orig_loc,
28365            self.buf.as_ptr().wrapping_add(pos) as usize,
28366        )))
28367    }
28368}
28369impl<'a> std::fmt::Debug for IterableTaprioSchedEntryList<'_> {
28370    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28371        let mut fmt = f.debug_struct("TaprioSchedEntryList");
28372        for attr in self.clone() {
28373            let attr = match attr {
28374                Ok(a) => a,
28375                Err(err) => {
28376                    fmt.finish()?;
28377                    f.write_str("Err(")?;
28378                    err.fmt(f)?;
28379                    return f.write_str(")");
28380                }
28381            };
28382            match attr {
28383                TaprioSchedEntryList::Entry(val) => fmt.field("Entry", &val),
28384            };
28385        }
28386        fmt.finish()
28387    }
28388}
28389impl IterableTaprioSchedEntryList<'_> {
28390    pub fn lookup_attr(
28391        &self,
28392        offset: usize,
28393        missing_type: Option<u16>,
28394    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
28395        let mut stack = Vec::new();
28396        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
28397        if missing_type.is_some() && cur == offset {
28398            stack.push(("TaprioSchedEntryList", offset));
28399            return (
28400                stack,
28401                missing_type.and_then(|t| TaprioSchedEntryList::attr_from_type(t)),
28402            );
28403        }
28404        if cur > offset || cur + self.buf.len() < offset {
28405            return (stack, None);
28406        }
28407        let mut attrs = self.clone();
28408        let mut last_off = cur + attrs.pos;
28409        let mut missing = None;
28410        while let Some(attr) = attrs.next() {
28411            let Ok(attr) = attr else { break };
28412            match attr {
28413                TaprioSchedEntryList::Entry(val) => {
28414                    (stack, missing) = val.lookup_attr(offset, missing_type);
28415                    if !stack.is_empty() {
28416                        break;
28417                    }
28418                }
28419                _ => {}
28420            };
28421            last_off = cur + attrs.pos;
28422        }
28423        if !stack.is_empty() {
28424            stack.push(("TaprioSchedEntryList", cur));
28425        }
28426        (stack, missing)
28427    }
28428}
28429#[derive(Clone)]
28430pub enum TaprioSchedEntry {
28431    Index(u32),
28432    Cmd(u8),
28433    GateMask(u32),
28434    Interval(u32),
28435}
28436impl<'a> IterableTaprioSchedEntry<'a> {
28437    pub fn get_index(&self) -> Result<u32, ErrorContext> {
28438        let mut iter = self.clone();
28439        iter.pos = 0;
28440        for attr in iter {
28441            if let TaprioSchedEntry::Index(val) = attr? {
28442                return Ok(val);
28443            }
28444        }
28445        Err(ErrorContext::new_missing(
28446            "TaprioSchedEntry",
28447            "Index",
28448            self.orig_loc,
28449            self.buf.as_ptr() as usize,
28450        ))
28451    }
28452    pub fn get_cmd(&self) -> Result<u8, ErrorContext> {
28453        let mut iter = self.clone();
28454        iter.pos = 0;
28455        for attr in iter {
28456            if let TaprioSchedEntry::Cmd(val) = attr? {
28457                return Ok(val);
28458            }
28459        }
28460        Err(ErrorContext::new_missing(
28461            "TaprioSchedEntry",
28462            "Cmd",
28463            self.orig_loc,
28464            self.buf.as_ptr() as usize,
28465        ))
28466    }
28467    pub fn get_gate_mask(&self) -> Result<u32, ErrorContext> {
28468        let mut iter = self.clone();
28469        iter.pos = 0;
28470        for attr in iter {
28471            if let TaprioSchedEntry::GateMask(val) = attr? {
28472                return Ok(val);
28473            }
28474        }
28475        Err(ErrorContext::new_missing(
28476            "TaprioSchedEntry",
28477            "GateMask",
28478            self.orig_loc,
28479            self.buf.as_ptr() as usize,
28480        ))
28481    }
28482    pub fn get_interval(&self) -> Result<u32, ErrorContext> {
28483        let mut iter = self.clone();
28484        iter.pos = 0;
28485        for attr in iter {
28486            if let TaprioSchedEntry::Interval(val) = attr? {
28487                return Ok(val);
28488            }
28489        }
28490        Err(ErrorContext::new_missing(
28491            "TaprioSchedEntry",
28492            "Interval",
28493            self.orig_loc,
28494            self.buf.as_ptr() as usize,
28495        ))
28496    }
28497}
28498impl TaprioSchedEntry {
28499    pub fn new<'a>(buf: &'a [u8]) -> IterableTaprioSchedEntry<'a> {
28500        IterableTaprioSchedEntry::with_loc(buf, buf.as_ptr() as usize)
28501    }
28502    fn attr_from_type(r#type: u16) -> Option<&'static str> {
28503        let res = match r#type {
28504            1u16 => "Index",
28505            2u16 => "Cmd",
28506            3u16 => "GateMask",
28507            4u16 => "Interval",
28508            _ => return None,
28509        };
28510        Some(res)
28511    }
28512}
28513#[derive(Clone, Copy, Default)]
28514pub struct IterableTaprioSchedEntry<'a> {
28515    buf: &'a [u8],
28516    pos: usize,
28517    orig_loc: usize,
28518}
28519impl<'a> IterableTaprioSchedEntry<'a> {
28520    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
28521        Self {
28522            buf,
28523            pos: 0,
28524            orig_loc,
28525        }
28526    }
28527    pub fn get_buf(&self) -> &'a [u8] {
28528        self.buf
28529    }
28530}
28531impl<'a> Iterator for IterableTaprioSchedEntry<'a> {
28532    type Item = Result<TaprioSchedEntry, ErrorContext>;
28533    fn next(&mut self) -> Option<Self::Item> {
28534        let pos = self.pos;
28535        let mut r#type;
28536        loop {
28537            r#type = None;
28538            if self.buf.len() == self.pos {
28539                return None;
28540            }
28541            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
28542                break;
28543            };
28544            r#type = Some(header.r#type);
28545            let res = match header.r#type {
28546                1u16 => TaprioSchedEntry::Index({
28547                    let res = parse_u32(next);
28548                    let Some(val) = res else { break };
28549                    val
28550                }),
28551                2u16 => TaprioSchedEntry::Cmd({
28552                    let res = parse_u8(next);
28553                    let Some(val) = res else { break };
28554                    val
28555                }),
28556                3u16 => TaprioSchedEntry::GateMask({
28557                    let res = parse_u32(next);
28558                    let Some(val) = res else { break };
28559                    val
28560                }),
28561                4u16 => TaprioSchedEntry::Interval({
28562                    let res = parse_u32(next);
28563                    let Some(val) = res else { break };
28564                    val
28565                }),
28566                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
28567                n => continue,
28568            };
28569            return Some(Ok(res));
28570        }
28571        Some(Err(ErrorContext::new(
28572            "TaprioSchedEntry",
28573            r#type.and_then(|t| TaprioSchedEntry::attr_from_type(t)),
28574            self.orig_loc,
28575            self.buf.as_ptr().wrapping_add(pos) as usize,
28576        )))
28577    }
28578}
28579impl std::fmt::Debug for IterableTaprioSchedEntry<'_> {
28580    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28581        let mut fmt = f.debug_struct("TaprioSchedEntry");
28582        for attr in self.clone() {
28583            let attr = match attr {
28584                Ok(a) => a,
28585                Err(err) => {
28586                    fmt.finish()?;
28587                    f.write_str("Err(")?;
28588                    err.fmt(f)?;
28589                    return f.write_str(")");
28590                }
28591            };
28592            match attr {
28593                TaprioSchedEntry::Index(val) => fmt.field("Index", &val),
28594                TaprioSchedEntry::Cmd(val) => fmt.field("Cmd", &val),
28595                TaprioSchedEntry::GateMask(val) => fmt.field("GateMask", &val),
28596                TaprioSchedEntry::Interval(val) => fmt.field("Interval", &val),
28597            };
28598        }
28599        fmt.finish()
28600    }
28601}
28602impl IterableTaprioSchedEntry<'_> {
28603    pub fn lookup_attr(
28604        &self,
28605        offset: usize,
28606        missing_type: Option<u16>,
28607    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
28608        let mut stack = Vec::new();
28609        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
28610        if missing_type.is_some() && cur == offset {
28611            stack.push(("TaprioSchedEntry", offset));
28612            return (
28613                stack,
28614                missing_type.and_then(|t| TaprioSchedEntry::attr_from_type(t)),
28615            );
28616        }
28617        if cur > offset || cur + self.buf.len() < offset {
28618            return (stack, None);
28619        }
28620        let mut attrs = self.clone();
28621        let mut last_off = cur + attrs.pos;
28622        while let Some(attr) = attrs.next() {
28623            let Ok(attr) = attr else { break };
28624            match attr {
28625                TaprioSchedEntry::Index(val) => {
28626                    if last_off == offset {
28627                        stack.push(("Index", last_off));
28628                        break;
28629                    }
28630                }
28631                TaprioSchedEntry::Cmd(val) => {
28632                    if last_off == offset {
28633                        stack.push(("Cmd", last_off));
28634                        break;
28635                    }
28636                }
28637                TaprioSchedEntry::GateMask(val) => {
28638                    if last_off == offset {
28639                        stack.push(("GateMask", last_off));
28640                        break;
28641                    }
28642                }
28643                TaprioSchedEntry::Interval(val) => {
28644                    if last_off == offset {
28645                        stack.push(("Interval", last_off));
28646                        break;
28647                    }
28648                }
28649                _ => {}
28650            };
28651            last_off = cur + attrs.pos;
28652        }
28653        if !stack.is_empty() {
28654            stack.push(("TaprioSchedEntry", cur));
28655        }
28656        (stack, None)
28657    }
28658}
28659#[derive(Clone)]
28660pub enum TaprioTcEntryAttrs {
28661    Index(u32),
28662    MaxSdu(u32),
28663    Fp(u32),
28664}
28665impl<'a> IterableTaprioTcEntryAttrs<'a> {
28666    pub fn get_index(&self) -> Result<u32, ErrorContext> {
28667        let mut iter = self.clone();
28668        iter.pos = 0;
28669        for attr in iter {
28670            if let TaprioTcEntryAttrs::Index(val) = attr? {
28671                return Ok(val);
28672            }
28673        }
28674        Err(ErrorContext::new_missing(
28675            "TaprioTcEntryAttrs",
28676            "Index",
28677            self.orig_loc,
28678            self.buf.as_ptr() as usize,
28679        ))
28680    }
28681    pub fn get_max_sdu(&self) -> Result<u32, ErrorContext> {
28682        let mut iter = self.clone();
28683        iter.pos = 0;
28684        for attr in iter {
28685            if let TaprioTcEntryAttrs::MaxSdu(val) = attr? {
28686                return Ok(val);
28687            }
28688        }
28689        Err(ErrorContext::new_missing(
28690            "TaprioTcEntryAttrs",
28691            "MaxSdu",
28692            self.orig_loc,
28693            self.buf.as_ptr() as usize,
28694        ))
28695    }
28696    pub fn get_fp(&self) -> Result<u32, ErrorContext> {
28697        let mut iter = self.clone();
28698        iter.pos = 0;
28699        for attr in iter {
28700            if let TaprioTcEntryAttrs::Fp(val) = attr? {
28701                return Ok(val);
28702            }
28703        }
28704        Err(ErrorContext::new_missing(
28705            "TaprioTcEntryAttrs",
28706            "Fp",
28707            self.orig_loc,
28708            self.buf.as_ptr() as usize,
28709        ))
28710    }
28711}
28712impl TaprioTcEntryAttrs {
28713    pub fn new<'a>(buf: &'a [u8]) -> IterableTaprioTcEntryAttrs<'a> {
28714        IterableTaprioTcEntryAttrs::with_loc(buf, buf.as_ptr() as usize)
28715    }
28716    fn attr_from_type(r#type: u16) -> Option<&'static str> {
28717        let res = match r#type {
28718            1u16 => "Index",
28719            2u16 => "MaxSdu",
28720            3u16 => "Fp",
28721            _ => return None,
28722        };
28723        Some(res)
28724    }
28725}
28726#[derive(Clone, Copy, Default)]
28727pub struct IterableTaprioTcEntryAttrs<'a> {
28728    buf: &'a [u8],
28729    pos: usize,
28730    orig_loc: usize,
28731}
28732impl<'a> IterableTaprioTcEntryAttrs<'a> {
28733    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
28734        Self {
28735            buf,
28736            pos: 0,
28737            orig_loc,
28738        }
28739    }
28740    pub fn get_buf(&self) -> &'a [u8] {
28741        self.buf
28742    }
28743}
28744impl<'a> Iterator for IterableTaprioTcEntryAttrs<'a> {
28745    type Item = Result<TaprioTcEntryAttrs, ErrorContext>;
28746    fn next(&mut self) -> Option<Self::Item> {
28747        let pos = self.pos;
28748        let mut r#type;
28749        loop {
28750            r#type = None;
28751            if self.buf.len() == self.pos {
28752                return None;
28753            }
28754            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
28755                break;
28756            };
28757            r#type = Some(header.r#type);
28758            let res = match header.r#type {
28759                1u16 => TaprioTcEntryAttrs::Index({
28760                    let res = parse_u32(next);
28761                    let Some(val) = res else { break };
28762                    val
28763                }),
28764                2u16 => TaprioTcEntryAttrs::MaxSdu({
28765                    let res = parse_u32(next);
28766                    let Some(val) = res else { break };
28767                    val
28768                }),
28769                3u16 => TaprioTcEntryAttrs::Fp({
28770                    let res = parse_u32(next);
28771                    let Some(val) = res else { break };
28772                    val
28773                }),
28774                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
28775                n => continue,
28776            };
28777            return Some(Ok(res));
28778        }
28779        Some(Err(ErrorContext::new(
28780            "TaprioTcEntryAttrs",
28781            r#type.and_then(|t| TaprioTcEntryAttrs::attr_from_type(t)),
28782            self.orig_loc,
28783            self.buf.as_ptr().wrapping_add(pos) as usize,
28784        )))
28785    }
28786}
28787impl std::fmt::Debug for IterableTaprioTcEntryAttrs<'_> {
28788    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28789        let mut fmt = f.debug_struct("TaprioTcEntryAttrs");
28790        for attr in self.clone() {
28791            let attr = match attr {
28792                Ok(a) => a,
28793                Err(err) => {
28794                    fmt.finish()?;
28795                    f.write_str("Err(")?;
28796                    err.fmt(f)?;
28797                    return f.write_str(")");
28798                }
28799            };
28800            match attr {
28801                TaprioTcEntryAttrs::Index(val) => fmt.field("Index", &val),
28802                TaprioTcEntryAttrs::MaxSdu(val) => fmt.field("MaxSdu", &val),
28803                TaprioTcEntryAttrs::Fp(val) => fmt.field("Fp", &val),
28804            };
28805        }
28806        fmt.finish()
28807    }
28808}
28809impl IterableTaprioTcEntryAttrs<'_> {
28810    pub fn lookup_attr(
28811        &self,
28812        offset: usize,
28813        missing_type: Option<u16>,
28814    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
28815        let mut stack = Vec::new();
28816        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
28817        if missing_type.is_some() && cur == offset {
28818            stack.push(("TaprioTcEntryAttrs", offset));
28819            return (
28820                stack,
28821                missing_type.and_then(|t| TaprioTcEntryAttrs::attr_from_type(t)),
28822            );
28823        }
28824        if cur > offset || cur + self.buf.len() < offset {
28825            return (stack, None);
28826        }
28827        let mut attrs = self.clone();
28828        let mut last_off = cur + attrs.pos;
28829        while let Some(attr) = attrs.next() {
28830            let Ok(attr) = attr else { break };
28831            match attr {
28832                TaprioTcEntryAttrs::Index(val) => {
28833                    if last_off == offset {
28834                        stack.push(("Index", last_off));
28835                        break;
28836                    }
28837                }
28838                TaprioTcEntryAttrs::MaxSdu(val) => {
28839                    if last_off == offset {
28840                        stack.push(("MaxSdu", last_off));
28841                        break;
28842                    }
28843                }
28844                TaprioTcEntryAttrs::Fp(val) => {
28845                    if last_off == offset {
28846                        stack.push(("Fp", last_off));
28847                        break;
28848                    }
28849                }
28850                _ => {}
28851            };
28852            last_off = cur + attrs.pos;
28853        }
28854        if !stack.is_empty() {
28855            stack.push(("TaprioTcEntryAttrs", cur));
28856        }
28857        (stack, None)
28858    }
28859}
28860#[derive(Clone)]
28861pub enum TbfAttrs<'a> {
28862    Parms(TcTbfQopt),
28863    Rtab(&'a [u8]),
28864    Ptab(&'a [u8]),
28865    Rate64(u64),
28866    Prate64(u64),
28867    Burst(u32),
28868    Pburst(u32),
28869    Pad(&'a [u8]),
28870}
28871impl<'a> IterableTbfAttrs<'a> {
28872    pub fn get_parms(&self) -> Result<TcTbfQopt, ErrorContext> {
28873        let mut iter = self.clone();
28874        iter.pos = 0;
28875        for attr in iter {
28876            if let TbfAttrs::Parms(val) = attr? {
28877                return Ok(val);
28878            }
28879        }
28880        Err(ErrorContext::new_missing(
28881            "TbfAttrs",
28882            "Parms",
28883            self.orig_loc,
28884            self.buf.as_ptr() as usize,
28885        ))
28886    }
28887    pub fn get_rtab(&self) -> Result<&'a [u8], ErrorContext> {
28888        let mut iter = self.clone();
28889        iter.pos = 0;
28890        for attr in iter {
28891            if let TbfAttrs::Rtab(val) = attr? {
28892                return Ok(val);
28893            }
28894        }
28895        Err(ErrorContext::new_missing(
28896            "TbfAttrs",
28897            "Rtab",
28898            self.orig_loc,
28899            self.buf.as_ptr() as usize,
28900        ))
28901    }
28902    pub fn get_ptab(&self) -> Result<&'a [u8], ErrorContext> {
28903        let mut iter = self.clone();
28904        iter.pos = 0;
28905        for attr in iter {
28906            if let TbfAttrs::Ptab(val) = attr? {
28907                return Ok(val);
28908            }
28909        }
28910        Err(ErrorContext::new_missing(
28911            "TbfAttrs",
28912            "Ptab",
28913            self.orig_loc,
28914            self.buf.as_ptr() as usize,
28915        ))
28916    }
28917    pub fn get_rate64(&self) -> Result<u64, ErrorContext> {
28918        let mut iter = self.clone();
28919        iter.pos = 0;
28920        for attr in iter {
28921            if let TbfAttrs::Rate64(val) = attr? {
28922                return Ok(val);
28923            }
28924        }
28925        Err(ErrorContext::new_missing(
28926            "TbfAttrs",
28927            "Rate64",
28928            self.orig_loc,
28929            self.buf.as_ptr() as usize,
28930        ))
28931    }
28932    pub fn get_prate64(&self) -> Result<u64, ErrorContext> {
28933        let mut iter = self.clone();
28934        iter.pos = 0;
28935        for attr in iter {
28936            if let TbfAttrs::Prate64(val) = attr? {
28937                return Ok(val);
28938            }
28939        }
28940        Err(ErrorContext::new_missing(
28941            "TbfAttrs",
28942            "Prate64",
28943            self.orig_loc,
28944            self.buf.as_ptr() as usize,
28945        ))
28946    }
28947    pub fn get_burst(&self) -> Result<u32, ErrorContext> {
28948        let mut iter = self.clone();
28949        iter.pos = 0;
28950        for attr in iter {
28951            if let TbfAttrs::Burst(val) = attr? {
28952                return Ok(val);
28953            }
28954        }
28955        Err(ErrorContext::new_missing(
28956            "TbfAttrs",
28957            "Burst",
28958            self.orig_loc,
28959            self.buf.as_ptr() as usize,
28960        ))
28961    }
28962    pub fn get_pburst(&self) -> Result<u32, ErrorContext> {
28963        let mut iter = self.clone();
28964        iter.pos = 0;
28965        for attr in iter {
28966            if let TbfAttrs::Pburst(val) = attr? {
28967                return Ok(val);
28968            }
28969        }
28970        Err(ErrorContext::new_missing(
28971            "TbfAttrs",
28972            "Pburst",
28973            self.orig_loc,
28974            self.buf.as_ptr() as usize,
28975        ))
28976    }
28977    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
28978        let mut iter = self.clone();
28979        iter.pos = 0;
28980        for attr in iter {
28981            if let TbfAttrs::Pad(val) = attr? {
28982                return Ok(val);
28983            }
28984        }
28985        Err(ErrorContext::new_missing(
28986            "TbfAttrs",
28987            "Pad",
28988            self.orig_loc,
28989            self.buf.as_ptr() as usize,
28990        ))
28991    }
28992}
28993impl TbfAttrs<'_> {
28994    pub fn new<'a>(buf: &'a [u8]) -> IterableTbfAttrs<'a> {
28995        IterableTbfAttrs::with_loc(buf, buf.as_ptr() as usize)
28996    }
28997    fn attr_from_type(r#type: u16) -> Option<&'static str> {
28998        let res = match r#type {
28999            1u16 => "Parms",
29000            2u16 => "Rtab",
29001            3u16 => "Ptab",
29002            4u16 => "Rate64",
29003            5u16 => "Prate64",
29004            6u16 => "Burst",
29005            7u16 => "Pburst",
29006            8u16 => "Pad",
29007            _ => return None,
29008        };
29009        Some(res)
29010    }
29011}
29012#[derive(Clone, Copy, Default)]
29013pub struct IterableTbfAttrs<'a> {
29014    buf: &'a [u8],
29015    pos: usize,
29016    orig_loc: usize,
29017}
29018impl<'a> IterableTbfAttrs<'a> {
29019    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
29020        Self {
29021            buf,
29022            pos: 0,
29023            orig_loc,
29024        }
29025    }
29026    pub fn get_buf(&self) -> &'a [u8] {
29027        self.buf
29028    }
29029}
29030impl<'a> Iterator for IterableTbfAttrs<'a> {
29031    type Item = Result<TbfAttrs<'a>, ErrorContext>;
29032    fn next(&mut self) -> Option<Self::Item> {
29033        let pos = self.pos;
29034        let mut r#type;
29035        loop {
29036            r#type = None;
29037            if self.buf.len() == self.pos {
29038                return None;
29039            }
29040            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
29041                break;
29042            };
29043            r#type = Some(header.r#type);
29044            let res = match header.r#type {
29045                1u16 => TbfAttrs::Parms({
29046                    let res = Some(TcTbfQopt::new_from_zeroed(next));
29047                    let Some(val) = res else { break };
29048                    val
29049                }),
29050                2u16 => TbfAttrs::Rtab({
29051                    let res = Some(next);
29052                    let Some(val) = res else { break };
29053                    val
29054                }),
29055                3u16 => TbfAttrs::Ptab({
29056                    let res = Some(next);
29057                    let Some(val) = res else { break };
29058                    val
29059                }),
29060                4u16 => TbfAttrs::Rate64({
29061                    let res = parse_u64(next);
29062                    let Some(val) = res else { break };
29063                    val
29064                }),
29065                5u16 => TbfAttrs::Prate64({
29066                    let res = parse_u64(next);
29067                    let Some(val) = res else { break };
29068                    val
29069                }),
29070                6u16 => TbfAttrs::Burst({
29071                    let res = parse_u32(next);
29072                    let Some(val) = res else { break };
29073                    val
29074                }),
29075                7u16 => TbfAttrs::Pburst({
29076                    let res = parse_u32(next);
29077                    let Some(val) = res else { break };
29078                    val
29079                }),
29080                8u16 => TbfAttrs::Pad({
29081                    let res = Some(next);
29082                    let Some(val) = res else { break };
29083                    val
29084                }),
29085                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
29086                n => continue,
29087            };
29088            return Some(Ok(res));
29089        }
29090        Some(Err(ErrorContext::new(
29091            "TbfAttrs",
29092            r#type.and_then(|t| TbfAttrs::attr_from_type(t)),
29093            self.orig_loc,
29094            self.buf.as_ptr().wrapping_add(pos) as usize,
29095        )))
29096    }
29097}
29098impl<'a> std::fmt::Debug for IterableTbfAttrs<'_> {
29099    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29100        let mut fmt = f.debug_struct("TbfAttrs");
29101        for attr in self.clone() {
29102            let attr = match attr {
29103                Ok(a) => a,
29104                Err(err) => {
29105                    fmt.finish()?;
29106                    f.write_str("Err(")?;
29107                    err.fmt(f)?;
29108                    return f.write_str(")");
29109                }
29110            };
29111            match attr {
29112                TbfAttrs::Parms(val) => fmt.field("Parms", &val),
29113                TbfAttrs::Rtab(val) => fmt.field("Rtab", &val),
29114                TbfAttrs::Ptab(val) => fmt.field("Ptab", &val),
29115                TbfAttrs::Rate64(val) => fmt.field("Rate64", &val),
29116                TbfAttrs::Prate64(val) => fmt.field("Prate64", &val),
29117                TbfAttrs::Burst(val) => fmt.field("Burst", &val),
29118                TbfAttrs::Pburst(val) => fmt.field("Pburst", &val),
29119                TbfAttrs::Pad(val) => fmt.field("Pad", &val),
29120            };
29121        }
29122        fmt.finish()
29123    }
29124}
29125impl IterableTbfAttrs<'_> {
29126    pub fn lookup_attr(
29127        &self,
29128        offset: usize,
29129        missing_type: Option<u16>,
29130    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
29131        let mut stack = Vec::new();
29132        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
29133        if missing_type.is_some() && cur == offset {
29134            stack.push(("TbfAttrs", offset));
29135            return (
29136                stack,
29137                missing_type.and_then(|t| TbfAttrs::attr_from_type(t)),
29138            );
29139        }
29140        if cur > offset || cur + self.buf.len() < offset {
29141            return (stack, None);
29142        }
29143        let mut attrs = self.clone();
29144        let mut last_off = cur + attrs.pos;
29145        while let Some(attr) = attrs.next() {
29146            let Ok(attr) = attr else { break };
29147            match attr {
29148                TbfAttrs::Parms(val) => {
29149                    if last_off == offset {
29150                        stack.push(("Parms", last_off));
29151                        break;
29152                    }
29153                }
29154                TbfAttrs::Rtab(val) => {
29155                    if last_off == offset {
29156                        stack.push(("Rtab", last_off));
29157                        break;
29158                    }
29159                }
29160                TbfAttrs::Ptab(val) => {
29161                    if last_off == offset {
29162                        stack.push(("Ptab", last_off));
29163                        break;
29164                    }
29165                }
29166                TbfAttrs::Rate64(val) => {
29167                    if last_off == offset {
29168                        stack.push(("Rate64", last_off));
29169                        break;
29170                    }
29171                }
29172                TbfAttrs::Prate64(val) => {
29173                    if last_off == offset {
29174                        stack.push(("Prate64", last_off));
29175                        break;
29176                    }
29177                }
29178                TbfAttrs::Burst(val) => {
29179                    if last_off == offset {
29180                        stack.push(("Burst", last_off));
29181                        break;
29182                    }
29183                }
29184                TbfAttrs::Pburst(val) => {
29185                    if last_off == offset {
29186                        stack.push(("Pburst", last_off));
29187                        break;
29188                    }
29189                }
29190                TbfAttrs::Pad(val) => {
29191                    if last_off == offset {
29192                        stack.push(("Pad", last_off));
29193                        break;
29194                    }
29195                }
29196                _ => {}
29197            };
29198            last_off = cur + attrs.pos;
29199        }
29200        if !stack.is_empty() {
29201            stack.push(("TbfAttrs", cur));
29202        }
29203        (stack, None)
29204    }
29205}
29206#[derive(Clone)]
29207pub enum ActSampleAttrs<'a> {
29208    Tm(TcfT),
29209    Parms(TcGact),
29210    Rate(u32),
29211    TruncSize(u32),
29212    PsampleGroup(u32),
29213    Pad(&'a [u8]),
29214}
29215impl<'a> IterableActSampleAttrs<'a> {
29216    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
29217        let mut iter = self.clone();
29218        iter.pos = 0;
29219        for attr in iter {
29220            if let ActSampleAttrs::Tm(val) = attr? {
29221                return Ok(val);
29222            }
29223        }
29224        Err(ErrorContext::new_missing(
29225            "ActSampleAttrs",
29226            "Tm",
29227            self.orig_loc,
29228            self.buf.as_ptr() as usize,
29229        ))
29230    }
29231    pub fn get_parms(&self) -> Result<TcGact, ErrorContext> {
29232        let mut iter = self.clone();
29233        iter.pos = 0;
29234        for attr in iter {
29235            if let ActSampleAttrs::Parms(val) = attr? {
29236                return Ok(val);
29237            }
29238        }
29239        Err(ErrorContext::new_missing(
29240            "ActSampleAttrs",
29241            "Parms",
29242            self.orig_loc,
29243            self.buf.as_ptr() as usize,
29244        ))
29245    }
29246    pub fn get_rate(&self) -> Result<u32, ErrorContext> {
29247        let mut iter = self.clone();
29248        iter.pos = 0;
29249        for attr in iter {
29250            if let ActSampleAttrs::Rate(val) = attr? {
29251                return Ok(val);
29252            }
29253        }
29254        Err(ErrorContext::new_missing(
29255            "ActSampleAttrs",
29256            "Rate",
29257            self.orig_loc,
29258            self.buf.as_ptr() as usize,
29259        ))
29260    }
29261    pub fn get_trunc_size(&self) -> Result<u32, ErrorContext> {
29262        let mut iter = self.clone();
29263        iter.pos = 0;
29264        for attr in iter {
29265            if let ActSampleAttrs::TruncSize(val) = attr? {
29266                return Ok(val);
29267            }
29268        }
29269        Err(ErrorContext::new_missing(
29270            "ActSampleAttrs",
29271            "TruncSize",
29272            self.orig_loc,
29273            self.buf.as_ptr() as usize,
29274        ))
29275    }
29276    pub fn get_psample_group(&self) -> Result<u32, ErrorContext> {
29277        let mut iter = self.clone();
29278        iter.pos = 0;
29279        for attr in iter {
29280            if let ActSampleAttrs::PsampleGroup(val) = attr? {
29281                return Ok(val);
29282            }
29283        }
29284        Err(ErrorContext::new_missing(
29285            "ActSampleAttrs",
29286            "PsampleGroup",
29287            self.orig_loc,
29288            self.buf.as_ptr() as usize,
29289        ))
29290    }
29291    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
29292        let mut iter = self.clone();
29293        iter.pos = 0;
29294        for attr in iter {
29295            if let ActSampleAttrs::Pad(val) = attr? {
29296                return Ok(val);
29297            }
29298        }
29299        Err(ErrorContext::new_missing(
29300            "ActSampleAttrs",
29301            "Pad",
29302            self.orig_loc,
29303            self.buf.as_ptr() as usize,
29304        ))
29305    }
29306}
29307impl ActSampleAttrs<'_> {
29308    pub fn new<'a>(buf: &'a [u8]) -> IterableActSampleAttrs<'a> {
29309        IterableActSampleAttrs::with_loc(buf, buf.as_ptr() as usize)
29310    }
29311    fn attr_from_type(r#type: u16) -> Option<&'static str> {
29312        let res = match r#type {
29313            1u16 => "Tm",
29314            2u16 => "Parms",
29315            3u16 => "Rate",
29316            4u16 => "TruncSize",
29317            5u16 => "PsampleGroup",
29318            6u16 => "Pad",
29319            _ => return None,
29320        };
29321        Some(res)
29322    }
29323}
29324#[derive(Clone, Copy, Default)]
29325pub struct IterableActSampleAttrs<'a> {
29326    buf: &'a [u8],
29327    pos: usize,
29328    orig_loc: usize,
29329}
29330impl<'a> IterableActSampleAttrs<'a> {
29331    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
29332        Self {
29333            buf,
29334            pos: 0,
29335            orig_loc,
29336        }
29337    }
29338    pub fn get_buf(&self) -> &'a [u8] {
29339        self.buf
29340    }
29341}
29342impl<'a> Iterator for IterableActSampleAttrs<'a> {
29343    type Item = Result<ActSampleAttrs<'a>, ErrorContext>;
29344    fn next(&mut self) -> Option<Self::Item> {
29345        let pos = self.pos;
29346        let mut r#type;
29347        loop {
29348            r#type = None;
29349            if self.buf.len() == self.pos {
29350                return None;
29351            }
29352            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
29353                break;
29354            };
29355            r#type = Some(header.r#type);
29356            let res = match header.r#type {
29357                1u16 => ActSampleAttrs::Tm({
29358                    let res = Some(TcfT::new_from_zeroed(next));
29359                    let Some(val) = res else { break };
29360                    val
29361                }),
29362                2u16 => ActSampleAttrs::Parms({
29363                    let res = Some(TcGact::new_from_zeroed(next));
29364                    let Some(val) = res else { break };
29365                    val
29366                }),
29367                3u16 => ActSampleAttrs::Rate({
29368                    let res = parse_u32(next);
29369                    let Some(val) = res else { break };
29370                    val
29371                }),
29372                4u16 => ActSampleAttrs::TruncSize({
29373                    let res = parse_u32(next);
29374                    let Some(val) = res else { break };
29375                    val
29376                }),
29377                5u16 => ActSampleAttrs::PsampleGroup({
29378                    let res = parse_u32(next);
29379                    let Some(val) = res else { break };
29380                    val
29381                }),
29382                6u16 => ActSampleAttrs::Pad({
29383                    let res = Some(next);
29384                    let Some(val) = res else { break };
29385                    val
29386                }),
29387                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
29388                n => continue,
29389            };
29390            return Some(Ok(res));
29391        }
29392        Some(Err(ErrorContext::new(
29393            "ActSampleAttrs",
29394            r#type.and_then(|t| ActSampleAttrs::attr_from_type(t)),
29395            self.orig_loc,
29396            self.buf.as_ptr().wrapping_add(pos) as usize,
29397        )))
29398    }
29399}
29400impl<'a> std::fmt::Debug for IterableActSampleAttrs<'_> {
29401    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29402        let mut fmt = f.debug_struct("ActSampleAttrs");
29403        for attr in self.clone() {
29404            let attr = match attr {
29405                Ok(a) => a,
29406                Err(err) => {
29407                    fmt.finish()?;
29408                    f.write_str("Err(")?;
29409                    err.fmt(f)?;
29410                    return f.write_str(")");
29411                }
29412            };
29413            match attr {
29414                ActSampleAttrs::Tm(val) => fmt.field("Tm", &val),
29415                ActSampleAttrs::Parms(val) => fmt.field("Parms", &val),
29416                ActSampleAttrs::Rate(val) => fmt.field("Rate", &val),
29417                ActSampleAttrs::TruncSize(val) => fmt.field("TruncSize", &val),
29418                ActSampleAttrs::PsampleGroup(val) => fmt.field("PsampleGroup", &val),
29419                ActSampleAttrs::Pad(val) => fmt.field("Pad", &val),
29420            };
29421        }
29422        fmt.finish()
29423    }
29424}
29425impl IterableActSampleAttrs<'_> {
29426    pub fn lookup_attr(
29427        &self,
29428        offset: usize,
29429        missing_type: Option<u16>,
29430    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
29431        let mut stack = Vec::new();
29432        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
29433        if missing_type.is_some() && cur == offset {
29434            stack.push(("ActSampleAttrs", offset));
29435            return (
29436                stack,
29437                missing_type.and_then(|t| ActSampleAttrs::attr_from_type(t)),
29438            );
29439        }
29440        if cur > offset || cur + self.buf.len() < offset {
29441            return (stack, None);
29442        }
29443        let mut attrs = self.clone();
29444        let mut last_off = cur + attrs.pos;
29445        while let Some(attr) = attrs.next() {
29446            let Ok(attr) = attr else { break };
29447            match attr {
29448                ActSampleAttrs::Tm(val) => {
29449                    if last_off == offset {
29450                        stack.push(("Tm", last_off));
29451                        break;
29452                    }
29453                }
29454                ActSampleAttrs::Parms(val) => {
29455                    if last_off == offset {
29456                        stack.push(("Parms", last_off));
29457                        break;
29458                    }
29459                }
29460                ActSampleAttrs::Rate(val) => {
29461                    if last_off == offset {
29462                        stack.push(("Rate", last_off));
29463                        break;
29464                    }
29465                }
29466                ActSampleAttrs::TruncSize(val) => {
29467                    if last_off == offset {
29468                        stack.push(("TruncSize", last_off));
29469                        break;
29470                    }
29471                }
29472                ActSampleAttrs::PsampleGroup(val) => {
29473                    if last_off == offset {
29474                        stack.push(("PsampleGroup", last_off));
29475                        break;
29476                    }
29477                }
29478                ActSampleAttrs::Pad(val) => {
29479                    if last_off == offset {
29480                        stack.push(("Pad", last_off));
29481                        break;
29482                    }
29483                }
29484                _ => {}
29485            };
29486            last_off = cur + attrs.pos;
29487        }
29488        if !stack.is_empty() {
29489            stack.push(("ActSampleAttrs", cur));
29490        }
29491        (stack, None)
29492    }
29493}
29494#[derive(Clone)]
29495pub enum ActGactAttrs<'a> {
29496    Tm(TcfT),
29497    Parms(TcGact),
29498    Prob(TcGactP),
29499    Pad(&'a [u8]),
29500}
29501impl<'a> IterableActGactAttrs<'a> {
29502    pub fn get_tm(&self) -> Result<TcfT, ErrorContext> {
29503        let mut iter = self.clone();
29504        iter.pos = 0;
29505        for attr in iter {
29506            if let ActGactAttrs::Tm(val) = attr? {
29507                return Ok(val);
29508            }
29509        }
29510        Err(ErrorContext::new_missing(
29511            "ActGactAttrs",
29512            "Tm",
29513            self.orig_loc,
29514            self.buf.as_ptr() as usize,
29515        ))
29516    }
29517    pub fn get_parms(&self) -> Result<TcGact, ErrorContext> {
29518        let mut iter = self.clone();
29519        iter.pos = 0;
29520        for attr in iter {
29521            if let ActGactAttrs::Parms(val) = attr? {
29522                return Ok(val);
29523            }
29524        }
29525        Err(ErrorContext::new_missing(
29526            "ActGactAttrs",
29527            "Parms",
29528            self.orig_loc,
29529            self.buf.as_ptr() as usize,
29530        ))
29531    }
29532    pub fn get_prob(&self) -> Result<TcGactP, ErrorContext> {
29533        let mut iter = self.clone();
29534        iter.pos = 0;
29535        for attr in iter {
29536            if let ActGactAttrs::Prob(val) = attr? {
29537                return Ok(val);
29538            }
29539        }
29540        Err(ErrorContext::new_missing(
29541            "ActGactAttrs",
29542            "Prob",
29543            self.orig_loc,
29544            self.buf.as_ptr() as usize,
29545        ))
29546    }
29547    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
29548        let mut iter = self.clone();
29549        iter.pos = 0;
29550        for attr in iter {
29551            if let ActGactAttrs::Pad(val) = attr? {
29552                return Ok(val);
29553            }
29554        }
29555        Err(ErrorContext::new_missing(
29556            "ActGactAttrs",
29557            "Pad",
29558            self.orig_loc,
29559            self.buf.as_ptr() as usize,
29560        ))
29561    }
29562}
29563impl ActGactAttrs<'_> {
29564    pub fn new<'a>(buf: &'a [u8]) -> IterableActGactAttrs<'a> {
29565        IterableActGactAttrs::with_loc(buf, buf.as_ptr() as usize)
29566    }
29567    fn attr_from_type(r#type: u16) -> Option<&'static str> {
29568        let res = match r#type {
29569            1u16 => "Tm",
29570            2u16 => "Parms",
29571            3u16 => "Prob",
29572            4u16 => "Pad",
29573            _ => return None,
29574        };
29575        Some(res)
29576    }
29577}
29578#[derive(Clone, Copy, Default)]
29579pub struct IterableActGactAttrs<'a> {
29580    buf: &'a [u8],
29581    pos: usize,
29582    orig_loc: usize,
29583}
29584impl<'a> IterableActGactAttrs<'a> {
29585    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
29586        Self {
29587            buf,
29588            pos: 0,
29589            orig_loc,
29590        }
29591    }
29592    pub fn get_buf(&self) -> &'a [u8] {
29593        self.buf
29594    }
29595}
29596impl<'a> Iterator for IterableActGactAttrs<'a> {
29597    type Item = Result<ActGactAttrs<'a>, ErrorContext>;
29598    fn next(&mut self) -> Option<Self::Item> {
29599        let pos = self.pos;
29600        let mut r#type;
29601        loop {
29602            r#type = None;
29603            if self.buf.len() == self.pos {
29604                return None;
29605            }
29606            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
29607                break;
29608            };
29609            r#type = Some(header.r#type);
29610            let res = match header.r#type {
29611                1u16 => ActGactAttrs::Tm({
29612                    let res = Some(TcfT::new_from_zeroed(next));
29613                    let Some(val) = res else { break };
29614                    val
29615                }),
29616                2u16 => ActGactAttrs::Parms({
29617                    let res = Some(TcGact::new_from_zeroed(next));
29618                    let Some(val) = res else { break };
29619                    val
29620                }),
29621                3u16 => ActGactAttrs::Prob({
29622                    let res = Some(TcGactP::new_from_zeroed(next));
29623                    let Some(val) = res else { break };
29624                    val
29625                }),
29626                4u16 => ActGactAttrs::Pad({
29627                    let res = Some(next);
29628                    let Some(val) = res else { break };
29629                    val
29630                }),
29631                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
29632                n => continue,
29633            };
29634            return Some(Ok(res));
29635        }
29636        Some(Err(ErrorContext::new(
29637            "ActGactAttrs",
29638            r#type.and_then(|t| ActGactAttrs::attr_from_type(t)),
29639            self.orig_loc,
29640            self.buf.as_ptr().wrapping_add(pos) as usize,
29641        )))
29642    }
29643}
29644impl<'a> std::fmt::Debug for IterableActGactAttrs<'_> {
29645    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29646        let mut fmt = f.debug_struct("ActGactAttrs");
29647        for attr in self.clone() {
29648            let attr = match attr {
29649                Ok(a) => a,
29650                Err(err) => {
29651                    fmt.finish()?;
29652                    f.write_str("Err(")?;
29653                    err.fmt(f)?;
29654                    return f.write_str(")");
29655                }
29656            };
29657            match attr {
29658                ActGactAttrs::Tm(val) => fmt.field("Tm", &val),
29659                ActGactAttrs::Parms(val) => fmt.field("Parms", &val),
29660                ActGactAttrs::Prob(val) => fmt.field("Prob", &val),
29661                ActGactAttrs::Pad(val) => fmt.field("Pad", &val),
29662            };
29663        }
29664        fmt.finish()
29665    }
29666}
29667impl IterableActGactAttrs<'_> {
29668    pub fn lookup_attr(
29669        &self,
29670        offset: usize,
29671        missing_type: Option<u16>,
29672    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
29673        let mut stack = Vec::new();
29674        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
29675        if missing_type.is_some() && cur == offset {
29676            stack.push(("ActGactAttrs", offset));
29677            return (
29678                stack,
29679                missing_type.and_then(|t| ActGactAttrs::attr_from_type(t)),
29680            );
29681        }
29682        if cur > offset || cur + self.buf.len() < offset {
29683            return (stack, None);
29684        }
29685        let mut attrs = self.clone();
29686        let mut last_off = cur + attrs.pos;
29687        while let Some(attr) = attrs.next() {
29688            let Ok(attr) = attr else { break };
29689            match attr {
29690                ActGactAttrs::Tm(val) => {
29691                    if last_off == offset {
29692                        stack.push(("Tm", last_off));
29693                        break;
29694                    }
29695                }
29696                ActGactAttrs::Parms(val) => {
29697                    if last_off == offset {
29698                        stack.push(("Parms", last_off));
29699                        break;
29700                    }
29701                }
29702                ActGactAttrs::Prob(val) => {
29703                    if last_off == offset {
29704                        stack.push(("Prob", last_off));
29705                        break;
29706                    }
29707                }
29708                ActGactAttrs::Pad(val) => {
29709                    if last_off == offset {
29710                        stack.push(("Pad", last_off));
29711                        break;
29712                    }
29713                }
29714                _ => {}
29715            };
29716            last_off = cur + attrs.pos;
29717        }
29718        if !stack.is_empty() {
29719            stack.push(("ActGactAttrs", cur));
29720        }
29721        (stack, None)
29722    }
29723}
29724#[derive(Clone)]
29725pub enum TcaStabAttrs<'a> {
29726    Base(TcSizespec),
29727    Data(&'a [u8]),
29728}
29729impl<'a> IterableTcaStabAttrs<'a> {
29730    pub fn get_base(&self) -> Result<TcSizespec, ErrorContext> {
29731        let mut iter = self.clone();
29732        iter.pos = 0;
29733        for attr in iter {
29734            if let TcaStabAttrs::Base(val) = attr? {
29735                return Ok(val);
29736            }
29737        }
29738        Err(ErrorContext::new_missing(
29739            "TcaStabAttrs",
29740            "Base",
29741            self.orig_loc,
29742            self.buf.as_ptr() as usize,
29743        ))
29744    }
29745    pub fn get_data(&self) -> Result<&'a [u8], ErrorContext> {
29746        let mut iter = self.clone();
29747        iter.pos = 0;
29748        for attr in iter {
29749            if let TcaStabAttrs::Data(val) = attr? {
29750                return Ok(val);
29751            }
29752        }
29753        Err(ErrorContext::new_missing(
29754            "TcaStabAttrs",
29755            "Data",
29756            self.orig_loc,
29757            self.buf.as_ptr() as usize,
29758        ))
29759    }
29760}
29761impl TcaStabAttrs<'_> {
29762    pub fn new<'a>(buf: &'a [u8]) -> IterableTcaStabAttrs<'a> {
29763        IterableTcaStabAttrs::with_loc(buf, buf.as_ptr() as usize)
29764    }
29765    fn attr_from_type(r#type: u16) -> Option<&'static str> {
29766        let res = match r#type {
29767            1u16 => "Base",
29768            2u16 => "Data",
29769            _ => return None,
29770        };
29771        Some(res)
29772    }
29773}
29774#[derive(Clone, Copy, Default)]
29775pub struct IterableTcaStabAttrs<'a> {
29776    buf: &'a [u8],
29777    pos: usize,
29778    orig_loc: usize,
29779}
29780impl<'a> IterableTcaStabAttrs<'a> {
29781    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
29782        Self {
29783            buf,
29784            pos: 0,
29785            orig_loc,
29786        }
29787    }
29788    pub fn get_buf(&self) -> &'a [u8] {
29789        self.buf
29790    }
29791}
29792impl<'a> Iterator for IterableTcaStabAttrs<'a> {
29793    type Item = Result<TcaStabAttrs<'a>, ErrorContext>;
29794    fn next(&mut self) -> Option<Self::Item> {
29795        let pos = self.pos;
29796        let mut r#type;
29797        loop {
29798            r#type = None;
29799            if self.buf.len() == self.pos {
29800                return None;
29801            }
29802            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
29803                break;
29804            };
29805            r#type = Some(header.r#type);
29806            let res = match header.r#type {
29807                1u16 => TcaStabAttrs::Base({
29808                    let res = Some(TcSizespec::new_from_zeroed(next));
29809                    let Some(val) = res else { break };
29810                    val
29811                }),
29812                2u16 => TcaStabAttrs::Data({
29813                    let res = Some(next);
29814                    let Some(val) = res else { break };
29815                    val
29816                }),
29817                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
29818                n => continue,
29819            };
29820            return Some(Ok(res));
29821        }
29822        Some(Err(ErrorContext::new(
29823            "TcaStabAttrs",
29824            r#type.and_then(|t| TcaStabAttrs::attr_from_type(t)),
29825            self.orig_loc,
29826            self.buf.as_ptr().wrapping_add(pos) as usize,
29827        )))
29828    }
29829}
29830impl<'a> std::fmt::Debug for IterableTcaStabAttrs<'_> {
29831    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29832        let mut fmt = f.debug_struct("TcaStabAttrs");
29833        for attr in self.clone() {
29834            let attr = match attr {
29835                Ok(a) => a,
29836                Err(err) => {
29837                    fmt.finish()?;
29838                    f.write_str("Err(")?;
29839                    err.fmt(f)?;
29840                    return f.write_str(")");
29841                }
29842            };
29843            match attr {
29844                TcaStabAttrs::Base(val) => fmt.field("Base", &val),
29845                TcaStabAttrs::Data(val) => fmt.field("Data", &val),
29846            };
29847        }
29848        fmt.finish()
29849    }
29850}
29851impl IterableTcaStabAttrs<'_> {
29852    pub fn lookup_attr(
29853        &self,
29854        offset: usize,
29855        missing_type: Option<u16>,
29856    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
29857        let mut stack = Vec::new();
29858        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
29859        if missing_type.is_some() && cur == offset {
29860            stack.push(("TcaStabAttrs", offset));
29861            return (
29862                stack,
29863                missing_type.and_then(|t| TcaStabAttrs::attr_from_type(t)),
29864            );
29865        }
29866        if cur > offset || cur + self.buf.len() < offset {
29867            return (stack, None);
29868        }
29869        let mut attrs = self.clone();
29870        let mut last_off = cur + attrs.pos;
29871        while let Some(attr) = attrs.next() {
29872            let Ok(attr) = attr else { break };
29873            match attr {
29874                TcaStabAttrs::Base(val) => {
29875                    if last_off == offset {
29876                        stack.push(("Base", last_off));
29877                        break;
29878                    }
29879                }
29880                TcaStabAttrs::Data(val) => {
29881                    if last_off == offset {
29882                        stack.push(("Data", last_off));
29883                        break;
29884                    }
29885                }
29886                _ => {}
29887            };
29888            last_off = cur + attrs.pos;
29889        }
29890        if !stack.is_empty() {
29891            stack.push(("TcaStabAttrs", cur));
29892        }
29893        (stack, None)
29894    }
29895}
29896#[derive(Clone)]
29897pub enum TcaStatsAttrs<'a> {
29898    Basic(GnetStatsBasic),
29899    RateEst(GnetStatsRateEst),
29900    Queue(GnetStatsQueue),
29901    App(TcaStatsAppMsg<'a>),
29902    RateEst64(GnetStatsRateEst64),
29903    Pad(&'a [u8]),
29904    BasicHw(GnetStatsBasic),
29905    Pkt64(u64),
29906}
29907impl<'a> IterableTcaStatsAttrs<'a> {
29908    pub fn get_basic(&self) -> Result<GnetStatsBasic, ErrorContext> {
29909        let mut iter = self.clone();
29910        iter.pos = 0;
29911        for attr in iter {
29912            if let TcaStatsAttrs::Basic(val) = attr? {
29913                return Ok(val);
29914            }
29915        }
29916        Err(ErrorContext::new_missing(
29917            "TcaStatsAttrs",
29918            "Basic",
29919            self.orig_loc,
29920            self.buf.as_ptr() as usize,
29921        ))
29922    }
29923    pub fn get_rate_est(&self) -> Result<GnetStatsRateEst, ErrorContext> {
29924        let mut iter = self.clone();
29925        iter.pos = 0;
29926        for attr in iter {
29927            if let TcaStatsAttrs::RateEst(val) = attr? {
29928                return Ok(val);
29929            }
29930        }
29931        Err(ErrorContext::new_missing(
29932            "TcaStatsAttrs",
29933            "RateEst",
29934            self.orig_loc,
29935            self.buf.as_ptr() as usize,
29936        ))
29937    }
29938    pub fn get_queue(&self) -> Result<GnetStatsQueue, ErrorContext> {
29939        let mut iter = self.clone();
29940        iter.pos = 0;
29941        for attr in iter {
29942            if let TcaStatsAttrs::Queue(val) = attr? {
29943                return Ok(val);
29944            }
29945        }
29946        Err(ErrorContext::new_missing(
29947            "TcaStatsAttrs",
29948            "Queue",
29949            self.orig_loc,
29950            self.buf.as_ptr() as usize,
29951        ))
29952    }
29953    pub fn get_app(&self) -> Result<TcaStatsAppMsg<'a>, ErrorContext> {
29954        let mut iter = self.clone();
29955        iter.pos = 0;
29956        for attr in iter {
29957            if let TcaStatsAttrs::App(val) = attr? {
29958                return Ok(val);
29959            }
29960        }
29961        Err(ErrorContext::new_missing(
29962            "TcaStatsAttrs",
29963            "App",
29964            self.orig_loc,
29965            self.buf.as_ptr() as usize,
29966        ))
29967    }
29968    pub fn get_rate_est64(&self) -> Result<GnetStatsRateEst64, ErrorContext> {
29969        let mut iter = self.clone();
29970        iter.pos = 0;
29971        for attr in iter {
29972            if let TcaStatsAttrs::RateEst64(val) = attr? {
29973                return Ok(val);
29974            }
29975        }
29976        Err(ErrorContext::new_missing(
29977            "TcaStatsAttrs",
29978            "RateEst64",
29979            self.orig_loc,
29980            self.buf.as_ptr() as usize,
29981        ))
29982    }
29983    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
29984        let mut iter = self.clone();
29985        iter.pos = 0;
29986        for attr in iter {
29987            if let TcaStatsAttrs::Pad(val) = attr? {
29988                return Ok(val);
29989            }
29990        }
29991        Err(ErrorContext::new_missing(
29992            "TcaStatsAttrs",
29993            "Pad",
29994            self.orig_loc,
29995            self.buf.as_ptr() as usize,
29996        ))
29997    }
29998    pub fn get_basic_hw(&self) -> Result<GnetStatsBasic, ErrorContext> {
29999        let mut iter = self.clone();
30000        iter.pos = 0;
30001        for attr in iter {
30002            if let TcaStatsAttrs::BasicHw(val) = attr? {
30003                return Ok(val);
30004            }
30005        }
30006        Err(ErrorContext::new_missing(
30007            "TcaStatsAttrs",
30008            "BasicHw",
30009            self.orig_loc,
30010            self.buf.as_ptr() as usize,
30011        ))
30012    }
30013    pub fn get_pkt64(&self) -> Result<u64, ErrorContext> {
30014        let mut iter = self.clone();
30015        iter.pos = 0;
30016        for attr in iter {
30017            if let TcaStatsAttrs::Pkt64(val) = attr? {
30018                return Ok(val);
30019            }
30020        }
30021        Err(ErrorContext::new_missing(
30022            "TcaStatsAttrs",
30023            "Pkt64",
30024            self.orig_loc,
30025            self.buf.as_ptr() as usize,
30026        ))
30027    }
30028}
30029impl TcaStatsAttrs<'_> {
30030    pub fn new<'a>(buf: &'a [u8]) -> IterableTcaStatsAttrs<'a> {
30031        IterableTcaStatsAttrs::with_loc(buf, buf.as_ptr() as usize)
30032    }
30033    fn attr_from_type(r#type: u16) -> Option<&'static str> {
30034        let res = match r#type {
30035            1u16 => "Basic",
30036            2u16 => "RateEst",
30037            3u16 => "Queue",
30038            4u16 => "App",
30039            5u16 => "RateEst64",
30040            6u16 => "Pad",
30041            7u16 => "BasicHw",
30042            8u16 => "Pkt64",
30043            _ => return None,
30044        };
30045        Some(res)
30046    }
30047}
30048#[derive(Clone, Copy, Default)]
30049pub struct IterableTcaStatsAttrs<'a> {
30050    buf: &'a [u8],
30051    pos: usize,
30052    orig_loc: usize,
30053}
30054impl<'a> IterableTcaStatsAttrs<'a> {
30055    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
30056        Self {
30057            buf,
30058            pos: 0,
30059            orig_loc,
30060        }
30061    }
30062    pub fn get_buf(&self) -> &'a [u8] {
30063        self.buf
30064    }
30065}
30066impl<'a> Iterator for IterableTcaStatsAttrs<'a> {
30067    type Item = Result<TcaStatsAttrs<'a>, ErrorContext>;
30068    fn next(&mut self) -> Option<Self::Item> {
30069        let pos = self.pos;
30070        let mut r#type;
30071        loop {
30072            r#type = None;
30073            if self.buf.len() == self.pos {
30074                return None;
30075            }
30076            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
30077                break;
30078            };
30079            r#type = Some(header.r#type);
30080            let res = match header.r#type {
30081                1u16 => TcaStatsAttrs::Basic({
30082                    let res = Some(GnetStatsBasic::new_from_zeroed(next));
30083                    let Some(val) = res else { break };
30084                    val
30085                }),
30086                2u16 => TcaStatsAttrs::RateEst({
30087                    let res = Some(GnetStatsRateEst::new_from_zeroed(next));
30088                    let Some(val) = res else { break };
30089                    val
30090                }),
30091                3u16 => TcaStatsAttrs::Queue({
30092                    let res = Some(GnetStatsQueue::new_from_zeroed(next));
30093                    let Some(val) = res else { break };
30094                    val
30095                }),
30096                5u16 => TcaStatsAttrs::RateEst64({
30097                    let res = Some(GnetStatsRateEst64::new_from_zeroed(next));
30098                    let Some(val) = res else { break };
30099                    val
30100                }),
30101                6u16 => TcaStatsAttrs::Pad({
30102                    let res = Some(next);
30103                    let Some(val) = res else { break };
30104                    val
30105                }),
30106                7u16 => TcaStatsAttrs::BasicHw({
30107                    let res = Some(GnetStatsBasic::new_from_zeroed(next));
30108                    let Some(val) = res else { break };
30109                    val
30110                }),
30111                8u16 => TcaStatsAttrs::Pkt64({
30112                    let res = parse_u64(next);
30113                    let Some(val) = res else { break };
30114                    val
30115                }),
30116                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
30117                n => continue,
30118            };
30119            return Some(Ok(res));
30120        }
30121        Some(Err(ErrorContext::new(
30122            "TcaStatsAttrs",
30123            r#type.and_then(|t| TcaStatsAttrs::attr_from_type(t)),
30124            self.orig_loc,
30125            self.buf.as_ptr().wrapping_add(pos) as usize,
30126        )))
30127    }
30128}
30129impl<'a> std::fmt::Debug for IterableTcaStatsAttrs<'_> {
30130    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30131        let mut fmt = f.debug_struct("TcaStatsAttrs");
30132        for attr in self.clone() {
30133            let attr = match attr {
30134                Ok(a) => a,
30135                Err(err) => {
30136                    fmt.finish()?;
30137                    f.write_str("Err(")?;
30138                    err.fmt(f)?;
30139                    return f.write_str(")");
30140                }
30141            };
30142            match attr {
30143                TcaStatsAttrs::Basic(val) => fmt.field("Basic", &val),
30144                TcaStatsAttrs::RateEst(val) => fmt.field("RateEst", &val),
30145                TcaStatsAttrs::Queue(val) => fmt.field("Queue", &val),
30146                TcaStatsAttrs::App(val) => fmt.field("App", &val),
30147                TcaStatsAttrs::RateEst64(val) => fmt.field("RateEst64", &val),
30148                TcaStatsAttrs::Pad(val) => fmt.field("Pad", &val),
30149                TcaStatsAttrs::BasicHw(val) => fmt.field("BasicHw", &val),
30150                TcaStatsAttrs::Pkt64(val) => fmt.field("Pkt64", &val),
30151            };
30152        }
30153        fmt.finish()
30154    }
30155}
30156impl IterableTcaStatsAttrs<'_> {
30157    pub fn lookup_attr(
30158        &self,
30159        offset: usize,
30160        missing_type: Option<u16>,
30161    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
30162        let mut stack = Vec::new();
30163        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
30164        if missing_type.is_some() && cur == offset {
30165            stack.push(("TcaStatsAttrs", offset));
30166            return (
30167                stack,
30168                missing_type.and_then(|t| TcaStatsAttrs::attr_from_type(t)),
30169            );
30170        }
30171        if cur > offset || cur + self.buf.len() < offset {
30172            return (stack, None);
30173        }
30174        let mut attrs = self.clone();
30175        let mut last_off = cur + attrs.pos;
30176        while let Some(attr) = attrs.next() {
30177            let Ok(attr) = attr else { break };
30178            match attr {
30179                TcaStatsAttrs::Basic(val) => {
30180                    if last_off == offset {
30181                        stack.push(("Basic", last_off));
30182                        break;
30183                    }
30184                }
30185                TcaStatsAttrs::RateEst(val) => {
30186                    if last_off == offset {
30187                        stack.push(("RateEst", last_off));
30188                        break;
30189                    }
30190                }
30191                TcaStatsAttrs::Queue(val) => {
30192                    if last_off == offset {
30193                        stack.push(("Queue", last_off));
30194                        break;
30195                    }
30196                }
30197                TcaStatsAttrs::App(val) => {
30198                    if last_off == offset {
30199                        stack.push(("App", last_off));
30200                        break;
30201                    }
30202                }
30203                TcaStatsAttrs::RateEst64(val) => {
30204                    if last_off == offset {
30205                        stack.push(("RateEst64", last_off));
30206                        break;
30207                    }
30208                }
30209                TcaStatsAttrs::Pad(val) => {
30210                    if last_off == offset {
30211                        stack.push(("Pad", last_off));
30212                        break;
30213                    }
30214                }
30215                TcaStatsAttrs::BasicHw(val) => {
30216                    if last_off == offset {
30217                        stack.push(("BasicHw", last_off));
30218                        break;
30219                    }
30220                }
30221                TcaStatsAttrs::Pkt64(val) => {
30222                    if last_off == offset {
30223                        stack.push(("Pkt64", last_off));
30224                        break;
30225                    }
30226                }
30227                _ => {}
30228            };
30229            last_off = cur + attrs.pos;
30230        }
30231        if !stack.is_empty() {
30232            stack.push(("TcaStatsAttrs", cur));
30233        }
30234        (stack, None)
30235    }
30236}
30237#[derive(Clone)]
30238pub enum U32Attrs<'a> {
30239    Classid(u32),
30240    Hash(u32),
30241    Link(u32),
30242    Divisor(u32),
30243    Sel(TcU32Sel),
30244    Police(IterablePoliceAttrs<'a>),
30245    Act(IterableArrayActAttrs<'a>),
30246    Indev(&'a CStr),
30247    Pcnt(TcU32Pcnt),
30248    Mark(TcU32Mark),
30249    Flags(u32),
30250    Pad(&'a [u8]),
30251}
30252impl<'a> IterableU32Attrs<'a> {
30253    pub fn get_classid(&self) -> Result<u32, ErrorContext> {
30254        let mut iter = self.clone();
30255        iter.pos = 0;
30256        for attr in iter {
30257            if let U32Attrs::Classid(val) = attr? {
30258                return Ok(val);
30259            }
30260        }
30261        Err(ErrorContext::new_missing(
30262            "U32Attrs",
30263            "Classid",
30264            self.orig_loc,
30265            self.buf.as_ptr() as usize,
30266        ))
30267    }
30268    pub fn get_hash(&self) -> Result<u32, ErrorContext> {
30269        let mut iter = self.clone();
30270        iter.pos = 0;
30271        for attr in iter {
30272            if let U32Attrs::Hash(val) = attr? {
30273                return Ok(val);
30274            }
30275        }
30276        Err(ErrorContext::new_missing(
30277            "U32Attrs",
30278            "Hash",
30279            self.orig_loc,
30280            self.buf.as_ptr() as usize,
30281        ))
30282    }
30283    pub fn get_link(&self) -> Result<u32, ErrorContext> {
30284        let mut iter = self.clone();
30285        iter.pos = 0;
30286        for attr in iter {
30287            if let U32Attrs::Link(val) = attr? {
30288                return Ok(val);
30289            }
30290        }
30291        Err(ErrorContext::new_missing(
30292            "U32Attrs",
30293            "Link",
30294            self.orig_loc,
30295            self.buf.as_ptr() as usize,
30296        ))
30297    }
30298    pub fn get_divisor(&self) -> Result<u32, ErrorContext> {
30299        let mut iter = self.clone();
30300        iter.pos = 0;
30301        for attr in iter {
30302            if let U32Attrs::Divisor(val) = attr? {
30303                return Ok(val);
30304            }
30305        }
30306        Err(ErrorContext::new_missing(
30307            "U32Attrs",
30308            "Divisor",
30309            self.orig_loc,
30310            self.buf.as_ptr() as usize,
30311        ))
30312    }
30313    pub fn get_sel(&self) -> Result<TcU32Sel, ErrorContext> {
30314        let mut iter = self.clone();
30315        iter.pos = 0;
30316        for attr in iter {
30317            if let U32Attrs::Sel(val) = attr? {
30318                return Ok(val);
30319            }
30320        }
30321        Err(ErrorContext::new_missing(
30322            "U32Attrs",
30323            "Sel",
30324            self.orig_loc,
30325            self.buf.as_ptr() as usize,
30326        ))
30327    }
30328    pub fn get_police(&self) -> Result<IterablePoliceAttrs<'a>, ErrorContext> {
30329        let mut iter = self.clone();
30330        iter.pos = 0;
30331        for attr in iter {
30332            if let U32Attrs::Police(val) = attr? {
30333                return Ok(val);
30334            }
30335        }
30336        Err(ErrorContext::new_missing(
30337            "U32Attrs",
30338            "Police",
30339            self.orig_loc,
30340            self.buf.as_ptr() as usize,
30341        ))
30342    }
30343    pub fn get_act(
30344        &self,
30345    ) -> Result<ArrayIterable<IterableArrayActAttrs<'a>, IterableActAttrs<'a>>, ErrorContext> {
30346        for attr in self.clone() {
30347            if let U32Attrs::Act(val) = attr? {
30348                return Ok(ArrayIterable::new(val));
30349            }
30350        }
30351        Err(ErrorContext::new_missing(
30352            "U32Attrs",
30353            "Act",
30354            self.orig_loc,
30355            self.buf.as_ptr() as usize,
30356        ))
30357    }
30358    pub fn get_indev(&self) -> Result<&'a CStr, ErrorContext> {
30359        let mut iter = self.clone();
30360        iter.pos = 0;
30361        for attr in iter {
30362            if let U32Attrs::Indev(val) = attr? {
30363                return Ok(val);
30364            }
30365        }
30366        Err(ErrorContext::new_missing(
30367            "U32Attrs",
30368            "Indev",
30369            self.orig_loc,
30370            self.buf.as_ptr() as usize,
30371        ))
30372    }
30373    pub fn get_pcnt(&self) -> Result<TcU32Pcnt, ErrorContext> {
30374        let mut iter = self.clone();
30375        iter.pos = 0;
30376        for attr in iter {
30377            if let U32Attrs::Pcnt(val) = attr? {
30378                return Ok(val);
30379            }
30380        }
30381        Err(ErrorContext::new_missing(
30382            "U32Attrs",
30383            "Pcnt",
30384            self.orig_loc,
30385            self.buf.as_ptr() as usize,
30386        ))
30387    }
30388    pub fn get_mark(&self) -> Result<TcU32Mark, ErrorContext> {
30389        let mut iter = self.clone();
30390        iter.pos = 0;
30391        for attr in iter {
30392            if let U32Attrs::Mark(val) = attr? {
30393                return Ok(val);
30394            }
30395        }
30396        Err(ErrorContext::new_missing(
30397            "U32Attrs",
30398            "Mark",
30399            self.orig_loc,
30400            self.buf.as_ptr() as usize,
30401        ))
30402    }
30403    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
30404        let mut iter = self.clone();
30405        iter.pos = 0;
30406        for attr in iter {
30407            if let U32Attrs::Flags(val) = attr? {
30408                return Ok(val);
30409            }
30410        }
30411        Err(ErrorContext::new_missing(
30412            "U32Attrs",
30413            "Flags",
30414            self.orig_loc,
30415            self.buf.as_ptr() as usize,
30416        ))
30417    }
30418    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
30419        let mut iter = self.clone();
30420        iter.pos = 0;
30421        for attr in iter {
30422            if let U32Attrs::Pad(val) = attr? {
30423                return Ok(val);
30424            }
30425        }
30426        Err(ErrorContext::new_missing(
30427            "U32Attrs",
30428            "Pad",
30429            self.orig_loc,
30430            self.buf.as_ptr() as usize,
30431        ))
30432    }
30433}
30434impl U32Attrs<'_> {
30435    pub fn new<'a>(buf: &'a [u8]) -> IterableU32Attrs<'a> {
30436        IterableU32Attrs::with_loc(buf, buf.as_ptr() as usize)
30437    }
30438    fn attr_from_type(r#type: u16) -> Option<&'static str> {
30439        let res = match r#type {
30440            1u16 => "Classid",
30441            2u16 => "Hash",
30442            3u16 => "Link",
30443            4u16 => "Divisor",
30444            5u16 => "Sel",
30445            6u16 => "Police",
30446            7u16 => "Act",
30447            8u16 => "Indev",
30448            9u16 => "Pcnt",
30449            10u16 => "Mark",
30450            11u16 => "Flags",
30451            12u16 => "Pad",
30452            _ => return None,
30453        };
30454        Some(res)
30455    }
30456}
30457#[derive(Clone, Copy, Default)]
30458pub struct IterableU32Attrs<'a> {
30459    buf: &'a [u8],
30460    pos: usize,
30461    orig_loc: usize,
30462}
30463impl<'a> IterableU32Attrs<'a> {
30464    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
30465        Self {
30466            buf,
30467            pos: 0,
30468            orig_loc,
30469        }
30470    }
30471    pub fn get_buf(&self) -> &'a [u8] {
30472        self.buf
30473    }
30474}
30475impl<'a> Iterator for IterableU32Attrs<'a> {
30476    type Item = Result<U32Attrs<'a>, ErrorContext>;
30477    fn next(&mut self) -> Option<Self::Item> {
30478        let pos = self.pos;
30479        let mut r#type;
30480        loop {
30481            r#type = None;
30482            if self.buf.len() == self.pos {
30483                return None;
30484            }
30485            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
30486                break;
30487            };
30488            r#type = Some(header.r#type);
30489            let res = match header.r#type {
30490                1u16 => U32Attrs::Classid({
30491                    let res = parse_u32(next);
30492                    let Some(val) = res else { break };
30493                    val
30494                }),
30495                2u16 => U32Attrs::Hash({
30496                    let res = parse_u32(next);
30497                    let Some(val) = res else { break };
30498                    val
30499                }),
30500                3u16 => U32Attrs::Link({
30501                    let res = parse_u32(next);
30502                    let Some(val) = res else { break };
30503                    val
30504                }),
30505                4u16 => U32Attrs::Divisor({
30506                    let res = parse_u32(next);
30507                    let Some(val) = res else { break };
30508                    val
30509                }),
30510                5u16 => U32Attrs::Sel({
30511                    let res = Some(TcU32Sel::new_from_zeroed(next));
30512                    let Some(val) = res else { break };
30513                    val
30514                }),
30515                6u16 => U32Attrs::Police({
30516                    let res = Some(IterablePoliceAttrs::with_loc(next, self.orig_loc));
30517                    let Some(val) = res else { break };
30518                    val
30519                }),
30520                7u16 => U32Attrs::Act({
30521                    let res = Some(IterableArrayActAttrs::with_loc(next, self.orig_loc));
30522                    let Some(val) = res else { break };
30523                    val
30524                }),
30525                8u16 => U32Attrs::Indev({
30526                    let res = CStr::from_bytes_with_nul(next).ok();
30527                    let Some(val) = res else { break };
30528                    val
30529                }),
30530                9u16 => U32Attrs::Pcnt({
30531                    let res = Some(TcU32Pcnt::new_from_zeroed(next));
30532                    let Some(val) = res else { break };
30533                    val
30534                }),
30535                10u16 => U32Attrs::Mark({
30536                    let res = Some(TcU32Mark::new_from_zeroed(next));
30537                    let Some(val) = res else { break };
30538                    val
30539                }),
30540                11u16 => U32Attrs::Flags({
30541                    let res = parse_u32(next);
30542                    let Some(val) = res else { break };
30543                    val
30544                }),
30545                12u16 => U32Attrs::Pad({
30546                    let res = Some(next);
30547                    let Some(val) = res else { break };
30548                    val
30549                }),
30550                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
30551                n => continue,
30552            };
30553            return Some(Ok(res));
30554        }
30555        Some(Err(ErrorContext::new(
30556            "U32Attrs",
30557            r#type.and_then(|t| U32Attrs::attr_from_type(t)),
30558            self.orig_loc,
30559            self.buf.as_ptr().wrapping_add(pos) as usize,
30560        )))
30561    }
30562}
30563impl<'a> std::fmt::Debug for IterableU32Attrs<'_> {
30564    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30565        let mut fmt = f.debug_struct("U32Attrs");
30566        for attr in self.clone() {
30567            let attr = match attr {
30568                Ok(a) => a,
30569                Err(err) => {
30570                    fmt.finish()?;
30571                    f.write_str("Err(")?;
30572                    err.fmt(f)?;
30573                    return f.write_str(")");
30574                }
30575            };
30576            match attr {
30577                U32Attrs::Classid(val) => fmt.field("Classid", &val),
30578                U32Attrs::Hash(val) => fmt.field("Hash", &val),
30579                U32Attrs::Link(val) => fmt.field("Link", &val),
30580                U32Attrs::Divisor(val) => fmt.field("Divisor", &val),
30581                U32Attrs::Sel(val) => fmt.field("Sel", &val),
30582                U32Attrs::Police(val) => fmt.field("Police", &val),
30583                U32Attrs::Act(val) => fmt.field("Act", &val),
30584                U32Attrs::Indev(val) => fmt.field("Indev", &val),
30585                U32Attrs::Pcnt(val) => fmt.field("Pcnt", &val),
30586                U32Attrs::Mark(val) => fmt.field("Mark", &val),
30587                U32Attrs::Flags(val) => fmt.field("Flags", &val),
30588                U32Attrs::Pad(val) => fmt.field("Pad", &val),
30589            };
30590        }
30591        fmt.finish()
30592    }
30593}
30594impl IterableU32Attrs<'_> {
30595    pub fn lookup_attr(
30596        &self,
30597        offset: usize,
30598        missing_type: Option<u16>,
30599    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
30600        let mut stack = Vec::new();
30601        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
30602        if missing_type.is_some() && cur == offset {
30603            stack.push(("U32Attrs", offset));
30604            return (
30605                stack,
30606                missing_type.and_then(|t| U32Attrs::attr_from_type(t)),
30607            );
30608        }
30609        if cur > offset || cur + self.buf.len() < offset {
30610            return (stack, None);
30611        }
30612        let mut attrs = self.clone();
30613        let mut last_off = cur + attrs.pos;
30614        let mut missing = None;
30615        while let Some(attr) = attrs.next() {
30616            let Ok(attr) = attr else { break };
30617            match attr {
30618                U32Attrs::Classid(val) => {
30619                    if last_off == offset {
30620                        stack.push(("Classid", last_off));
30621                        break;
30622                    }
30623                }
30624                U32Attrs::Hash(val) => {
30625                    if last_off == offset {
30626                        stack.push(("Hash", last_off));
30627                        break;
30628                    }
30629                }
30630                U32Attrs::Link(val) => {
30631                    if last_off == offset {
30632                        stack.push(("Link", last_off));
30633                        break;
30634                    }
30635                }
30636                U32Attrs::Divisor(val) => {
30637                    if last_off == offset {
30638                        stack.push(("Divisor", last_off));
30639                        break;
30640                    }
30641                }
30642                U32Attrs::Sel(val) => {
30643                    if last_off == offset {
30644                        stack.push(("Sel", last_off));
30645                        break;
30646                    }
30647                }
30648                U32Attrs::Police(val) => {
30649                    (stack, missing) = val.lookup_attr(offset, missing_type);
30650                    if !stack.is_empty() {
30651                        break;
30652                    }
30653                }
30654                U32Attrs::Act(val) => {
30655                    for entry in val {
30656                        let Ok(attr) = entry else { break };
30657                        (stack, missing) = attr.lookup_attr(offset, missing_type);
30658                        if !stack.is_empty() {
30659                            break;
30660                        }
30661                    }
30662                    if !stack.is_empty() {
30663                        stack.push(("Act", last_off));
30664                        break;
30665                    }
30666                }
30667                U32Attrs::Indev(val) => {
30668                    if last_off == offset {
30669                        stack.push(("Indev", last_off));
30670                        break;
30671                    }
30672                }
30673                U32Attrs::Pcnt(val) => {
30674                    if last_off == offset {
30675                        stack.push(("Pcnt", last_off));
30676                        break;
30677                    }
30678                }
30679                U32Attrs::Mark(val) => {
30680                    if last_off == offset {
30681                        stack.push(("Mark", last_off));
30682                        break;
30683                    }
30684                }
30685                U32Attrs::Flags(val) => {
30686                    if last_off == offset {
30687                        stack.push(("Flags", last_off));
30688                        break;
30689                    }
30690                }
30691                U32Attrs::Pad(val) => {
30692                    if last_off == offset {
30693                        stack.push(("Pad", last_off));
30694                        break;
30695                    }
30696                }
30697                _ => {}
30698            };
30699            last_off = cur + attrs.pos;
30700        }
30701        if !stack.is_empty() {
30702            stack.push(("U32Attrs", cur));
30703        }
30704        (stack, missing)
30705    }
30706}
30707pub struct PushAttrs<Prev: Rec> {
30708    pub(crate) prev: Option<Prev>,
30709    pub(crate) header_offset: Option<usize>,
30710}
30711impl<Prev: Rec> Rec for PushAttrs<Prev> {
30712    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
30713        self.prev.as_mut().unwrap().as_rec_mut()
30714    }
30715    fn as_rec(&self) -> &Vec<u8> {
30716        self.prev.as_ref().unwrap().as_rec()
30717    }
30718}
30719impl<Prev: Rec> PushAttrs<Prev> {
30720    pub fn new(prev: Prev) -> Self {
30721        Self {
30722            prev: Some(prev),
30723            header_offset: None,
30724        }
30725    }
30726    pub fn end_nested(mut self) -> Prev {
30727        let mut prev = self.prev.take().unwrap();
30728        if let Some(header_offset) = &self.header_offset {
30729            finalize_nested_header(prev.as_rec_mut(), *header_offset);
30730        }
30731        prev
30732    }
30733    pub fn push_kind(mut self, value: &CStr) -> Self {
30734        push_header(
30735            self.as_rec_mut(),
30736            1u16,
30737            value.to_bytes_with_nul().len() as u16,
30738        );
30739        self.as_rec_mut().extend(value.to_bytes_with_nul());
30740        self
30741    }
30742    pub fn push_kind_bytes(mut self, value: &[u8]) -> Self {
30743        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
30744        self.as_rec_mut().extend(value);
30745        self.as_rec_mut().push(0);
30746        self
30747    }
30748    #[doc = "Selector attribute is inserted automatically."]
30749    #[doc = "At most one sub-message attribute is expected per attribute set."]
30750    pub fn nested_options_basic(mut self) -> PushBasicAttrs<PushDummy<Prev>> {
30751        self = self.push_kind(c"basic");
30752        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30753        let dummy = PushDummy {
30754            prev: self.prev.take(),
30755            header_offset: self.header_offset.take(),
30756        };
30757        PushBasicAttrs {
30758            prev: Some(dummy),
30759            header_offset: Some(new_header_offset),
30760        }
30761    }
30762    #[doc = "Selector attribute is inserted automatically."]
30763    #[doc = "At most one sub-message attribute is expected per attribute set."]
30764    pub fn nested_options_bpf(mut self) -> PushBpfAttrs<PushDummy<Prev>> {
30765        self = self.push_kind(c"bpf");
30766        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30767        let dummy = PushDummy {
30768            prev: self.prev.take(),
30769            header_offset: self.header_offset.take(),
30770        };
30771        PushBpfAttrs {
30772            prev: Some(dummy),
30773            header_offset: Some(new_header_offset),
30774        }
30775    }
30776    #[doc = "Selector attribute is inserted automatically."]
30777    #[doc = "At most one sub-message attribute is expected per attribute set."]
30778    pub fn nested_options_bfifo(mut self, fixed_header: &TcFifoQopt) -> Self {
30779        self = self.push_kind(c"bfifo");
30780        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
30781        self.as_rec_mut().extend(fixed_header.as_slice());
30782        self
30783    }
30784    #[doc = "Selector attribute is inserted automatically."]
30785    #[doc = "At most one sub-message attribute is expected per attribute set."]
30786    pub fn nested_options_cake(mut self) -> PushCakeAttrs<PushDummy<Prev>> {
30787        self = self.push_kind(c"cake");
30788        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30789        let dummy = PushDummy {
30790            prev: self.prev.take(),
30791            header_offset: self.header_offset.take(),
30792        };
30793        PushCakeAttrs {
30794            prev: Some(dummy),
30795            header_offset: Some(new_header_offset),
30796        }
30797    }
30798    #[doc = "Selector attribute is inserted automatically."]
30799    #[doc = "At most one sub-message attribute is expected per attribute set."]
30800    pub fn nested_options_cbs(mut self) -> PushCbsAttrs<PushDummy<Prev>> {
30801        self = self.push_kind(c"cbs");
30802        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30803        let dummy = PushDummy {
30804            prev: self.prev.take(),
30805            header_offset: self.header_offset.take(),
30806        };
30807        PushCbsAttrs {
30808            prev: Some(dummy),
30809            header_offset: Some(new_header_offset),
30810        }
30811    }
30812    #[doc = "Selector attribute is inserted automatically."]
30813    #[doc = "At most one sub-message attribute is expected per attribute set."]
30814    pub fn nested_options_cgroup(mut self) -> PushCgroupAttrs<PushDummy<Prev>> {
30815        self = self.push_kind(c"cgroup");
30816        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30817        let dummy = PushDummy {
30818            prev: self.prev.take(),
30819            header_offset: self.header_offset.take(),
30820        };
30821        PushCgroupAttrs {
30822            prev: Some(dummy),
30823            header_offset: Some(new_header_offset),
30824        }
30825    }
30826    #[doc = "Selector attribute is inserted automatically."]
30827    #[doc = "At most one sub-message attribute is expected per attribute set."]
30828    pub fn nested_options_choke(mut self) -> PushChokeAttrs<PushDummy<Prev>> {
30829        self = self.push_kind(c"choke");
30830        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30831        let dummy = PushDummy {
30832            prev: self.prev.take(),
30833            header_offset: self.header_offset.take(),
30834        };
30835        PushChokeAttrs {
30836            prev: Some(dummy),
30837            header_offset: Some(new_header_offset),
30838        }
30839    }
30840    #[doc = "Selector attribute is inserted automatically."]
30841    #[doc = "At most one sub-message attribute is expected per attribute set."]
30842    pub fn nested_options_clsact(mut self) -> Self {
30843        self = self.push_kind(c"clsact");
30844        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
30845        self
30846    }
30847    #[doc = "Selector attribute is inserted automatically."]
30848    #[doc = "At most one sub-message attribute is expected per attribute set."]
30849    pub fn nested_options_codel(mut self) -> PushCodelAttrs<PushDummy<Prev>> {
30850        self = self.push_kind(c"codel");
30851        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30852        let dummy = PushDummy {
30853            prev: self.prev.take(),
30854            header_offset: self.header_offset.take(),
30855        };
30856        PushCodelAttrs {
30857            prev: Some(dummy),
30858            header_offset: Some(new_header_offset),
30859        }
30860    }
30861    #[doc = "Selector attribute is inserted automatically."]
30862    #[doc = "At most one sub-message attribute is expected per attribute set."]
30863    pub fn nested_options_drr(mut self) -> PushDrrAttrs<PushDummy<Prev>> {
30864        self = self.push_kind(c"drr");
30865        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30866        let dummy = PushDummy {
30867            prev: self.prev.take(),
30868            header_offset: self.header_offset.take(),
30869        };
30870        PushDrrAttrs {
30871            prev: Some(dummy),
30872            header_offset: Some(new_header_offset),
30873        }
30874    }
30875    #[doc = "Selector attribute is inserted automatically."]
30876    #[doc = "At most one sub-message attribute is expected per attribute set."]
30877    pub fn nested_options_dualpi2(mut self) -> PushDualpi2Attrs<PushDummy<Prev>> {
30878        self = self.push_kind(c"dualpi2");
30879        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30880        let dummy = PushDummy {
30881            prev: self.prev.take(),
30882            header_offset: self.header_offset.take(),
30883        };
30884        PushDualpi2Attrs {
30885            prev: Some(dummy),
30886            header_offset: Some(new_header_offset),
30887        }
30888    }
30889    #[doc = "Selector attribute is inserted automatically."]
30890    #[doc = "At most one sub-message attribute is expected per attribute set."]
30891    pub fn nested_options_etf(mut self) -> PushEtfAttrs<PushDummy<Prev>> {
30892        self = self.push_kind(c"etf");
30893        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30894        let dummy = PushDummy {
30895            prev: self.prev.take(),
30896            header_offset: self.header_offset.take(),
30897        };
30898        PushEtfAttrs {
30899            prev: Some(dummy),
30900            header_offset: Some(new_header_offset),
30901        }
30902    }
30903    #[doc = "Selector attribute is inserted automatically."]
30904    #[doc = "At most one sub-message attribute is expected per attribute set."]
30905    pub fn nested_options_ets(mut self) -> PushEtsAttrs<PushDummy<Prev>> {
30906        self = self.push_kind(c"ets");
30907        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30908        let dummy = PushDummy {
30909            prev: self.prev.take(),
30910            header_offset: self.header_offset.take(),
30911        };
30912        PushEtsAttrs {
30913            prev: Some(dummy),
30914            header_offset: Some(new_header_offset),
30915        }
30916    }
30917    #[doc = "Selector attribute is inserted automatically."]
30918    #[doc = "At most one sub-message attribute is expected per attribute set."]
30919    pub fn nested_options_flow(mut self) -> PushFlowAttrs<PushDummy<Prev>> {
30920        self = self.push_kind(c"flow");
30921        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30922        let dummy = PushDummy {
30923            prev: self.prev.take(),
30924            header_offset: self.header_offset.take(),
30925        };
30926        PushFlowAttrs {
30927            prev: Some(dummy),
30928            header_offset: Some(new_header_offset),
30929        }
30930    }
30931    #[doc = "Selector attribute is inserted automatically."]
30932    #[doc = "At most one sub-message attribute is expected per attribute set."]
30933    pub fn nested_options_flower(mut self) -> PushFlowerAttrs<PushDummy<Prev>> {
30934        self = self.push_kind(c"flower");
30935        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30936        let dummy = PushDummy {
30937            prev: self.prev.take(),
30938            header_offset: self.header_offset.take(),
30939        };
30940        PushFlowerAttrs {
30941            prev: Some(dummy),
30942            header_offset: Some(new_header_offset),
30943        }
30944    }
30945    #[doc = "Selector attribute is inserted automatically."]
30946    #[doc = "At most one sub-message attribute is expected per attribute set."]
30947    pub fn nested_options_fq(mut self) -> PushFqAttrs<PushDummy<Prev>> {
30948        self = self.push_kind(c"fq");
30949        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30950        let dummy = PushDummy {
30951            prev: self.prev.take(),
30952            header_offset: self.header_offset.take(),
30953        };
30954        PushFqAttrs {
30955            prev: Some(dummy),
30956            header_offset: Some(new_header_offset),
30957        }
30958    }
30959    #[doc = "Selector attribute is inserted automatically."]
30960    #[doc = "At most one sub-message attribute is expected per attribute set."]
30961    pub fn nested_options_fq_codel(mut self) -> PushFqCodelAttrs<PushDummy<Prev>> {
30962        self = self.push_kind(c"fq_codel");
30963        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30964        let dummy = PushDummy {
30965            prev: self.prev.take(),
30966            header_offset: self.header_offset.take(),
30967        };
30968        PushFqCodelAttrs {
30969            prev: Some(dummy),
30970            header_offset: Some(new_header_offset),
30971        }
30972    }
30973    #[doc = "Selector attribute is inserted automatically."]
30974    #[doc = "At most one sub-message attribute is expected per attribute set."]
30975    pub fn nested_options_fq_pie(mut self) -> PushFqPieAttrs<PushDummy<Prev>> {
30976        self = self.push_kind(c"fq_pie");
30977        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30978        let dummy = PushDummy {
30979            prev: self.prev.take(),
30980            header_offset: self.header_offset.take(),
30981        };
30982        PushFqPieAttrs {
30983            prev: Some(dummy),
30984            header_offset: Some(new_header_offset),
30985        }
30986    }
30987    #[doc = "Selector attribute is inserted automatically."]
30988    #[doc = "At most one sub-message attribute is expected per attribute set."]
30989    pub fn nested_options_fw(mut self) -> PushFwAttrs<PushDummy<Prev>> {
30990        self = self.push_kind(c"fw");
30991        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
30992        let dummy = PushDummy {
30993            prev: self.prev.take(),
30994            header_offset: self.header_offset.take(),
30995        };
30996        PushFwAttrs {
30997            prev: Some(dummy),
30998            header_offset: Some(new_header_offset),
30999        }
31000    }
31001    #[doc = "Selector attribute is inserted automatically."]
31002    #[doc = "At most one sub-message attribute is expected per attribute set."]
31003    pub fn nested_options_gred(mut self) -> PushGredAttrs<PushDummy<Prev>> {
31004        self = self.push_kind(c"gred");
31005        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31006        let dummy = PushDummy {
31007            prev: self.prev.take(),
31008            header_offset: self.header_offset.take(),
31009        };
31010        PushGredAttrs {
31011            prev: Some(dummy),
31012            header_offset: Some(new_header_offset),
31013        }
31014    }
31015    #[doc = "Selector attribute is inserted automatically."]
31016    #[doc = "At most one sub-message attribute is expected per attribute set."]
31017    pub fn nested_options_hfsc(mut self, fixed_header: &TcHfscQopt) -> Self {
31018        self = self.push_kind(c"hfsc");
31019        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31020        self.as_rec_mut().extend(fixed_header.as_slice());
31021        self
31022    }
31023    #[doc = "Selector attribute is inserted automatically."]
31024    #[doc = "At most one sub-message attribute is expected per attribute set."]
31025    pub fn nested_options_hhf(mut self) -> PushHhfAttrs<PushDummy<Prev>> {
31026        self = self.push_kind(c"hhf");
31027        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31028        let dummy = PushDummy {
31029            prev: self.prev.take(),
31030            header_offset: self.header_offset.take(),
31031        };
31032        PushHhfAttrs {
31033            prev: Some(dummy),
31034            header_offset: Some(new_header_offset),
31035        }
31036    }
31037    #[doc = "Selector attribute is inserted automatically."]
31038    #[doc = "At most one sub-message attribute is expected per attribute set."]
31039    pub fn nested_options_htb(mut self) -> PushHtbAttrs<PushDummy<Prev>> {
31040        self = self.push_kind(c"htb");
31041        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31042        let dummy = PushDummy {
31043            prev: self.prev.take(),
31044            header_offset: self.header_offset.take(),
31045        };
31046        PushHtbAttrs {
31047            prev: Some(dummy),
31048            header_offset: Some(new_header_offset),
31049        }
31050    }
31051    #[doc = "Selector attribute is inserted automatically."]
31052    #[doc = "At most one sub-message attribute is expected per attribute set."]
31053    pub fn nested_options_ingress(mut self) -> Self {
31054        self = self.push_kind(c"ingress");
31055        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31056        self
31057    }
31058    #[doc = "Selector attribute is inserted automatically."]
31059    #[doc = "At most one sub-message attribute is expected per attribute set."]
31060    pub fn nested_options_matchall(mut self) -> PushMatchallAttrs<PushDummy<Prev>> {
31061        self = self.push_kind(c"matchall");
31062        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31063        let dummy = PushDummy {
31064            prev: self.prev.take(),
31065            header_offset: self.header_offset.take(),
31066        };
31067        PushMatchallAttrs {
31068            prev: Some(dummy),
31069            header_offset: Some(new_header_offset),
31070        }
31071    }
31072    #[doc = "Selector attribute is inserted automatically."]
31073    #[doc = "At most one sub-message attribute is expected per attribute set."]
31074    pub fn nested_options_mq(mut self) -> Self {
31075        self = self.push_kind(c"mq");
31076        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31077        self
31078    }
31079    #[doc = "Selector attribute is inserted automatically."]
31080    #[doc = "At most one sub-message attribute is expected per attribute set."]
31081    pub fn nested_options_mqprio(mut self, fixed_header: &TcMqprioQopt) -> Self {
31082        self = self.push_kind(c"mqprio");
31083        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31084        self.as_rec_mut().extend(fixed_header.as_slice());
31085        self
31086    }
31087    #[doc = "Selector attribute is inserted automatically."]
31088    #[doc = "At most one sub-message attribute is expected per attribute set."]
31089    pub fn nested_options_multiq(mut self, fixed_header: &TcMultiqQopt) -> Self {
31090        self = self.push_kind(c"multiq");
31091        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31092        self.as_rec_mut().extend(fixed_header.as_slice());
31093        self
31094    }
31095    #[doc = "Selector attribute is inserted automatically."]
31096    #[doc = "At most one sub-message attribute is expected per attribute set."]
31097    pub fn nested_options_netem(
31098        mut self,
31099        fixed_header: &TcNetemQopt,
31100    ) -> PushNetemAttrs<PushDummy<Prev>> {
31101        self = self.push_kind(c"netem");
31102        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31103        self.as_rec_mut().extend(fixed_header.as_slice());
31104        let dummy = PushDummy {
31105            prev: self.prev.take(),
31106            header_offset: self.header_offset.take(),
31107        };
31108        PushNetemAttrs {
31109            prev: Some(dummy),
31110            header_offset: Some(new_header_offset),
31111        }
31112    }
31113    #[doc = "Selector attribute is inserted automatically."]
31114    #[doc = "At most one sub-message attribute is expected per attribute set."]
31115    pub fn nested_options_pfifo(mut self, fixed_header: &TcFifoQopt) -> Self {
31116        self = self.push_kind(c"pfifo");
31117        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31118        self.as_rec_mut().extend(fixed_header.as_slice());
31119        self
31120    }
31121    #[doc = "Selector attribute is inserted automatically."]
31122    #[doc = "At most one sub-message attribute is expected per attribute set."]
31123    pub fn nested_options_pfifo_fast(mut self, fixed_header: &TcPrioQopt) -> Self {
31124        self = self.push_kind(c"pfifo_fast");
31125        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31126        self.as_rec_mut().extend(fixed_header.as_slice());
31127        self
31128    }
31129    #[doc = "Selector attribute is inserted automatically."]
31130    #[doc = "At most one sub-message attribute is expected per attribute set."]
31131    pub fn nested_options_pfifo_head_drop(mut self, fixed_header: &TcFifoQopt) -> Self {
31132        self = self.push_kind(c"pfifo_head_drop");
31133        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31134        self.as_rec_mut().extend(fixed_header.as_slice());
31135        self
31136    }
31137    #[doc = "Selector attribute is inserted automatically."]
31138    #[doc = "At most one sub-message attribute is expected per attribute set."]
31139    pub fn nested_options_pie(mut self) -> PushPieAttrs<PushDummy<Prev>> {
31140        self = self.push_kind(c"pie");
31141        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31142        let dummy = PushDummy {
31143            prev: self.prev.take(),
31144            header_offset: self.header_offset.take(),
31145        };
31146        PushPieAttrs {
31147            prev: Some(dummy),
31148            header_offset: Some(new_header_offset),
31149        }
31150    }
31151    #[doc = "Selector attribute is inserted automatically."]
31152    #[doc = "At most one sub-message attribute is expected per attribute set."]
31153    pub fn nested_options_plug(mut self, fixed_header: &TcPlugQopt) -> Self {
31154        self = self.push_kind(c"plug");
31155        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31156        self.as_rec_mut().extend(fixed_header.as_slice());
31157        self
31158    }
31159    #[doc = "Selector attribute is inserted automatically."]
31160    #[doc = "At most one sub-message attribute is expected per attribute set."]
31161    pub fn nested_options_prio(mut self, fixed_header: &TcPrioQopt) -> Self {
31162        self = self.push_kind(c"prio");
31163        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31164        self.as_rec_mut().extend(fixed_header.as_slice());
31165        self
31166    }
31167    #[doc = "Selector attribute is inserted automatically."]
31168    #[doc = "At most one sub-message attribute is expected per attribute set."]
31169    pub fn nested_options_qfq(mut self) -> PushQfqAttrs<PushDummy<Prev>> {
31170        self = self.push_kind(c"qfq");
31171        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31172        let dummy = PushDummy {
31173            prev: self.prev.take(),
31174            header_offset: self.header_offset.take(),
31175        };
31176        PushQfqAttrs {
31177            prev: Some(dummy),
31178            header_offset: Some(new_header_offset),
31179        }
31180    }
31181    #[doc = "Selector attribute is inserted automatically."]
31182    #[doc = "At most one sub-message attribute is expected per attribute set."]
31183    pub fn nested_options_red(mut self) -> PushRedAttrs<PushDummy<Prev>> {
31184        self = self.push_kind(c"red");
31185        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31186        let dummy = PushDummy {
31187            prev: self.prev.take(),
31188            header_offset: self.header_offset.take(),
31189        };
31190        PushRedAttrs {
31191            prev: Some(dummy),
31192            header_offset: Some(new_header_offset),
31193        }
31194    }
31195    #[doc = "Selector attribute is inserted automatically."]
31196    #[doc = "At most one sub-message attribute is expected per attribute set."]
31197    pub fn nested_options_route(mut self) -> PushRouteAttrs<PushDummy<Prev>> {
31198        self = self.push_kind(c"route");
31199        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31200        let dummy = PushDummy {
31201            prev: self.prev.take(),
31202            header_offset: self.header_offset.take(),
31203        };
31204        PushRouteAttrs {
31205            prev: Some(dummy),
31206            header_offset: Some(new_header_offset),
31207        }
31208    }
31209    #[doc = "Selector attribute is inserted automatically."]
31210    #[doc = "At most one sub-message attribute is expected per attribute set."]
31211    pub fn nested_options_sfb(mut self, fixed_header: &TcSfbQopt) -> Self {
31212        self = self.push_kind(c"sfb");
31213        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31214        self.as_rec_mut().extend(fixed_header.as_slice());
31215        self
31216    }
31217    #[doc = "Selector attribute is inserted automatically."]
31218    #[doc = "At most one sub-message attribute is expected per attribute set."]
31219    pub fn nested_options_sfq(mut self, fixed_header: &TcSfqQoptV1) -> Self {
31220        self = self.push_kind(c"sfq");
31221        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 2u16));
31222        self.as_rec_mut().extend(fixed_header.as_slice());
31223        self
31224    }
31225    #[doc = "Selector attribute is inserted automatically."]
31226    #[doc = "At most one sub-message attribute is expected per attribute set."]
31227    pub fn nested_options_taprio(mut self) -> PushTaprioAttrs<PushDummy<Prev>> {
31228        self = self.push_kind(c"taprio");
31229        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31230        let dummy = PushDummy {
31231            prev: self.prev.take(),
31232            header_offset: self.header_offset.take(),
31233        };
31234        PushTaprioAttrs {
31235            prev: Some(dummy),
31236            header_offset: Some(new_header_offset),
31237        }
31238    }
31239    #[doc = "Selector attribute is inserted automatically."]
31240    #[doc = "At most one sub-message attribute is expected per attribute set."]
31241    pub fn nested_options_tbf(mut self) -> PushTbfAttrs<PushDummy<Prev>> {
31242        self = self.push_kind(c"tbf");
31243        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31244        let dummy = PushDummy {
31245            prev: self.prev.take(),
31246            header_offset: self.header_offset.take(),
31247        };
31248        PushTbfAttrs {
31249            prev: Some(dummy),
31250            header_offset: Some(new_header_offset),
31251        }
31252    }
31253    #[doc = "Selector attribute is inserted automatically."]
31254    #[doc = "At most one sub-message attribute is expected per attribute set."]
31255    pub fn nested_options_u32(mut self) -> PushU32Attrs<PushDummy<Prev>> {
31256        self = self.push_kind(c"u32");
31257        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31258        let dummy = PushDummy {
31259            prev: self.prev.take(),
31260            header_offset: self.header_offset.take(),
31261        };
31262        PushU32Attrs {
31263            prev: Some(dummy),
31264            header_offset: Some(new_header_offset),
31265        }
31266    }
31267    pub fn push_stats(mut self, value: TcStats) -> Self {
31268        push_header(self.as_rec_mut(), 3u16, value.as_slice().len() as u16);
31269        self.as_rec_mut().extend(value.as_slice());
31270        self
31271    }
31272    #[doc = "Selector attribute is inserted automatically."]
31273    #[doc = "At most one sub-message attribute is expected per attribute set."]
31274    pub fn nested_xstats_cake(mut self) -> PushCakeStatsAttrs<PushDummy<Prev>> {
31275        self = self.push_kind(c"cake");
31276        let new_header_offset = push_nested_header(self.as_rec_mut(), 4u16);
31277        let dummy = PushDummy {
31278            prev: self.prev.take(),
31279            header_offset: self.header_offset.take(),
31280        };
31281        PushCakeStatsAttrs {
31282            prev: Some(dummy),
31283            header_offset: Some(new_header_offset),
31284        }
31285    }
31286    #[doc = "Selector attribute is inserted automatically."]
31287    #[doc = "At most one sub-message attribute is expected per attribute set."]
31288    pub fn nested_xstats_choke(mut self, fixed_header: &TcChokeXstats) -> Self {
31289        self = self.push_kind(c"choke");
31290        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31291        self.as_rec_mut().extend(fixed_header.as_slice());
31292        self
31293    }
31294    #[doc = "Selector attribute is inserted automatically."]
31295    #[doc = "At most one sub-message attribute is expected per attribute set."]
31296    pub fn nested_xstats_codel(mut self, fixed_header: &TcCodelXstats) -> Self {
31297        self = self.push_kind(c"codel");
31298        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31299        self.as_rec_mut().extend(fixed_header.as_slice());
31300        self
31301    }
31302    #[doc = "Selector attribute is inserted automatically."]
31303    #[doc = "At most one sub-message attribute is expected per attribute set."]
31304    pub fn nested_xstats_dualpi2(mut self, fixed_header: &TcDualpi2Xstats) -> Self {
31305        self = self.push_kind(c"dualpi2");
31306        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31307        self.as_rec_mut().extend(fixed_header.as_slice());
31308        self
31309    }
31310    #[doc = "Selector attribute is inserted automatically."]
31311    #[doc = "At most one sub-message attribute is expected per attribute set."]
31312    pub fn nested_xstats_fq(mut self, fixed_header: &TcFqQdStats) -> Self {
31313        self = self.push_kind(c"fq");
31314        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31315        self.as_rec_mut().extend(fixed_header.as_slice());
31316        self
31317    }
31318    #[doc = "Selector attribute is inserted automatically."]
31319    #[doc = "At most one sub-message attribute is expected per attribute set."]
31320    pub fn nested_xstats_fq_codel(mut self, fixed_header: &TcFqCodelXstats) -> Self {
31321        self = self.push_kind(c"fq_codel");
31322        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31323        self.as_rec_mut().extend(fixed_header.as_slice());
31324        self
31325    }
31326    #[doc = "Selector attribute is inserted automatically."]
31327    #[doc = "At most one sub-message attribute is expected per attribute set."]
31328    pub fn nested_xstats_fq_pie(mut self, fixed_header: &TcFqPieXstats) -> Self {
31329        self = self.push_kind(c"fq_pie");
31330        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31331        self.as_rec_mut().extend(fixed_header.as_slice());
31332        self
31333    }
31334    #[doc = "Selector attribute is inserted automatically."]
31335    #[doc = "At most one sub-message attribute is expected per attribute set."]
31336    pub fn nested_xstats_hhf(mut self, fixed_header: &TcHhfXstats) -> Self {
31337        self = self.push_kind(c"hhf");
31338        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31339        self.as_rec_mut().extend(fixed_header.as_slice());
31340        self
31341    }
31342    #[doc = "Selector attribute is inserted automatically."]
31343    #[doc = "At most one sub-message attribute is expected per attribute set."]
31344    pub fn nested_xstats_pie(mut self, fixed_header: &TcPieXstats) -> Self {
31345        self = self.push_kind(c"pie");
31346        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31347        self.as_rec_mut().extend(fixed_header.as_slice());
31348        self
31349    }
31350    #[doc = "Selector attribute is inserted automatically."]
31351    #[doc = "At most one sub-message attribute is expected per attribute set."]
31352    pub fn nested_xstats_red(mut self, fixed_header: &TcRedXstats) -> Self {
31353        self = self.push_kind(c"red");
31354        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31355        self.as_rec_mut().extend(fixed_header.as_slice());
31356        self
31357    }
31358    #[doc = "Selector attribute is inserted automatically."]
31359    #[doc = "At most one sub-message attribute is expected per attribute set."]
31360    pub fn nested_xstats_sfb(mut self, fixed_header: &TcSfbXstats) -> Self {
31361        self = self.push_kind(c"sfb");
31362        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31363        self.as_rec_mut().extend(fixed_header.as_slice());
31364        self
31365    }
31366    #[doc = "Selector attribute is inserted automatically."]
31367    #[doc = "At most one sub-message attribute is expected per attribute set."]
31368    pub fn nested_xstats_sfq(mut self, fixed_header: &TcSfqXstats) -> Self {
31369        self = self.push_kind(c"sfq");
31370        self.header_offset = Some(push_nested_header(self.as_rec_mut(), 4u16));
31371        self.as_rec_mut().extend(fixed_header.as_slice());
31372        self
31373    }
31374    pub fn push_rate(mut self, value: GnetEstimator) -> Self {
31375        push_header(self.as_rec_mut(), 5u16, value.as_slice().len() as u16);
31376        self.as_rec_mut().extend(value.as_slice());
31377        self
31378    }
31379    pub fn push_fcnt(mut self, value: u32) -> Self {
31380        push_header(self.as_rec_mut(), 6u16, 4 as u16);
31381        self.as_rec_mut().extend(value.to_ne_bytes());
31382        self
31383    }
31384    pub fn nested_stats2(mut self) -> PushTcaStatsAttrs<Self> {
31385        let header_offset = push_nested_header(self.as_rec_mut(), 7u16);
31386        PushTcaStatsAttrs {
31387            prev: Some(self),
31388            header_offset: Some(header_offset),
31389        }
31390    }
31391    pub fn nested_stab(mut self) -> PushTcaStabAttrs<Self> {
31392        let header_offset = push_nested_header(self.as_rec_mut(), 8u16);
31393        PushTcaStabAttrs {
31394            prev: Some(self),
31395            header_offset: Some(header_offset),
31396        }
31397    }
31398    pub fn push_pad(mut self, value: &[u8]) -> Self {
31399        push_header(self.as_rec_mut(), 9u16, value.len() as u16);
31400        self.as_rec_mut().extend(value);
31401        self
31402    }
31403    pub fn push_dump_invisible(mut self, value: ()) -> Self {
31404        push_header(self.as_rec_mut(), 10u16, 0 as u16);
31405        self
31406    }
31407    pub fn push_chain(mut self, value: u32) -> Self {
31408        push_header(self.as_rec_mut(), 11u16, 4 as u16);
31409        self.as_rec_mut().extend(value.to_ne_bytes());
31410        self
31411    }
31412    pub fn push_hw_offload(mut self, value: u8) -> Self {
31413        push_header(self.as_rec_mut(), 12u16, 1 as u16);
31414        self.as_rec_mut().extend(value.to_ne_bytes());
31415        self
31416    }
31417    pub fn push_ingress_block(mut self, value: u32) -> Self {
31418        push_header(self.as_rec_mut(), 13u16, 4 as u16);
31419        self.as_rec_mut().extend(value.to_ne_bytes());
31420        self
31421    }
31422    pub fn push_egress_block(mut self, value: u32) -> Self {
31423        push_header(self.as_rec_mut(), 14u16, 4 as u16);
31424        self.as_rec_mut().extend(value.to_ne_bytes());
31425        self
31426    }
31427    pub fn push_dump_flags(mut self, value: BuiltinBitfield32) -> Self {
31428        push_header(self.as_rec_mut(), 15u16, value.as_slice().len() as u16);
31429        self.as_rec_mut().extend(value.as_slice());
31430        self
31431    }
31432    pub fn push_ext_warn_msg(mut self, value: &CStr) -> Self {
31433        push_header(
31434            self.as_rec_mut(),
31435            16u16,
31436            value.to_bytes_with_nul().len() as u16,
31437        );
31438        self.as_rec_mut().extend(value.to_bytes_with_nul());
31439        self
31440    }
31441    pub fn push_ext_warn_msg_bytes(mut self, value: &[u8]) -> Self {
31442        push_header(self.as_rec_mut(), 16u16, (value.len() + 1) as u16);
31443        self.as_rec_mut().extend(value);
31444        self.as_rec_mut().push(0);
31445        self
31446    }
31447}
31448impl<Prev: Rec> Drop for PushAttrs<Prev> {
31449    fn drop(&mut self) {
31450        if let Some(prev) = &mut self.prev {
31451            if let Some(header_offset) = &self.header_offset {
31452                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31453            }
31454        }
31455    }
31456}
31457pub struct PushActAttrs<Prev: Rec> {
31458    pub(crate) prev: Option<Prev>,
31459    pub(crate) header_offset: Option<usize>,
31460}
31461impl<Prev: Rec> Rec for PushActAttrs<Prev> {
31462    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31463        self.prev.as_mut().unwrap().as_rec_mut()
31464    }
31465    fn as_rec(&self) -> &Vec<u8> {
31466        self.prev.as_ref().unwrap().as_rec()
31467    }
31468}
31469impl<Prev: Rec> PushActAttrs<Prev> {
31470    pub fn new(prev: Prev) -> Self {
31471        Self {
31472            prev: Some(prev),
31473            header_offset: None,
31474        }
31475    }
31476    pub fn end_nested(mut self) -> Prev {
31477        let mut prev = self.prev.take().unwrap();
31478        if let Some(header_offset) = &self.header_offset {
31479            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31480        }
31481        prev
31482    }
31483    pub fn push_kind(mut self, value: &CStr) -> Self {
31484        push_header(
31485            self.as_rec_mut(),
31486            1u16,
31487            value.to_bytes_with_nul().len() as u16,
31488        );
31489        self.as_rec_mut().extend(value.to_bytes_with_nul());
31490        self
31491    }
31492    pub fn push_kind_bytes(mut self, value: &[u8]) -> Self {
31493        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
31494        self.as_rec_mut().extend(value);
31495        self.as_rec_mut().push(0);
31496        self
31497    }
31498    #[doc = "Selector attribute is inserted automatically."]
31499    #[doc = "At most one sub-message attribute is expected per attribute set."]
31500    pub fn nested_options_bpf(mut self) -> PushActBpfAttrs<PushDummy<Prev>> {
31501        self = self.push_kind(c"bpf");
31502        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31503        let dummy = PushDummy {
31504            prev: self.prev.take(),
31505            header_offset: self.header_offset.take(),
31506        };
31507        PushActBpfAttrs {
31508            prev: Some(dummy),
31509            header_offset: Some(new_header_offset),
31510        }
31511    }
31512    #[doc = "Selector attribute is inserted automatically."]
31513    #[doc = "At most one sub-message attribute is expected per attribute set."]
31514    pub fn nested_options_connmark(mut self) -> PushActConnmarkAttrs<PushDummy<Prev>> {
31515        self = self.push_kind(c"connmark");
31516        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31517        let dummy = PushDummy {
31518            prev: self.prev.take(),
31519            header_offset: self.header_offset.take(),
31520        };
31521        PushActConnmarkAttrs {
31522            prev: Some(dummy),
31523            header_offset: Some(new_header_offset),
31524        }
31525    }
31526    #[doc = "Selector attribute is inserted automatically."]
31527    #[doc = "At most one sub-message attribute is expected per attribute set."]
31528    pub fn nested_options_csum(mut self) -> PushActCsumAttrs<PushDummy<Prev>> {
31529        self = self.push_kind(c"csum");
31530        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31531        let dummy = PushDummy {
31532            prev: self.prev.take(),
31533            header_offset: self.header_offset.take(),
31534        };
31535        PushActCsumAttrs {
31536            prev: Some(dummy),
31537            header_offset: Some(new_header_offset),
31538        }
31539    }
31540    #[doc = "Selector attribute is inserted automatically."]
31541    #[doc = "At most one sub-message attribute is expected per attribute set."]
31542    pub fn nested_options_ct(mut self) -> PushActCtAttrs<PushDummy<Prev>> {
31543        self = self.push_kind(c"ct");
31544        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31545        let dummy = PushDummy {
31546            prev: self.prev.take(),
31547            header_offset: self.header_offset.take(),
31548        };
31549        PushActCtAttrs {
31550            prev: Some(dummy),
31551            header_offset: Some(new_header_offset),
31552        }
31553    }
31554    #[doc = "Selector attribute is inserted automatically."]
31555    #[doc = "At most one sub-message attribute is expected per attribute set."]
31556    pub fn nested_options_ctinfo(mut self) -> PushActCtinfoAttrs<PushDummy<Prev>> {
31557        self = self.push_kind(c"ctinfo");
31558        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31559        let dummy = PushDummy {
31560            prev: self.prev.take(),
31561            header_offset: self.header_offset.take(),
31562        };
31563        PushActCtinfoAttrs {
31564            prev: Some(dummy),
31565            header_offset: Some(new_header_offset),
31566        }
31567    }
31568    #[doc = "Selector attribute is inserted automatically."]
31569    #[doc = "At most one sub-message attribute is expected per attribute set."]
31570    pub fn nested_options_gact(mut self) -> PushActGactAttrs<PushDummy<Prev>> {
31571        self = self.push_kind(c"gact");
31572        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31573        let dummy = PushDummy {
31574            prev: self.prev.take(),
31575            header_offset: self.header_offset.take(),
31576        };
31577        PushActGactAttrs {
31578            prev: Some(dummy),
31579            header_offset: Some(new_header_offset),
31580        }
31581    }
31582    #[doc = "Selector attribute is inserted automatically."]
31583    #[doc = "At most one sub-message attribute is expected per attribute set."]
31584    pub fn nested_options_gate(mut self) -> PushActGateAttrs<PushDummy<Prev>> {
31585        self = self.push_kind(c"gate");
31586        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31587        let dummy = PushDummy {
31588            prev: self.prev.take(),
31589            header_offset: self.header_offset.take(),
31590        };
31591        PushActGateAttrs {
31592            prev: Some(dummy),
31593            header_offset: Some(new_header_offset),
31594        }
31595    }
31596    #[doc = "Selector attribute is inserted automatically."]
31597    #[doc = "At most one sub-message attribute is expected per attribute set."]
31598    pub fn nested_options_ife(mut self) -> PushActIfeAttrs<PushDummy<Prev>> {
31599        self = self.push_kind(c"ife");
31600        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31601        let dummy = PushDummy {
31602            prev: self.prev.take(),
31603            header_offset: self.header_offset.take(),
31604        };
31605        PushActIfeAttrs {
31606            prev: Some(dummy),
31607            header_offset: Some(new_header_offset),
31608        }
31609    }
31610    #[doc = "Selector attribute is inserted automatically."]
31611    #[doc = "At most one sub-message attribute is expected per attribute set."]
31612    pub fn nested_options_mirred(mut self) -> PushActMirredAttrs<PushDummy<Prev>> {
31613        self = self.push_kind(c"mirred");
31614        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31615        let dummy = PushDummy {
31616            prev: self.prev.take(),
31617            header_offset: self.header_offset.take(),
31618        };
31619        PushActMirredAttrs {
31620            prev: Some(dummy),
31621            header_offset: Some(new_header_offset),
31622        }
31623    }
31624    #[doc = "Selector attribute is inserted automatically."]
31625    #[doc = "At most one sub-message attribute is expected per attribute set."]
31626    pub fn nested_options_mpls(mut self) -> PushActMplsAttrs<PushDummy<Prev>> {
31627        self = self.push_kind(c"mpls");
31628        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31629        let dummy = PushDummy {
31630            prev: self.prev.take(),
31631            header_offset: self.header_offset.take(),
31632        };
31633        PushActMplsAttrs {
31634            prev: Some(dummy),
31635            header_offset: Some(new_header_offset),
31636        }
31637    }
31638    #[doc = "Selector attribute is inserted automatically."]
31639    #[doc = "At most one sub-message attribute is expected per attribute set."]
31640    pub fn nested_options_nat(mut self) -> PushActNatAttrs<PushDummy<Prev>> {
31641        self = self.push_kind(c"nat");
31642        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31643        let dummy = PushDummy {
31644            prev: self.prev.take(),
31645            header_offset: self.header_offset.take(),
31646        };
31647        PushActNatAttrs {
31648            prev: Some(dummy),
31649            header_offset: Some(new_header_offset),
31650        }
31651    }
31652    #[doc = "Selector attribute is inserted automatically."]
31653    #[doc = "At most one sub-message attribute is expected per attribute set."]
31654    pub fn nested_options_pedit(mut self) -> PushActPeditAttrs<PushDummy<Prev>> {
31655        self = self.push_kind(c"pedit");
31656        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31657        let dummy = PushDummy {
31658            prev: self.prev.take(),
31659            header_offset: self.header_offset.take(),
31660        };
31661        PushActPeditAttrs {
31662            prev: Some(dummy),
31663            header_offset: Some(new_header_offset),
31664        }
31665    }
31666    #[doc = "Selector attribute is inserted automatically."]
31667    #[doc = "At most one sub-message attribute is expected per attribute set."]
31668    pub fn nested_options_police(mut self) -> PushPoliceAttrs<PushDummy<Prev>> {
31669        self = self.push_kind(c"police");
31670        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31671        let dummy = PushDummy {
31672            prev: self.prev.take(),
31673            header_offset: self.header_offset.take(),
31674        };
31675        PushPoliceAttrs {
31676            prev: Some(dummy),
31677            header_offset: Some(new_header_offset),
31678        }
31679    }
31680    #[doc = "Selector attribute is inserted automatically."]
31681    #[doc = "At most one sub-message attribute is expected per attribute set."]
31682    pub fn nested_options_sample(mut self) -> PushActSampleAttrs<PushDummy<Prev>> {
31683        self = self.push_kind(c"sample");
31684        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31685        let dummy = PushDummy {
31686            prev: self.prev.take(),
31687            header_offset: self.header_offset.take(),
31688        };
31689        PushActSampleAttrs {
31690            prev: Some(dummy),
31691            header_offset: Some(new_header_offset),
31692        }
31693    }
31694    #[doc = "Selector attribute is inserted automatically."]
31695    #[doc = "At most one sub-message attribute is expected per attribute set."]
31696    pub fn nested_options_simple(mut self) -> PushActSimpleAttrs<PushDummy<Prev>> {
31697        self = self.push_kind(c"simple");
31698        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31699        let dummy = PushDummy {
31700            prev: self.prev.take(),
31701            header_offset: self.header_offset.take(),
31702        };
31703        PushActSimpleAttrs {
31704            prev: Some(dummy),
31705            header_offset: Some(new_header_offset),
31706        }
31707    }
31708    #[doc = "Selector attribute is inserted automatically."]
31709    #[doc = "At most one sub-message attribute is expected per attribute set."]
31710    pub fn nested_options_skbedit(mut self) -> PushActSkbeditAttrs<PushDummy<Prev>> {
31711        self = self.push_kind(c"skbedit");
31712        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31713        let dummy = PushDummy {
31714            prev: self.prev.take(),
31715            header_offset: self.header_offset.take(),
31716        };
31717        PushActSkbeditAttrs {
31718            prev: Some(dummy),
31719            header_offset: Some(new_header_offset),
31720        }
31721    }
31722    #[doc = "Selector attribute is inserted automatically."]
31723    #[doc = "At most one sub-message attribute is expected per attribute set."]
31724    pub fn nested_options_skbmod(mut self) -> PushActSkbmodAttrs<PushDummy<Prev>> {
31725        self = self.push_kind(c"skbmod");
31726        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31727        let dummy = PushDummy {
31728            prev: self.prev.take(),
31729            header_offset: self.header_offset.take(),
31730        };
31731        PushActSkbmodAttrs {
31732            prev: Some(dummy),
31733            header_offset: Some(new_header_offset),
31734        }
31735    }
31736    #[doc = "Selector attribute is inserted automatically."]
31737    #[doc = "At most one sub-message attribute is expected per attribute set."]
31738    pub fn nested_options_tunnel_key(mut self) -> PushActTunnelKeyAttrs<PushDummy<Prev>> {
31739        self = self.push_kind(c"tunnel_key");
31740        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31741        let dummy = PushDummy {
31742            prev: self.prev.take(),
31743            header_offset: self.header_offset.take(),
31744        };
31745        PushActTunnelKeyAttrs {
31746            prev: Some(dummy),
31747            header_offset: Some(new_header_offset),
31748        }
31749    }
31750    #[doc = "Selector attribute is inserted automatically."]
31751    #[doc = "At most one sub-message attribute is expected per attribute set."]
31752    pub fn nested_options_vlan(mut self) -> PushActVlanAttrs<PushDummy<Prev>> {
31753        self = self.push_kind(c"vlan");
31754        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
31755        let dummy = PushDummy {
31756            prev: self.prev.take(),
31757            header_offset: self.header_offset.take(),
31758        };
31759        PushActVlanAttrs {
31760            prev: Some(dummy),
31761            header_offset: Some(new_header_offset),
31762        }
31763    }
31764    pub fn push_index(mut self, value: u32) -> Self {
31765        push_header(self.as_rec_mut(), 3u16, 4 as u16);
31766        self.as_rec_mut().extend(value.to_ne_bytes());
31767        self
31768    }
31769    pub fn nested_stats(mut self) -> PushTcaStatsAttrs<Self> {
31770        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
31771        PushTcaStatsAttrs {
31772            prev: Some(self),
31773            header_offset: Some(header_offset),
31774        }
31775    }
31776    pub fn push_pad(mut self, value: &[u8]) -> Self {
31777        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
31778        self.as_rec_mut().extend(value);
31779        self
31780    }
31781    pub fn push_cookie(mut self, value: &[u8]) -> Self {
31782        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
31783        self.as_rec_mut().extend(value);
31784        self
31785    }
31786    pub fn push_flags(mut self, value: BuiltinBitfield32) -> Self {
31787        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
31788        self.as_rec_mut().extend(value.as_slice());
31789        self
31790    }
31791    pub fn push_hw_stats(mut self, value: BuiltinBitfield32) -> Self {
31792        push_header(self.as_rec_mut(), 8u16, value.as_slice().len() as u16);
31793        self.as_rec_mut().extend(value.as_slice());
31794        self
31795    }
31796    pub fn push_used_hw_stats(mut self, value: BuiltinBitfield32) -> Self {
31797        push_header(self.as_rec_mut(), 9u16, value.as_slice().len() as u16);
31798        self.as_rec_mut().extend(value.as_slice());
31799        self
31800    }
31801    pub fn push_in_hw_count(mut self, value: u32) -> Self {
31802        push_header(self.as_rec_mut(), 10u16, 4 as u16);
31803        self.as_rec_mut().extend(value.to_ne_bytes());
31804        self
31805    }
31806}
31807impl<Prev: Rec> Drop for PushActAttrs<Prev> {
31808    fn drop(&mut self) {
31809        if let Some(prev) = &mut self.prev {
31810            if let Some(header_offset) = &self.header_offset {
31811                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31812            }
31813        }
31814    }
31815}
31816pub struct PushActBpfAttrs<Prev: Rec> {
31817    pub(crate) prev: Option<Prev>,
31818    pub(crate) header_offset: Option<usize>,
31819}
31820impl<Prev: Rec> Rec for PushActBpfAttrs<Prev> {
31821    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31822        self.prev.as_mut().unwrap().as_rec_mut()
31823    }
31824    fn as_rec(&self) -> &Vec<u8> {
31825        self.prev.as_ref().unwrap().as_rec()
31826    }
31827}
31828impl<Prev: Rec> PushActBpfAttrs<Prev> {
31829    pub fn new(prev: Prev) -> Self {
31830        Self {
31831            prev: Some(prev),
31832            header_offset: None,
31833        }
31834    }
31835    pub fn end_nested(mut self) -> Prev {
31836        let mut prev = self.prev.take().unwrap();
31837        if let Some(header_offset) = &self.header_offset {
31838            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31839        }
31840        prev
31841    }
31842    pub fn push_tm(mut self, value: TcfT) -> Self {
31843        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
31844        self.as_rec_mut().extend(value.as_slice());
31845        self
31846    }
31847    pub fn push_parms(mut self, value: &[u8]) -> Self {
31848        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
31849        self.as_rec_mut().extend(value);
31850        self
31851    }
31852    pub fn push_ops_len(mut self, value: u16) -> Self {
31853        push_header(self.as_rec_mut(), 3u16, 2 as u16);
31854        self.as_rec_mut().extend(value.to_ne_bytes());
31855        self
31856    }
31857    pub fn push_ops(mut self, value: &[u8]) -> Self {
31858        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
31859        self.as_rec_mut().extend(value);
31860        self
31861    }
31862    pub fn push_fd(mut self, value: u32) -> Self {
31863        push_header(self.as_rec_mut(), 5u16, 4 as u16);
31864        self.as_rec_mut().extend(value.to_ne_bytes());
31865        self
31866    }
31867    pub fn push_name(mut self, value: &CStr) -> Self {
31868        push_header(
31869            self.as_rec_mut(),
31870            6u16,
31871            value.to_bytes_with_nul().len() as u16,
31872        );
31873        self.as_rec_mut().extend(value.to_bytes_with_nul());
31874        self
31875    }
31876    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
31877        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
31878        self.as_rec_mut().extend(value);
31879        self.as_rec_mut().push(0);
31880        self
31881    }
31882    pub fn push_pad(mut self, value: &[u8]) -> Self {
31883        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
31884        self.as_rec_mut().extend(value);
31885        self
31886    }
31887    pub fn push_tag(mut self, value: &[u8]) -> Self {
31888        push_header(self.as_rec_mut(), 8u16, value.len() as u16);
31889        self.as_rec_mut().extend(value);
31890        self
31891    }
31892    pub fn push_id(mut self, value: &[u8]) -> Self {
31893        push_header(self.as_rec_mut(), 9u16, value.len() as u16);
31894        self.as_rec_mut().extend(value);
31895        self
31896    }
31897}
31898impl<Prev: Rec> Drop for PushActBpfAttrs<Prev> {
31899    fn drop(&mut self) {
31900        if let Some(prev) = &mut self.prev {
31901            if let Some(header_offset) = &self.header_offset {
31902                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31903            }
31904        }
31905    }
31906}
31907pub struct PushActConnmarkAttrs<Prev: Rec> {
31908    pub(crate) prev: Option<Prev>,
31909    pub(crate) header_offset: Option<usize>,
31910}
31911impl<Prev: Rec> Rec for PushActConnmarkAttrs<Prev> {
31912    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31913        self.prev.as_mut().unwrap().as_rec_mut()
31914    }
31915    fn as_rec(&self) -> &Vec<u8> {
31916        self.prev.as_ref().unwrap().as_rec()
31917    }
31918}
31919impl<Prev: Rec> PushActConnmarkAttrs<Prev> {
31920    pub fn new(prev: Prev) -> Self {
31921        Self {
31922            prev: Some(prev),
31923            header_offset: None,
31924        }
31925    }
31926    pub fn end_nested(mut self) -> Prev {
31927        let mut prev = self.prev.take().unwrap();
31928        if let Some(header_offset) = &self.header_offset {
31929            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31930        }
31931        prev
31932    }
31933    pub fn push_parms(mut self, value: &[u8]) -> Self {
31934        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
31935        self.as_rec_mut().extend(value);
31936        self
31937    }
31938    pub fn push_tm(mut self, value: TcfT) -> Self {
31939        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
31940        self.as_rec_mut().extend(value.as_slice());
31941        self
31942    }
31943    pub fn push_pad(mut self, value: &[u8]) -> Self {
31944        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
31945        self.as_rec_mut().extend(value);
31946        self
31947    }
31948}
31949impl<Prev: Rec> Drop for PushActConnmarkAttrs<Prev> {
31950    fn drop(&mut self) {
31951        if let Some(prev) = &mut self.prev {
31952            if let Some(header_offset) = &self.header_offset {
31953                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31954            }
31955        }
31956    }
31957}
31958pub struct PushActCsumAttrs<Prev: Rec> {
31959    pub(crate) prev: Option<Prev>,
31960    pub(crate) header_offset: Option<usize>,
31961}
31962impl<Prev: Rec> Rec for PushActCsumAttrs<Prev> {
31963    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31964        self.prev.as_mut().unwrap().as_rec_mut()
31965    }
31966    fn as_rec(&self) -> &Vec<u8> {
31967        self.prev.as_ref().unwrap().as_rec()
31968    }
31969}
31970impl<Prev: Rec> PushActCsumAttrs<Prev> {
31971    pub fn new(prev: Prev) -> Self {
31972        Self {
31973            prev: Some(prev),
31974            header_offset: None,
31975        }
31976    }
31977    pub fn end_nested(mut self) -> Prev {
31978        let mut prev = self.prev.take().unwrap();
31979        if let Some(header_offset) = &self.header_offset {
31980            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31981        }
31982        prev
31983    }
31984    pub fn push_parms(mut self, value: &[u8]) -> Self {
31985        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
31986        self.as_rec_mut().extend(value);
31987        self
31988    }
31989    pub fn push_tm(mut self, value: TcfT) -> Self {
31990        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
31991        self.as_rec_mut().extend(value.as_slice());
31992        self
31993    }
31994    pub fn push_pad(mut self, value: &[u8]) -> Self {
31995        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
31996        self.as_rec_mut().extend(value);
31997        self
31998    }
31999}
32000impl<Prev: Rec> Drop for PushActCsumAttrs<Prev> {
32001    fn drop(&mut self) {
32002        if let Some(prev) = &mut self.prev {
32003            if let Some(header_offset) = &self.header_offset {
32004                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32005            }
32006        }
32007    }
32008}
32009pub struct PushActCtAttrs<Prev: Rec> {
32010    pub(crate) prev: Option<Prev>,
32011    pub(crate) header_offset: Option<usize>,
32012}
32013impl<Prev: Rec> Rec for PushActCtAttrs<Prev> {
32014    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32015        self.prev.as_mut().unwrap().as_rec_mut()
32016    }
32017    fn as_rec(&self) -> &Vec<u8> {
32018        self.prev.as_ref().unwrap().as_rec()
32019    }
32020}
32021impl<Prev: Rec> PushActCtAttrs<Prev> {
32022    pub fn new(prev: Prev) -> Self {
32023        Self {
32024            prev: Some(prev),
32025            header_offset: None,
32026        }
32027    }
32028    pub fn end_nested(mut self) -> Prev {
32029        let mut prev = self.prev.take().unwrap();
32030        if let Some(header_offset) = &self.header_offset {
32031            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32032        }
32033        prev
32034    }
32035    pub fn push_parms(mut self, value: &[u8]) -> Self {
32036        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
32037        self.as_rec_mut().extend(value);
32038        self
32039    }
32040    pub fn push_tm(mut self, value: TcfT) -> Self {
32041        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
32042        self.as_rec_mut().extend(value.as_slice());
32043        self
32044    }
32045    pub fn push_action(mut self, value: u16) -> Self {
32046        push_header(self.as_rec_mut(), 3u16, 2 as u16);
32047        self.as_rec_mut().extend(value.to_ne_bytes());
32048        self
32049    }
32050    pub fn push_zone(mut self, value: u16) -> Self {
32051        push_header(self.as_rec_mut(), 4u16, 2 as u16);
32052        self.as_rec_mut().extend(value.to_ne_bytes());
32053        self
32054    }
32055    pub fn push_mark(mut self, value: u32) -> Self {
32056        push_header(self.as_rec_mut(), 5u16, 4 as u16);
32057        self.as_rec_mut().extend(value.to_ne_bytes());
32058        self
32059    }
32060    pub fn push_mark_mask(mut self, value: u32) -> Self {
32061        push_header(self.as_rec_mut(), 6u16, 4 as u16);
32062        self.as_rec_mut().extend(value.to_ne_bytes());
32063        self
32064    }
32065    pub fn push_labels(mut self, value: &[u8]) -> Self {
32066        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
32067        self.as_rec_mut().extend(value);
32068        self
32069    }
32070    pub fn push_labels_mask(mut self, value: &[u8]) -> Self {
32071        push_header(self.as_rec_mut(), 8u16, value.len() as u16);
32072        self.as_rec_mut().extend(value);
32073        self
32074    }
32075    pub fn push_nat_ipv4_min(mut self, value: u32) -> Self {
32076        push_header(self.as_rec_mut(), 9u16, 4 as u16);
32077        self.as_rec_mut().extend(value.to_be_bytes());
32078        self
32079    }
32080    pub fn push_nat_ipv4_max(mut self, value: u32) -> Self {
32081        push_header(self.as_rec_mut(), 10u16, 4 as u16);
32082        self.as_rec_mut().extend(value.to_be_bytes());
32083        self
32084    }
32085    pub fn push_nat_ipv6_min(mut self, value: &[u8]) -> Self {
32086        push_header(self.as_rec_mut(), 11u16, value.len() as u16);
32087        self.as_rec_mut().extend(value);
32088        self
32089    }
32090    pub fn push_nat_ipv6_max(mut self, value: &[u8]) -> Self {
32091        push_header(self.as_rec_mut(), 12u16, value.len() as u16);
32092        self.as_rec_mut().extend(value);
32093        self
32094    }
32095    pub fn push_nat_port_min(mut self, value: u16) -> Self {
32096        push_header(self.as_rec_mut(), 13u16, 2 as u16);
32097        self.as_rec_mut().extend(value.to_be_bytes());
32098        self
32099    }
32100    pub fn push_nat_port_max(mut self, value: u16) -> Self {
32101        push_header(self.as_rec_mut(), 14u16, 2 as u16);
32102        self.as_rec_mut().extend(value.to_be_bytes());
32103        self
32104    }
32105    pub fn push_pad(mut self, value: &[u8]) -> Self {
32106        push_header(self.as_rec_mut(), 15u16, value.len() as u16);
32107        self.as_rec_mut().extend(value);
32108        self
32109    }
32110    pub fn push_helper_name(mut self, value: &CStr) -> Self {
32111        push_header(
32112            self.as_rec_mut(),
32113            16u16,
32114            value.to_bytes_with_nul().len() as u16,
32115        );
32116        self.as_rec_mut().extend(value.to_bytes_with_nul());
32117        self
32118    }
32119    pub fn push_helper_name_bytes(mut self, value: &[u8]) -> Self {
32120        push_header(self.as_rec_mut(), 16u16, (value.len() + 1) as u16);
32121        self.as_rec_mut().extend(value);
32122        self.as_rec_mut().push(0);
32123        self
32124    }
32125    pub fn push_helper_family(mut self, value: u8) -> Self {
32126        push_header(self.as_rec_mut(), 17u16, 1 as u16);
32127        self.as_rec_mut().extend(value.to_ne_bytes());
32128        self
32129    }
32130    pub fn push_helper_proto(mut self, value: u8) -> Self {
32131        push_header(self.as_rec_mut(), 18u16, 1 as u16);
32132        self.as_rec_mut().extend(value.to_ne_bytes());
32133        self
32134    }
32135}
32136impl<Prev: Rec> Drop for PushActCtAttrs<Prev> {
32137    fn drop(&mut self) {
32138        if let Some(prev) = &mut self.prev {
32139            if let Some(header_offset) = &self.header_offset {
32140                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32141            }
32142        }
32143    }
32144}
32145pub struct PushActCtinfoAttrs<Prev: Rec> {
32146    pub(crate) prev: Option<Prev>,
32147    pub(crate) header_offset: Option<usize>,
32148}
32149impl<Prev: Rec> Rec for PushActCtinfoAttrs<Prev> {
32150    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32151        self.prev.as_mut().unwrap().as_rec_mut()
32152    }
32153    fn as_rec(&self) -> &Vec<u8> {
32154        self.prev.as_ref().unwrap().as_rec()
32155    }
32156}
32157impl<Prev: Rec> PushActCtinfoAttrs<Prev> {
32158    pub fn new(prev: Prev) -> Self {
32159        Self {
32160            prev: Some(prev),
32161            header_offset: None,
32162        }
32163    }
32164    pub fn end_nested(mut self) -> Prev {
32165        let mut prev = self.prev.take().unwrap();
32166        if let Some(header_offset) = &self.header_offset {
32167            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32168        }
32169        prev
32170    }
32171    pub fn push_pad(mut self, value: &[u8]) -> Self {
32172        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
32173        self.as_rec_mut().extend(value);
32174        self
32175    }
32176    pub fn push_tm(mut self, value: TcfT) -> Self {
32177        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
32178        self.as_rec_mut().extend(value.as_slice());
32179        self
32180    }
32181    pub fn push_act(mut self, value: &[u8]) -> Self {
32182        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32183        self.as_rec_mut().extend(value);
32184        self
32185    }
32186    pub fn push_zone(mut self, value: u16) -> Self {
32187        push_header(self.as_rec_mut(), 4u16, 2 as u16);
32188        self.as_rec_mut().extend(value.to_ne_bytes());
32189        self
32190    }
32191    pub fn push_parms_dscp_mask(mut self, value: u32) -> Self {
32192        push_header(self.as_rec_mut(), 5u16, 4 as u16);
32193        self.as_rec_mut().extend(value.to_ne_bytes());
32194        self
32195    }
32196    pub fn push_parms_dscp_statemask(mut self, value: u32) -> Self {
32197        push_header(self.as_rec_mut(), 6u16, 4 as u16);
32198        self.as_rec_mut().extend(value.to_ne_bytes());
32199        self
32200    }
32201    pub fn push_parms_cpmark_mask(mut self, value: u32) -> Self {
32202        push_header(self.as_rec_mut(), 7u16, 4 as u16);
32203        self.as_rec_mut().extend(value.to_ne_bytes());
32204        self
32205    }
32206    pub fn push_stats_dscp_set(mut self, value: u64) -> Self {
32207        push_header(self.as_rec_mut(), 8u16, 8 as u16);
32208        self.as_rec_mut().extend(value.to_ne_bytes());
32209        self
32210    }
32211    pub fn push_stats_dscp_error(mut self, value: u64) -> Self {
32212        push_header(self.as_rec_mut(), 9u16, 8 as u16);
32213        self.as_rec_mut().extend(value.to_ne_bytes());
32214        self
32215    }
32216    pub fn push_stats_cpmark_set(mut self, value: u64) -> Self {
32217        push_header(self.as_rec_mut(), 10u16, 8 as u16);
32218        self.as_rec_mut().extend(value.to_ne_bytes());
32219        self
32220    }
32221}
32222impl<Prev: Rec> Drop for PushActCtinfoAttrs<Prev> {
32223    fn drop(&mut self) {
32224        if let Some(prev) = &mut self.prev {
32225            if let Some(header_offset) = &self.header_offset {
32226                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32227            }
32228        }
32229    }
32230}
32231pub struct PushActGateAttrs<Prev: Rec> {
32232    pub(crate) prev: Option<Prev>,
32233    pub(crate) header_offset: Option<usize>,
32234}
32235impl<Prev: Rec> Rec for PushActGateAttrs<Prev> {
32236    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32237        self.prev.as_mut().unwrap().as_rec_mut()
32238    }
32239    fn as_rec(&self) -> &Vec<u8> {
32240        self.prev.as_ref().unwrap().as_rec()
32241    }
32242}
32243impl<Prev: Rec> PushActGateAttrs<Prev> {
32244    pub fn new(prev: Prev) -> Self {
32245        Self {
32246            prev: Some(prev),
32247            header_offset: None,
32248        }
32249    }
32250    pub fn end_nested(mut self) -> Prev {
32251        let mut prev = self.prev.take().unwrap();
32252        if let Some(header_offset) = &self.header_offset {
32253            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32254        }
32255        prev
32256    }
32257    pub fn push_tm(mut self, value: TcfT) -> Self {
32258        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32259        self.as_rec_mut().extend(value.as_slice());
32260        self
32261    }
32262    pub fn push_parms(mut self, value: &[u8]) -> Self {
32263        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32264        self.as_rec_mut().extend(value);
32265        self
32266    }
32267    pub fn push_pad(mut self, value: &[u8]) -> Self {
32268        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32269        self.as_rec_mut().extend(value);
32270        self
32271    }
32272    pub fn push_priority(mut self, value: i32) -> Self {
32273        push_header(self.as_rec_mut(), 4u16, 4 as u16);
32274        self.as_rec_mut().extend(value.to_ne_bytes());
32275        self
32276    }
32277    pub fn push_entry_list(mut self, value: &[u8]) -> Self {
32278        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
32279        self.as_rec_mut().extend(value);
32280        self
32281    }
32282    pub fn push_base_time(mut self, value: u64) -> Self {
32283        push_header(self.as_rec_mut(), 6u16, 8 as u16);
32284        self.as_rec_mut().extend(value.to_ne_bytes());
32285        self
32286    }
32287    pub fn push_cycle_time(mut self, value: u64) -> Self {
32288        push_header(self.as_rec_mut(), 7u16, 8 as u16);
32289        self.as_rec_mut().extend(value.to_ne_bytes());
32290        self
32291    }
32292    pub fn push_cycle_time_ext(mut self, value: u64) -> Self {
32293        push_header(self.as_rec_mut(), 8u16, 8 as u16);
32294        self.as_rec_mut().extend(value.to_ne_bytes());
32295        self
32296    }
32297    pub fn push_flags(mut self, value: u32) -> Self {
32298        push_header(self.as_rec_mut(), 9u16, 4 as u16);
32299        self.as_rec_mut().extend(value.to_ne_bytes());
32300        self
32301    }
32302    pub fn push_clockid(mut self, value: i32) -> Self {
32303        push_header(self.as_rec_mut(), 10u16, 4 as u16);
32304        self.as_rec_mut().extend(value.to_ne_bytes());
32305        self
32306    }
32307}
32308impl<Prev: Rec> Drop for PushActGateAttrs<Prev> {
32309    fn drop(&mut self) {
32310        if let Some(prev) = &mut self.prev {
32311            if let Some(header_offset) = &self.header_offset {
32312                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32313            }
32314        }
32315    }
32316}
32317pub struct PushActIfeAttrs<Prev: Rec> {
32318    pub(crate) prev: Option<Prev>,
32319    pub(crate) header_offset: Option<usize>,
32320}
32321impl<Prev: Rec> Rec for PushActIfeAttrs<Prev> {
32322    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32323        self.prev.as_mut().unwrap().as_rec_mut()
32324    }
32325    fn as_rec(&self) -> &Vec<u8> {
32326        self.prev.as_ref().unwrap().as_rec()
32327    }
32328}
32329impl<Prev: Rec> PushActIfeAttrs<Prev> {
32330    pub fn new(prev: Prev) -> Self {
32331        Self {
32332            prev: Some(prev),
32333            header_offset: None,
32334        }
32335    }
32336    pub fn end_nested(mut self) -> Prev {
32337        let mut prev = self.prev.take().unwrap();
32338        if let Some(header_offset) = &self.header_offset {
32339            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32340        }
32341        prev
32342    }
32343    pub fn push_parms(mut self, value: &[u8]) -> Self {
32344        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
32345        self.as_rec_mut().extend(value);
32346        self
32347    }
32348    pub fn push_tm(mut self, value: TcfT) -> Self {
32349        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
32350        self.as_rec_mut().extend(value.as_slice());
32351        self
32352    }
32353    pub fn push_dmac(mut self, value: &[u8]) -> Self {
32354        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32355        self.as_rec_mut().extend(value);
32356        self
32357    }
32358    pub fn push_smac(mut self, value: &[u8]) -> Self {
32359        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
32360        self.as_rec_mut().extend(value);
32361        self
32362    }
32363    pub fn push_type(mut self, value: u16) -> Self {
32364        push_header(self.as_rec_mut(), 5u16, 2 as u16);
32365        self.as_rec_mut().extend(value.to_ne_bytes());
32366        self
32367    }
32368    pub fn push_metalst(mut self, value: &[u8]) -> Self {
32369        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
32370        self.as_rec_mut().extend(value);
32371        self
32372    }
32373    pub fn push_pad(mut self, value: &[u8]) -> Self {
32374        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
32375        self.as_rec_mut().extend(value);
32376        self
32377    }
32378}
32379impl<Prev: Rec> Drop for PushActIfeAttrs<Prev> {
32380    fn drop(&mut self) {
32381        if let Some(prev) = &mut self.prev {
32382            if let Some(header_offset) = &self.header_offset {
32383                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32384            }
32385        }
32386    }
32387}
32388pub struct PushActMirredAttrs<Prev: Rec> {
32389    pub(crate) prev: Option<Prev>,
32390    pub(crate) header_offset: Option<usize>,
32391}
32392impl<Prev: Rec> Rec for PushActMirredAttrs<Prev> {
32393    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32394        self.prev.as_mut().unwrap().as_rec_mut()
32395    }
32396    fn as_rec(&self) -> &Vec<u8> {
32397        self.prev.as_ref().unwrap().as_rec()
32398    }
32399}
32400impl<Prev: Rec> PushActMirredAttrs<Prev> {
32401    pub fn new(prev: Prev) -> Self {
32402        Self {
32403            prev: Some(prev),
32404            header_offset: None,
32405        }
32406    }
32407    pub fn end_nested(mut self) -> Prev {
32408        let mut prev = self.prev.take().unwrap();
32409        if let Some(header_offset) = &self.header_offset {
32410            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32411        }
32412        prev
32413    }
32414    pub fn push_tm(mut self, value: TcfT) -> Self {
32415        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32416        self.as_rec_mut().extend(value.as_slice());
32417        self
32418    }
32419    pub fn push_parms(mut self, value: &[u8]) -> Self {
32420        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32421        self.as_rec_mut().extend(value);
32422        self
32423    }
32424    pub fn push_pad(mut self, value: &[u8]) -> Self {
32425        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32426        self.as_rec_mut().extend(value);
32427        self
32428    }
32429    pub fn push_blockid(mut self, value: &[u8]) -> Self {
32430        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
32431        self.as_rec_mut().extend(value);
32432        self
32433    }
32434}
32435impl<Prev: Rec> Drop for PushActMirredAttrs<Prev> {
32436    fn drop(&mut self) {
32437        if let Some(prev) = &mut self.prev {
32438            if let Some(header_offset) = &self.header_offset {
32439                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32440            }
32441        }
32442    }
32443}
32444pub struct PushActMplsAttrs<Prev: Rec> {
32445    pub(crate) prev: Option<Prev>,
32446    pub(crate) header_offset: Option<usize>,
32447}
32448impl<Prev: Rec> Rec for PushActMplsAttrs<Prev> {
32449    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32450        self.prev.as_mut().unwrap().as_rec_mut()
32451    }
32452    fn as_rec(&self) -> &Vec<u8> {
32453        self.prev.as_ref().unwrap().as_rec()
32454    }
32455}
32456impl<Prev: Rec> PushActMplsAttrs<Prev> {
32457    pub fn new(prev: Prev) -> Self {
32458        Self {
32459            prev: Some(prev),
32460            header_offset: None,
32461        }
32462    }
32463    pub fn end_nested(mut self) -> Prev {
32464        let mut prev = self.prev.take().unwrap();
32465        if let Some(header_offset) = &self.header_offset {
32466            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32467        }
32468        prev
32469    }
32470    pub fn push_tm(mut self, value: TcfT) -> Self {
32471        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32472        self.as_rec_mut().extend(value.as_slice());
32473        self
32474    }
32475    pub fn push_parms(mut self, value: TcMpls) -> Self {
32476        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
32477        self.as_rec_mut().extend(value.as_slice());
32478        self
32479    }
32480    pub fn push_pad(mut self, value: &[u8]) -> Self {
32481        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32482        self.as_rec_mut().extend(value);
32483        self
32484    }
32485    pub fn push_proto(mut self, value: u16) -> Self {
32486        push_header(self.as_rec_mut(), 4u16, 2 as u16);
32487        self.as_rec_mut().extend(value.to_be_bytes());
32488        self
32489    }
32490    pub fn push_label(mut self, value: u32) -> Self {
32491        push_header(self.as_rec_mut(), 5u16, 4 as u16);
32492        self.as_rec_mut().extend(value.to_ne_bytes());
32493        self
32494    }
32495    pub fn push_tc(mut self, value: u8) -> Self {
32496        push_header(self.as_rec_mut(), 6u16, 1 as u16);
32497        self.as_rec_mut().extend(value.to_ne_bytes());
32498        self
32499    }
32500    pub fn push_ttl(mut self, value: u8) -> Self {
32501        push_header(self.as_rec_mut(), 7u16, 1 as u16);
32502        self.as_rec_mut().extend(value.to_ne_bytes());
32503        self
32504    }
32505    pub fn push_bos(mut self, value: u8) -> Self {
32506        push_header(self.as_rec_mut(), 8u16, 1 as u16);
32507        self.as_rec_mut().extend(value.to_ne_bytes());
32508        self
32509    }
32510}
32511impl<Prev: Rec> Drop for PushActMplsAttrs<Prev> {
32512    fn drop(&mut self) {
32513        if let Some(prev) = &mut self.prev {
32514            if let Some(header_offset) = &self.header_offset {
32515                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32516            }
32517        }
32518    }
32519}
32520pub struct PushActNatAttrs<Prev: Rec> {
32521    pub(crate) prev: Option<Prev>,
32522    pub(crate) header_offset: Option<usize>,
32523}
32524impl<Prev: Rec> Rec for PushActNatAttrs<Prev> {
32525    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32526        self.prev.as_mut().unwrap().as_rec_mut()
32527    }
32528    fn as_rec(&self) -> &Vec<u8> {
32529        self.prev.as_ref().unwrap().as_rec()
32530    }
32531}
32532impl<Prev: Rec> PushActNatAttrs<Prev> {
32533    pub fn new(prev: Prev) -> Self {
32534        Self {
32535            prev: Some(prev),
32536            header_offset: None,
32537        }
32538    }
32539    pub fn end_nested(mut self) -> Prev {
32540        let mut prev = self.prev.take().unwrap();
32541        if let Some(header_offset) = &self.header_offset {
32542            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32543        }
32544        prev
32545    }
32546    pub fn push_parms(mut self, value: &[u8]) -> Self {
32547        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
32548        self.as_rec_mut().extend(value);
32549        self
32550    }
32551    pub fn push_tm(mut self, value: TcfT) -> Self {
32552        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
32553        self.as_rec_mut().extend(value.as_slice());
32554        self
32555    }
32556    pub fn push_pad(mut self, value: &[u8]) -> Self {
32557        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32558        self.as_rec_mut().extend(value);
32559        self
32560    }
32561}
32562impl<Prev: Rec> Drop for PushActNatAttrs<Prev> {
32563    fn drop(&mut self) {
32564        if let Some(prev) = &mut self.prev {
32565            if let Some(header_offset) = &self.header_offset {
32566                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32567            }
32568        }
32569    }
32570}
32571pub struct PushActPeditAttrs<Prev: Rec> {
32572    pub(crate) prev: Option<Prev>,
32573    pub(crate) header_offset: Option<usize>,
32574}
32575impl<Prev: Rec> Rec for PushActPeditAttrs<Prev> {
32576    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32577        self.prev.as_mut().unwrap().as_rec_mut()
32578    }
32579    fn as_rec(&self) -> &Vec<u8> {
32580        self.prev.as_ref().unwrap().as_rec()
32581    }
32582}
32583impl<Prev: Rec> PushActPeditAttrs<Prev> {
32584    pub fn new(prev: Prev) -> Self {
32585        Self {
32586            prev: Some(prev),
32587            header_offset: None,
32588        }
32589    }
32590    pub fn end_nested(mut self) -> Prev {
32591        let mut prev = self.prev.take().unwrap();
32592        if let Some(header_offset) = &self.header_offset {
32593            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32594        }
32595        prev
32596    }
32597    pub fn push_tm(mut self, value: TcfT) -> Self {
32598        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32599        self.as_rec_mut().extend(value.as_slice());
32600        self
32601    }
32602    pub fn push_parms(mut self, value: TcPeditSel) -> Self {
32603        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
32604        self.as_rec_mut().extend(value.as_slice());
32605        self
32606    }
32607    pub fn push_pad(mut self, value: &[u8]) -> Self {
32608        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32609        self.as_rec_mut().extend(value);
32610        self
32611    }
32612    pub fn push_parms_ex(mut self, value: &[u8]) -> Self {
32613        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
32614        self.as_rec_mut().extend(value);
32615        self
32616    }
32617    pub fn push_keys_ex(mut self, value: &[u8]) -> Self {
32618        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
32619        self.as_rec_mut().extend(value);
32620        self
32621    }
32622    pub fn push_key_ex(mut self, value: &[u8]) -> Self {
32623        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
32624        self.as_rec_mut().extend(value);
32625        self
32626    }
32627}
32628impl<Prev: Rec> Drop for PushActPeditAttrs<Prev> {
32629    fn drop(&mut self) {
32630        if let Some(prev) = &mut self.prev {
32631            if let Some(header_offset) = &self.header_offset {
32632                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32633            }
32634        }
32635    }
32636}
32637pub struct PushActSimpleAttrs<Prev: Rec> {
32638    pub(crate) prev: Option<Prev>,
32639    pub(crate) header_offset: Option<usize>,
32640}
32641impl<Prev: Rec> Rec for PushActSimpleAttrs<Prev> {
32642    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32643        self.prev.as_mut().unwrap().as_rec_mut()
32644    }
32645    fn as_rec(&self) -> &Vec<u8> {
32646        self.prev.as_ref().unwrap().as_rec()
32647    }
32648}
32649impl<Prev: Rec> PushActSimpleAttrs<Prev> {
32650    pub fn new(prev: Prev) -> Self {
32651        Self {
32652            prev: Some(prev),
32653            header_offset: None,
32654        }
32655    }
32656    pub fn end_nested(mut self) -> Prev {
32657        let mut prev = self.prev.take().unwrap();
32658        if let Some(header_offset) = &self.header_offset {
32659            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32660        }
32661        prev
32662    }
32663    pub fn push_tm(mut self, value: TcfT) -> Self {
32664        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32665        self.as_rec_mut().extend(value.as_slice());
32666        self
32667    }
32668    pub fn push_parms(mut self, value: &[u8]) -> Self {
32669        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32670        self.as_rec_mut().extend(value);
32671        self
32672    }
32673    pub fn push_data(mut self, value: &[u8]) -> Self {
32674        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32675        self.as_rec_mut().extend(value);
32676        self
32677    }
32678    pub fn push_pad(mut self, value: &[u8]) -> Self {
32679        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
32680        self.as_rec_mut().extend(value);
32681        self
32682    }
32683}
32684impl<Prev: Rec> Drop for PushActSimpleAttrs<Prev> {
32685    fn drop(&mut self) {
32686        if let Some(prev) = &mut self.prev {
32687            if let Some(header_offset) = &self.header_offset {
32688                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32689            }
32690        }
32691    }
32692}
32693pub struct PushActSkbeditAttrs<Prev: Rec> {
32694    pub(crate) prev: Option<Prev>,
32695    pub(crate) header_offset: Option<usize>,
32696}
32697impl<Prev: Rec> Rec for PushActSkbeditAttrs<Prev> {
32698    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32699        self.prev.as_mut().unwrap().as_rec_mut()
32700    }
32701    fn as_rec(&self) -> &Vec<u8> {
32702        self.prev.as_ref().unwrap().as_rec()
32703    }
32704}
32705impl<Prev: Rec> PushActSkbeditAttrs<Prev> {
32706    pub fn new(prev: Prev) -> Self {
32707        Self {
32708            prev: Some(prev),
32709            header_offset: None,
32710        }
32711    }
32712    pub fn end_nested(mut self) -> Prev {
32713        let mut prev = self.prev.take().unwrap();
32714        if let Some(header_offset) = &self.header_offset {
32715            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32716        }
32717        prev
32718    }
32719    pub fn push_tm(mut self, value: TcfT) -> Self {
32720        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32721        self.as_rec_mut().extend(value.as_slice());
32722        self
32723    }
32724    pub fn push_parms(mut self, value: &[u8]) -> Self {
32725        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32726        self.as_rec_mut().extend(value);
32727        self
32728    }
32729    pub fn push_priority(mut self, value: u32) -> Self {
32730        push_header(self.as_rec_mut(), 3u16, 4 as u16);
32731        self.as_rec_mut().extend(value.to_ne_bytes());
32732        self
32733    }
32734    pub fn push_queue_mapping(mut self, value: u16) -> Self {
32735        push_header(self.as_rec_mut(), 4u16, 2 as u16);
32736        self.as_rec_mut().extend(value.to_ne_bytes());
32737        self
32738    }
32739    pub fn push_mark(mut self, value: u32) -> Self {
32740        push_header(self.as_rec_mut(), 5u16, 4 as u16);
32741        self.as_rec_mut().extend(value.to_ne_bytes());
32742        self
32743    }
32744    pub fn push_pad(mut self, value: &[u8]) -> Self {
32745        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
32746        self.as_rec_mut().extend(value);
32747        self
32748    }
32749    pub fn push_ptype(mut self, value: u16) -> Self {
32750        push_header(self.as_rec_mut(), 7u16, 2 as u16);
32751        self.as_rec_mut().extend(value.to_ne_bytes());
32752        self
32753    }
32754    pub fn push_mask(mut self, value: u32) -> Self {
32755        push_header(self.as_rec_mut(), 8u16, 4 as u16);
32756        self.as_rec_mut().extend(value.to_ne_bytes());
32757        self
32758    }
32759    pub fn push_flags(mut self, value: u64) -> Self {
32760        push_header(self.as_rec_mut(), 9u16, 8 as u16);
32761        self.as_rec_mut().extend(value.to_ne_bytes());
32762        self
32763    }
32764    pub fn push_queue_mapping_max(mut self, value: u16) -> Self {
32765        push_header(self.as_rec_mut(), 10u16, 2 as u16);
32766        self.as_rec_mut().extend(value.to_ne_bytes());
32767        self
32768    }
32769}
32770impl<Prev: Rec> Drop for PushActSkbeditAttrs<Prev> {
32771    fn drop(&mut self) {
32772        if let Some(prev) = &mut self.prev {
32773            if let Some(header_offset) = &self.header_offset {
32774                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32775            }
32776        }
32777    }
32778}
32779pub struct PushActSkbmodAttrs<Prev: Rec> {
32780    pub(crate) prev: Option<Prev>,
32781    pub(crate) header_offset: Option<usize>,
32782}
32783impl<Prev: Rec> Rec for PushActSkbmodAttrs<Prev> {
32784    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32785        self.prev.as_mut().unwrap().as_rec_mut()
32786    }
32787    fn as_rec(&self) -> &Vec<u8> {
32788        self.prev.as_ref().unwrap().as_rec()
32789    }
32790}
32791impl<Prev: Rec> PushActSkbmodAttrs<Prev> {
32792    pub fn new(prev: Prev) -> Self {
32793        Self {
32794            prev: Some(prev),
32795            header_offset: None,
32796        }
32797    }
32798    pub fn end_nested(mut self) -> Prev {
32799        let mut prev = self.prev.take().unwrap();
32800        if let Some(header_offset) = &self.header_offset {
32801            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32802        }
32803        prev
32804    }
32805    pub fn push_tm(mut self, value: TcfT) -> Self {
32806        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32807        self.as_rec_mut().extend(value.as_slice());
32808        self
32809    }
32810    pub fn push_parms(mut self, value: &[u8]) -> Self {
32811        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32812        self.as_rec_mut().extend(value);
32813        self
32814    }
32815    pub fn push_dmac(mut self, value: &[u8]) -> Self {
32816        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32817        self.as_rec_mut().extend(value);
32818        self
32819    }
32820    pub fn push_smac(mut self, value: &[u8]) -> Self {
32821        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
32822        self.as_rec_mut().extend(value);
32823        self
32824    }
32825    pub fn push_etype(mut self, value: &[u8]) -> Self {
32826        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
32827        self.as_rec_mut().extend(value);
32828        self
32829    }
32830    pub fn push_pad(mut self, value: &[u8]) -> Self {
32831        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
32832        self.as_rec_mut().extend(value);
32833        self
32834    }
32835}
32836impl<Prev: Rec> Drop for PushActSkbmodAttrs<Prev> {
32837    fn drop(&mut self) {
32838        if let Some(prev) = &mut self.prev {
32839            if let Some(header_offset) = &self.header_offset {
32840                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32841            }
32842        }
32843    }
32844}
32845pub struct PushActTunnelKeyAttrs<Prev: Rec> {
32846    pub(crate) prev: Option<Prev>,
32847    pub(crate) header_offset: Option<usize>,
32848}
32849impl<Prev: Rec> Rec for PushActTunnelKeyAttrs<Prev> {
32850    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32851        self.prev.as_mut().unwrap().as_rec_mut()
32852    }
32853    fn as_rec(&self) -> &Vec<u8> {
32854        self.prev.as_ref().unwrap().as_rec()
32855    }
32856}
32857impl<Prev: Rec> PushActTunnelKeyAttrs<Prev> {
32858    pub fn new(prev: Prev) -> Self {
32859        Self {
32860            prev: Some(prev),
32861            header_offset: None,
32862        }
32863    }
32864    pub fn end_nested(mut self) -> Prev {
32865        let mut prev = self.prev.take().unwrap();
32866        if let Some(header_offset) = &self.header_offset {
32867            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32868        }
32869        prev
32870    }
32871    pub fn push_tm(mut self, value: TcfT) -> Self {
32872        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32873        self.as_rec_mut().extend(value.as_slice());
32874        self
32875    }
32876    pub fn push_parms(mut self, value: &[u8]) -> Self {
32877        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32878        self.as_rec_mut().extend(value);
32879        self
32880    }
32881    pub fn push_enc_ipv4_src(mut self, value: u32) -> Self {
32882        push_header(self.as_rec_mut(), 3u16, 4 as u16);
32883        self.as_rec_mut().extend(value.to_be_bytes());
32884        self
32885    }
32886    pub fn push_enc_ipv4_dst(mut self, value: u32) -> Self {
32887        push_header(self.as_rec_mut(), 4u16, 4 as u16);
32888        self.as_rec_mut().extend(value.to_be_bytes());
32889        self
32890    }
32891    pub fn push_enc_ipv6_src(mut self, value: &[u8]) -> Self {
32892        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
32893        self.as_rec_mut().extend(value);
32894        self
32895    }
32896    pub fn push_enc_ipv6_dst(mut self, value: &[u8]) -> Self {
32897        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
32898        self.as_rec_mut().extend(value);
32899        self
32900    }
32901    pub fn push_enc_key_id(mut self, value: u64) -> Self {
32902        push_header(self.as_rec_mut(), 7u16, 8 as u16);
32903        self.as_rec_mut().extend(value.to_be_bytes());
32904        self
32905    }
32906    pub fn push_pad(mut self, value: &[u8]) -> Self {
32907        push_header(self.as_rec_mut(), 8u16, value.len() as u16);
32908        self.as_rec_mut().extend(value);
32909        self
32910    }
32911    pub fn push_enc_dst_port(mut self, value: u16) -> Self {
32912        push_header(self.as_rec_mut(), 9u16, 2 as u16);
32913        self.as_rec_mut().extend(value.to_be_bytes());
32914        self
32915    }
32916    pub fn push_no_csum(mut self, value: u8) -> Self {
32917        push_header(self.as_rec_mut(), 10u16, 1 as u16);
32918        self.as_rec_mut().extend(value.to_ne_bytes());
32919        self
32920    }
32921    pub fn push_enc_opts(mut self, value: &[u8]) -> Self {
32922        push_header(self.as_rec_mut(), 11u16, value.len() as u16);
32923        self.as_rec_mut().extend(value);
32924        self
32925    }
32926    pub fn push_enc_tos(mut self, value: u8) -> Self {
32927        push_header(self.as_rec_mut(), 12u16, 1 as u16);
32928        self.as_rec_mut().extend(value.to_ne_bytes());
32929        self
32930    }
32931    pub fn push_enc_ttl(mut self, value: u8) -> Self {
32932        push_header(self.as_rec_mut(), 13u16, 1 as u16);
32933        self.as_rec_mut().extend(value.to_ne_bytes());
32934        self
32935    }
32936    pub fn push_no_frag(mut self, value: ()) -> Self {
32937        push_header(self.as_rec_mut(), 14u16, 0 as u16);
32938        self
32939    }
32940}
32941impl<Prev: Rec> Drop for PushActTunnelKeyAttrs<Prev> {
32942    fn drop(&mut self) {
32943        if let Some(prev) = &mut self.prev {
32944            if let Some(header_offset) = &self.header_offset {
32945                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32946            }
32947        }
32948    }
32949}
32950pub struct PushActVlanAttrs<Prev: Rec> {
32951    pub(crate) prev: Option<Prev>,
32952    pub(crate) header_offset: Option<usize>,
32953}
32954impl<Prev: Rec> Rec for PushActVlanAttrs<Prev> {
32955    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32956        self.prev.as_mut().unwrap().as_rec_mut()
32957    }
32958    fn as_rec(&self) -> &Vec<u8> {
32959        self.prev.as_ref().unwrap().as_rec()
32960    }
32961}
32962impl<Prev: Rec> PushActVlanAttrs<Prev> {
32963    pub fn new(prev: Prev) -> Self {
32964        Self {
32965            prev: Some(prev),
32966            header_offset: None,
32967        }
32968    }
32969    pub fn end_nested(mut self) -> Prev {
32970        let mut prev = self.prev.take().unwrap();
32971        if let Some(header_offset) = &self.header_offset {
32972            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32973        }
32974        prev
32975    }
32976    pub fn push_tm(mut self, value: TcfT) -> Self {
32977        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32978        self.as_rec_mut().extend(value.as_slice());
32979        self
32980    }
32981    pub fn push_parms(mut self, value: TcVlan) -> Self {
32982        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
32983        self.as_rec_mut().extend(value.as_slice());
32984        self
32985    }
32986    pub fn push_push_vlan_id(mut self, value: u16) -> Self {
32987        push_header(self.as_rec_mut(), 3u16, 2 as u16);
32988        self.as_rec_mut().extend(value.to_ne_bytes());
32989        self
32990    }
32991    pub fn push_push_vlan_protocol(mut self, value: u16) -> Self {
32992        push_header(self.as_rec_mut(), 4u16, 2 as u16);
32993        self.as_rec_mut().extend(value.to_ne_bytes());
32994        self
32995    }
32996    pub fn push_pad(mut self, value: &[u8]) -> Self {
32997        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
32998        self.as_rec_mut().extend(value);
32999        self
33000    }
33001    pub fn push_push_vlan_priority(mut self, value: u8) -> Self {
33002        push_header(self.as_rec_mut(), 6u16, 1 as u16);
33003        self.as_rec_mut().extend(value.to_ne_bytes());
33004        self
33005    }
33006    pub fn push_push_eth_dst(mut self, value: &[u8]) -> Self {
33007        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
33008        self.as_rec_mut().extend(value);
33009        self
33010    }
33011    pub fn push_push_eth_src(mut self, value: &[u8]) -> Self {
33012        push_header(self.as_rec_mut(), 8u16, value.len() as u16);
33013        self.as_rec_mut().extend(value);
33014        self
33015    }
33016}
33017impl<Prev: Rec> Drop for PushActVlanAttrs<Prev> {
33018    fn drop(&mut self) {
33019        if let Some(prev) = &mut self.prev {
33020            if let Some(header_offset) = &self.header_offset {
33021                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33022            }
33023        }
33024    }
33025}
33026pub struct PushBasicAttrs<Prev: Rec> {
33027    pub(crate) prev: Option<Prev>,
33028    pub(crate) header_offset: Option<usize>,
33029}
33030impl<Prev: Rec> Rec for PushBasicAttrs<Prev> {
33031    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33032        self.prev.as_mut().unwrap().as_rec_mut()
33033    }
33034    fn as_rec(&self) -> &Vec<u8> {
33035        self.prev.as_ref().unwrap().as_rec()
33036    }
33037}
33038pub struct PushArrayActAttrs<Prev: Rec> {
33039    pub(crate) prev: Option<Prev>,
33040    pub(crate) header_offset: Option<usize>,
33041    pub(crate) counter: u16,
33042}
33043impl<Prev: Rec> Rec for PushArrayActAttrs<Prev> {
33044    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33045        self.prev.as_mut().unwrap().as_rec_mut()
33046    }
33047    fn as_rec(&self) -> &Vec<u8> {
33048        self.prev.as_ref().unwrap().as_rec()
33049    }
33050}
33051impl<Prev: Rec> PushArrayActAttrs<Prev> {
33052    pub fn new(prev: Prev) -> Self {
33053        Self {
33054            prev: Some(prev),
33055            header_offset: None,
33056            counter: 0,
33057        }
33058    }
33059    pub fn end_array(mut self) -> Prev {
33060        let mut prev = self.prev.take().unwrap();
33061        if let Some(header_offset) = &self.header_offset {
33062            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33063        }
33064        prev
33065    }
33066    pub fn entry_nested(mut self) -> PushActAttrs<Self> {
33067        let index = self.counter;
33068        self.counter += 1;
33069        let header_offset = push_nested_header(self.as_rec_mut(), index);
33070        PushActAttrs {
33071            prev: Some(self),
33072            header_offset: Some(header_offset),
33073        }
33074    }
33075}
33076impl<Prev: Rec> Drop for PushArrayActAttrs<Prev> {
33077    fn drop(&mut self) {
33078        if let Some(prev) = &mut self.prev {
33079            if let Some(header_offset) = &self.header_offset {
33080                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33081            }
33082        }
33083    }
33084}
33085impl<Prev: Rec> PushBasicAttrs<Prev> {
33086    pub fn new(prev: Prev) -> Self {
33087        Self {
33088            prev: Some(prev),
33089            header_offset: None,
33090        }
33091    }
33092    pub fn end_nested(mut self) -> Prev {
33093        let mut prev = self.prev.take().unwrap();
33094        if let Some(header_offset) = &self.header_offset {
33095            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33096        }
33097        prev
33098    }
33099    pub fn push_classid(mut self, value: u32) -> Self {
33100        push_header(self.as_rec_mut(), 1u16, 4 as u16);
33101        self.as_rec_mut().extend(value.to_ne_bytes());
33102        self
33103    }
33104    pub fn nested_ematches(mut self) -> PushEmatchAttrs<Self> {
33105        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
33106        PushEmatchAttrs {
33107            prev: Some(self),
33108            header_offset: Some(header_offset),
33109        }
33110    }
33111    pub fn array_act(mut self) -> PushArrayActAttrs<Self> {
33112        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
33113        PushArrayActAttrs {
33114            prev: Some(self),
33115            header_offset: Some(header_offset),
33116            counter: 0,
33117        }
33118    }
33119    pub fn nested_police(mut self) -> PushPoliceAttrs<Self> {
33120        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
33121        PushPoliceAttrs {
33122            prev: Some(self),
33123            header_offset: Some(header_offset),
33124        }
33125    }
33126    pub fn push_pcnt(mut self, value: TcBasicPcnt) -> Self {
33127        push_header(self.as_rec_mut(), 5u16, value.as_slice().len() as u16);
33128        self.as_rec_mut().extend(value.as_slice());
33129        self
33130    }
33131    pub fn push_pad(mut self, value: &[u8]) -> Self {
33132        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
33133        self.as_rec_mut().extend(value);
33134        self
33135    }
33136}
33137impl<Prev: Rec> Drop for PushBasicAttrs<Prev> {
33138    fn drop(&mut self) {
33139        if let Some(prev) = &mut self.prev {
33140            if let Some(header_offset) = &self.header_offset {
33141                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33142            }
33143        }
33144    }
33145}
33146pub struct PushBpfAttrs<Prev: Rec> {
33147    pub(crate) prev: Option<Prev>,
33148    pub(crate) header_offset: Option<usize>,
33149}
33150impl<Prev: Rec> Rec for PushBpfAttrs<Prev> {
33151    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33152        self.prev.as_mut().unwrap().as_rec_mut()
33153    }
33154    fn as_rec(&self) -> &Vec<u8> {
33155        self.prev.as_ref().unwrap().as_rec()
33156    }
33157}
33158impl<Prev: Rec> PushBpfAttrs<Prev> {
33159    pub fn new(prev: Prev) -> Self {
33160        Self {
33161            prev: Some(prev),
33162            header_offset: None,
33163        }
33164    }
33165    pub fn end_nested(mut self) -> Prev {
33166        let mut prev = self.prev.take().unwrap();
33167        if let Some(header_offset) = &self.header_offset {
33168            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33169        }
33170        prev
33171    }
33172    pub fn array_act(mut self) -> PushArrayActAttrs<Self> {
33173        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
33174        PushArrayActAttrs {
33175            prev: Some(self),
33176            header_offset: Some(header_offset),
33177            counter: 0,
33178        }
33179    }
33180    pub fn nested_police(mut self) -> PushPoliceAttrs<Self> {
33181        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
33182        PushPoliceAttrs {
33183            prev: Some(self),
33184            header_offset: Some(header_offset),
33185        }
33186    }
33187    pub fn push_classid(mut self, value: u32) -> Self {
33188        push_header(self.as_rec_mut(), 3u16, 4 as u16);
33189        self.as_rec_mut().extend(value.to_ne_bytes());
33190        self
33191    }
33192    pub fn push_ops_len(mut self, value: u16) -> Self {
33193        push_header(self.as_rec_mut(), 4u16, 2 as u16);
33194        self.as_rec_mut().extend(value.to_ne_bytes());
33195        self
33196    }
33197    pub fn push_ops(mut self, value: &[u8]) -> Self {
33198        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
33199        self.as_rec_mut().extend(value);
33200        self
33201    }
33202    pub fn push_fd(mut self, value: u32) -> Self {
33203        push_header(self.as_rec_mut(), 6u16, 4 as u16);
33204        self.as_rec_mut().extend(value.to_ne_bytes());
33205        self
33206    }
33207    pub fn push_name(mut self, value: &CStr) -> Self {
33208        push_header(
33209            self.as_rec_mut(),
33210            7u16,
33211            value.to_bytes_with_nul().len() as u16,
33212        );
33213        self.as_rec_mut().extend(value.to_bytes_with_nul());
33214        self
33215    }
33216    pub fn push_name_bytes(mut self, value: &[u8]) -> Self {
33217        push_header(self.as_rec_mut(), 7u16, (value.len() + 1) as u16);
33218        self.as_rec_mut().extend(value);
33219        self.as_rec_mut().push(0);
33220        self
33221    }
33222    pub fn push_flags(mut self, value: u32) -> Self {
33223        push_header(self.as_rec_mut(), 8u16, 4 as u16);
33224        self.as_rec_mut().extend(value.to_ne_bytes());
33225        self
33226    }
33227    pub fn push_flags_gen(mut self, value: u32) -> Self {
33228        push_header(self.as_rec_mut(), 9u16, 4 as u16);
33229        self.as_rec_mut().extend(value.to_ne_bytes());
33230        self
33231    }
33232    pub fn push_tag(mut self, value: &[u8]) -> Self {
33233        push_header(self.as_rec_mut(), 10u16, value.len() as u16);
33234        self.as_rec_mut().extend(value);
33235        self
33236    }
33237    pub fn push_id(mut self, value: u32) -> Self {
33238        push_header(self.as_rec_mut(), 11u16, 4 as u16);
33239        self.as_rec_mut().extend(value.to_ne_bytes());
33240        self
33241    }
33242}
33243impl<Prev: Rec> Drop for PushBpfAttrs<Prev> {
33244    fn drop(&mut self) {
33245        if let Some(prev) = &mut self.prev {
33246            if let Some(header_offset) = &self.header_offset {
33247                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33248            }
33249        }
33250    }
33251}
33252pub struct PushCakeAttrs<Prev: Rec> {
33253    pub(crate) prev: Option<Prev>,
33254    pub(crate) header_offset: Option<usize>,
33255}
33256impl<Prev: Rec> Rec for PushCakeAttrs<Prev> {
33257    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33258        self.prev.as_mut().unwrap().as_rec_mut()
33259    }
33260    fn as_rec(&self) -> &Vec<u8> {
33261        self.prev.as_ref().unwrap().as_rec()
33262    }
33263}
33264impl<Prev: Rec> PushCakeAttrs<Prev> {
33265    pub fn new(prev: Prev) -> Self {
33266        Self {
33267            prev: Some(prev),
33268            header_offset: None,
33269        }
33270    }
33271    pub fn end_nested(mut self) -> Prev {
33272        let mut prev = self.prev.take().unwrap();
33273        if let Some(header_offset) = &self.header_offset {
33274            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33275        }
33276        prev
33277    }
33278    pub fn push_pad(mut self, value: &[u8]) -> Self {
33279        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
33280        self.as_rec_mut().extend(value);
33281        self
33282    }
33283    pub fn push_base_rate64(mut self, value: u64) -> Self {
33284        push_header(self.as_rec_mut(), 2u16, 8 as u16);
33285        self.as_rec_mut().extend(value.to_ne_bytes());
33286        self
33287    }
33288    pub fn push_diffserv_mode(mut self, value: u32) -> Self {
33289        push_header(self.as_rec_mut(), 3u16, 4 as u16);
33290        self.as_rec_mut().extend(value.to_ne_bytes());
33291        self
33292    }
33293    pub fn push_atm(mut self, value: u32) -> Self {
33294        push_header(self.as_rec_mut(), 4u16, 4 as u16);
33295        self.as_rec_mut().extend(value.to_ne_bytes());
33296        self
33297    }
33298    pub fn push_flow_mode(mut self, value: u32) -> Self {
33299        push_header(self.as_rec_mut(), 5u16, 4 as u16);
33300        self.as_rec_mut().extend(value.to_ne_bytes());
33301        self
33302    }
33303    pub fn push_overhead(mut self, value: u32) -> Self {
33304        push_header(self.as_rec_mut(), 6u16, 4 as u16);
33305        self.as_rec_mut().extend(value.to_ne_bytes());
33306        self
33307    }
33308    pub fn push_rtt(mut self, value: u32) -> Self {
33309        push_header(self.as_rec_mut(), 7u16, 4 as u16);
33310        self.as_rec_mut().extend(value.to_ne_bytes());
33311        self
33312    }
33313    pub fn push_target(mut self, value: u32) -> Self {
33314        push_header(self.as_rec_mut(), 8u16, 4 as u16);
33315        self.as_rec_mut().extend(value.to_ne_bytes());
33316        self
33317    }
33318    pub fn push_autorate(mut self, value: u32) -> Self {
33319        push_header(self.as_rec_mut(), 9u16, 4 as u16);
33320        self.as_rec_mut().extend(value.to_ne_bytes());
33321        self
33322    }
33323    pub fn push_memory(mut self, value: u32) -> Self {
33324        push_header(self.as_rec_mut(), 10u16, 4 as u16);
33325        self.as_rec_mut().extend(value.to_ne_bytes());
33326        self
33327    }
33328    pub fn push_nat(mut self, value: u32) -> Self {
33329        push_header(self.as_rec_mut(), 11u16, 4 as u16);
33330        self.as_rec_mut().extend(value.to_ne_bytes());
33331        self
33332    }
33333    pub fn push_raw(mut self, value: u32) -> Self {
33334        push_header(self.as_rec_mut(), 12u16, 4 as u16);
33335        self.as_rec_mut().extend(value.to_ne_bytes());
33336        self
33337    }
33338    pub fn push_wash(mut self, value: u32) -> Self {
33339        push_header(self.as_rec_mut(), 13u16, 4 as u16);
33340        self.as_rec_mut().extend(value.to_ne_bytes());
33341        self
33342    }
33343    pub fn push_mpu(mut self, value: u32) -> Self {
33344        push_header(self.as_rec_mut(), 14u16, 4 as u16);
33345        self.as_rec_mut().extend(value.to_ne_bytes());
33346        self
33347    }
33348    pub fn push_ingress(mut self, value: u32) -> Self {
33349        push_header(self.as_rec_mut(), 15u16, 4 as u16);
33350        self.as_rec_mut().extend(value.to_ne_bytes());
33351        self
33352    }
33353    pub fn push_ack_filter(mut self, value: u32) -> Self {
33354        push_header(self.as_rec_mut(), 16u16, 4 as u16);
33355        self.as_rec_mut().extend(value.to_ne_bytes());
33356        self
33357    }
33358    pub fn push_split_gso(mut self, value: u32) -> Self {
33359        push_header(self.as_rec_mut(), 17u16, 4 as u16);
33360        self.as_rec_mut().extend(value.to_ne_bytes());
33361        self
33362    }
33363    pub fn push_fwmark(mut self, value: u32) -> Self {
33364        push_header(self.as_rec_mut(), 18u16, 4 as u16);
33365        self.as_rec_mut().extend(value.to_ne_bytes());
33366        self
33367    }
33368}
33369impl<Prev: Rec> Drop for PushCakeAttrs<Prev> {
33370    fn drop(&mut self) {
33371        if let Some(prev) = &mut self.prev {
33372            if let Some(header_offset) = &self.header_offset {
33373                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33374            }
33375        }
33376    }
33377}
33378pub struct PushCakeStatsAttrs<Prev: Rec> {
33379    pub(crate) prev: Option<Prev>,
33380    pub(crate) header_offset: Option<usize>,
33381}
33382impl<Prev: Rec> Rec for PushCakeStatsAttrs<Prev> {
33383    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33384        self.prev.as_mut().unwrap().as_rec_mut()
33385    }
33386    fn as_rec(&self) -> &Vec<u8> {
33387        self.prev.as_ref().unwrap().as_rec()
33388    }
33389}
33390pub struct PushArrayCakeTinStatsAttrs<Prev: Rec> {
33391    pub(crate) prev: Option<Prev>,
33392    pub(crate) header_offset: Option<usize>,
33393    pub(crate) counter: u16,
33394}
33395impl<Prev: Rec> Rec for PushArrayCakeTinStatsAttrs<Prev> {
33396    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33397        self.prev.as_mut().unwrap().as_rec_mut()
33398    }
33399    fn as_rec(&self) -> &Vec<u8> {
33400        self.prev.as_ref().unwrap().as_rec()
33401    }
33402}
33403impl<Prev: Rec> PushArrayCakeTinStatsAttrs<Prev> {
33404    pub fn new(prev: Prev) -> Self {
33405        Self {
33406            prev: Some(prev),
33407            header_offset: None,
33408            counter: 0,
33409        }
33410    }
33411    pub fn end_array(mut self) -> Prev {
33412        let mut prev = self.prev.take().unwrap();
33413        if let Some(header_offset) = &self.header_offset {
33414            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33415        }
33416        prev
33417    }
33418    pub fn entry_nested(mut self) -> PushCakeTinStatsAttrs<Self> {
33419        let index = self.counter;
33420        self.counter += 1;
33421        let header_offset = push_nested_header(self.as_rec_mut(), index);
33422        PushCakeTinStatsAttrs {
33423            prev: Some(self),
33424            header_offset: Some(header_offset),
33425        }
33426    }
33427}
33428impl<Prev: Rec> Drop for PushArrayCakeTinStatsAttrs<Prev> {
33429    fn drop(&mut self) {
33430        if let Some(prev) = &mut self.prev {
33431            if let Some(header_offset) = &self.header_offset {
33432                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33433            }
33434        }
33435    }
33436}
33437impl<Prev: Rec> PushCakeStatsAttrs<Prev> {
33438    pub fn new(prev: Prev) -> Self {
33439        Self {
33440            prev: Some(prev),
33441            header_offset: None,
33442        }
33443    }
33444    pub fn end_nested(mut self) -> Prev {
33445        let mut prev = self.prev.take().unwrap();
33446        if let Some(header_offset) = &self.header_offset {
33447            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33448        }
33449        prev
33450    }
33451    pub fn push_pad(mut self, value: &[u8]) -> Self {
33452        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
33453        self.as_rec_mut().extend(value);
33454        self
33455    }
33456    pub fn push_capacity_estimate64(mut self, value: u64) -> Self {
33457        push_header(self.as_rec_mut(), 2u16, 8 as u16);
33458        self.as_rec_mut().extend(value.to_ne_bytes());
33459        self
33460    }
33461    pub fn push_memory_limit(mut self, value: u32) -> Self {
33462        push_header(self.as_rec_mut(), 3u16, 4 as u16);
33463        self.as_rec_mut().extend(value.to_ne_bytes());
33464        self
33465    }
33466    pub fn push_memory_used(mut self, value: u32) -> Self {
33467        push_header(self.as_rec_mut(), 4u16, 4 as u16);
33468        self.as_rec_mut().extend(value.to_ne_bytes());
33469        self
33470    }
33471    pub fn push_avg_netoff(mut self, value: u32) -> Self {
33472        push_header(self.as_rec_mut(), 5u16, 4 as u16);
33473        self.as_rec_mut().extend(value.to_ne_bytes());
33474        self
33475    }
33476    pub fn push_min_netlen(mut self, value: u32) -> Self {
33477        push_header(self.as_rec_mut(), 6u16, 4 as u16);
33478        self.as_rec_mut().extend(value.to_ne_bytes());
33479        self
33480    }
33481    pub fn push_max_netlen(mut self, value: u32) -> Self {
33482        push_header(self.as_rec_mut(), 7u16, 4 as u16);
33483        self.as_rec_mut().extend(value.to_ne_bytes());
33484        self
33485    }
33486    pub fn push_min_adjlen(mut self, value: u32) -> Self {
33487        push_header(self.as_rec_mut(), 8u16, 4 as u16);
33488        self.as_rec_mut().extend(value.to_ne_bytes());
33489        self
33490    }
33491    pub fn push_max_adjlen(mut self, value: u32) -> Self {
33492        push_header(self.as_rec_mut(), 9u16, 4 as u16);
33493        self.as_rec_mut().extend(value.to_ne_bytes());
33494        self
33495    }
33496    pub fn array_tin_stats(mut self) -> PushArrayCakeTinStatsAttrs<Self> {
33497        let header_offset = push_nested_header(self.as_rec_mut(), 10u16);
33498        PushArrayCakeTinStatsAttrs {
33499            prev: Some(self),
33500            header_offset: Some(header_offset),
33501            counter: 0,
33502        }
33503    }
33504    pub fn push_deficit(mut self, value: i32) -> Self {
33505        push_header(self.as_rec_mut(), 11u16, 4 as u16);
33506        self.as_rec_mut().extend(value.to_ne_bytes());
33507        self
33508    }
33509    pub fn push_cobalt_count(mut self, value: u32) -> Self {
33510        push_header(self.as_rec_mut(), 12u16, 4 as u16);
33511        self.as_rec_mut().extend(value.to_ne_bytes());
33512        self
33513    }
33514    pub fn push_dropping(mut self, value: u32) -> Self {
33515        push_header(self.as_rec_mut(), 13u16, 4 as u16);
33516        self.as_rec_mut().extend(value.to_ne_bytes());
33517        self
33518    }
33519    pub fn push_drop_next_us(mut self, value: i32) -> Self {
33520        push_header(self.as_rec_mut(), 14u16, 4 as u16);
33521        self.as_rec_mut().extend(value.to_ne_bytes());
33522        self
33523    }
33524    pub fn push_p_drop(mut self, value: u32) -> Self {
33525        push_header(self.as_rec_mut(), 15u16, 4 as u16);
33526        self.as_rec_mut().extend(value.to_ne_bytes());
33527        self
33528    }
33529    pub fn push_blue_timer_us(mut self, value: i32) -> Self {
33530        push_header(self.as_rec_mut(), 16u16, 4 as u16);
33531        self.as_rec_mut().extend(value.to_ne_bytes());
33532        self
33533    }
33534    pub fn push_active_queues(mut self, value: u32) -> Self {
33535        push_header(self.as_rec_mut(), 17u16, 4 as u16);
33536        self.as_rec_mut().extend(value.to_ne_bytes());
33537        self
33538    }
33539}
33540impl<Prev: Rec> Drop for PushCakeStatsAttrs<Prev> {
33541    fn drop(&mut self) {
33542        if let Some(prev) = &mut self.prev {
33543            if let Some(header_offset) = &self.header_offset {
33544                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33545            }
33546        }
33547    }
33548}
33549pub struct PushCakeTinStatsAttrs<Prev: Rec> {
33550    pub(crate) prev: Option<Prev>,
33551    pub(crate) header_offset: Option<usize>,
33552}
33553impl<Prev: Rec> Rec for PushCakeTinStatsAttrs<Prev> {
33554    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33555        self.prev.as_mut().unwrap().as_rec_mut()
33556    }
33557    fn as_rec(&self) -> &Vec<u8> {
33558        self.prev.as_ref().unwrap().as_rec()
33559    }
33560}
33561impl<Prev: Rec> PushCakeTinStatsAttrs<Prev> {
33562    pub fn new(prev: Prev) -> Self {
33563        Self {
33564            prev: Some(prev),
33565            header_offset: None,
33566        }
33567    }
33568    pub fn end_nested(mut self) -> Prev {
33569        let mut prev = self.prev.take().unwrap();
33570        if let Some(header_offset) = &self.header_offset {
33571            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33572        }
33573        prev
33574    }
33575    pub fn push_pad(mut self, value: &[u8]) -> Self {
33576        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
33577        self.as_rec_mut().extend(value);
33578        self
33579    }
33580    pub fn push_sent_packets(mut self, value: u32) -> Self {
33581        push_header(self.as_rec_mut(), 2u16, 4 as u16);
33582        self.as_rec_mut().extend(value.to_ne_bytes());
33583        self
33584    }
33585    pub fn push_sent_bytes64(mut self, value: u64) -> Self {
33586        push_header(self.as_rec_mut(), 3u16, 8 as u16);
33587        self.as_rec_mut().extend(value.to_ne_bytes());
33588        self
33589    }
33590    pub fn push_dropped_packets(mut self, value: u32) -> Self {
33591        push_header(self.as_rec_mut(), 4u16, 4 as u16);
33592        self.as_rec_mut().extend(value.to_ne_bytes());
33593        self
33594    }
33595    pub fn push_dropped_bytes64(mut self, value: u64) -> Self {
33596        push_header(self.as_rec_mut(), 5u16, 8 as u16);
33597        self.as_rec_mut().extend(value.to_ne_bytes());
33598        self
33599    }
33600    pub fn push_acks_dropped_packets(mut self, value: u32) -> Self {
33601        push_header(self.as_rec_mut(), 6u16, 4 as u16);
33602        self.as_rec_mut().extend(value.to_ne_bytes());
33603        self
33604    }
33605    pub fn push_acks_dropped_bytes64(mut self, value: u64) -> Self {
33606        push_header(self.as_rec_mut(), 7u16, 8 as u16);
33607        self.as_rec_mut().extend(value.to_ne_bytes());
33608        self
33609    }
33610    pub fn push_ecn_marked_packets(mut self, value: u32) -> Self {
33611        push_header(self.as_rec_mut(), 8u16, 4 as u16);
33612        self.as_rec_mut().extend(value.to_ne_bytes());
33613        self
33614    }
33615    pub fn push_ecn_marked_bytes64(mut self, value: u64) -> Self {
33616        push_header(self.as_rec_mut(), 9u16, 8 as u16);
33617        self.as_rec_mut().extend(value.to_ne_bytes());
33618        self
33619    }
33620    pub fn push_backlog_packets(mut self, value: u32) -> Self {
33621        push_header(self.as_rec_mut(), 10u16, 4 as u16);
33622        self.as_rec_mut().extend(value.to_ne_bytes());
33623        self
33624    }
33625    pub fn push_backlog_bytes(mut self, value: u32) -> Self {
33626        push_header(self.as_rec_mut(), 11u16, 4 as u16);
33627        self.as_rec_mut().extend(value.to_ne_bytes());
33628        self
33629    }
33630    pub fn push_threshold_rate64(mut self, value: u64) -> Self {
33631        push_header(self.as_rec_mut(), 12u16, 8 as u16);
33632        self.as_rec_mut().extend(value.to_ne_bytes());
33633        self
33634    }
33635    pub fn push_target_us(mut self, value: u32) -> Self {
33636        push_header(self.as_rec_mut(), 13u16, 4 as u16);
33637        self.as_rec_mut().extend(value.to_ne_bytes());
33638        self
33639    }
33640    pub fn push_interval_us(mut self, value: u32) -> Self {
33641        push_header(self.as_rec_mut(), 14u16, 4 as u16);
33642        self.as_rec_mut().extend(value.to_ne_bytes());
33643        self
33644    }
33645    pub fn push_way_indirect_hits(mut self, value: u32) -> Self {
33646        push_header(self.as_rec_mut(), 15u16, 4 as u16);
33647        self.as_rec_mut().extend(value.to_ne_bytes());
33648        self
33649    }
33650    pub fn push_way_misses(mut self, value: u32) -> Self {
33651        push_header(self.as_rec_mut(), 16u16, 4 as u16);
33652        self.as_rec_mut().extend(value.to_ne_bytes());
33653        self
33654    }
33655    pub fn push_way_collisions(mut self, value: u32) -> Self {
33656        push_header(self.as_rec_mut(), 17u16, 4 as u16);
33657        self.as_rec_mut().extend(value.to_ne_bytes());
33658        self
33659    }
33660    pub fn push_peak_delay_us(mut self, value: u32) -> Self {
33661        push_header(self.as_rec_mut(), 18u16, 4 as u16);
33662        self.as_rec_mut().extend(value.to_ne_bytes());
33663        self
33664    }
33665    pub fn push_avg_delay_us(mut self, value: u32) -> Self {
33666        push_header(self.as_rec_mut(), 19u16, 4 as u16);
33667        self.as_rec_mut().extend(value.to_ne_bytes());
33668        self
33669    }
33670    pub fn push_base_delay_us(mut self, value: u32) -> Self {
33671        push_header(self.as_rec_mut(), 20u16, 4 as u16);
33672        self.as_rec_mut().extend(value.to_ne_bytes());
33673        self
33674    }
33675    pub fn push_sparse_flows(mut self, value: u32) -> Self {
33676        push_header(self.as_rec_mut(), 21u16, 4 as u16);
33677        self.as_rec_mut().extend(value.to_ne_bytes());
33678        self
33679    }
33680    pub fn push_bulk_flows(mut self, value: u32) -> Self {
33681        push_header(self.as_rec_mut(), 22u16, 4 as u16);
33682        self.as_rec_mut().extend(value.to_ne_bytes());
33683        self
33684    }
33685    pub fn push_unresponsive_flows(mut self, value: u32) -> Self {
33686        push_header(self.as_rec_mut(), 23u16, 4 as u16);
33687        self.as_rec_mut().extend(value.to_ne_bytes());
33688        self
33689    }
33690    pub fn push_max_skblen(mut self, value: u32) -> Self {
33691        push_header(self.as_rec_mut(), 24u16, 4 as u16);
33692        self.as_rec_mut().extend(value.to_ne_bytes());
33693        self
33694    }
33695    pub fn push_flow_quantum(mut self, value: u32) -> Self {
33696        push_header(self.as_rec_mut(), 25u16, 4 as u16);
33697        self.as_rec_mut().extend(value.to_ne_bytes());
33698        self
33699    }
33700}
33701impl<Prev: Rec> Drop for PushCakeTinStatsAttrs<Prev> {
33702    fn drop(&mut self) {
33703        if let Some(prev) = &mut self.prev {
33704            if let Some(header_offset) = &self.header_offset {
33705                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33706            }
33707        }
33708    }
33709}
33710pub struct PushCbsAttrs<Prev: Rec> {
33711    pub(crate) prev: Option<Prev>,
33712    pub(crate) header_offset: Option<usize>,
33713}
33714impl<Prev: Rec> Rec for PushCbsAttrs<Prev> {
33715    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33716        self.prev.as_mut().unwrap().as_rec_mut()
33717    }
33718    fn as_rec(&self) -> &Vec<u8> {
33719        self.prev.as_ref().unwrap().as_rec()
33720    }
33721}
33722impl<Prev: Rec> PushCbsAttrs<Prev> {
33723    pub fn new(prev: Prev) -> Self {
33724        Self {
33725            prev: Some(prev),
33726            header_offset: None,
33727        }
33728    }
33729    pub fn end_nested(mut self) -> Prev {
33730        let mut prev = self.prev.take().unwrap();
33731        if let Some(header_offset) = &self.header_offset {
33732            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33733        }
33734        prev
33735    }
33736    pub fn push_parms(mut self, value: TcCbsQopt) -> Self {
33737        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
33738        self.as_rec_mut().extend(value.as_slice());
33739        self
33740    }
33741}
33742impl<Prev: Rec> Drop for PushCbsAttrs<Prev> {
33743    fn drop(&mut self) {
33744        if let Some(prev) = &mut self.prev {
33745            if let Some(header_offset) = &self.header_offset {
33746                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33747            }
33748        }
33749    }
33750}
33751pub struct PushCgroupAttrs<Prev: Rec> {
33752    pub(crate) prev: Option<Prev>,
33753    pub(crate) header_offset: Option<usize>,
33754}
33755impl<Prev: Rec> Rec for PushCgroupAttrs<Prev> {
33756    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33757        self.prev.as_mut().unwrap().as_rec_mut()
33758    }
33759    fn as_rec(&self) -> &Vec<u8> {
33760        self.prev.as_ref().unwrap().as_rec()
33761    }
33762}
33763impl<Prev: Rec> PushCgroupAttrs<Prev> {
33764    pub fn new(prev: Prev) -> Self {
33765        Self {
33766            prev: Some(prev),
33767            header_offset: None,
33768        }
33769    }
33770    pub fn end_nested(mut self) -> Prev {
33771        let mut prev = self.prev.take().unwrap();
33772        if let Some(header_offset) = &self.header_offset {
33773            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33774        }
33775        prev
33776    }
33777    pub fn array_act(mut self) -> PushArrayActAttrs<Self> {
33778        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
33779        PushArrayActAttrs {
33780            prev: Some(self),
33781            header_offset: Some(header_offset),
33782            counter: 0,
33783        }
33784    }
33785    pub fn nested_police(mut self) -> PushPoliceAttrs<Self> {
33786        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
33787        PushPoliceAttrs {
33788            prev: Some(self),
33789            header_offset: Some(header_offset),
33790        }
33791    }
33792    pub fn push_ematches(mut self, value: &[u8]) -> Self {
33793        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
33794        self.as_rec_mut().extend(value);
33795        self
33796    }
33797}
33798impl<Prev: Rec> Drop for PushCgroupAttrs<Prev> {
33799    fn drop(&mut self) {
33800        if let Some(prev) = &mut self.prev {
33801            if let Some(header_offset) = &self.header_offset {
33802                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33803            }
33804        }
33805    }
33806}
33807pub struct PushChokeAttrs<Prev: Rec> {
33808    pub(crate) prev: Option<Prev>,
33809    pub(crate) header_offset: Option<usize>,
33810}
33811impl<Prev: Rec> Rec for PushChokeAttrs<Prev> {
33812    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33813        self.prev.as_mut().unwrap().as_rec_mut()
33814    }
33815    fn as_rec(&self) -> &Vec<u8> {
33816        self.prev.as_ref().unwrap().as_rec()
33817    }
33818}
33819impl<Prev: Rec> PushChokeAttrs<Prev> {
33820    pub fn new(prev: Prev) -> Self {
33821        Self {
33822            prev: Some(prev),
33823            header_offset: None,
33824        }
33825    }
33826    pub fn end_nested(mut self) -> Prev {
33827        let mut prev = self.prev.take().unwrap();
33828        if let Some(header_offset) = &self.header_offset {
33829            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33830        }
33831        prev
33832    }
33833    pub fn push_parms(mut self, value: TcRedQopt) -> Self {
33834        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
33835        self.as_rec_mut().extend(value.as_slice());
33836        self
33837    }
33838    pub fn push_stab(mut self, value: &[u8]) -> Self {
33839        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
33840        self.as_rec_mut().extend(value);
33841        self
33842    }
33843    pub fn push_max_p(mut self, value: u32) -> Self {
33844        push_header(self.as_rec_mut(), 3u16, 4 as u16);
33845        self.as_rec_mut().extend(value.to_ne_bytes());
33846        self
33847    }
33848}
33849impl<Prev: Rec> Drop for PushChokeAttrs<Prev> {
33850    fn drop(&mut self) {
33851        if let Some(prev) = &mut self.prev {
33852            if let Some(header_offset) = &self.header_offset {
33853                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33854            }
33855        }
33856    }
33857}
33858pub struct PushCodelAttrs<Prev: Rec> {
33859    pub(crate) prev: Option<Prev>,
33860    pub(crate) header_offset: Option<usize>,
33861}
33862impl<Prev: Rec> Rec for PushCodelAttrs<Prev> {
33863    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33864        self.prev.as_mut().unwrap().as_rec_mut()
33865    }
33866    fn as_rec(&self) -> &Vec<u8> {
33867        self.prev.as_ref().unwrap().as_rec()
33868    }
33869}
33870impl<Prev: Rec> PushCodelAttrs<Prev> {
33871    pub fn new(prev: Prev) -> Self {
33872        Self {
33873            prev: Some(prev),
33874            header_offset: None,
33875        }
33876    }
33877    pub fn end_nested(mut self) -> Prev {
33878        let mut prev = self.prev.take().unwrap();
33879        if let Some(header_offset) = &self.header_offset {
33880            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33881        }
33882        prev
33883    }
33884    pub fn push_target(mut self, value: u32) -> Self {
33885        push_header(self.as_rec_mut(), 1u16, 4 as u16);
33886        self.as_rec_mut().extend(value.to_ne_bytes());
33887        self
33888    }
33889    pub fn push_limit(mut self, value: u32) -> Self {
33890        push_header(self.as_rec_mut(), 2u16, 4 as u16);
33891        self.as_rec_mut().extend(value.to_ne_bytes());
33892        self
33893    }
33894    pub fn push_interval(mut self, value: u32) -> Self {
33895        push_header(self.as_rec_mut(), 3u16, 4 as u16);
33896        self.as_rec_mut().extend(value.to_ne_bytes());
33897        self
33898    }
33899    pub fn push_ecn(mut self, value: u32) -> Self {
33900        push_header(self.as_rec_mut(), 4u16, 4 as u16);
33901        self.as_rec_mut().extend(value.to_ne_bytes());
33902        self
33903    }
33904    pub fn push_ce_threshold(mut self, value: u32) -> Self {
33905        push_header(self.as_rec_mut(), 5u16, 4 as u16);
33906        self.as_rec_mut().extend(value.to_ne_bytes());
33907        self
33908    }
33909}
33910impl<Prev: Rec> Drop for PushCodelAttrs<Prev> {
33911    fn drop(&mut self) {
33912        if let Some(prev) = &mut self.prev {
33913            if let Some(header_offset) = &self.header_offset {
33914                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33915            }
33916        }
33917    }
33918}
33919pub struct PushDrrAttrs<Prev: Rec> {
33920    pub(crate) prev: Option<Prev>,
33921    pub(crate) header_offset: Option<usize>,
33922}
33923impl<Prev: Rec> Rec for PushDrrAttrs<Prev> {
33924    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33925        self.prev.as_mut().unwrap().as_rec_mut()
33926    }
33927    fn as_rec(&self) -> &Vec<u8> {
33928        self.prev.as_ref().unwrap().as_rec()
33929    }
33930}
33931impl<Prev: Rec> PushDrrAttrs<Prev> {
33932    pub fn new(prev: Prev) -> Self {
33933        Self {
33934            prev: Some(prev),
33935            header_offset: None,
33936        }
33937    }
33938    pub fn end_nested(mut self) -> Prev {
33939        let mut prev = self.prev.take().unwrap();
33940        if let Some(header_offset) = &self.header_offset {
33941            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33942        }
33943        prev
33944    }
33945    pub fn push_quantum(mut self, value: u32) -> Self {
33946        push_header(self.as_rec_mut(), 1u16, 4 as u16);
33947        self.as_rec_mut().extend(value.to_ne_bytes());
33948        self
33949    }
33950}
33951impl<Prev: Rec> Drop for PushDrrAttrs<Prev> {
33952    fn drop(&mut self) {
33953        if let Some(prev) = &mut self.prev {
33954            if let Some(header_offset) = &self.header_offset {
33955                finalize_nested_header(prev.as_rec_mut(), *header_offset);
33956            }
33957        }
33958    }
33959}
33960pub struct PushDualpi2Attrs<Prev: Rec> {
33961    pub(crate) prev: Option<Prev>,
33962    pub(crate) header_offset: Option<usize>,
33963}
33964impl<Prev: Rec> Rec for PushDualpi2Attrs<Prev> {
33965    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
33966        self.prev.as_mut().unwrap().as_rec_mut()
33967    }
33968    fn as_rec(&self) -> &Vec<u8> {
33969        self.prev.as_ref().unwrap().as_rec()
33970    }
33971}
33972impl<Prev: Rec> PushDualpi2Attrs<Prev> {
33973    pub fn new(prev: Prev) -> Self {
33974        Self {
33975            prev: Some(prev),
33976            header_offset: None,
33977        }
33978    }
33979    pub fn end_nested(mut self) -> Prev {
33980        let mut prev = self.prev.take().unwrap();
33981        if let Some(header_offset) = &self.header_offset {
33982            finalize_nested_header(prev.as_rec_mut(), *header_offset);
33983        }
33984        prev
33985    }
33986    #[doc = "Limit of total number of packets in queue"]
33987    pub fn push_limit(mut self, value: u32) -> Self {
33988        push_header(self.as_rec_mut(), 1u16, 4 as u16);
33989        self.as_rec_mut().extend(value.to_ne_bytes());
33990        self
33991    }
33992    #[doc = "Memory limit of total number of packets in queue"]
33993    pub fn push_memory_limit(mut self, value: u32) -> Self {
33994        push_header(self.as_rec_mut(), 2u16, 4 as u16);
33995        self.as_rec_mut().extend(value.to_ne_bytes());
33996        self
33997    }
33998    #[doc = "Classic target delay in microseconds"]
33999    pub fn push_target(mut self, value: u32) -> Self {
34000        push_header(self.as_rec_mut(), 3u16, 4 as u16);
34001        self.as_rec_mut().extend(value.to_ne_bytes());
34002        self
34003    }
34004    #[doc = "Drop probability update interval time in microseconds"]
34005    pub fn push_tupdate(mut self, value: u32) -> Self {
34006        push_header(self.as_rec_mut(), 4u16, 4 as u16);
34007        self.as_rec_mut().extend(value.to_ne_bytes());
34008        self
34009    }
34010    #[doc = "Integral gain factor in Hz for PI controller"]
34011    pub fn push_alpha(mut self, value: u32) -> Self {
34012        push_header(self.as_rec_mut(), 5u16, 4 as u16);
34013        self.as_rec_mut().extend(value.to_ne_bytes());
34014        self
34015    }
34016    #[doc = "Proportional gain factor in Hz for PI controller"]
34017    pub fn push_beta(mut self, value: u32) -> Self {
34018        push_header(self.as_rec_mut(), 6u16, 4 as u16);
34019        self.as_rec_mut().extend(value.to_ne_bytes());
34020        self
34021    }
34022    #[doc = "L4S step marking threshold in packets"]
34023    pub fn push_step_thresh_pkts(mut self, value: u32) -> Self {
34024        push_header(self.as_rec_mut(), 7u16, 4 as u16);
34025        self.as_rec_mut().extend(value.to_ne_bytes());
34026        self
34027    }
34028    #[doc = "L4S Step marking threshold in microseconds"]
34029    pub fn push_step_thresh_us(mut self, value: u32) -> Self {
34030        push_header(self.as_rec_mut(), 8u16, 4 as u16);
34031        self.as_rec_mut().extend(value.to_ne_bytes());
34032        self
34033    }
34034    #[doc = "Packets enqueued to the L\\-queue can apply the step threshold when the queue length of L\\-queue is larger than this value\\. (0 is recommended)"]
34035    pub fn push_min_qlen_step(mut self, value: u32) -> Self {
34036        push_header(self.as_rec_mut(), 9u16, 4 as u16);
34037        self.as_rec_mut().extend(value.to_ne_bytes());
34038        self
34039    }
34040    #[doc = "Probability coupling factor between Classic and L4S (2 is recommended)"]
34041    pub fn push_coupling(mut self, value: u8) -> Self {
34042        push_header(self.as_rec_mut(), 10u16, 1 as u16);
34043        self.as_rec_mut().extend(value.to_ne_bytes());
34044        self
34045    }
34046    #[doc = "Control the overload strategy (drop to preserve latency or let the queue overflow)\nAssociated type: [`Dualpi2DropOverload`] (enum)"]
34047    pub fn push_drop_overload(mut self, value: u8) -> Self {
34048        push_header(self.as_rec_mut(), 11u16, 1 as u16);
34049        self.as_rec_mut().extend(value.to_ne_bytes());
34050        self
34051    }
34052    #[doc = "Decide where the Classic packets are PI\\-based dropped or marked\nAssociated type: [`Dualpi2DropEarly`] (enum)"]
34053    pub fn push_drop_early(mut self, value: u8) -> Self {
34054        push_header(self.as_rec_mut(), 12u16, 1 as u16);
34055        self.as_rec_mut().extend(value.to_ne_bytes());
34056        self
34057    }
34058    #[doc = "Classic WRR weight in percentage (from 0 to 100)"]
34059    pub fn push_c_protection(mut self, value: u8) -> Self {
34060        push_header(self.as_rec_mut(), 13u16, 1 as u16);
34061        self.as_rec_mut().extend(value.to_ne_bytes());
34062        self
34063    }
34064    #[doc = "Configure the L\\-queue ECN classifier\nAssociated type: [`Dualpi2EcnMask`] (enum)"]
34065    pub fn push_ecn_mask(mut self, value: u8) -> Self {
34066        push_header(self.as_rec_mut(), 14u16, 1 as u16);
34067        self.as_rec_mut().extend(value.to_ne_bytes());
34068        self
34069    }
34070    #[doc = "Split aggregated skb or not\nAssociated type: [`Dualpi2SplitGso`] (enum)"]
34071    pub fn push_split_gso(mut self, value: u8) -> Self {
34072        push_header(self.as_rec_mut(), 15u16, 1 as u16);
34073        self.as_rec_mut().extend(value.to_ne_bytes());
34074        self
34075    }
34076}
34077impl<Prev: Rec> Drop for PushDualpi2Attrs<Prev> {
34078    fn drop(&mut self) {
34079        if let Some(prev) = &mut self.prev {
34080            if let Some(header_offset) = &self.header_offset {
34081                finalize_nested_header(prev.as_rec_mut(), *header_offset);
34082            }
34083        }
34084    }
34085}
34086pub struct PushEmatchAttrs<Prev: Rec> {
34087    pub(crate) prev: Option<Prev>,
34088    pub(crate) header_offset: Option<usize>,
34089}
34090impl<Prev: Rec> Rec for PushEmatchAttrs<Prev> {
34091    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
34092        self.prev.as_mut().unwrap().as_rec_mut()
34093    }
34094    fn as_rec(&self) -> &Vec<u8> {
34095        self.prev.as_ref().unwrap().as_rec()
34096    }
34097}
34098impl<Prev: Rec> PushEmatchAttrs<Prev> {
34099    pub fn new(prev: Prev) -> Self {
34100        Self {
34101            prev: Some(prev),
34102            header_offset: None,
34103        }
34104    }
34105    pub fn end_nested(mut self) -> Prev {
34106        let mut prev = self.prev.take().unwrap();
34107        if let Some(header_offset) = &self.header_offset {
34108            finalize_nested_header(prev.as_rec_mut(), *header_offset);
34109        }
34110        prev
34111    }
34112    pub fn push_tree_hdr(mut self, value: TcfEmatchTreeHdr) -> Self {
34113        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
34114        self.as_rec_mut().extend(value.as_slice());
34115        self
34116    }
34117    pub fn push_tree_list(mut self, value: &[u8]) -> Self {
34118        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
34119        self.as_rec_mut().extend(value);
34120        self
34121    }
34122}
34123impl<Prev: Rec> Drop for PushEmatchAttrs<Prev> {
34124    fn drop(&mut self) {
34125        if let Some(prev) = &mut self.prev {
34126            if let Some(header_offset) = &self.header_offset {
34127                finalize_nested_header(prev.as_rec_mut(), *header_offset);
34128            }
34129        }
34130    }
34131}
34132pub struct PushFlowAttrs<Prev: Rec> {
34133    pub(crate) prev: Option<Prev>,
34134    pub(crate) header_offset: Option<usize>,
34135}
34136impl<Prev: Rec> Rec for PushFlowAttrs<Prev> {
34137    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
34138        self.prev.as_mut().unwrap().as_rec_mut()
34139    }
34140    fn as_rec(&self) -> &Vec<u8> {
34141        self.prev.as_ref().unwrap().as_rec()
34142    }
34143}
34144impl<Prev: Rec> PushFlowAttrs<Prev> {
34145    pub fn new(prev: Prev) -> Self {
34146        Self {
34147            prev: Some(prev),
34148            header_offset: None,
34149        }
34150    }
34151    pub fn end_nested(mut self) -> Prev {
34152        let mut prev = self.prev.take().unwrap();
34153        if let Some(header_offset) = &self.header_offset {
34154            finalize_nested_header(prev.as_rec_mut(), *header_offset);
34155        }
34156        prev
34157    }
34158    pub fn push_keys(mut self, value: u32) -> Self {
34159        push_header(self.as_rec_mut(), 1u16, 4 as u16);
34160        self.as_rec_mut().extend(value.to_ne_bytes());
34161        self
34162    }
34163    pub fn push_mode(mut self, value: u32) -> Self {
34164        push_header(self.as_rec_mut(), 2u16, 4 as u16);
34165        self.as_rec_mut().extend(value.to_ne_bytes());
34166        self
34167    }
34168    pub fn push_baseclass(mut self, value: u32) -> Self {
34169        push_header(self.as_rec_mut(), 3u16, 4 as u16);
34170        self.as_rec_mut().extend(value.to_ne_bytes());
34171        self
34172    }
34173    pub fn push_rshift(mut self, value: u32) -> Self {
34174        push_header(self.as_rec_mut(), 4u16, 4 as u16);
34175        self.as_rec_mut().extend(value.to_ne_bytes());
34176        self
34177    }
34178    pub fn push_addend(mut self, value: u32) -> Self {
34179        push_header(self.as_rec_mut(), 5u16, 4 as u16);
34180        self.as_rec_mut().extend(value.to_ne_bytes());
34181        self
34182    }
34183    pub fn push_mask(mut self, value: u32) -> Self {
34184        push_header(self.as_rec_mut(), 6u16, 4 as u16);
34185        self.as_rec_mut().extend(value.to_ne_bytes());
34186        self
34187    }
34188    pub fn push_xor(mut self, value: u32) -> Self {
34189        push_header(self.as_rec_mut(), 7u16, 4 as u16);
34190        self.as_rec_mut().extend(value.to_ne_bytes());
34191        self
34192    }
34193    pub fn push_divisor(mut self, value: u32) -> Self {
34194        push_header(self.as_rec_mut(), 8u16, 4 as u16);
34195        self.as_rec_mut().extend(value.to_ne_bytes());
34196        self
34197    }
34198    pub fn push_act(mut self, value: &[u8]) -> Self {
34199        push_header(self.as_rec_mut(), 9u16, value.len() as u16);
34200        self.as_rec_mut().extend(value);
34201        self
34202    }
34203    pub fn nested_police(mut self) -> PushPoliceAttrs<Self> {
34204        let header_offset = push_nested_header(self.as_rec_mut(), 10u16);
34205        PushPoliceAttrs {
34206            prev: Some(self),
34207            header_offset: Some(header_offset),
34208        }
34209    }
34210    pub fn push_ematches(mut self, value: &[u8]) -> Self {
34211        push_header(self.as_rec_mut(), 11u16, value.len() as u16);
34212        self.as_rec_mut().extend(value);
34213        self
34214    }
34215    pub fn push_perturb(mut self, value: u32) -> Self {
34216        push_header(self.as_rec_mut(), 12u16, 4 as u16);
34217        self.as_rec_mut().extend(value.to_ne_bytes());
34218        self
34219    }
34220}
34221impl<Prev: Rec> Drop for PushFlowAttrs<Prev> {
34222    fn drop(&mut self) {
34223        if let Some(prev) = &mut self.prev {
34224            if let Some(header_offset) = &self.header_offset {
34225                finalize_nested_header(prev.as_rec_mut(), *header_offset);
34226            }
34227        }
34228    }
34229}
34230pub struct PushFlowerAttrs<Prev: Rec> {
34231    pub(crate) prev: Option<Prev>,
34232    pub(crate) header_offset: Option<usize>,
34233}
34234impl<Prev: Rec> Rec for PushFlowerAttrs<Prev> {
34235    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
34236        self.prev.as_mut().unwrap().as_rec_mut()
34237    }
34238    fn as_rec(&self) -> &Vec<u8> {
34239        self.prev.as_ref().unwrap().as_rec()
34240    }
34241}
34242impl<Prev: Rec> PushFlowerAttrs<Prev> {
34243    pub fn new(prev: Prev) -> Self {
34244        Self {
34245            prev: Some(prev),
34246            header_offset: None,
34247        }
34248    }
34249    pub fn end_nested(mut self) -> Prev {
34250        let mut prev = self.prev.take().unwrap();
34251        if let Some(header_offset) = &self.header_offset {
34252            finalize_nested_header(prev.as_rec_mut(), *header_offset);
34253        }
34254        prev
34255    }
34256    pub fn push_classid(mut self, value: u32) -> Self {
34257        push_header(self.as_rec_mut(), 1u16, 4 as u16);
34258        self.as_rec_mut().extend(value.to_ne_bytes());
34259        self
34260    }
34261    pub fn push_indev(mut self, value: &CStr) -> Self {
34262        push_header(
34263            self.as_rec_mut(),
34264            2u16,
34265            value.to_bytes_with_nul().len() as u16,
34266        );
34267        self.as_rec_mut().extend(value.to_bytes_with_nul());
34268        self
34269    }
34270    pub fn push_indev_bytes(mut self, value: &[u8]) -> Self {
34271        push_header(self.as_rec_mut(), 2u16, (value.len() + 1) as u16);
34272        self.as_rec_mut().extend(value);
34273        self.as_rec_mut().push(0);
34274        self
34275    }
34276    pub fn array_act(mut self) -> PushArrayActAttrs<Self> {
34277        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
34278        PushArrayActAttrs {
34279            prev: Some(self),
34280            header_offset: Some(header_offset),
34281            counter: 0,
34282        }
34283    }
34284    pub fn push_key_eth_dst(mut self, value: &[u8]) -> Self {
34285        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
34286        self.as_rec_mut().extend(value);
34287        self
34288    }
34289    pub fn push_key_eth_dst_mask(mut self, value: &[u8]) -> Self {
34290        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
34291        self.as_rec_mut().extend(value);
34292        self
34293    }
34294    pub fn push_key_eth_src(mut self, value: &[u8]) -> Self {
34295        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
34296        self.as_rec_mut().extend(value);
34297        self
34298    }
34299    pub fn push_key_eth_src_mask(mut self, value: &[u8]) -> Self {
34300        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
34301        self.as_rec_mut().extend(value);
34302        self
34303    }
34304    pub fn push_key_eth_type(mut self, value: u16) -> Self {
34305        push_header(self.as_rec_mut(), 8u16, 2 as u16);
34306        self.as_rec_mut().extend(value.to_be_bytes());
34307        self
34308    }
34309    pub fn push_key_ip_proto(mut self, value: u8) -> Self {
34310        push_header(self.as_rec_mut(), 9u16, 1 as u16);
34311        self.as_rec_mut().extend(value.to_ne_bytes());
34312        self
34313    }
34314    pub fn push_key_ipv4_src(mut self, value: std::net::Ipv4Addr) -> Self {
34315        push_header(self.as_rec_mut(), 10u16, 4 as u16);
34316        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
34317        self
34318    }
34319    pub fn push_key_ipv4_src_mask(mut self, value: std::net::Ipv4Addr) -> Self {
34320        push_header(self.as_rec_mut(), 11u16, 4 as u16);
34321        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
34322        self
34323    }
34324    pub fn push_key_ipv4_dst(mut self, value: std::net::Ipv4Addr) -> Self {
34325        push_header(self.as_rec_mut(), 12u16, 4 as u16);
34326        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
34327        self
34328    }
34329    pub fn push_key_ipv4_dst_mask(mut self, value: std::net::Ipv4Addr) -> Self {
34330        push_header(self.as_rec_mut(), 13u16, 4 as u16);
34331        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
34332        self
34333    }
34334    pub fn push_key_ipv6_src(mut self, value: &[u8]) -> Self {
34335        push_header(self.as_rec_mut(), 14u16, value.len() as u16);
34336        self.as_rec_mut().extend(value);
34337        self
34338    }
34339    pub fn push_key_ipv6_src_mask(mut self, value: &[u8]) -> Self {
34340        push_header(self.as_rec_mut(), 15u16, value.len() as u16);
34341        self.as_rec_mut().extend(value);
34342        self
34343    }
34344    pub fn push_key_ipv6_dst(mut self, value: &[u8]) -> Self {
34345        push_header(self.as_rec_mut(), 16u16, value.len() as u16);
34346        self.as_rec_mut().extend(value);
34347        self
34348    }
34349    pub fn push_key_ipv6_dst_mask(mut self, value: &[u8]) -> Self {
34350        push_header(self.as_rec_mut(), 17u16, value.len() as u16);
34351        self.as_rec_mut().extend(value);
34352        self
34353    }
34354    pub fn push_key_tcp_src(mut self, value: u16) -> Self {
34355        push_header(self.as_rec_mut(), 18u16, 2 as u16);
34356        self.as_rec_mut().extend(value.to_be_bytes());
34357        self
34358    }
34359    pub fn push_key_tcp_dst(mut self, value: u16) -> Self {
34360        push_header(self.as_rec_mut(), 19u16, 2 as u16);
34361        self.as_rec_mut().extend(value.to_be_bytes());
34362        self
34363    }
34364    pub fn push_key_udp_src(mut self, value: u16) -> Self {
34365        push_header(self.as_rec_mut(), 20u16, 2 as u16);
34366        self.as_rec_mut().extend(value.to_be_bytes());
34367        self
34368    }
34369    pub fn push_key_udp_dst(mut self, value: u16) -> Self {
34370        push_header(self.as_rec_mut(), 21u16, 2 as u16);
34371        self.as_rec_mut().extend(value.to_be_bytes());
34372        self
34373    }
34374    #[doc = "Associated type: [`ClsFlags`] (1 bit per enumeration)"]
34375    pub fn push_flags(mut self, value: u32) -> Self {
34376        push_header(self.as_rec_mut(), 22u16, 4 as u16);
34377        self.as_rec_mut().extend(value.to_ne_bytes());
34378        self
34379    }
34380    pub fn push_key_vlan_id(mut self, value: u16) -> Self {
34381        push_header(self.as_rec_mut(), 23u16, 2 as u16);
34382        self.as_rec_mut().extend(value.to_be_bytes());
34383        self
34384    }
34385    pub fn push_key_vlan_prio(mut self, value: u8) -> Self {
34386        push_header(self.as_rec_mut(), 24u16, 1 as u16);
34387        self.as_rec_mut().extend(value.to_ne_bytes());
34388        self
34389    }
34390    pub fn push_key_vlan_eth_type(mut self, value: u16) -> Self {
34391        push_header(self.as_rec_mut(), 25u16, 2 as u16);
34392        self.as_rec_mut().extend(value.to_be_bytes());
34393        self
34394    }
34395    pub fn push_key_enc_key_id(mut self, value: u32) -> Self {
34396        push_header(self.as_rec_mut(), 26u16, 4 as u16);
34397        self.as_rec_mut().extend(value.to_be_bytes());
34398        self
34399    }
34400    pub fn push_key_enc_ipv4_src(mut self, value: std::net::Ipv4Addr) -> Self {
34401        push_header(self.as_rec_mut(), 27u16, 4 as u16);
34402        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
34403        self
34404    }
34405    pub fn push_key_enc_ipv4_src_mask(mut self, value: std::net::Ipv4Addr) -> Self {
34406        push_header(self.as_rec_mut(), 28u16, 4 as u16);
34407        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
34408        self
34409    }
34410    pub fn push_key_enc_ipv4_dst(mut self, value: std::net::Ipv4Addr) -> Self {
34411        push_header(self.as_rec_mut(), 29u16, 4 as u16);
34412        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
34413        self
34414    }
34415    pub fn push_key_enc_ipv4_dst_mask(mut self, value: std::net::Ipv4Addr) -> Self {
34416        push_header(self.as_rec_mut(), 30u16, 4 as u16);
34417        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
34418        self
34419    }
34420    pub fn push_key_enc_ipv6_src(mut self, value: &[u8]) -> Self {
34421        push_header(self.as_rec_mut(), 31u16, value.len() as u16);
34422        self.as_rec_mut().extend(value);
34423        self
34424    }
34425    pub fn push_key_enc_ipv6_src_mask(mut self, value: &[u8]) -> Self {
34426        push_header(self.as_rec_mut(), 32u16, value.len() as u16);
34427        self.as_rec_mut().extend(value);
34428        self
34429    }
34430    pub fn push_key_enc_ipv6_dst(mut self, value: &[u8]) -> Self {
34431        push_header(self.as_rec_mut(), 33u16, value.len() as u16);
34432        self.as_rec_mut().extend(value);
34433        self
34434    }
34435    pub fn push_key_enc_ipv6_dst_mask(mut self, value: &[u8]) -> Self {
34436        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
34437        self.as_rec_mut().extend(value);
34438        self
34439    }
34440    pub fn push_key_tcp_src_mask(mut self, value: u16) -> Self {
34441        push_header(self.as_rec_mut(), 35u16, 2 as u16);
34442        self.as_rec_mut().extend(value.to_be_bytes());
34443        self
34444    }
34445    pub fn push_key_tcp_dst_mask(mut self, value: u16) -> Self {
34446        push_header(self.as_rec_mut(), 36u16, 2 as u16);
34447        self.as_rec_mut().extend(value.to_be_bytes());
34448        self
34449    }
34450    pub fn push_key_udp_src_mask(mut self, value: u16) -> Self {
34451        push_header(self.as_rec_mut(), 37u16, 2 as u16);
34452        self.as_rec_mut().extend(value.to_be_bytes());
34453        self
34454    }
34455    pub fn push_key_udp_dst_mask(mut self, value: u16) -> Self {
34456        push_header(self.as_rec_mut(), 38u16, 2 as u16);
34457        self.as_rec_mut().extend(value.to_be_bytes());
34458        self
34459    }
34460    pub fn push_key_sctp_src_mask(mut self, value: u16) -> Self {
34461        push_header(self.as_rec_mut(), 39u16, 2 as u16);
34462        self.as_rec_mut().extend(value.to_be_bytes());
34463        self
34464    }
34465    pub fn push_key_sctp_dst_mask(mut self, value: u16) -> Self {
34466        push_header(self.as_rec_mut(), 40u16, 2 as u16);
34467        self.as_rec_mut().extend(value.to_be_bytes());
34468        self
34469    }
34470    pub fn push_key_sctp_src(mut self, value: u16) -> Self {
34471        push_header(self.as_rec_mut(), 41u16, 2 as u16);
34472        self.as_rec_mut().extend(value.to_be_bytes());
34473        self
34474    }
34475    pub fn push_key_sctp_dst(mut self, value: u16) -> Self {
34476        push_header(self.as_rec_mut(), 42u16, 2 as u16);
34477        self.as_rec_mut().extend(value.to_be_bytes());
34478        self
34479    }
34480    pub fn push_key_enc_udp_src_port(mut self, value: u16) -> Self {
34481        push_header(self.as_rec_mut(), 43u16, 2 as u16);
34482        self.as_rec_mut().extend(value.to_be_bytes());
34483        self
34484    }
34485    pub fn push_key_enc_udp_src_port_mask(mut self, value: u16) -> Self {
34486        push_header(self.as_rec_mut(), 44u16, 2 as u16);
34487        self.as_rec_mut().extend(value.to_be_bytes());
34488        self
34489    }
34490    pub fn push_key_enc_udp_dst_port(mut self, value: u16) -> Self {
34491        push_header(self.as_rec_mut(), 45u16, 2 as u16);
34492        self.as_rec_mut().extend(value.to_be_bytes());
34493        self
34494    }
34495    pub fn push_key_enc_udp_dst_port_mask(mut self, value: u16) -> Self {
34496        push_header(self.as_rec_mut(), 46u16, 2 as u16);
34497        self.as_rec_mut().extend(value.to_be_bytes());
34498        self
34499    }
34500    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
34501    pub fn push_key_flags(mut self, value: u32) -> Self {
34502        push_header(self.as_rec_mut(), 47u16, 4 as u16);
34503        self.as_rec_mut().extend(value.to_be_bytes());
34504        self
34505    }
34506    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
34507    pub fn push_key_flags_mask(mut self, value: u32) -> Self {
34508        push_header(self.as_rec_mut(), 48u16, 4 as u16);
34509        self.as_rec_mut().extend(value.to_be_bytes());
34510        self
34511    }
34512    pub fn push_key_icmpv4_code(mut self, value: u8) -> Self {
34513        push_header(self.as_rec_mut(), 49u16, 1 as u16);
34514        self.as_rec_mut().extend(value.to_ne_bytes());
34515        self
34516    }
34517    pub fn push_key_icmpv4_code_mask(mut self, value: u8) -> Self {
34518        push_header(self.as_rec_mut(), 50u16, 1 as u16);
34519        self.as_rec_mut().extend(value.to_ne_bytes());
34520        self
34521    }
34522    pub fn push_key_icmpv4_type(mut self, value: u8) -> Self {
34523        push_header(self.as_rec_mut(), 51u16, 1 as u16);
34524        self.as_rec_mut().extend(value.to_ne_bytes());
34525        self
34526    }
34527    pub fn push_key_icmpv4_type_mask(mut self, value: u8) -> Self {
34528        push_header(self.as_rec_mut(), 52u16, 1 as u16);
34529        self.as_rec_mut().extend(value.to_ne_bytes());
34530        self
34531    }
34532    pub fn push_key_icmpv6_code(mut self, value: u8) -> Self {
34533        push_header(self.as_rec_mut(), 53u16, 1 as u16);
34534        self.as_rec_mut().extend(value.to_ne_bytes());
34535        self
34536    }
34537    pub fn push_key_icmpv6_code_mask(mut self, value: u8) -> Self {
34538        push_header(self.as_rec_mut(), 54u16, 1 as u16);
34539        self.as_rec_mut().extend(value.to_ne_bytes());
34540        self
34541    }
34542    pub fn push_key_icmpv6_type(mut self, value: u8) -> Self {
34543        push_header(self.as_rec_mut(), 55u16, 1 as u16);
34544        self.as_rec_mut().extend(value.to_ne_bytes());
34545        self
34546    }
34547    pub fn push_key_icmpv6_type_mask(mut self, value: u8) -> Self {
34548        push_header(self.as_rec_mut(), 56u16, 1 as u16);
34549        self.as_rec_mut().extend(value.to_ne_bytes());
34550        self
34551    }
34552    pub fn push_key_arp_sip(mut self, value: u32) -> Self {
34553        push_header(self.as_rec_mut(), 57u16, 4 as u16);
34554        self.as_rec_mut().extend(value.to_be_bytes());
34555        self
34556    }
34557    pub fn push_key_arp_sip_mask(mut self, value: u32) -> Self {
34558        push_header(self.as_rec_mut(), 58u16, 4 as u16);
34559        self.as_rec_mut().extend(value.to_be_bytes());
34560        self
34561    }
34562    pub fn push_key_arp_tip(mut self, value: u32) -> Self {
34563        push_header(self.as_rec_mut(), 59u16, 4 as u16);
34564        self.as_rec_mut().extend(value.to_be_bytes());
34565        self
34566    }
34567    pub fn push_key_arp_tip_mask(mut self, value: u32) -> Self {
34568        push_header(self.as_rec_mut(), 60u16, 4 as u16);
34569        self.as_rec_mut().extend(value.to_be_bytes());
34570        self
34571    }
34572    pub fn push_key_arp_op(mut self, value: u8) -> Self {
34573        push_header(self.as_rec_mut(), 61u16, 1 as u16);
34574        self.as_rec_mut().extend(value.to_ne_bytes());
34575        self
34576    }
34577    pub fn push_key_arp_op_mask(mut self, value: u8) -> Self {
34578        push_header(self.as_rec_mut(), 62u16, 1 as u16);
34579        self.as_rec_mut().extend(value.to_ne_bytes());
34580        self
34581    }
34582    pub fn push_key_arp_sha(mut self, value: &[u8]) -> Self {
34583        push_header(self.as_rec_mut(), 63u16, value.len() as u16);
34584        self.as_rec_mut().extend(value);
34585        self
34586    }
34587    pub fn push_key_arp_sha_mask(mut self, value: &[u8]) -> Self {
34588        push_header(self.as_rec_mut(), 64u16, value.len() as u16);
34589        self.as_rec_mut().extend(value);
34590        self
34591    }
34592    pub fn push_key_arp_tha(mut self, value: &[u8]) -> Self {
34593        push_header(self.as_rec_mut(), 65u16, value.len() as u16);
34594        self.as_rec_mut().extend(value);
34595        self
34596    }
34597    pub fn push_key_arp_tha_mask(mut self, value: &[u8]) -> Self {
34598        push_header(self.as_rec_mut(), 66u16, value.len() as u16);
34599        self.as_rec_mut().extend(value);
34600        self
34601    }
34602    pub fn push_key_mpls_ttl(mut self, value: u8) -> Self {
34603        push_header(self.as_rec_mut(), 67u16, 1 as u16);
34604        self.as_rec_mut().extend(value.to_ne_bytes());
34605        self
34606    }
34607    pub fn push_key_mpls_bos(mut self, value: u8) -> Self {
34608        push_header(self.as_rec_mut(), 68u16, 1 as u16);
34609        self.as_rec_mut().extend(value.to_ne_bytes());
34610        self
34611    }
34612    pub fn push_key_mpls_tc(mut self, value: u8) -> Self {
34613        push_header(self.as_rec_mut(), 69u16, 1 as u16);
34614        self.as_rec_mut().extend(value.to_ne_bytes());
34615        self
34616    }
34617    pub fn push_key_mpls_label(mut self, value: u32) -> Self {
34618        push_header(self.as_rec_mut(), 70u16, 4 as u16);
34619        self.as_rec_mut().extend(value.to_be_bytes());
34620        self
34621    }
34622    pub fn push_key_tcp_flags(mut self, value: u16) -> Self {
34623        push_header(self.as_rec_mut(), 71u16, 2 as u16);
34624        self.as_rec_mut().extend(value.to_be_bytes());
34625        self
34626    }
34627    pub fn push_key_tcp_flags_mask(mut self, value: u16) -> Self {
34628        push_header(self.as_rec_mut(), 72u16, 2 as u16);
34629        self.as_rec_mut().extend(value.to_be_bytes());
34630        self
34631    }
34632    pub fn push_key_ip_tos(mut self, value: u8) -> Self {
34633        push_header(self.as_rec_mut(), 73u16, 1 as u16);
34634        self.as_rec_mut().extend(value.to_ne_bytes());
34635        self
34636    }
34637    pub fn push_key_ip_tos_mask(mut self, value: u8) -> Self {
34638        push_header(self.as_rec_mut(), 74u16, 1 as u16);
34639        self.as_rec_mut().extend(value.to_ne_bytes());
34640        self
34641    }
34642    pub fn push_key_ip_ttl(mut self, value: u8) -> Self {
34643        push_header(self.as_rec_mut(), 75u16, 1 as u16);
34644        self.as_rec_mut().extend(value.to_ne_bytes());
34645        self
34646    }
34647    pub fn push_key_ip_ttl_mask(mut self, value: u8) -> Self {
34648        push_header(self.as_rec_mut(), 76u16, 1 as u16);
34649        self.as_rec_mut().extend(value.to_ne_bytes());
34650        self
34651    }
34652    pub fn push_key_cvlan_id(mut self, value: u16) -> Self {
34653        push_header(self.as_rec_mut(), 77u16, 2 as u16);
34654        self.as_rec_mut().extend(value.to_be_bytes());
34655        self
34656    }
34657    pub fn push_key_cvlan_prio(mut self, value: u8) -> Self {
34658        push_header(self.as_rec_mut(), 78u16, 1 as u16);
34659        self.as_rec_mut().extend(value.to_ne_bytes());
34660        self
34661    }
34662    pub fn push_key_cvlan_eth_type(mut self, value: u16) -> Self {
34663        push_header(self.as_rec_mut(), 79u16, 2 as u16);
34664        self.as_rec_mut().extend(value.to_be_bytes());
34665        self
34666    }
34667    pub fn push_key_enc_ip_tos(mut self, value: u8) -> Self {
34668        push_header(self.as_rec_mut(), 80u16, 1 as u16);
34669        self.as_rec_mut().extend(value.to_ne_bytes());
34670        self
34671    }
34672    pub fn push_key_enc_ip_tos_mask(mut self, value: u8) -> Self {
34673        push_header(self.as_rec_mut(), 81u16, 1 as u16);
34674        self.as_rec_mut().extend(value.to_ne_bytes());
34675        self
34676    }
34677    pub fn push_key_enc_ip_ttl(mut self, value: u8) -> Self {
34678        push_header(self.as_rec_mut(), 82u16, 1 as u16);
34679        self.as_rec_mut().extend(value.to_ne_bytes());
34680        self
34681    }
34682    pub fn push_key_enc_ip_ttl_mask(mut self, value: u8) -> Self {
34683        push_header(self.as_rec_mut(), 83u16, 1 as u16);
34684        self.as_rec_mut().extend(value.to_ne_bytes());
34685        self
34686    }
34687    pub fn nested_key_enc_opts(mut self) -> PushFlowerKeyEncOptsAttrs<Self> {
34688        let header_offset = push_nested_header(self.as_rec_mut(), 84u16);
34689        PushFlowerKeyEncOptsAttrs {
34690            prev: Some(self),
34691            header_offset: Some(header_offset),
34692        }
34693    }
34694    pub fn nested_key_enc_opts_mask(mut self) -> PushFlowerKeyEncOptsAttrs<Self> {
34695        let header_offset = push_nested_header(self.as_rec_mut(), 85u16);
34696        PushFlowerKeyEncOptsAttrs {
34697            prev: Some(self),
34698            header_offset: Some(header_offset),
34699        }
34700    }
34701    pub fn push_in_hw_count(mut self, value: u32) -> Self {
34702        push_header(self.as_rec_mut(), 86u16, 4 as u16);
34703        self.as_rec_mut().extend(value.to_ne_bytes());
34704        self
34705    }
34706    pub fn push_key_port_src_min(mut self, value: u16) -> Self {
34707        push_header(self.as_rec_mut(), 87u16, 2 as u16);
34708        self.as_rec_mut().extend(value.to_be_bytes());
34709        self
34710    }
34711    pub fn push_key_port_src_max(mut self, value: u16) -> Self {
34712        push_header(self.as_rec_mut(), 88u16, 2 as u16);
34713        self.as_rec_mut().extend(value.to_be_bytes());
34714        self
34715    }
34716    pub fn push_key_port_dst_min(mut self, value: u16) -> Self {
34717        push_header(self.as_rec_mut(), 89u16, 2 as u16);
34718        self.as_rec_mut().extend(value.to_be_bytes());
34719        self
34720    }
34721    pub fn push_key_port_dst_max(mut self, value: u16) -> Self {
34722        push_header(self.as_rec_mut(), 90u16, 2 as u16);
34723        self.as_rec_mut().extend(value.to_be_bytes());
34724        self
34725    }
34726    pub fn push_key_ct_state(mut self, value: u16) -> Self {
34727        push_header(self.as_rec_mut(), 91u16, 2 as u16);
34728        self.as_rec_mut().extend(value.to_ne_bytes());
34729        self
34730    }
34731    pub fn push_key_ct_state_mask(mut self, value: u16) -> Self {
34732        push_header(self.as_rec_mut(), 92u16, 2 as u16);
34733        self.as_rec_mut().extend(value.to_ne_bytes());
34734        self
34735    }
34736    pub fn push_key_ct_zone(mut self, value: u16) -> Self {
34737        push_header(self.as_rec_mut(), 93u16, 2 as u16);
34738        self.as_rec_mut().extend(value.to_ne_bytes());
34739        self
34740    }
34741    pub fn push_key_ct_zone_mask(mut self, value: u16) -> Self {
34742        push_header(self.as_rec_mut(), 94u16, 2 as u16);
34743        self.as_rec_mut().extend(value.to_ne_bytes());
34744        self
34745    }
34746    pub fn push_key_ct_mark(mut self, value: u32) -> Self {
34747        push_header(self.as_rec_mut(), 95u16, 4 as u16);
34748        self.as_rec_mut().extend(value.to_ne_bytes());
34749        self
34750    }
34751    pub fn push_key_ct_mark_mask(mut self, value: u32) -> Self {
34752        push_header(self.as_rec_mut(), 96u16, 4 as u16);
34753        self.as_rec_mut().extend(value.to_ne_bytes());
34754        self
34755    }
34756    pub fn push_key_ct_labels(mut self, value: &[u8]) -> Self {
34757        push_header(self.as_rec_mut(), 97u16, value.len() as u16);
34758        self.as_rec_mut().extend(value);
34759        self
34760    }
34761    pub fn push_key_ct_labels_mask(mut self, value: &[u8]) -> Self {
34762        push_header(self.as_rec_mut(), 98u16, value.len() as u16);
34763        self.as_rec_mut().extend(value);
34764        self
34765    }
34766    pub fn nested_key_mpls_opts(mut self) -> PushFlowerKeyMplsOptAttrs<Self> {
34767        let header_offset = push_nested_header(self.as_rec_mut(), 99u16);
34768        PushFlowerKeyMplsOptAttrs {
34769            prev: Some(self),
34770            header_offset: Some(header_offset),
34771        }
34772    }
34773    pub fn push_key_hash(mut self, value: u32) -> Self {
34774        push_header(self.as_rec_mut(), 100u16, 4 as u16);
34775        self.as_rec_mut().extend(value.to_ne_bytes());
34776        self
34777    }
34778    pub fn push_key_hash_mask(mut self, value: u32) -> Self {
34779        push_header(self.as_rec_mut(), 101u16, 4 as u16);
34780        self.as_rec_mut().extend(value.to_ne_bytes());
34781        self
34782    }
34783    pub fn push_key_num_of_vlans(mut self, value: u8) -> Self {
34784        push_header(self.as_rec_mut(), 102u16, 1 as u16);
34785        self.as_rec_mut().extend(value.to_ne_bytes());
34786        self
34787    }
34788    pub fn push_key_pppoe_sid(mut self, value: u16) -> Self {
34789        push_header(self.as_rec_mut(), 103u16, 2 as u16);
34790        self.as_rec_mut().extend(value.to_be_bytes());
34791        self
34792    }
34793    pub fn push_key_ppp_proto(mut self, value: u16) -> Self {
34794        push_header(self.as_rec_mut(), 104u16, 2 as u16);
34795        self.as_rec_mut().extend(value.to_be_bytes());
34796        self
34797    }
34798    pub fn push_key_l2tpv3_sid(mut self, value: u32) -> Self {
34799        push_header(self.as_rec_mut(), 105u16, 4 as u16);
34800        self.as_rec_mut().extend(value.to_be_bytes());
34801        self
34802    }
34803    pub fn push_l2_miss(mut self, value: u8) -> Self {
34804        push_header(self.as_rec_mut(), 106u16, 1 as u16);
34805        self.as_rec_mut().extend(value.to_ne_bytes());
34806        self
34807    }
34808    pub fn nested_key_cfm(mut self) -> PushFlowerKeyCfmAttrs<Self> {
34809        let header_offset = push_nested_header(self.as_rec_mut(), 107u16);
34810        PushFlowerKeyCfmAttrs {
34811            prev: Some(self),
34812            header_offset: Some(header_offset),
34813        }
34814    }
34815    pub fn push_key_spi(mut self, value: u32) -> Self {
34816        push_header(self.as_rec_mut(), 108u16, 4 as u16);
34817        self.as_rec_mut().extend(value.to_be_bytes());
34818        self
34819    }
34820    pub fn push_key_spi_mask(mut self, value: u32) -> Self {
34821        push_header(self.as_rec_mut(), 109u16, 4 as u16);
34822        self.as_rec_mut().extend(value.to_be_bytes());
34823        self
34824    }
34825    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
34826    pub fn push_key_enc_flags(mut self, value: u32) -> Self {
34827        push_header(self.as_rec_mut(), 110u16, 4 as u16);
34828        self.as_rec_mut().extend(value.to_be_bytes());
34829        self
34830    }
34831    #[doc = "Associated type: [`FlowerKeyCtrlFlags`] (1 bit per enumeration)"]
34832    pub fn push_key_enc_flags_mask(mut self, value: u32) -> Self {
34833        push_header(self.as_rec_mut(), 111u16, 4 as u16);
34834        self.as_rec_mut().extend(value.to_be_bytes());
34835        self
34836    }
34837}
34838impl<Prev: Rec> Drop for PushFlowerAttrs<Prev> {
34839    fn drop(&mut self) {
34840        if let Some(prev) = &mut self.prev {
34841            if let Some(header_offset) = &self.header_offset {
34842                finalize_nested_header(prev.as_rec_mut(), *header_offset);
34843            }
34844        }
34845    }
34846}
34847pub struct PushFlowerKeyEncOptsAttrs<Prev: Rec> {
34848    pub(crate) prev: Option<Prev>,
34849    pub(crate) header_offset: Option<usize>,
34850}
34851impl<Prev: Rec> Rec for PushFlowerKeyEncOptsAttrs<Prev> {
34852    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
34853        self.prev.as_mut().unwrap().as_rec_mut()
34854    }
34855    fn as_rec(&self) -> &Vec<u8> {
34856        self.prev.as_ref().unwrap().as_rec()
34857    }
34858}
34859impl<Prev: Rec> PushFlowerKeyEncOptsAttrs<Prev> {
34860    pub fn new(prev: Prev) -> Self {
34861        Self {
34862            prev: Some(prev),
34863            header_offset: None,
34864        }
34865    }
34866    pub fn end_nested(mut self) -> Prev {
34867        let mut prev = self.prev.take().unwrap();
34868        if let Some(header_offset) = &self.header_offset {
34869            finalize_nested_header(prev.as_rec_mut(), *header_offset);
34870        }
34871        prev
34872    }
34873    pub fn nested_geneve(mut self) -> PushFlowerKeyEncOptGeneveAttrs<Self> {
34874        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
34875        PushFlowerKeyEncOptGeneveAttrs {
34876            prev: Some(self),
34877            header_offset: Some(header_offset),
34878        }
34879    }
34880    pub fn nested_vxlan(mut self) -> PushFlowerKeyEncOptVxlanAttrs<Self> {
34881        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
34882        PushFlowerKeyEncOptVxlanAttrs {
34883            prev: Some(self),
34884            header_offset: Some(header_offset),
34885        }
34886    }
34887    pub fn nested_erspan(mut self) -> PushFlowerKeyEncOptErspanAttrs<Self> {
34888        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
34889        PushFlowerKeyEncOptErspanAttrs {
34890            prev: Some(self),
34891            header_offset: Some(header_offset),
34892        }
34893    }
34894    pub fn nested_gtp(mut self) -> PushFlowerKeyEncOptGtpAttrs<Self> {
34895        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
34896        PushFlowerKeyEncOptGtpAttrs {
34897            prev: Some(self),
34898            header_offset: Some(header_offset),
34899        }
34900    }
34901}
34902impl<Prev: Rec> Drop for PushFlowerKeyEncOptsAttrs<Prev> {
34903    fn drop(&mut self) {
34904        if let Some(prev) = &mut self.prev {
34905            if let Some(header_offset) = &self.header_offset {
34906                finalize_nested_header(prev.as_rec_mut(), *header_offset);
34907            }
34908        }
34909    }
34910}
34911pub struct PushFlowerKeyEncOptGeneveAttrs<Prev: Rec> {
34912    pub(crate) prev: Option<Prev>,
34913    pub(crate) header_offset: Option<usize>,
34914}
34915impl<Prev: Rec> Rec for PushFlowerKeyEncOptGeneveAttrs<Prev> {
34916    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
34917        self.prev.as_mut().unwrap().as_rec_mut()
34918    }
34919    fn as_rec(&self) -> &Vec<u8> {
34920        self.prev.as_ref().unwrap().as_rec()
34921    }
34922}
34923impl<Prev: Rec> PushFlowerKeyEncOptGeneveAttrs<Prev> {
34924    pub fn new(prev: Prev) -> Self {
34925        Self {
34926            prev: Some(prev),
34927            header_offset: None,
34928        }
34929    }
34930    pub fn end_nested(mut self) -> Prev {
34931        let mut prev = self.prev.take().unwrap();
34932        if let Some(header_offset) = &self.header_offset {
34933            finalize_nested_header(prev.as_rec_mut(), *header_offset);
34934        }
34935        prev
34936    }
34937    pub fn push_class(mut self, value: u16) -> Self {
34938        push_header(self.as_rec_mut(), 1u16, 2 as u16);
34939        self.as_rec_mut().extend(value.to_ne_bytes());
34940        self
34941    }
34942    pub fn push_type(mut self, value: u8) -> Self {
34943        push_header(self.as_rec_mut(), 2u16, 1 as u16);
34944        self.as_rec_mut().extend(value.to_ne_bytes());
34945        self
34946    }
34947    pub fn push_data(mut self, value: &[u8]) -> Self {
34948        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
34949        self.as_rec_mut().extend(value);
34950        self
34951    }
34952}
34953impl<Prev: Rec> Drop for PushFlowerKeyEncOptGeneveAttrs<Prev> {
34954    fn drop(&mut self) {
34955        if let Some(prev) = &mut self.prev {
34956            if let Some(header_offset) = &self.header_offset {
34957                finalize_nested_header(prev.as_rec_mut(), *header_offset);
34958            }
34959        }
34960    }
34961}
34962pub struct PushFlowerKeyEncOptVxlanAttrs<Prev: Rec> {
34963    pub(crate) prev: Option<Prev>,
34964    pub(crate) header_offset: Option<usize>,
34965}
34966impl<Prev: Rec> Rec for PushFlowerKeyEncOptVxlanAttrs<Prev> {
34967    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
34968        self.prev.as_mut().unwrap().as_rec_mut()
34969    }
34970    fn as_rec(&self) -> &Vec<u8> {
34971        self.prev.as_ref().unwrap().as_rec()
34972    }
34973}
34974impl<Prev: Rec> PushFlowerKeyEncOptVxlanAttrs<Prev> {
34975    pub fn new(prev: Prev) -> Self {
34976        Self {
34977            prev: Some(prev),
34978            header_offset: None,
34979        }
34980    }
34981    pub fn end_nested(mut self) -> Prev {
34982        let mut prev = self.prev.take().unwrap();
34983        if let Some(header_offset) = &self.header_offset {
34984            finalize_nested_header(prev.as_rec_mut(), *header_offset);
34985        }
34986        prev
34987    }
34988    pub fn push_gbp(mut self, value: u32) -> Self {
34989        push_header(self.as_rec_mut(), 1u16, 4 as u16);
34990        self.as_rec_mut().extend(value.to_ne_bytes());
34991        self
34992    }
34993}
34994impl<Prev: Rec> Drop for PushFlowerKeyEncOptVxlanAttrs<Prev> {
34995    fn drop(&mut self) {
34996        if let Some(prev) = &mut self.prev {
34997            if let Some(header_offset) = &self.header_offset {
34998                finalize_nested_header(prev.as_rec_mut(), *header_offset);
34999            }
35000        }
35001    }
35002}
35003pub struct PushFlowerKeyEncOptErspanAttrs<Prev: Rec> {
35004    pub(crate) prev: Option<Prev>,
35005    pub(crate) header_offset: Option<usize>,
35006}
35007impl<Prev: Rec> Rec for PushFlowerKeyEncOptErspanAttrs<Prev> {
35008    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35009        self.prev.as_mut().unwrap().as_rec_mut()
35010    }
35011    fn as_rec(&self) -> &Vec<u8> {
35012        self.prev.as_ref().unwrap().as_rec()
35013    }
35014}
35015impl<Prev: Rec> PushFlowerKeyEncOptErspanAttrs<Prev> {
35016    pub fn new(prev: Prev) -> Self {
35017        Self {
35018            prev: Some(prev),
35019            header_offset: None,
35020        }
35021    }
35022    pub fn end_nested(mut self) -> Prev {
35023        let mut prev = self.prev.take().unwrap();
35024        if let Some(header_offset) = &self.header_offset {
35025            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35026        }
35027        prev
35028    }
35029    pub fn push_ver(mut self, value: u8) -> Self {
35030        push_header(self.as_rec_mut(), 1u16, 1 as u16);
35031        self.as_rec_mut().extend(value.to_ne_bytes());
35032        self
35033    }
35034    pub fn push_index(mut self, value: u32) -> Self {
35035        push_header(self.as_rec_mut(), 2u16, 4 as u16);
35036        self.as_rec_mut().extend(value.to_ne_bytes());
35037        self
35038    }
35039    pub fn push_dir(mut self, value: u8) -> Self {
35040        push_header(self.as_rec_mut(), 3u16, 1 as u16);
35041        self.as_rec_mut().extend(value.to_ne_bytes());
35042        self
35043    }
35044    pub fn push_hwid(mut self, value: u8) -> Self {
35045        push_header(self.as_rec_mut(), 4u16, 1 as u16);
35046        self.as_rec_mut().extend(value.to_ne_bytes());
35047        self
35048    }
35049}
35050impl<Prev: Rec> Drop for PushFlowerKeyEncOptErspanAttrs<Prev> {
35051    fn drop(&mut self) {
35052        if let Some(prev) = &mut self.prev {
35053            if let Some(header_offset) = &self.header_offset {
35054                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35055            }
35056        }
35057    }
35058}
35059pub struct PushFlowerKeyEncOptGtpAttrs<Prev: Rec> {
35060    pub(crate) prev: Option<Prev>,
35061    pub(crate) header_offset: Option<usize>,
35062}
35063impl<Prev: Rec> Rec for PushFlowerKeyEncOptGtpAttrs<Prev> {
35064    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35065        self.prev.as_mut().unwrap().as_rec_mut()
35066    }
35067    fn as_rec(&self) -> &Vec<u8> {
35068        self.prev.as_ref().unwrap().as_rec()
35069    }
35070}
35071impl<Prev: Rec> PushFlowerKeyEncOptGtpAttrs<Prev> {
35072    pub fn new(prev: Prev) -> Self {
35073        Self {
35074            prev: Some(prev),
35075            header_offset: None,
35076        }
35077    }
35078    pub fn end_nested(mut self) -> Prev {
35079        let mut prev = self.prev.take().unwrap();
35080        if let Some(header_offset) = &self.header_offset {
35081            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35082        }
35083        prev
35084    }
35085    pub fn push_pdu_type(mut self, value: u8) -> Self {
35086        push_header(self.as_rec_mut(), 1u16, 1 as u16);
35087        self.as_rec_mut().extend(value.to_ne_bytes());
35088        self
35089    }
35090    pub fn push_qfi(mut self, value: u8) -> Self {
35091        push_header(self.as_rec_mut(), 2u16, 1 as u16);
35092        self.as_rec_mut().extend(value.to_ne_bytes());
35093        self
35094    }
35095}
35096impl<Prev: Rec> Drop for PushFlowerKeyEncOptGtpAttrs<Prev> {
35097    fn drop(&mut self) {
35098        if let Some(prev) = &mut self.prev {
35099            if let Some(header_offset) = &self.header_offset {
35100                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35101            }
35102        }
35103    }
35104}
35105pub struct PushFlowerKeyMplsOptAttrs<Prev: Rec> {
35106    pub(crate) prev: Option<Prev>,
35107    pub(crate) header_offset: Option<usize>,
35108}
35109impl<Prev: Rec> Rec for PushFlowerKeyMplsOptAttrs<Prev> {
35110    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35111        self.prev.as_mut().unwrap().as_rec_mut()
35112    }
35113    fn as_rec(&self) -> &Vec<u8> {
35114        self.prev.as_ref().unwrap().as_rec()
35115    }
35116}
35117impl<Prev: Rec> PushFlowerKeyMplsOptAttrs<Prev> {
35118    pub fn new(prev: Prev) -> Self {
35119        Self {
35120            prev: Some(prev),
35121            header_offset: None,
35122        }
35123    }
35124    pub fn end_nested(mut self) -> Prev {
35125        let mut prev = self.prev.take().unwrap();
35126        if let Some(header_offset) = &self.header_offset {
35127            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35128        }
35129        prev
35130    }
35131    pub fn push_lse_depth(mut self, value: u8) -> Self {
35132        push_header(self.as_rec_mut(), 1u16, 1 as u16);
35133        self.as_rec_mut().extend(value.to_ne_bytes());
35134        self
35135    }
35136    pub fn push_lse_ttl(mut self, value: u8) -> Self {
35137        push_header(self.as_rec_mut(), 2u16, 1 as u16);
35138        self.as_rec_mut().extend(value.to_ne_bytes());
35139        self
35140    }
35141    pub fn push_lse_bos(mut self, value: u8) -> Self {
35142        push_header(self.as_rec_mut(), 3u16, 1 as u16);
35143        self.as_rec_mut().extend(value.to_ne_bytes());
35144        self
35145    }
35146    pub fn push_lse_tc(mut self, value: u8) -> Self {
35147        push_header(self.as_rec_mut(), 4u16, 1 as u16);
35148        self.as_rec_mut().extend(value.to_ne_bytes());
35149        self
35150    }
35151    pub fn push_lse_label(mut self, value: u32) -> Self {
35152        push_header(self.as_rec_mut(), 5u16, 4 as u16);
35153        self.as_rec_mut().extend(value.to_ne_bytes());
35154        self
35155    }
35156}
35157impl<Prev: Rec> Drop for PushFlowerKeyMplsOptAttrs<Prev> {
35158    fn drop(&mut self) {
35159        if let Some(prev) = &mut self.prev {
35160            if let Some(header_offset) = &self.header_offset {
35161                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35162            }
35163        }
35164    }
35165}
35166pub struct PushFlowerKeyCfmAttrs<Prev: Rec> {
35167    pub(crate) prev: Option<Prev>,
35168    pub(crate) header_offset: Option<usize>,
35169}
35170impl<Prev: Rec> Rec for PushFlowerKeyCfmAttrs<Prev> {
35171    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35172        self.prev.as_mut().unwrap().as_rec_mut()
35173    }
35174    fn as_rec(&self) -> &Vec<u8> {
35175        self.prev.as_ref().unwrap().as_rec()
35176    }
35177}
35178impl<Prev: Rec> PushFlowerKeyCfmAttrs<Prev> {
35179    pub fn new(prev: Prev) -> Self {
35180        Self {
35181            prev: Some(prev),
35182            header_offset: None,
35183        }
35184    }
35185    pub fn end_nested(mut self) -> Prev {
35186        let mut prev = self.prev.take().unwrap();
35187        if let Some(header_offset) = &self.header_offset {
35188            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35189        }
35190        prev
35191    }
35192    pub fn push_md_level(mut self, value: u8) -> Self {
35193        push_header(self.as_rec_mut(), 1u16, 1 as u16);
35194        self.as_rec_mut().extend(value.to_ne_bytes());
35195        self
35196    }
35197    pub fn push_opcode(mut self, value: u8) -> Self {
35198        push_header(self.as_rec_mut(), 2u16, 1 as u16);
35199        self.as_rec_mut().extend(value.to_ne_bytes());
35200        self
35201    }
35202}
35203impl<Prev: Rec> Drop for PushFlowerKeyCfmAttrs<Prev> {
35204    fn drop(&mut self) {
35205        if let Some(prev) = &mut self.prev {
35206            if let Some(header_offset) = &self.header_offset {
35207                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35208            }
35209        }
35210    }
35211}
35212pub struct PushFwAttrs<Prev: Rec> {
35213    pub(crate) prev: Option<Prev>,
35214    pub(crate) header_offset: Option<usize>,
35215}
35216impl<Prev: Rec> Rec for PushFwAttrs<Prev> {
35217    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35218        self.prev.as_mut().unwrap().as_rec_mut()
35219    }
35220    fn as_rec(&self) -> &Vec<u8> {
35221        self.prev.as_ref().unwrap().as_rec()
35222    }
35223}
35224impl<Prev: Rec> PushFwAttrs<Prev> {
35225    pub fn new(prev: Prev) -> Self {
35226        Self {
35227            prev: Some(prev),
35228            header_offset: None,
35229        }
35230    }
35231    pub fn end_nested(mut self) -> Prev {
35232        let mut prev = self.prev.take().unwrap();
35233        if let Some(header_offset) = &self.header_offset {
35234            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35235        }
35236        prev
35237    }
35238    pub fn push_classid(mut self, value: u32) -> Self {
35239        push_header(self.as_rec_mut(), 1u16, 4 as u16);
35240        self.as_rec_mut().extend(value.to_ne_bytes());
35241        self
35242    }
35243    pub fn nested_police(mut self) -> PushPoliceAttrs<Self> {
35244        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
35245        PushPoliceAttrs {
35246            prev: Some(self),
35247            header_offset: Some(header_offset),
35248        }
35249    }
35250    pub fn push_indev(mut self, value: &CStr) -> Self {
35251        push_header(
35252            self.as_rec_mut(),
35253            3u16,
35254            value.to_bytes_with_nul().len() as u16,
35255        );
35256        self.as_rec_mut().extend(value.to_bytes_with_nul());
35257        self
35258    }
35259    pub fn push_indev_bytes(mut self, value: &[u8]) -> Self {
35260        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
35261        self.as_rec_mut().extend(value);
35262        self.as_rec_mut().push(0);
35263        self
35264    }
35265    pub fn array_act(mut self) -> PushArrayActAttrs<Self> {
35266        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
35267        PushArrayActAttrs {
35268            prev: Some(self),
35269            header_offset: Some(header_offset),
35270            counter: 0,
35271        }
35272    }
35273    pub fn push_mask(mut self, value: u32) -> Self {
35274        push_header(self.as_rec_mut(), 5u16, 4 as u16);
35275        self.as_rec_mut().extend(value.to_ne_bytes());
35276        self
35277    }
35278}
35279impl<Prev: Rec> Drop for PushFwAttrs<Prev> {
35280    fn drop(&mut self) {
35281        if let Some(prev) = &mut self.prev {
35282            if let Some(header_offset) = &self.header_offset {
35283                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35284            }
35285        }
35286    }
35287}
35288pub struct PushGredAttrs<Prev: Rec> {
35289    pub(crate) prev: Option<Prev>,
35290    pub(crate) header_offset: Option<usize>,
35291}
35292impl<Prev: Rec> Rec for PushGredAttrs<Prev> {
35293    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35294        self.prev.as_mut().unwrap().as_rec_mut()
35295    }
35296    fn as_rec(&self) -> &Vec<u8> {
35297        self.prev.as_ref().unwrap().as_rec()
35298    }
35299}
35300impl<Prev: Rec> PushGredAttrs<Prev> {
35301    pub fn new(prev: Prev) -> Self {
35302        Self {
35303            prev: Some(prev),
35304            header_offset: None,
35305        }
35306    }
35307    pub fn end_nested(mut self) -> Prev {
35308        let mut prev = self.prev.take().unwrap();
35309        if let Some(header_offset) = &self.header_offset {
35310            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35311        }
35312        prev
35313    }
35314    pub fn push_parms(mut self, value: &[u8]) -> Self {
35315        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
35316        self.as_rec_mut().extend(value);
35317        self
35318    }
35319    pub fn push_stab(mut self, value: &[u8]) -> Self {
35320        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
35321        self.as_rec_mut().extend(value);
35322        self
35323    }
35324    pub fn push_dps(mut self, value: TcGredSopt) -> Self {
35325        push_header(self.as_rec_mut(), 3u16, value.as_slice().len() as u16);
35326        self.as_rec_mut().extend(value.as_slice());
35327        self
35328    }
35329    pub fn push_max_p(mut self, value: &[u8]) -> Self {
35330        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
35331        self.as_rec_mut().extend(value);
35332        self
35333    }
35334    pub fn push_limit(mut self, value: u32) -> Self {
35335        push_header(self.as_rec_mut(), 5u16, 4 as u16);
35336        self.as_rec_mut().extend(value.to_ne_bytes());
35337        self
35338    }
35339    pub fn nested_vq_list(mut self) -> PushTcaGredVqListAttrs<Self> {
35340        let header_offset = push_nested_header(self.as_rec_mut(), 6u16);
35341        PushTcaGredVqListAttrs {
35342            prev: Some(self),
35343            header_offset: Some(header_offset),
35344        }
35345    }
35346}
35347impl<Prev: Rec> Drop for PushGredAttrs<Prev> {
35348    fn drop(&mut self) {
35349        if let Some(prev) = &mut self.prev {
35350            if let Some(header_offset) = &self.header_offset {
35351                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35352            }
35353        }
35354    }
35355}
35356pub struct PushTcaGredVqListAttrs<Prev: Rec> {
35357    pub(crate) prev: Option<Prev>,
35358    pub(crate) header_offset: Option<usize>,
35359}
35360impl<Prev: Rec> Rec for PushTcaGredVqListAttrs<Prev> {
35361    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35362        self.prev.as_mut().unwrap().as_rec_mut()
35363    }
35364    fn as_rec(&self) -> &Vec<u8> {
35365        self.prev.as_ref().unwrap().as_rec()
35366    }
35367}
35368impl<Prev: Rec> PushTcaGredVqListAttrs<Prev> {
35369    pub fn new(prev: Prev) -> Self {
35370        Self {
35371            prev: Some(prev),
35372            header_offset: None,
35373        }
35374    }
35375    pub fn end_nested(mut self) -> Prev {
35376        let mut prev = self.prev.take().unwrap();
35377        if let Some(header_offset) = &self.header_offset {
35378            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35379        }
35380        prev
35381    }
35382    #[doc = "Attribute may repeat multiple times (treat it as array)"]
35383    pub fn nested_entry(mut self) -> PushTcaGredVqEntryAttrs<Self> {
35384        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
35385        PushTcaGredVqEntryAttrs {
35386            prev: Some(self),
35387            header_offset: Some(header_offset),
35388        }
35389    }
35390}
35391impl<Prev: Rec> Drop for PushTcaGredVqListAttrs<Prev> {
35392    fn drop(&mut self) {
35393        if let Some(prev) = &mut self.prev {
35394            if let Some(header_offset) = &self.header_offset {
35395                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35396            }
35397        }
35398    }
35399}
35400pub struct PushTcaGredVqEntryAttrs<Prev: Rec> {
35401    pub(crate) prev: Option<Prev>,
35402    pub(crate) header_offset: Option<usize>,
35403}
35404impl<Prev: Rec> Rec for PushTcaGredVqEntryAttrs<Prev> {
35405    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35406        self.prev.as_mut().unwrap().as_rec_mut()
35407    }
35408    fn as_rec(&self) -> &Vec<u8> {
35409        self.prev.as_ref().unwrap().as_rec()
35410    }
35411}
35412impl<Prev: Rec> PushTcaGredVqEntryAttrs<Prev> {
35413    pub fn new(prev: Prev) -> Self {
35414        Self {
35415            prev: Some(prev),
35416            header_offset: None,
35417        }
35418    }
35419    pub fn end_nested(mut self) -> Prev {
35420        let mut prev = self.prev.take().unwrap();
35421        if let Some(header_offset) = &self.header_offset {
35422            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35423        }
35424        prev
35425    }
35426    pub fn push_pad(mut self, value: &[u8]) -> Self {
35427        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
35428        self.as_rec_mut().extend(value);
35429        self
35430    }
35431    pub fn push_dp(mut self, value: u32) -> Self {
35432        push_header(self.as_rec_mut(), 2u16, 4 as u16);
35433        self.as_rec_mut().extend(value.to_ne_bytes());
35434        self
35435    }
35436    pub fn push_stat_bytes(mut self, value: u64) -> Self {
35437        push_header(self.as_rec_mut(), 3u16, 8 as u16);
35438        self.as_rec_mut().extend(value.to_ne_bytes());
35439        self
35440    }
35441    pub fn push_stat_packets(mut self, value: u32) -> Self {
35442        push_header(self.as_rec_mut(), 4u16, 4 as u16);
35443        self.as_rec_mut().extend(value.to_ne_bytes());
35444        self
35445    }
35446    pub fn push_stat_backlog(mut self, value: u32) -> Self {
35447        push_header(self.as_rec_mut(), 5u16, 4 as u16);
35448        self.as_rec_mut().extend(value.to_ne_bytes());
35449        self
35450    }
35451    pub fn push_stat_prob_drop(mut self, value: u32) -> Self {
35452        push_header(self.as_rec_mut(), 6u16, 4 as u16);
35453        self.as_rec_mut().extend(value.to_ne_bytes());
35454        self
35455    }
35456    pub fn push_stat_prob_mark(mut self, value: u32) -> Self {
35457        push_header(self.as_rec_mut(), 7u16, 4 as u16);
35458        self.as_rec_mut().extend(value.to_ne_bytes());
35459        self
35460    }
35461    pub fn push_stat_forced_drop(mut self, value: u32) -> Self {
35462        push_header(self.as_rec_mut(), 8u16, 4 as u16);
35463        self.as_rec_mut().extend(value.to_ne_bytes());
35464        self
35465    }
35466    pub fn push_stat_forced_mark(mut self, value: u32) -> Self {
35467        push_header(self.as_rec_mut(), 9u16, 4 as u16);
35468        self.as_rec_mut().extend(value.to_ne_bytes());
35469        self
35470    }
35471    pub fn push_stat_pdrop(mut self, value: u32) -> Self {
35472        push_header(self.as_rec_mut(), 10u16, 4 as u16);
35473        self.as_rec_mut().extend(value.to_ne_bytes());
35474        self
35475    }
35476    pub fn push_stat_other(mut self, value: u32) -> Self {
35477        push_header(self.as_rec_mut(), 11u16, 4 as u16);
35478        self.as_rec_mut().extend(value.to_ne_bytes());
35479        self
35480    }
35481    pub fn push_flags(mut self, value: u32) -> Self {
35482        push_header(self.as_rec_mut(), 12u16, 4 as u16);
35483        self.as_rec_mut().extend(value.to_ne_bytes());
35484        self
35485    }
35486}
35487impl<Prev: Rec> Drop for PushTcaGredVqEntryAttrs<Prev> {
35488    fn drop(&mut self) {
35489        if let Some(prev) = &mut self.prev {
35490            if let Some(header_offset) = &self.header_offset {
35491                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35492            }
35493        }
35494    }
35495}
35496pub struct PushHfscAttrs<Prev: Rec> {
35497    pub(crate) prev: Option<Prev>,
35498    pub(crate) header_offset: Option<usize>,
35499}
35500impl<Prev: Rec> Rec for PushHfscAttrs<Prev> {
35501    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35502        self.prev.as_mut().unwrap().as_rec_mut()
35503    }
35504    fn as_rec(&self) -> &Vec<u8> {
35505        self.prev.as_ref().unwrap().as_rec()
35506    }
35507}
35508impl<Prev: Rec> PushHfscAttrs<Prev> {
35509    pub fn new(prev: Prev) -> Self {
35510        Self {
35511            prev: Some(prev),
35512            header_offset: None,
35513        }
35514    }
35515    pub fn end_nested(mut self) -> Prev {
35516        let mut prev = self.prev.take().unwrap();
35517        if let Some(header_offset) = &self.header_offset {
35518            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35519        }
35520        prev
35521    }
35522    pub fn push_rsc(mut self, value: &[u8]) -> Self {
35523        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
35524        self.as_rec_mut().extend(value);
35525        self
35526    }
35527    pub fn push_fsc(mut self, value: &[u8]) -> Self {
35528        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
35529        self.as_rec_mut().extend(value);
35530        self
35531    }
35532    pub fn push_usc(mut self, value: &[u8]) -> Self {
35533        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
35534        self.as_rec_mut().extend(value);
35535        self
35536    }
35537}
35538impl<Prev: Rec> Drop for PushHfscAttrs<Prev> {
35539    fn drop(&mut self) {
35540        if let Some(prev) = &mut self.prev {
35541            if let Some(header_offset) = &self.header_offset {
35542                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35543            }
35544        }
35545    }
35546}
35547pub struct PushHhfAttrs<Prev: Rec> {
35548    pub(crate) prev: Option<Prev>,
35549    pub(crate) header_offset: Option<usize>,
35550}
35551impl<Prev: Rec> Rec for PushHhfAttrs<Prev> {
35552    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35553        self.prev.as_mut().unwrap().as_rec_mut()
35554    }
35555    fn as_rec(&self) -> &Vec<u8> {
35556        self.prev.as_ref().unwrap().as_rec()
35557    }
35558}
35559impl<Prev: Rec> PushHhfAttrs<Prev> {
35560    pub fn new(prev: Prev) -> Self {
35561        Self {
35562            prev: Some(prev),
35563            header_offset: None,
35564        }
35565    }
35566    pub fn end_nested(mut self) -> Prev {
35567        let mut prev = self.prev.take().unwrap();
35568        if let Some(header_offset) = &self.header_offset {
35569            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35570        }
35571        prev
35572    }
35573    pub fn push_backlog_limit(mut self, value: u32) -> Self {
35574        push_header(self.as_rec_mut(), 1u16, 4 as u16);
35575        self.as_rec_mut().extend(value.to_ne_bytes());
35576        self
35577    }
35578    pub fn push_quantum(mut self, value: u32) -> Self {
35579        push_header(self.as_rec_mut(), 2u16, 4 as u16);
35580        self.as_rec_mut().extend(value.to_ne_bytes());
35581        self
35582    }
35583    pub fn push_hh_flows_limit(mut self, value: u32) -> Self {
35584        push_header(self.as_rec_mut(), 3u16, 4 as u16);
35585        self.as_rec_mut().extend(value.to_ne_bytes());
35586        self
35587    }
35588    pub fn push_reset_timeout(mut self, value: u32) -> Self {
35589        push_header(self.as_rec_mut(), 4u16, 4 as u16);
35590        self.as_rec_mut().extend(value.to_ne_bytes());
35591        self
35592    }
35593    pub fn push_admit_bytes(mut self, value: u32) -> Self {
35594        push_header(self.as_rec_mut(), 5u16, 4 as u16);
35595        self.as_rec_mut().extend(value.to_ne_bytes());
35596        self
35597    }
35598    pub fn push_evict_timeout(mut self, value: u32) -> Self {
35599        push_header(self.as_rec_mut(), 6u16, 4 as u16);
35600        self.as_rec_mut().extend(value.to_ne_bytes());
35601        self
35602    }
35603    pub fn push_non_hh_weight(mut self, value: u32) -> Self {
35604        push_header(self.as_rec_mut(), 7u16, 4 as u16);
35605        self.as_rec_mut().extend(value.to_ne_bytes());
35606        self
35607    }
35608}
35609impl<Prev: Rec> Drop for PushHhfAttrs<Prev> {
35610    fn drop(&mut self) {
35611        if let Some(prev) = &mut self.prev {
35612            if let Some(header_offset) = &self.header_offset {
35613                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35614            }
35615        }
35616    }
35617}
35618pub struct PushHtbAttrs<Prev: Rec> {
35619    pub(crate) prev: Option<Prev>,
35620    pub(crate) header_offset: Option<usize>,
35621}
35622impl<Prev: Rec> Rec for PushHtbAttrs<Prev> {
35623    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35624        self.prev.as_mut().unwrap().as_rec_mut()
35625    }
35626    fn as_rec(&self) -> &Vec<u8> {
35627        self.prev.as_ref().unwrap().as_rec()
35628    }
35629}
35630impl<Prev: Rec> PushHtbAttrs<Prev> {
35631    pub fn new(prev: Prev) -> Self {
35632        Self {
35633            prev: Some(prev),
35634            header_offset: None,
35635        }
35636    }
35637    pub fn end_nested(mut self) -> Prev {
35638        let mut prev = self.prev.take().unwrap();
35639        if let Some(header_offset) = &self.header_offset {
35640            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35641        }
35642        prev
35643    }
35644    pub fn push_parms(mut self, value: TcHtbOpt) -> Self {
35645        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
35646        self.as_rec_mut().extend(value.as_slice());
35647        self
35648    }
35649    pub fn push_init(mut self, value: TcHtbGlob) -> Self {
35650        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
35651        self.as_rec_mut().extend(value.as_slice());
35652        self
35653    }
35654    pub fn push_ctab(mut self, value: &[u8]) -> Self {
35655        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
35656        self.as_rec_mut().extend(value);
35657        self
35658    }
35659    pub fn push_rtab(mut self, value: &[u8]) -> Self {
35660        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
35661        self.as_rec_mut().extend(value);
35662        self
35663    }
35664    pub fn push_direct_qlen(mut self, value: u32) -> Self {
35665        push_header(self.as_rec_mut(), 5u16, 4 as u16);
35666        self.as_rec_mut().extend(value.to_ne_bytes());
35667        self
35668    }
35669    pub fn push_rate64(mut self, value: u64) -> Self {
35670        push_header(self.as_rec_mut(), 6u16, 8 as u16);
35671        self.as_rec_mut().extend(value.to_ne_bytes());
35672        self
35673    }
35674    pub fn push_ceil64(mut self, value: u64) -> Self {
35675        push_header(self.as_rec_mut(), 7u16, 8 as u16);
35676        self.as_rec_mut().extend(value.to_ne_bytes());
35677        self
35678    }
35679    pub fn push_pad(mut self, value: &[u8]) -> Self {
35680        push_header(self.as_rec_mut(), 8u16, value.len() as u16);
35681        self.as_rec_mut().extend(value);
35682        self
35683    }
35684    pub fn push_offload(mut self, value: ()) -> Self {
35685        push_header(self.as_rec_mut(), 9u16, 0 as u16);
35686        self
35687    }
35688}
35689impl<Prev: Rec> Drop for PushHtbAttrs<Prev> {
35690    fn drop(&mut self) {
35691        if let Some(prev) = &mut self.prev {
35692            if let Some(header_offset) = &self.header_offset {
35693                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35694            }
35695        }
35696    }
35697}
35698pub struct PushMatchallAttrs<Prev: Rec> {
35699    pub(crate) prev: Option<Prev>,
35700    pub(crate) header_offset: Option<usize>,
35701}
35702impl<Prev: Rec> Rec for PushMatchallAttrs<Prev> {
35703    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35704        self.prev.as_mut().unwrap().as_rec_mut()
35705    }
35706    fn as_rec(&self) -> &Vec<u8> {
35707        self.prev.as_ref().unwrap().as_rec()
35708    }
35709}
35710impl<Prev: Rec> PushMatchallAttrs<Prev> {
35711    pub fn new(prev: Prev) -> Self {
35712        Self {
35713            prev: Some(prev),
35714            header_offset: None,
35715        }
35716    }
35717    pub fn end_nested(mut self) -> Prev {
35718        let mut prev = self.prev.take().unwrap();
35719        if let Some(header_offset) = &self.header_offset {
35720            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35721        }
35722        prev
35723    }
35724    pub fn push_classid(mut self, value: u32) -> Self {
35725        push_header(self.as_rec_mut(), 1u16, 4 as u16);
35726        self.as_rec_mut().extend(value.to_ne_bytes());
35727        self
35728    }
35729    pub fn array_act(mut self) -> PushArrayActAttrs<Self> {
35730        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
35731        PushArrayActAttrs {
35732            prev: Some(self),
35733            header_offset: Some(header_offset),
35734            counter: 0,
35735        }
35736    }
35737    pub fn push_flags(mut self, value: u32) -> Self {
35738        push_header(self.as_rec_mut(), 3u16, 4 as u16);
35739        self.as_rec_mut().extend(value.to_ne_bytes());
35740        self
35741    }
35742    pub fn push_pcnt(mut self, value: TcMatchallPcnt) -> Self {
35743        push_header(self.as_rec_mut(), 4u16, value.as_slice().len() as u16);
35744        self.as_rec_mut().extend(value.as_slice());
35745        self
35746    }
35747    pub fn push_pad(mut self, value: &[u8]) -> Self {
35748        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
35749        self.as_rec_mut().extend(value);
35750        self
35751    }
35752}
35753impl<Prev: Rec> Drop for PushMatchallAttrs<Prev> {
35754    fn drop(&mut self) {
35755        if let Some(prev) = &mut self.prev {
35756            if let Some(header_offset) = &self.header_offset {
35757                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35758            }
35759        }
35760    }
35761}
35762pub struct PushEtfAttrs<Prev: Rec> {
35763    pub(crate) prev: Option<Prev>,
35764    pub(crate) header_offset: Option<usize>,
35765}
35766impl<Prev: Rec> Rec for PushEtfAttrs<Prev> {
35767    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35768        self.prev.as_mut().unwrap().as_rec_mut()
35769    }
35770    fn as_rec(&self) -> &Vec<u8> {
35771        self.prev.as_ref().unwrap().as_rec()
35772    }
35773}
35774impl<Prev: Rec> PushEtfAttrs<Prev> {
35775    pub fn new(prev: Prev) -> Self {
35776        Self {
35777            prev: Some(prev),
35778            header_offset: None,
35779        }
35780    }
35781    pub fn end_nested(mut self) -> Prev {
35782        let mut prev = self.prev.take().unwrap();
35783        if let Some(header_offset) = &self.header_offset {
35784            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35785        }
35786        prev
35787    }
35788    pub fn push_parms(mut self, value: TcEtfQopt) -> Self {
35789        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
35790        self.as_rec_mut().extend(value.as_slice());
35791        self
35792    }
35793}
35794impl<Prev: Rec> Drop for PushEtfAttrs<Prev> {
35795    fn drop(&mut self) {
35796        if let Some(prev) = &mut self.prev {
35797            if let Some(header_offset) = &self.header_offset {
35798                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35799            }
35800        }
35801    }
35802}
35803pub struct PushEtsAttrs<Prev: Rec> {
35804    pub(crate) prev: Option<Prev>,
35805    pub(crate) header_offset: Option<usize>,
35806}
35807impl<Prev: Rec> Rec for PushEtsAttrs<Prev> {
35808    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35809        self.prev.as_mut().unwrap().as_rec_mut()
35810    }
35811    fn as_rec(&self) -> &Vec<u8> {
35812        self.prev.as_ref().unwrap().as_rec()
35813    }
35814}
35815impl<Prev: Rec> PushEtsAttrs<Prev> {
35816    pub fn new(prev: Prev) -> Self {
35817        Self {
35818            prev: Some(prev),
35819            header_offset: None,
35820        }
35821    }
35822    pub fn end_nested(mut self) -> Prev {
35823        let mut prev = self.prev.take().unwrap();
35824        if let Some(header_offset) = &self.header_offset {
35825            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35826        }
35827        prev
35828    }
35829    pub fn push_nbands(mut self, value: u8) -> Self {
35830        push_header(self.as_rec_mut(), 1u16, 1 as u16);
35831        self.as_rec_mut().extend(value.to_ne_bytes());
35832        self
35833    }
35834    pub fn push_nstrict(mut self, value: u8) -> Self {
35835        push_header(self.as_rec_mut(), 2u16, 1 as u16);
35836        self.as_rec_mut().extend(value.to_ne_bytes());
35837        self
35838    }
35839    pub fn nested_quanta(mut self) -> PushEtsAttrs<Self> {
35840        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
35841        PushEtsAttrs {
35842            prev: Some(self),
35843            header_offset: Some(header_offset),
35844        }
35845    }
35846    #[doc = "Attribute may repeat multiple times (treat it as array)"]
35847    pub fn push_quanta_band(mut self, value: u32) -> Self {
35848        push_header(self.as_rec_mut(), 4u16, 4 as u16);
35849        self.as_rec_mut().extend(value.to_ne_bytes());
35850        self
35851    }
35852    pub fn nested_priomap(mut self) -> PushEtsAttrs<Self> {
35853        let header_offset = push_nested_header(self.as_rec_mut(), 5u16);
35854        PushEtsAttrs {
35855            prev: Some(self),
35856            header_offset: Some(header_offset),
35857        }
35858    }
35859    #[doc = "Attribute may repeat multiple times (treat it as array)"]
35860    pub fn push_priomap_band(mut self, value: u8) -> Self {
35861        push_header(self.as_rec_mut(), 6u16, 1 as u16);
35862        self.as_rec_mut().extend(value.to_ne_bytes());
35863        self
35864    }
35865}
35866impl<Prev: Rec> Drop for PushEtsAttrs<Prev> {
35867    fn drop(&mut self) {
35868        if let Some(prev) = &mut self.prev {
35869            if let Some(header_offset) = &self.header_offset {
35870                finalize_nested_header(prev.as_rec_mut(), *header_offset);
35871            }
35872        }
35873    }
35874}
35875pub struct PushFqAttrs<Prev: Rec> {
35876    pub(crate) prev: Option<Prev>,
35877    pub(crate) header_offset: Option<usize>,
35878}
35879impl<Prev: Rec> Rec for PushFqAttrs<Prev> {
35880    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
35881        self.prev.as_mut().unwrap().as_rec_mut()
35882    }
35883    fn as_rec(&self) -> &Vec<u8> {
35884        self.prev.as_ref().unwrap().as_rec()
35885    }
35886}
35887impl<Prev: Rec> PushFqAttrs<Prev> {
35888    pub fn new(prev: Prev) -> Self {
35889        Self {
35890            prev: Some(prev),
35891            header_offset: None,
35892        }
35893    }
35894    pub fn end_nested(mut self) -> Prev {
35895        let mut prev = self.prev.take().unwrap();
35896        if let Some(header_offset) = &self.header_offset {
35897            finalize_nested_header(prev.as_rec_mut(), *header_offset);
35898        }
35899        prev
35900    }
35901    #[doc = "Limit of total number of packets in queue"]
35902    pub fn push_plimit(mut self, value: u32) -> Self {
35903        push_header(self.as_rec_mut(), 1u16, 4 as u16);
35904        self.as_rec_mut().extend(value.to_ne_bytes());
35905        self
35906    }
35907    #[doc = "Limit of packets per flow"]
35908    pub fn push_flow_plimit(mut self, value: u32) -> Self {
35909        push_header(self.as_rec_mut(), 2u16, 4 as u16);
35910        self.as_rec_mut().extend(value.to_ne_bytes());
35911        self
35912    }
35913    #[doc = "RR quantum"]
35914    pub fn push_quantum(mut self, value: u32) -> Self {
35915        push_header(self.as_rec_mut(), 3u16, 4 as u16);
35916        self.as_rec_mut().extend(value.to_ne_bytes());
35917        self
35918    }
35919    #[doc = "RR quantum for new flow"]
35920    pub fn push_initial_quantum(mut self, value: u32) -> Self {
35921        push_header(self.as_rec_mut(), 4u16, 4 as u16);
35922        self.as_rec_mut().extend(value.to_ne_bytes());
35923        self
35924    }
35925    #[doc = "Enable / disable rate limiting"]
35926    pub fn push_rate_enable(mut self, value: u32) -> Self {
35927        push_header(self.as_rec_mut(), 5u16, 4 as u16);
35928        self.as_rec_mut().extend(value.to_ne_bytes());
35929        self
35930    }
35931    #[doc = "Obsolete, do not use"]
35932    pub fn push_flow_default_rate(mut self, value: u32) -> Self {
35933        push_header(self.as_rec_mut(), 6u16, 4 as u16);
35934        self.as_rec_mut().extend(value.to_ne_bytes());
35935        self
35936    }
35937    #[doc = "Per flow max rate"]
35938    pub fn push_flow_max_rate(mut self, value: u32) -> Self {
35939        push_header(self.as_rec_mut(), 7u16, 4 as u16);
35940        self.as_rec_mut().extend(value.to_ne_bytes());
35941        self
35942    }
35943    #[doc = "log2(number of buckets)"]
35944    pub fn push_buckets_log(mut self, value: u32) -> Self {
35945        push_header(self.as_rec_mut(), 8u16, 4 as u16);
35946        self.as_rec_mut().extend(value.to_ne_bytes());
35947        self
35948    }
35949    #[doc = "Flow credit refill delay in usec"]
35950    pub fn push_flow_refill_delay(mut self, value: u32) -> Self {
35951        push_header(self.as_rec_mut(), 9u16, 4 as u16);
35952        self.as_rec_mut().extend(value.to_ne_bytes());
35953        self
35954    }
35955    #[doc = "Mask applied to orphaned skb hashes"]
35956    pub fn push_orphan_mask(mut self, value: u32) -> Self {
35957        push_header(self.as_rec_mut(), 10u16, 4 as u16);
35958        self.as_rec_mut().extend(value.to_ne_bytes());
35959        self
35960    }
35961    #[doc = "Per packet delay under this rate"]
35962    pub fn push_low_rate_threshold(mut self, value: u32) -> Self {
35963        push_header(self.as_rec_mut(), 11u16, 4 as u16);
35964        self.as_rec_mut().extend(value.to_ne_bytes());
35965        self
35966    }
35967    #[doc = "DCTCP\\-like CE marking threshold"]
35968    pub fn push_ce_threshold(mut self, value: u32) -> Self {
35969        push_header(self.as_rec_mut(), 12u16, 4 as u16);
35970        self.as_rec_mut().extend(value.to_ne_bytes());
35971        self
35972    }
35973    pub fn push_timer_slack(mut self, value: u32) -> Self {
35974        push_header(self.as_rec_mut(), 13u16, 4 as u16);
35975        self.as_rec_mut().extend(value.to_ne_bytes());
35976        self
35977    }
35978    #[doc = "Time horizon in usec"]
35979    pub fn push_horizon(mut self, value: u32) -> Self {
35980        push_header(self.as_rec_mut(), 14u16, 4 as u16);
35981        self.as_rec_mut().extend(value.to_ne_bytes());
35982        self
35983    }
35984    #[doc = "Drop packets beyond horizon, or cap their EDT"]
35985    pub fn push_horizon_drop(mut self, value: u8) -> Self {
35986        push_header(self.as_rec_mut(), 15u16, 1 as u16);
35987        self.as_rec_mut().extend(value.to_ne_bytes());
35988        self
35989    }
35990    pub fn push_priomap(mut self, value: TcPrioQopt) -> Self {
35991        push_header(self.as_rec_mut(), 16u16, value.as_slice().len() as u16);
35992        self.as_rec_mut().extend(value.as_slice());
35993        self
35994    }
35995    #[doc = "Weights for each band"]
35996    pub fn push_weights(mut self, value: &[u8]) -> Self {
35997        push_header(self.as_rec_mut(), 17u16, value.len() as u16);
35998        self.as_rec_mut().extend(value);
35999        self
36000    }
36001}
36002impl<Prev: Rec> Drop for PushFqAttrs<Prev> {
36003    fn drop(&mut self) {
36004        if let Some(prev) = &mut self.prev {
36005            if let Some(header_offset) = &self.header_offset {
36006                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36007            }
36008        }
36009    }
36010}
36011pub struct PushFqCodelAttrs<Prev: Rec> {
36012    pub(crate) prev: Option<Prev>,
36013    pub(crate) header_offset: Option<usize>,
36014}
36015impl<Prev: Rec> Rec for PushFqCodelAttrs<Prev> {
36016    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36017        self.prev.as_mut().unwrap().as_rec_mut()
36018    }
36019    fn as_rec(&self) -> &Vec<u8> {
36020        self.prev.as_ref().unwrap().as_rec()
36021    }
36022}
36023impl<Prev: Rec> PushFqCodelAttrs<Prev> {
36024    pub fn new(prev: Prev) -> Self {
36025        Self {
36026            prev: Some(prev),
36027            header_offset: None,
36028        }
36029    }
36030    pub fn end_nested(mut self) -> Prev {
36031        let mut prev = self.prev.take().unwrap();
36032        if let Some(header_offset) = &self.header_offset {
36033            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36034        }
36035        prev
36036    }
36037    pub fn push_target(mut self, value: u32) -> Self {
36038        push_header(self.as_rec_mut(), 1u16, 4 as u16);
36039        self.as_rec_mut().extend(value.to_ne_bytes());
36040        self
36041    }
36042    pub fn push_limit(mut self, value: u32) -> Self {
36043        push_header(self.as_rec_mut(), 2u16, 4 as u16);
36044        self.as_rec_mut().extend(value.to_ne_bytes());
36045        self
36046    }
36047    pub fn push_interval(mut self, value: u32) -> Self {
36048        push_header(self.as_rec_mut(), 3u16, 4 as u16);
36049        self.as_rec_mut().extend(value.to_ne_bytes());
36050        self
36051    }
36052    pub fn push_ecn(mut self, value: u32) -> Self {
36053        push_header(self.as_rec_mut(), 4u16, 4 as u16);
36054        self.as_rec_mut().extend(value.to_ne_bytes());
36055        self
36056    }
36057    pub fn push_flows(mut self, value: u32) -> Self {
36058        push_header(self.as_rec_mut(), 5u16, 4 as u16);
36059        self.as_rec_mut().extend(value.to_ne_bytes());
36060        self
36061    }
36062    pub fn push_quantum(mut self, value: u32) -> Self {
36063        push_header(self.as_rec_mut(), 6u16, 4 as u16);
36064        self.as_rec_mut().extend(value.to_ne_bytes());
36065        self
36066    }
36067    pub fn push_ce_threshold(mut self, value: u32) -> Self {
36068        push_header(self.as_rec_mut(), 7u16, 4 as u16);
36069        self.as_rec_mut().extend(value.to_ne_bytes());
36070        self
36071    }
36072    pub fn push_drop_batch_size(mut self, value: u32) -> Self {
36073        push_header(self.as_rec_mut(), 8u16, 4 as u16);
36074        self.as_rec_mut().extend(value.to_ne_bytes());
36075        self
36076    }
36077    pub fn push_memory_limit(mut self, value: u32) -> Self {
36078        push_header(self.as_rec_mut(), 9u16, 4 as u16);
36079        self.as_rec_mut().extend(value.to_ne_bytes());
36080        self
36081    }
36082    pub fn push_ce_threshold_selector(mut self, value: u8) -> Self {
36083        push_header(self.as_rec_mut(), 10u16, 1 as u16);
36084        self.as_rec_mut().extend(value.to_ne_bytes());
36085        self
36086    }
36087    pub fn push_ce_threshold_mask(mut self, value: u8) -> Self {
36088        push_header(self.as_rec_mut(), 11u16, 1 as u16);
36089        self.as_rec_mut().extend(value.to_ne_bytes());
36090        self
36091    }
36092}
36093impl<Prev: Rec> Drop for PushFqCodelAttrs<Prev> {
36094    fn drop(&mut self) {
36095        if let Some(prev) = &mut self.prev {
36096            if let Some(header_offset) = &self.header_offset {
36097                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36098            }
36099        }
36100    }
36101}
36102pub struct PushFqPieAttrs<Prev: Rec> {
36103    pub(crate) prev: Option<Prev>,
36104    pub(crate) header_offset: Option<usize>,
36105}
36106impl<Prev: Rec> Rec for PushFqPieAttrs<Prev> {
36107    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36108        self.prev.as_mut().unwrap().as_rec_mut()
36109    }
36110    fn as_rec(&self) -> &Vec<u8> {
36111        self.prev.as_ref().unwrap().as_rec()
36112    }
36113}
36114impl<Prev: Rec> PushFqPieAttrs<Prev> {
36115    pub fn new(prev: Prev) -> Self {
36116        Self {
36117            prev: Some(prev),
36118            header_offset: None,
36119        }
36120    }
36121    pub fn end_nested(mut self) -> Prev {
36122        let mut prev = self.prev.take().unwrap();
36123        if let Some(header_offset) = &self.header_offset {
36124            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36125        }
36126        prev
36127    }
36128    pub fn push_limit(mut self, value: u32) -> Self {
36129        push_header(self.as_rec_mut(), 1u16, 4 as u16);
36130        self.as_rec_mut().extend(value.to_ne_bytes());
36131        self
36132    }
36133    pub fn push_flows(mut self, value: u32) -> Self {
36134        push_header(self.as_rec_mut(), 2u16, 4 as u16);
36135        self.as_rec_mut().extend(value.to_ne_bytes());
36136        self
36137    }
36138    pub fn push_target(mut self, value: u32) -> Self {
36139        push_header(self.as_rec_mut(), 3u16, 4 as u16);
36140        self.as_rec_mut().extend(value.to_ne_bytes());
36141        self
36142    }
36143    pub fn push_tupdate(mut self, value: u32) -> Self {
36144        push_header(self.as_rec_mut(), 4u16, 4 as u16);
36145        self.as_rec_mut().extend(value.to_ne_bytes());
36146        self
36147    }
36148    pub fn push_alpha(mut self, value: u32) -> Self {
36149        push_header(self.as_rec_mut(), 5u16, 4 as u16);
36150        self.as_rec_mut().extend(value.to_ne_bytes());
36151        self
36152    }
36153    pub fn push_beta(mut self, value: u32) -> Self {
36154        push_header(self.as_rec_mut(), 6u16, 4 as u16);
36155        self.as_rec_mut().extend(value.to_ne_bytes());
36156        self
36157    }
36158    pub fn push_quantum(mut self, value: u32) -> Self {
36159        push_header(self.as_rec_mut(), 7u16, 4 as u16);
36160        self.as_rec_mut().extend(value.to_ne_bytes());
36161        self
36162    }
36163    pub fn push_memory_limit(mut self, value: u32) -> Self {
36164        push_header(self.as_rec_mut(), 8u16, 4 as u16);
36165        self.as_rec_mut().extend(value.to_ne_bytes());
36166        self
36167    }
36168    pub fn push_ecn_prob(mut self, value: u32) -> Self {
36169        push_header(self.as_rec_mut(), 9u16, 4 as u16);
36170        self.as_rec_mut().extend(value.to_ne_bytes());
36171        self
36172    }
36173    pub fn push_ecn(mut self, value: u32) -> Self {
36174        push_header(self.as_rec_mut(), 10u16, 4 as u16);
36175        self.as_rec_mut().extend(value.to_ne_bytes());
36176        self
36177    }
36178    pub fn push_bytemode(mut self, value: u32) -> Self {
36179        push_header(self.as_rec_mut(), 11u16, 4 as u16);
36180        self.as_rec_mut().extend(value.to_ne_bytes());
36181        self
36182    }
36183    pub fn push_dq_rate_estimator(mut self, value: u32) -> Self {
36184        push_header(self.as_rec_mut(), 12u16, 4 as u16);
36185        self.as_rec_mut().extend(value.to_ne_bytes());
36186        self
36187    }
36188}
36189impl<Prev: Rec> Drop for PushFqPieAttrs<Prev> {
36190    fn drop(&mut self) {
36191        if let Some(prev) = &mut self.prev {
36192            if let Some(header_offset) = &self.header_offset {
36193                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36194            }
36195        }
36196    }
36197}
36198pub struct PushNetemAttrs<Prev: Rec> {
36199    pub(crate) prev: Option<Prev>,
36200    pub(crate) header_offset: Option<usize>,
36201}
36202impl<Prev: Rec> Rec for PushNetemAttrs<Prev> {
36203    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36204        self.prev.as_mut().unwrap().as_rec_mut()
36205    }
36206    fn as_rec(&self) -> &Vec<u8> {
36207        self.prev.as_ref().unwrap().as_rec()
36208    }
36209}
36210impl<Prev: Rec> PushNetemAttrs<Prev> {
36211    pub fn new(prev: Prev) -> Self {
36212        Self {
36213            prev: Some(prev),
36214            header_offset: None,
36215        }
36216    }
36217    pub fn end_nested(mut self) -> Prev {
36218        let mut prev = self.prev.take().unwrap();
36219        if let Some(header_offset) = &self.header_offset {
36220            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36221        }
36222        prev
36223    }
36224    pub fn push_corr(mut self, value: TcNetemCorr) -> Self {
36225        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
36226        self.as_rec_mut().extend(value.as_slice());
36227        self
36228    }
36229    pub fn push_delay_dist(mut self, value: &[u8]) -> Self {
36230        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
36231        self.as_rec_mut().extend(value);
36232        self
36233    }
36234    pub fn push_reorder(mut self, value: TcNetemReorder) -> Self {
36235        push_header(self.as_rec_mut(), 3u16, value.as_slice().len() as u16);
36236        self.as_rec_mut().extend(value.as_slice());
36237        self
36238    }
36239    pub fn push_corrupt(mut self, value: TcNetemCorrupt) -> Self {
36240        push_header(self.as_rec_mut(), 4u16, value.as_slice().len() as u16);
36241        self.as_rec_mut().extend(value.as_slice());
36242        self
36243    }
36244    pub fn nested_loss(mut self) -> PushNetemLossAttrs<Self> {
36245        let header_offset = push_nested_header(self.as_rec_mut(), 5u16);
36246        PushNetemLossAttrs {
36247            prev: Some(self),
36248            header_offset: Some(header_offset),
36249        }
36250    }
36251    pub fn push_rate(mut self, value: TcNetemRate) -> Self {
36252        push_header(self.as_rec_mut(), 6u16, value.as_slice().len() as u16);
36253        self.as_rec_mut().extend(value.as_slice());
36254        self
36255    }
36256    pub fn push_ecn(mut self, value: u32) -> Self {
36257        push_header(self.as_rec_mut(), 7u16, 4 as u16);
36258        self.as_rec_mut().extend(value.to_ne_bytes());
36259        self
36260    }
36261    pub fn push_rate64(mut self, value: u64) -> Self {
36262        push_header(self.as_rec_mut(), 8u16, 8 as u16);
36263        self.as_rec_mut().extend(value.to_ne_bytes());
36264        self
36265    }
36266    pub fn push_pad(mut self, value: u32) -> Self {
36267        push_header(self.as_rec_mut(), 9u16, 4 as u16);
36268        self.as_rec_mut().extend(value.to_ne_bytes());
36269        self
36270    }
36271    pub fn push_latency64(mut self, value: i64) -> Self {
36272        push_header(self.as_rec_mut(), 10u16, 8 as u16);
36273        self.as_rec_mut().extend(value.to_ne_bytes());
36274        self
36275    }
36276    pub fn push_jitter64(mut self, value: i64) -> Self {
36277        push_header(self.as_rec_mut(), 11u16, 8 as u16);
36278        self.as_rec_mut().extend(value.to_ne_bytes());
36279        self
36280    }
36281    pub fn push_slot(mut self, value: TcNetemSlot) -> Self {
36282        push_header(self.as_rec_mut(), 12u16, value.as_slice().len() as u16);
36283        self.as_rec_mut().extend(value.as_slice());
36284        self
36285    }
36286    pub fn push_slot_dist(mut self, value: &[u8]) -> Self {
36287        push_header(self.as_rec_mut(), 13u16, value.len() as u16);
36288        self.as_rec_mut().extend(value);
36289        self
36290    }
36291    pub fn push_prng_seed(mut self, value: u64) -> Self {
36292        push_header(self.as_rec_mut(), 14u16, 8 as u16);
36293        self.as_rec_mut().extend(value.to_ne_bytes());
36294        self
36295    }
36296}
36297impl<Prev: Rec> Drop for PushNetemAttrs<Prev> {
36298    fn drop(&mut self) {
36299        if let Some(prev) = &mut self.prev {
36300            if let Some(header_offset) = &self.header_offset {
36301                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36302            }
36303        }
36304    }
36305}
36306pub struct PushNetemLossAttrs<Prev: Rec> {
36307    pub(crate) prev: Option<Prev>,
36308    pub(crate) header_offset: Option<usize>,
36309}
36310impl<Prev: Rec> Rec for PushNetemLossAttrs<Prev> {
36311    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36312        self.prev.as_mut().unwrap().as_rec_mut()
36313    }
36314    fn as_rec(&self) -> &Vec<u8> {
36315        self.prev.as_ref().unwrap().as_rec()
36316    }
36317}
36318impl<Prev: Rec> PushNetemLossAttrs<Prev> {
36319    pub fn new(prev: Prev) -> Self {
36320        Self {
36321            prev: Some(prev),
36322            header_offset: None,
36323        }
36324    }
36325    pub fn end_nested(mut self) -> Prev {
36326        let mut prev = self.prev.take().unwrap();
36327        if let Some(header_offset) = &self.header_offset {
36328            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36329        }
36330        prev
36331    }
36332    #[doc = "General Intuitive \\- 4 state model"]
36333    pub fn push_gi(mut self, value: TcNetemGimodel) -> Self {
36334        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
36335        self.as_rec_mut().extend(value.as_slice());
36336        self
36337    }
36338    #[doc = "Gilbert Elliot models"]
36339    pub fn push_ge(mut self, value: TcNetemGemodel) -> Self {
36340        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
36341        self.as_rec_mut().extend(value.as_slice());
36342        self
36343    }
36344}
36345impl<Prev: Rec> Drop for PushNetemLossAttrs<Prev> {
36346    fn drop(&mut self) {
36347        if let Some(prev) = &mut self.prev {
36348            if let Some(header_offset) = &self.header_offset {
36349                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36350            }
36351        }
36352    }
36353}
36354pub struct PushPieAttrs<Prev: Rec> {
36355    pub(crate) prev: Option<Prev>,
36356    pub(crate) header_offset: Option<usize>,
36357}
36358impl<Prev: Rec> Rec for PushPieAttrs<Prev> {
36359    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36360        self.prev.as_mut().unwrap().as_rec_mut()
36361    }
36362    fn as_rec(&self) -> &Vec<u8> {
36363        self.prev.as_ref().unwrap().as_rec()
36364    }
36365}
36366impl<Prev: Rec> PushPieAttrs<Prev> {
36367    pub fn new(prev: Prev) -> Self {
36368        Self {
36369            prev: Some(prev),
36370            header_offset: None,
36371        }
36372    }
36373    pub fn end_nested(mut self) -> Prev {
36374        let mut prev = self.prev.take().unwrap();
36375        if let Some(header_offset) = &self.header_offset {
36376            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36377        }
36378        prev
36379    }
36380    pub fn push_target(mut self, value: u32) -> Self {
36381        push_header(self.as_rec_mut(), 1u16, 4 as u16);
36382        self.as_rec_mut().extend(value.to_ne_bytes());
36383        self
36384    }
36385    pub fn push_limit(mut self, value: u32) -> Self {
36386        push_header(self.as_rec_mut(), 2u16, 4 as u16);
36387        self.as_rec_mut().extend(value.to_ne_bytes());
36388        self
36389    }
36390    pub fn push_tupdate(mut self, value: u32) -> Self {
36391        push_header(self.as_rec_mut(), 3u16, 4 as u16);
36392        self.as_rec_mut().extend(value.to_ne_bytes());
36393        self
36394    }
36395    pub fn push_alpha(mut self, value: u32) -> Self {
36396        push_header(self.as_rec_mut(), 4u16, 4 as u16);
36397        self.as_rec_mut().extend(value.to_ne_bytes());
36398        self
36399    }
36400    pub fn push_beta(mut self, value: u32) -> Self {
36401        push_header(self.as_rec_mut(), 5u16, 4 as u16);
36402        self.as_rec_mut().extend(value.to_ne_bytes());
36403        self
36404    }
36405    pub fn push_ecn(mut self, value: u32) -> Self {
36406        push_header(self.as_rec_mut(), 6u16, 4 as u16);
36407        self.as_rec_mut().extend(value.to_ne_bytes());
36408        self
36409    }
36410    pub fn push_bytemode(mut self, value: u32) -> Self {
36411        push_header(self.as_rec_mut(), 7u16, 4 as u16);
36412        self.as_rec_mut().extend(value.to_ne_bytes());
36413        self
36414    }
36415    pub fn push_dq_rate_estimator(mut self, value: u32) -> Self {
36416        push_header(self.as_rec_mut(), 8u16, 4 as u16);
36417        self.as_rec_mut().extend(value.to_ne_bytes());
36418        self
36419    }
36420}
36421impl<Prev: Rec> Drop for PushPieAttrs<Prev> {
36422    fn drop(&mut self) {
36423        if let Some(prev) = &mut self.prev {
36424            if let Some(header_offset) = &self.header_offset {
36425                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36426            }
36427        }
36428    }
36429}
36430pub struct PushPoliceAttrs<Prev: Rec> {
36431    pub(crate) prev: Option<Prev>,
36432    pub(crate) header_offset: Option<usize>,
36433}
36434impl<Prev: Rec> Rec for PushPoliceAttrs<Prev> {
36435    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36436        self.prev.as_mut().unwrap().as_rec_mut()
36437    }
36438    fn as_rec(&self) -> &Vec<u8> {
36439        self.prev.as_ref().unwrap().as_rec()
36440    }
36441}
36442impl<Prev: Rec> PushPoliceAttrs<Prev> {
36443    pub fn new(prev: Prev) -> Self {
36444        Self {
36445            prev: Some(prev),
36446            header_offset: None,
36447        }
36448    }
36449    pub fn end_nested(mut self) -> Prev {
36450        let mut prev = self.prev.take().unwrap();
36451        if let Some(header_offset) = &self.header_offset {
36452            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36453        }
36454        prev
36455    }
36456    pub fn push_tbf(mut self, value: TcPolice) -> Self {
36457        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
36458        self.as_rec_mut().extend(value.as_slice());
36459        self
36460    }
36461    pub fn push_rate(mut self, value: &[u8]) -> Self {
36462        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
36463        self.as_rec_mut().extend(value);
36464        self
36465    }
36466    pub fn push_peakrate(mut self, value: &[u8]) -> Self {
36467        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
36468        self.as_rec_mut().extend(value);
36469        self
36470    }
36471    pub fn push_avrate(mut self, value: u32) -> Self {
36472        push_header(self.as_rec_mut(), 4u16, 4 as u16);
36473        self.as_rec_mut().extend(value.to_ne_bytes());
36474        self
36475    }
36476    pub fn push_result(mut self, value: u32) -> Self {
36477        push_header(self.as_rec_mut(), 5u16, 4 as u16);
36478        self.as_rec_mut().extend(value.to_ne_bytes());
36479        self
36480    }
36481    pub fn push_tm(mut self, value: TcfT) -> Self {
36482        push_header(self.as_rec_mut(), 6u16, value.as_slice().len() as u16);
36483        self.as_rec_mut().extend(value.as_slice());
36484        self
36485    }
36486    pub fn push_pad(mut self, value: &[u8]) -> Self {
36487        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
36488        self.as_rec_mut().extend(value);
36489        self
36490    }
36491    pub fn push_rate64(mut self, value: u64) -> Self {
36492        push_header(self.as_rec_mut(), 8u16, 8 as u16);
36493        self.as_rec_mut().extend(value.to_ne_bytes());
36494        self
36495    }
36496    pub fn push_peakrate64(mut self, value: u64) -> Self {
36497        push_header(self.as_rec_mut(), 9u16, 8 as u16);
36498        self.as_rec_mut().extend(value.to_ne_bytes());
36499        self
36500    }
36501    pub fn push_pktrate64(mut self, value: u64) -> Self {
36502        push_header(self.as_rec_mut(), 10u16, 8 as u16);
36503        self.as_rec_mut().extend(value.to_ne_bytes());
36504        self
36505    }
36506    pub fn push_pktburst64(mut self, value: u64) -> Self {
36507        push_header(self.as_rec_mut(), 11u16, 8 as u16);
36508        self.as_rec_mut().extend(value.to_ne_bytes());
36509        self
36510    }
36511}
36512impl<Prev: Rec> Drop for PushPoliceAttrs<Prev> {
36513    fn drop(&mut self) {
36514        if let Some(prev) = &mut self.prev {
36515            if let Some(header_offset) = &self.header_offset {
36516                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36517            }
36518        }
36519    }
36520}
36521pub struct PushQfqAttrs<Prev: Rec> {
36522    pub(crate) prev: Option<Prev>,
36523    pub(crate) header_offset: Option<usize>,
36524}
36525impl<Prev: Rec> Rec for PushQfqAttrs<Prev> {
36526    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36527        self.prev.as_mut().unwrap().as_rec_mut()
36528    }
36529    fn as_rec(&self) -> &Vec<u8> {
36530        self.prev.as_ref().unwrap().as_rec()
36531    }
36532}
36533impl<Prev: Rec> PushQfqAttrs<Prev> {
36534    pub fn new(prev: Prev) -> Self {
36535        Self {
36536            prev: Some(prev),
36537            header_offset: None,
36538        }
36539    }
36540    pub fn end_nested(mut self) -> Prev {
36541        let mut prev = self.prev.take().unwrap();
36542        if let Some(header_offset) = &self.header_offset {
36543            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36544        }
36545        prev
36546    }
36547    pub fn push_weight(mut self, value: u32) -> Self {
36548        push_header(self.as_rec_mut(), 1u16, 4 as u16);
36549        self.as_rec_mut().extend(value.to_ne_bytes());
36550        self
36551    }
36552    pub fn push_lmax(mut self, value: u32) -> Self {
36553        push_header(self.as_rec_mut(), 2u16, 4 as u16);
36554        self.as_rec_mut().extend(value.to_ne_bytes());
36555        self
36556    }
36557}
36558impl<Prev: Rec> Drop for PushQfqAttrs<Prev> {
36559    fn drop(&mut self) {
36560        if let Some(prev) = &mut self.prev {
36561            if let Some(header_offset) = &self.header_offset {
36562                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36563            }
36564        }
36565    }
36566}
36567pub struct PushRedAttrs<Prev: Rec> {
36568    pub(crate) prev: Option<Prev>,
36569    pub(crate) header_offset: Option<usize>,
36570}
36571impl<Prev: Rec> Rec for PushRedAttrs<Prev> {
36572    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36573        self.prev.as_mut().unwrap().as_rec_mut()
36574    }
36575    fn as_rec(&self) -> &Vec<u8> {
36576        self.prev.as_ref().unwrap().as_rec()
36577    }
36578}
36579impl<Prev: Rec> PushRedAttrs<Prev> {
36580    pub fn new(prev: Prev) -> Self {
36581        Self {
36582            prev: Some(prev),
36583            header_offset: None,
36584        }
36585    }
36586    pub fn end_nested(mut self) -> Prev {
36587        let mut prev = self.prev.take().unwrap();
36588        if let Some(header_offset) = &self.header_offset {
36589            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36590        }
36591        prev
36592    }
36593    pub fn push_parms(mut self, value: TcRedQopt) -> Self {
36594        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
36595        self.as_rec_mut().extend(value.as_slice());
36596        self
36597    }
36598    pub fn push_stab(mut self, value: &[u8]) -> Self {
36599        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
36600        self.as_rec_mut().extend(value);
36601        self
36602    }
36603    pub fn push_max_p(mut self, value: u32) -> Self {
36604        push_header(self.as_rec_mut(), 3u16, 4 as u16);
36605        self.as_rec_mut().extend(value.to_ne_bytes());
36606        self
36607    }
36608    pub fn push_flags(mut self, value: BuiltinBitfield32) -> Self {
36609        push_header(self.as_rec_mut(), 4u16, value.as_slice().len() as u16);
36610        self.as_rec_mut().extend(value.as_slice());
36611        self
36612    }
36613    pub fn push_early_drop_block(mut self, value: u32) -> Self {
36614        push_header(self.as_rec_mut(), 5u16, 4 as u16);
36615        self.as_rec_mut().extend(value.to_ne_bytes());
36616        self
36617    }
36618    pub fn push_mark_block(mut self, value: u32) -> Self {
36619        push_header(self.as_rec_mut(), 6u16, 4 as u16);
36620        self.as_rec_mut().extend(value.to_ne_bytes());
36621        self
36622    }
36623}
36624impl<Prev: Rec> Drop for PushRedAttrs<Prev> {
36625    fn drop(&mut self) {
36626        if let Some(prev) = &mut self.prev {
36627            if let Some(header_offset) = &self.header_offset {
36628                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36629            }
36630        }
36631    }
36632}
36633pub struct PushRouteAttrs<Prev: Rec> {
36634    pub(crate) prev: Option<Prev>,
36635    pub(crate) header_offset: Option<usize>,
36636}
36637impl<Prev: Rec> Rec for PushRouteAttrs<Prev> {
36638    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36639        self.prev.as_mut().unwrap().as_rec_mut()
36640    }
36641    fn as_rec(&self) -> &Vec<u8> {
36642        self.prev.as_ref().unwrap().as_rec()
36643    }
36644}
36645impl<Prev: Rec> PushRouteAttrs<Prev> {
36646    pub fn new(prev: Prev) -> Self {
36647        Self {
36648            prev: Some(prev),
36649            header_offset: None,
36650        }
36651    }
36652    pub fn end_nested(mut self) -> Prev {
36653        let mut prev = self.prev.take().unwrap();
36654        if let Some(header_offset) = &self.header_offset {
36655            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36656        }
36657        prev
36658    }
36659    pub fn push_classid(mut self, value: u32) -> Self {
36660        push_header(self.as_rec_mut(), 1u16, 4 as u16);
36661        self.as_rec_mut().extend(value.to_ne_bytes());
36662        self
36663    }
36664    pub fn push_to(mut self, value: u32) -> Self {
36665        push_header(self.as_rec_mut(), 2u16, 4 as u16);
36666        self.as_rec_mut().extend(value.to_ne_bytes());
36667        self
36668    }
36669    pub fn push_from(mut self, value: u32) -> Self {
36670        push_header(self.as_rec_mut(), 3u16, 4 as u16);
36671        self.as_rec_mut().extend(value.to_ne_bytes());
36672        self
36673    }
36674    pub fn push_iif(mut self, value: u32) -> Self {
36675        push_header(self.as_rec_mut(), 4u16, 4 as u16);
36676        self.as_rec_mut().extend(value.to_ne_bytes());
36677        self
36678    }
36679    pub fn nested_police(mut self) -> PushPoliceAttrs<Self> {
36680        let header_offset = push_nested_header(self.as_rec_mut(), 5u16);
36681        PushPoliceAttrs {
36682            prev: Some(self),
36683            header_offset: Some(header_offset),
36684        }
36685    }
36686    pub fn array_act(mut self) -> PushArrayActAttrs<Self> {
36687        let header_offset = push_nested_header(self.as_rec_mut(), 6u16);
36688        PushArrayActAttrs {
36689            prev: Some(self),
36690            header_offset: Some(header_offset),
36691            counter: 0,
36692        }
36693    }
36694}
36695impl<Prev: Rec> Drop for PushRouteAttrs<Prev> {
36696    fn drop(&mut self) {
36697        if let Some(prev) = &mut self.prev {
36698            if let Some(header_offset) = &self.header_offset {
36699                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36700            }
36701        }
36702    }
36703}
36704pub struct PushTaprioAttrs<Prev: Rec> {
36705    pub(crate) prev: Option<Prev>,
36706    pub(crate) header_offset: Option<usize>,
36707}
36708impl<Prev: Rec> Rec for PushTaprioAttrs<Prev> {
36709    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36710        self.prev.as_mut().unwrap().as_rec_mut()
36711    }
36712    fn as_rec(&self) -> &Vec<u8> {
36713        self.prev.as_ref().unwrap().as_rec()
36714    }
36715}
36716impl<Prev: Rec> PushTaprioAttrs<Prev> {
36717    pub fn new(prev: Prev) -> Self {
36718        Self {
36719            prev: Some(prev),
36720            header_offset: None,
36721        }
36722    }
36723    pub fn end_nested(mut self) -> Prev {
36724        let mut prev = self.prev.take().unwrap();
36725        if let Some(header_offset) = &self.header_offset {
36726            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36727        }
36728        prev
36729    }
36730    pub fn push_priomap(mut self, value: TcMqprioQopt) -> Self {
36731        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
36732        self.as_rec_mut().extend(value.as_slice());
36733        self
36734    }
36735    pub fn nested_sched_entry_list(mut self) -> PushTaprioSchedEntryList<Self> {
36736        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
36737        PushTaprioSchedEntryList {
36738            prev: Some(self),
36739            header_offset: Some(header_offset),
36740        }
36741    }
36742    pub fn push_sched_base_time(mut self, value: i64) -> Self {
36743        push_header(self.as_rec_mut(), 3u16, 8 as u16);
36744        self.as_rec_mut().extend(value.to_ne_bytes());
36745        self
36746    }
36747    pub fn nested_sched_single_entry(mut self) -> PushTaprioSchedEntry<Self> {
36748        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
36749        PushTaprioSchedEntry {
36750            prev: Some(self),
36751            header_offset: Some(header_offset),
36752        }
36753    }
36754    pub fn push_sched_clockid(mut self, value: i32) -> Self {
36755        push_header(self.as_rec_mut(), 5u16, 4 as u16);
36756        self.as_rec_mut().extend(value.to_ne_bytes());
36757        self
36758    }
36759    pub fn push_pad(mut self, value: &[u8]) -> Self {
36760        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
36761        self.as_rec_mut().extend(value);
36762        self
36763    }
36764    pub fn push_admin_sched(mut self, value: &[u8]) -> Self {
36765        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
36766        self.as_rec_mut().extend(value);
36767        self
36768    }
36769    pub fn push_sched_cycle_time(mut self, value: i64) -> Self {
36770        push_header(self.as_rec_mut(), 8u16, 8 as u16);
36771        self.as_rec_mut().extend(value.to_ne_bytes());
36772        self
36773    }
36774    pub fn push_sched_cycle_time_extension(mut self, value: i64) -> Self {
36775        push_header(self.as_rec_mut(), 9u16, 8 as u16);
36776        self.as_rec_mut().extend(value.to_ne_bytes());
36777        self
36778    }
36779    pub fn push_flags(mut self, value: u32) -> Self {
36780        push_header(self.as_rec_mut(), 10u16, 4 as u16);
36781        self.as_rec_mut().extend(value.to_ne_bytes());
36782        self
36783    }
36784    pub fn push_txtime_delay(mut self, value: u32) -> Self {
36785        push_header(self.as_rec_mut(), 11u16, 4 as u16);
36786        self.as_rec_mut().extend(value.to_ne_bytes());
36787        self
36788    }
36789    pub fn nested_tc_entry(mut self) -> PushTaprioTcEntryAttrs<Self> {
36790        let header_offset = push_nested_header(self.as_rec_mut(), 12u16);
36791        PushTaprioTcEntryAttrs {
36792            prev: Some(self),
36793            header_offset: Some(header_offset),
36794        }
36795    }
36796}
36797impl<Prev: Rec> Drop for PushTaprioAttrs<Prev> {
36798    fn drop(&mut self) {
36799        if let Some(prev) = &mut self.prev {
36800            if let Some(header_offset) = &self.header_offset {
36801                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36802            }
36803        }
36804    }
36805}
36806pub struct PushTaprioSchedEntryList<Prev: Rec> {
36807    pub(crate) prev: Option<Prev>,
36808    pub(crate) header_offset: Option<usize>,
36809}
36810impl<Prev: Rec> Rec for PushTaprioSchedEntryList<Prev> {
36811    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36812        self.prev.as_mut().unwrap().as_rec_mut()
36813    }
36814    fn as_rec(&self) -> &Vec<u8> {
36815        self.prev.as_ref().unwrap().as_rec()
36816    }
36817}
36818impl<Prev: Rec> PushTaprioSchedEntryList<Prev> {
36819    pub fn new(prev: Prev) -> Self {
36820        Self {
36821            prev: Some(prev),
36822            header_offset: None,
36823        }
36824    }
36825    pub fn end_nested(mut self) -> Prev {
36826        let mut prev = self.prev.take().unwrap();
36827        if let Some(header_offset) = &self.header_offset {
36828            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36829        }
36830        prev
36831    }
36832    #[doc = "Attribute may repeat multiple times (treat it as array)"]
36833    pub fn nested_entry(mut self) -> PushTaprioSchedEntry<Self> {
36834        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
36835        PushTaprioSchedEntry {
36836            prev: Some(self),
36837            header_offset: Some(header_offset),
36838        }
36839    }
36840}
36841impl<Prev: Rec> Drop for PushTaprioSchedEntryList<Prev> {
36842    fn drop(&mut self) {
36843        if let Some(prev) = &mut self.prev {
36844            if let Some(header_offset) = &self.header_offset {
36845                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36846            }
36847        }
36848    }
36849}
36850pub struct PushTaprioSchedEntry<Prev: Rec> {
36851    pub(crate) prev: Option<Prev>,
36852    pub(crate) header_offset: Option<usize>,
36853}
36854impl<Prev: Rec> Rec for PushTaprioSchedEntry<Prev> {
36855    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36856        self.prev.as_mut().unwrap().as_rec_mut()
36857    }
36858    fn as_rec(&self) -> &Vec<u8> {
36859        self.prev.as_ref().unwrap().as_rec()
36860    }
36861}
36862impl<Prev: Rec> PushTaprioSchedEntry<Prev> {
36863    pub fn new(prev: Prev) -> Self {
36864        Self {
36865            prev: Some(prev),
36866            header_offset: None,
36867        }
36868    }
36869    pub fn end_nested(mut self) -> Prev {
36870        let mut prev = self.prev.take().unwrap();
36871        if let Some(header_offset) = &self.header_offset {
36872            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36873        }
36874        prev
36875    }
36876    pub fn push_index(mut self, value: u32) -> Self {
36877        push_header(self.as_rec_mut(), 1u16, 4 as u16);
36878        self.as_rec_mut().extend(value.to_ne_bytes());
36879        self
36880    }
36881    pub fn push_cmd(mut self, value: u8) -> Self {
36882        push_header(self.as_rec_mut(), 2u16, 1 as u16);
36883        self.as_rec_mut().extend(value.to_ne_bytes());
36884        self
36885    }
36886    pub fn push_gate_mask(mut self, value: u32) -> Self {
36887        push_header(self.as_rec_mut(), 3u16, 4 as u16);
36888        self.as_rec_mut().extend(value.to_ne_bytes());
36889        self
36890    }
36891    pub fn push_interval(mut self, value: u32) -> Self {
36892        push_header(self.as_rec_mut(), 4u16, 4 as u16);
36893        self.as_rec_mut().extend(value.to_ne_bytes());
36894        self
36895    }
36896}
36897impl<Prev: Rec> Drop for PushTaprioSchedEntry<Prev> {
36898    fn drop(&mut self) {
36899        if let Some(prev) = &mut self.prev {
36900            if let Some(header_offset) = &self.header_offset {
36901                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36902            }
36903        }
36904    }
36905}
36906pub struct PushTaprioTcEntryAttrs<Prev: Rec> {
36907    pub(crate) prev: Option<Prev>,
36908    pub(crate) header_offset: Option<usize>,
36909}
36910impl<Prev: Rec> Rec for PushTaprioTcEntryAttrs<Prev> {
36911    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36912        self.prev.as_mut().unwrap().as_rec_mut()
36913    }
36914    fn as_rec(&self) -> &Vec<u8> {
36915        self.prev.as_ref().unwrap().as_rec()
36916    }
36917}
36918impl<Prev: Rec> PushTaprioTcEntryAttrs<Prev> {
36919    pub fn new(prev: Prev) -> Self {
36920        Self {
36921            prev: Some(prev),
36922            header_offset: None,
36923        }
36924    }
36925    pub fn end_nested(mut self) -> Prev {
36926        let mut prev = self.prev.take().unwrap();
36927        if let Some(header_offset) = &self.header_offset {
36928            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36929        }
36930        prev
36931    }
36932    pub fn push_index(mut self, value: u32) -> Self {
36933        push_header(self.as_rec_mut(), 1u16, 4 as u16);
36934        self.as_rec_mut().extend(value.to_ne_bytes());
36935        self
36936    }
36937    pub fn push_max_sdu(mut self, value: u32) -> Self {
36938        push_header(self.as_rec_mut(), 2u16, 4 as u16);
36939        self.as_rec_mut().extend(value.to_ne_bytes());
36940        self
36941    }
36942    pub fn push_fp(mut self, value: u32) -> Self {
36943        push_header(self.as_rec_mut(), 3u16, 4 as u16);
36944        self.as_rec_mut().extend(value.to_ne_bytes());
36945        self
36946    }
36947}
36948impl<Prev: Rec> Drop for PushTaprioTcEntryAttrs<Prev> {
36949    fn drop(&mut self) {
36950        if let Some(prev) = &mut self.prev {
36951            if let Some(header_offset) = &self.header_offset {
36952                finalize_nested_header(prev.as_rec_mut(), *header_offset);
36953            }
36954        }
36955    }
36956}
36957pub struct PushTbfAttrs<Prev: Rec> {
36958    pub(crate) prev: Option<Prev>,
36959    pub(crate) header_offset: Option<usize>,
36960}
36961impl<Prev: Rec> Rec for PushTbfAttrs<Prev> {
36962    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
36963        self.prev.as_mut().unwrap().as_rec_mut()
36964    }
36965    fn as_rec(&self) -> &Vec<u8> {
36966        self.prev.as_ref().unwrap().as_rec()
36967    }
36968}
36969impl<Prev: Rec> PushTbfAttrs<Prev> {
36970    pub fn new(prev: Prev) -> Self {
36971        Self {
36972            prev: Some(prev),
36973            header_offset: None,
36974        }
36975    }
36976    pub fn end_nested(mut self) -> Prev {
36977        let mut prev = self.prev.take().unwrap();
36978        if let Some(header_offset) = &self.header_offset {
36979            finalize_nested_header(prev.as_rec_mut(), *header_offset);
36980        }
36981        prev
36982    }
36983    pub fn push_parms(mut self, value: TcTbfQopt) -> Self {
36984        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
36985        self.as_rec_mut().extend(value.as_slice());
36986        self
36987    }
36988    pub fn push_rtab(mut self, value: &[u8]) -> Self {
36989        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
36990        self.as_rec_mut().extend(value);
36991        self
36992    }
36993    pub fn push_ptab(mut self, value: &[u8]) -> Self {
36994        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
36995        self.as_rec_mut().extend(value);
36996        self
36997    }
36998    pub fn push_rate64(mut self, value: u64) -> Self {
36999        push_header(self.as_rec_mut(), 4u16, 8 as u16);
37000        self.as_rec_mut().extend(value.to_ne_bytes());
37001        self
37002    }
37003    pub fn push_prate64(mut self, value: u64) -> Self {
37004        push_header(self.as_rec_mut(), 5u16, 8 as u16);
37005        self.as_rec_mut().extend(value.to_ne_bytes());
37006        self
37007    }
37008    pub fn push_burst(mut self, value: u32) -> Self {
37009        push_header(self.as_rec_mut(), 6u16, 4 as u16);
37010        self.as_rec_mut().extend(value.to_ne_bytes());
37011        self
37012    }
37013    pub fn push_pburst(mut self, value: u32) -> Self {
37014        push_header(self.as_rec_mut(), 7u16, 4 as u16);
37015        self.as_rec_mut().extend(value.to_ne_bytes());
37016        self
37017    }
37018    pub fn push_pad(mut self, value: &[u8]) -> Self {
37019        push_header(self.as_rec_mut(), 8u16, value.len() as u16);
37020        self.as_rec_mut().extend(value);
37021        self
37022    }
37023}
37024impl<Prev: Rec> Drop for PushTbfAttrs<Prev> {
37025    fn drop(&mut self) {
37026        if let Some(prev) = &mut self.prev {
37027            if let Some(header_offset) = &self.header_offset {
37028                finalize_nested_header(prev.as_rec_mut(), *header_offset);
37029            }
37030        }
37031    }
37032}
37033pub struct PushActSampleAttrs<Prev: Rec> {
37034    pub(crate) prev: Option<Prev>,
37035    pub(crate) header_offset: Option<usize>,
37036}
37037impl<Prev: Rec> Rec for PushActSampleAttrs<Prev> {
37038    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
37039        self.prev.as_mut().unwrap().as_rec_mut()
37040    }
37041    fn as_rec(&self) -> &Vec<u8> {
37042        self.prev.as_ref().unwrap().as_rec()
37043    }
37044}
37045impl<Prev: Rec> PushActSampleAttrs<Prev> {
37046    pub fn new(prev: Prev) -> Self {
37047        Self {
37048            prev: Some(prev),
37049            header_offset: None,
37050        }
37051    }
37052    pub fn end_nested(mut self) -> Prev {
37053        let mut prev = self.prev.take().unwrap();
37054        if let Some(header_offset) = &self.header_offset {
37055            finalize_nested_header(prev.as_rec_mut(), *header_offset);
37056        }
37057        prev
37058    }
37059    pub fn push_tm(mut self, value: TcfT) -> Self {
37060        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
37061        self.as_rec_mut().extend(value.as_slice());
37062        self
37063    }
37064    pub fn push_parms(mut self, value: TcGact) -> Self {
37065        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
37066        self.as_rec_mut().extend(value.as_slice());
37067        self
37068    }
37069    pub fn push_rate(mut self, value: u32) -> Self {
37070        push_header(self.as_rec_mut(), 3u16, 4 as u16);
37071        self.as_rec_mut().extend(value.to_ne_bytes());
37072        self
37073    }
37074    pub fn push_trunc_size(mut self, value: u32) -> Self {
37075        push_header(self.as_rec_mut(), 4u16, 4 as u16);
37076        self.as_rec_mut().extend(value.to_ne_bytes());
37077        self
37078    }
37079    pub fn push_psample_group(mut self, value: u32) -> Self {
37080        push_header(self.as_rec_mut(), 5u16, 4 as u16);
37081        self.as_rec_mut().extend(value.to_ne_bytes());
37082        self
37083    }
37084    pub fn push_pad(mut self, value: &[u8]) -> Self {
37085        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
37086        self.as_rec_mut().extend(value);
37087        self
37088    }
37089}
37090impl<Prev: Rec> Drop for PushActSampleAttrs<Prev> {
37091    fn drop(&mut self) {
37092        if let Some(prev) = &mut self.prev {
37093            if let Some(header_offset) = &self.header_offset {
37094                finalize_nested_header(prev.as_rec_mut(), *header_offset);
37095            }
37096        }
37097    }
37098}
37099pub struct PushActGactAttrs<Prev: Rec> {
37100    pub(crate) prev: Option<Prev>,
37101    pub(crate) header_offset: Option<usize>,
37102}
37103impl<Prev: Rec> Rec for PushActGactAttrs<Prev> {
37104    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
37105        self.prev.as_mut().unwrap().as_rec_mut()
37106    }
37107    fn as_rec(&self) -> &Vec<u8> {
37108        self.prev.as_ref().unwrap().as_rec()
37109    }
37110}
37111impl<Prev: Rec> PushActGactAttrs<Prev> {
37112    pub fn new(prev: Prev) -> Self {
37113        Self {
37114            prev: Some(prev),
37115            header_offset: None,
37116        }
37117    }
37118    pub fn end_nested(mut self) -> Prev {
37119        let mut prev = self.prev.take().unwrap();
37120        if let Some(header_offset) = &self.header_offset {
37121            finalize_nested_header(prev.as_rec_mut(), *header_offset);
37122        }
37123        prev
37124    }
37125    pub fn push_tm(mut self, value: TcfT) -> Self {
37126        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
37127        self.as_rec_mut().extend(value.as_slice());
37128        self
37129    }
37130    pub fn push_parms(mut self, value: TcGact) -> Self {
37131        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
37132        self.as_rec_mut().extend(value.as_slice());
37133        self
37134    }
37135    pub fn push_prob(mut self, value: TcGactP) -> Self {
37136        push_header(self.as_rec_mut(), 3u16, value.as_slice().len() as u16);
37137        self.as_rec_mut().extend(value.as_slice());
37138        self
37139    }
37140    pub fn push_pad(mut self, value: &[u8]) -> Self {
37141        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
37142        self.as_rec_mut().extend(value);
37143        self
37144    }
37145}
37146impl<Prev: Rec> Drop for PushActGactAttrs<Prev> {
37147    fn drop(&mut self) {
37148        if let Some(prev) = &mut self.prev {
37149            if let Some(header_offset) = &self.header_offset {
37150                finalize_nested_header(prev.as_rec_mut(), *header_offset);
37151            }
37152        }
37153    }
37154}
37155pub struct PushTcaStabAttrs<Prev: Rec> {
37156    pub(crate) prev: Option<Prev>,
37157    pub(crate) header_offset: Option<usize>,
37158}
37159impl<Prev: Rec> Rec for PushTcaStabAttrs<Prev> {
37160    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
37161        self.prev.as_mut().unwrap().as_rec_mut()
37162    }
37163    fn as_rec(&self) -> &Vec<u8> {
37164        self.prev.as_ref().unwrap().as_rec()
37165    }
37166}
37167impl<Prev: Rec> PushTcaStabAttrs<Prev> {
37168    pub fn new(prev: Prev) -> Self {
37169        Self {
37170            prev: Some(prev),
37171            header_offset: None,
37172        }
37173    }
37174    pub fn end_nested(mut self) -> Prev {
37175        let mut prev = self.prev.take().unwrap();
37176        if let Some(header_offset) = &self.header_offset {
37177            finalize_nested_header(prev.as_rec_mut(), *header_offset);
37178        }
37179        prev
37180    }
37181    pub fn push_base(mut self, value: TcSizespec) -> Self {
37182        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
37183        self.as_rec_mut().extend(value.as_slice());
37184        self
37185    }
37186    pub fn push_data(mut self, value: &[u8]) -> Self {
37187        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
37188        self.as_rec_mut().extend(value);
37189        self
37190    }
37191}
37192impl<Prev: Rec> Drop for PushTcaStabAttrs<Prev> {
37193    fn drop(&mut self) {
37194        if let Some(prev) = &mut self.prev {
37195            if let Some(header_offset) = &self.header_offset {
37196                finalize_nested_header(prev.as_rec_mut(), *header_offset);
37197            }
37198        }
37199    }
37200}
37201pub struct PushTcaStatsAttrs<Prev: Rec> {
37202    pub(crate) prev: Option<Prev>,
37203    pub(crate) header_offset: Option<usize>,
37204}
37205impl<Prev: Rec> Rec for PushTcaStatsAttrs<Prev> {
37206    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
37207        self.prev.as_mut().unwrap().as_rec_mut()
37208    }
37209    fn as_rec(&self) -> &Vec<u8> {
37210        self.prev.as_ref().unwrap().as_rec()
37211    }
37212}
37213impl<Prev: Rec> PushTcaStatsAttrs<Prev> {
37214    pub fn new(prev: Prev) -> Self {
37215        Self {
37216            prev: Some(prev),
37217            header_offset: None,
37218        }
37219    }
37220    pub fn end_nested(mut self) -> Prev {
37221        let mut prev = self.prev.take().unwrap();
37222        if let Some(header_offset) = &self.header_offset {
37223            finalize_nested_header(prev.as_rec_mut(), *header_offset);
37224        }
37225        prev
37226    }
37227    pub fn push_basic(mut self, value: GnetStatsBasic) -> Self {
37228        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
37229        self.as_rec_mut().extend(value.as_slice());
37230        self
37231    }
37232    pub fn push_rate_est(mut self, value: GnetStatsRateEst) -> Self {
37233        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
37234        self.as_rec_mut().extend(value.as_slice());
37235        self
37236    }
37237    pub fn push_queue(mut self, value: GnetStatsQueue) -> Self {
37238        push_header(self.as_rec_mut(), 3u16, value.as_slice().len() as u16);
37239        self.as_rec_mut().extend(value.as_slice());
37240        self
37241    }
37242    pub fn push_rate_est64(mut self, value: GnetStatsRateEst64) -> Self {
37243        push_header(self.as_rec_mut(), 5u16, value.as_slice().len() as u16);
37244        self.as_rec_mut().extend(value.as_slice());
37245        self
37246    }
37247    pub fn push_pad(mut self, value: &[u8]) -> Self {
37248        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
37249        self.as_rec_mut().extend(value);
37250        self
37251    }
37252    pub fn push_basic_hw(mut self, value: GnetStatsBasic) -> Self {
37253        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
37254        self.as_rec_mut().extend(value.as_slice());
37255        self
37256    }
37257    pub fn push_pkt64(mut self, value: u64) -> Self {
37258        push_header(self.as_rec_mut(), 8u16, 8 as u16);
37259        self.as_rec_mut().extend(value.to_ne_bytes());
37260        self
37261    }
37262}
37263impl<Prev: Rec> Drop for PushTcaStatsAttrs<Prev> {
37264    fn drop(&mut self) {
37265        if let Some(prev) = &mut self.prev {
37266            if let Some(header_offset) = &self.header_offset {
37267                finalize_nested_header(prev.as_rec_mut(), *header_offset);
37268            }
37269        }
37270    }
37271}
37272pub struct PushU32Attrs<Prev: Rec> {
37273    pub(crate) prev: Option<Prev>,
37274    pub(crate) header_offset: Option<usize>,
37275}
37276impl<Prev: Rec> Rec for PushU32Attrs<Prev> {
37277    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
37278        self.prev.as_mut().unwrap().as_rec_mut()
37279    }
37280    fn as_rec(&self) -> &Vec<u8> {
37281        self.prev.as_ref().unwrap().as_rec()
37282    }
37283}
37284impl<Prev: Rec> PushU32Attrs<Prev> {
37285    pub fn new(prev: Prev) -> Self {
37286        Self {
37287            prev: Some(prev),
37288            header_offset: None,
37289        }
37290    }
37291    pub fn end_nested(mut self) -> Prev {
37292        let mut prev = self.prev.take().unwrap();
37293        if let Some(header_offset) = &self.header_offset {
37294            finalize_nested_header(prev.as_rec_mut(), *header_offset);
37295        }
37296        prev
37297    }
37298    pub fn push_classid(mut self, value: u32) -> Self {
37299        push_header(self.as_rec_mut(), 1u16, 4 as u16);
37300        self.as_rec_mut().extend(value.to_ne_bytes());
37301        self
37302    }
37303    pub fn push_hash(mut self, value: u32) -> Self {
37304        push_header(self.as_rec_mut(), 2u16, 4 as u16);
37305        self.as_rec_mut().extend(value.to_ne_bytes());
37306        self
37307    }
37308    pub fn push_link(mut self, value: u32) -> Self {
37309        push_header(self.as_rec_mut(), 3u16, 4 as u16);
37310        self.as_rec_mut().extend(value.to_ne_bytes());
37311        self
37312    }
37313    pub fn push_divisor(mut self, value: u32) -> Self {
37314        push_header(self.as_rec_mut(), 4u16, 4 as u16);
37315        self.as_rec_mut().extend(value.to_ne_bytes());
37316        self
37317    }
37318    pub fn push_sel(mut self, value: TcU32Sel) -> Self {
37319        push_header(self.as_rec_mut(), 5u16, value.as_slice().len() as u16);
37320        self.as_rec_mut().extend(value.as_slice());
37321        self
37322    }
37323    pub fn nested_police(mut self) -> PushPoliceAttrs<Self> {
37324        let header_offset = push_nested_header(self.as_rec_mut(), 6u16);
37325        PushPoliceAttrs {
37326            prev: Some(self),
37327            header_offset: Some(header_offset),
37328        }
37329    }
37330    pub fn array_act(mut self) -> PushArrayActAttrs<Self> {
37331        let header_offset = push_nested_header(self.as_rec_mut(), 7u16);
37332        PushArrayActAttrs {
37333            prev: Some(self),
37334            header_offset: Some(header_offset),
37335            counter: 0,
37336        }
37337    }
37338    pub fn push_indev(mut self, value: &CStr) -> Self {
37339        push_header(
37340            self.as_rec_mut(),
37341            8u16,
37342            value.to_bytes_with_nul().len() as u16,
37343        );
37344        self.as_rec_mut().extend(value.to_bytes_with_nul());
37345        self
37346    }
37347    pub fn push_indev_bytes(mut self, value: &[u8]) -> Self {
37348        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
37349        self.as_rec_mut().extend(value);
37350        self.as_rec_mut().push(0);
37351        self
37352    }
37353    pub fn push_pcnt(mut self, value: TcU32Pcnt) -> Self {
37354        push_header(self.as_rec_mut(), 9u16, value.as_slice().len() as u16);
37355        self.as_rec_mut().extend(value.as_slice());
37356        self
37357    }
37358    pub fn push_mark(mut self, value: TcU32Mark) -> Self {
37359        push_header(self.as_rec_mut(), 10u16, value.as_slice().len() as u16);
37360        self.as_rec_mut().extend(value.as_slice());
37361        self
37362    }
37363    pub fn push_flags(mut self, value: u32) -> Self {
37364        push_header(self.as_rec_mut(), 11u16, 4 as u16);
37365        self.as_rec_mut().extend(value.to_ne_bytes());
37366        self
37367    }
37368    pub fn push_pad(mut self, value: &[u8]) -> Self {
37369        push_header(self.as_rec_mut(), 12u16, value.len() as u16);
37370        self.as_rec_mut().extend(value);
37371        self
37372    }
37373}
37374impl<Prev: Rec> Drop for PushU32Attrs<Prev> {
37375    fn drop(&mut self) {
37376        if let Some(prev) = &mut self.prev {
37377            if let Some(header_offset) = &self.header_offset {
37378                finalize_nested_header(prev.as_rec_mut(), *header_offset);
37379            }
37380        }
37381    }
37382}
37383#[doc = "Create new tc qdisc\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.nested_options_basic()](PushAttrs::nested_options_basic)\n- [.nested_options_bpf()](PushAttrs::nested_options_bpf)\n- [.nested_options_bfifo()](PushAttrs::nested_options_bfifo)\n- [.nested_options_cake()](PushAttrs::nested_options_cake)\n- [.nested_options_cbs()](PushAttrs::nested_options_cbs)\n- [.nested_options_cgroup()](PushAttrs::nested_options_cgroup)\n- [.nested_options_choke()](PushAttrs::nested_options_choke)\n- [.nested_options_clsact()](PushAttrs::nested_options_clsact)\n- [.nested_options_codel()](PushAttrs::nested_options_codel)\n- [.nested_options_drr()](PushAttrs::nested_options_drr)\n- [.nested_options_dualpi2()](PushAttrs::nested_options_dualpi2)\n- [.nested_options_etf()](PushAttrs::nested_options_etf)\n- [.nested_options_ets()](PushAttrs::nested_options_ets)\n- [.nested_options_flow()](PushAttrs::nested_options_flow)\n- [.nested_options_flower()](PushAttrs::nested_options_flower)\n- [.nested_options_fq()](PushAttrs::nested_options_fq)\n- [.nested_options_fq_codel()](PushAttrs::nested_options_fq_codel)\n- [.nested_options_fq_pie()](PushAttrs::nested_options_fq_pie)\n- [.nested_options_fw()](PushAttrs::nested_options_fw)\n- [.nested_options_gred()](PushAttrs::nested_options_gred)\n- [.nested_options_hfsc()](PushAttrs::nested_options_hfsc)\n- [.nested_options_hhf()](PushAttrs::nested_options_hhf)\n- [.nested_options_htb()](PushAttrs::nested_options_htb)\n- [.nested_options_ingress()](PushAttrs::nested_options_ingress)\n- [.nested_options_matchall()](PushAttrs::nested_options_matchall)\n- [.nested_options_mq()](PushAttrs::nested_options_mq)\n- [.nested_options_mqprio()](PushAttrs::nested_options_mqprio)\n- [.nested_options_multiq()](PushAttrs::nested_options_multiq)\n- [.nested_options_netem()](PushAttrs::nested_options_netem)\n- [.nested_options_pfifo()](PushAttrs::nested_options_pfifo)\n- [.nested_options_pfifo_fast()](PushAttrs::nested_options_pfifo_fast)\n- [.nested_options_pfifo_head_drop()](PushAttrs::nested_options_pfifo_head_drop)\n- [.nested_options_pie()](PushAttrs::nested_options_pie)\n- [.nested_options_plug()](PushAttrs::nested_options_plug)\n- [.nested_options_prio()](PushAttrs::nested_options_prio)\n- [.nested_options_qfq()](PushAttrs::nested_options_qfq)\n- [.nested_options_red()](PushAttrs::nested_options_red)\n- [.nested_options_route()](PushAttrs::nested_options_route)\n- [.nested_options_sfb()](PushAttrs::nested_options_sfb)\n- [.nested_options_sfq()](PushAttrs::nested_options_sfq)\n- [.nested_options_taprio()](PushAttrs::nested_options_taprio)\n- [.nested_options_tbf()](PushAttrs::nested_options_tbf)\n- [.nested_options_u32()](PushAttrs::nested_options_u32)\n- [.push_rate()](PushAttrs::push_rate)\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_ingress_block()](PushAttrs::push_ingress_block)\n- [.push_egress_block()](PushAttrs::push_egress_block)\n"]
37384#[derive(Debug)]
37385pub struct OpNewqdiscDo<'r> {
37386    request: Request<'r>,
37387}
37388impl<'r> OpNewqdiscDo<'r> {
37389    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37390        Self::write_header(request.buf_mut(), header);
37391        Self { request: request }
37392    }
37393    pub fn encode_request<'buf>(
37394        buf: &'buf mut Vec<u8>,
37395        header: &Tcmsg,
37396    ) -> PushAttrs<&'buf mut Vec<u8>> {
37397        Self::write_header(buf, header);
37398        PushAttrs::new(buf)
37399    }
37400    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37401        PushAttrs::new(self.request.buf_mut())
37402    }
37403    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37404        PushAttrs::new(self.request.buf)
37405    }
37406    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37407        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37408        (
37409            Tcmsg::new_from_slice(header).unwrap_or_default(),
37410            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37411        )
37412    }
37413    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37414        prev.as_rec_mut().extend(header.as_slice());
37415    }
37416}
37417impl NetlinkRequest for OpNewqdiscDo<'_> {
37418    fn protocol(&self) -> Protocol {
37419        Protocol::Raw {
37420            protonum: 0u16,
37421            request_type: 36u16,
37422        }
37423    }
37424    fn flags(&self) -> u16 {
37425        self.request.flags
37426    }
37427    fn payload(&self) -> &[u8] {
37428        self.request.buf()
37429    }
37430    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37431    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37432        Self::decode_request(buf)
37433    }
37434    fn lookup(
37435        buf: &[u8],
37436        offset: usize,
37437        missing_type: Option<u16>,
37438    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37439        Self::decode_request(buf)
37440            .1
37441            .lookup_attr(offset, missing_type)
37442    }
37443}
37444#[doc = "Delete existing tc qdisc\\.\n"]
37445#[derive(Debug)]
37446pub struct OpDelqdiscDo<'r> {
37447    request: Request<'r>,
37448}
37449impl<'r> OpDelqdiscDo<'r> {
37450    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37451        Self::write_header(request.buf_mut(), header);
37452        Self { request: request }
37453    }
37454    pub fn encode_request<'buf>(
37455        buf: &'buf mut Vec<u8>,
37456        header: &Tcmsg,
37457    ) -> PushAttrs<&'buf mut Vec<u8>> {
37458        Self::write_header(buf, header);
37459        PushAttrs::new(buf)
37460    }
37461    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37462        PushAttrs::new(self.request.buf_mut())
37463    }
37464    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37465        PushAttrs::new(self.request.buf)
37466    }
37467    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37468        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37469        (
37470            Tcmsg::new_from_slice(header).unwrap_or_default(),
37471            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37472        )
37473    }
37474    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37475        prev.as_rec_mut().extend(header.as_slice());
37476    }
37477}
37478impl NetlinkRequest for OpDelqdiscDo<'_> {
37479    fn protocol(&self) -> Protocol {
37480        Protocol::Raw {
37481            protonum: 0u16,
37482            request_type: 37u16,
37483        }
37484    }
37485    fn flags(&self) -> u16 {
37486        self.request.flags
37487    }
37488    fn payload(&self) -> &[u8] {
37489        self.request.buf()
37490    }
37491    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37492    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37493        Self::decode_request(buf)
37494    }
37495    fn lookup(
37496        buf: &[u8],
37497        offset: usize,
37498        missing_type: Option<u16>,
37499    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37500        Self::decode_request(buf)
37501            .1
37502            .lookup_attr(offset, missing_type)
37503    }
37504}
37505#[doc = "Get / dump tc qdisc information\\.\nRequest attributes:\n- [.push_dump_invisible()](PushAttrs::push_dump_invisible)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
37506#[derive(Debug)]
37507pub struct OpGetqdiscDump<'r> {
37508    request: Request<'r>,
37509}
37510impl<'r> OpGetqdiscDump<'r> {
37511    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37512        Self::write_header(request.buf_mut(), header);
37513        Self {
37514            request: request.set_dump(),
37515        }
37516    }
37517    pub fn encode_request<'buf>(
37518        buf: &'buf mut Vec<u8>,
37519        header: &Tcmsg,
37520    ) -> PushAttrs<&'buf mut Vec<u8>> {
37521        Self::write_header(buf, header);
37522        PushAttrs::new(buf)
37523    }
37524    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37525        PushAttrs::new(self.request.buf_mut())
37526    }
37527    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37528        PushAttrs::new(self.request.buf)
37529    }
37530    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37531        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37532        (
37533            Tcmsg::new_from_slice(header).unwrap_or_default(),
37534            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37535        )
37536    }
37537    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37538        prev.as_rec_mut().extend(header.as_slice());
37539    }
37540}
37541impl NetlinkRequest for OpGetqdiscDump<'_> {
37542    fn protocol(&self) -> Protocol {
37543        Protocol::Raw {
37544            protonum: 0u16,
37545            request_type: 38u16,
37546        }
37547    }
37548    fn flags(&self) -> u16 {
37549        self.request.flags
37550    }
37551    fn payload(&self) -> &[u8] {
37552        self.request.buf()
37553    }
37554    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37555    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37556        Self::decode_request(buf)
37557    }
37558    fn lookup(
37559        buf: &[u8],
37560        offset: usize,
37561        missing_type: Option<u16>,
37562    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37563        Self::decode_request(buf)
37564            .1
37565            .lookup_attr(offset, missing_type)
37566    }
37567}
37568#[doc = "Get / dump tc qdisc information\\.\nRequest attributes:\n- [.push_dump_invisible()](PushAttrs::push_dump_invisible)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
37569#[derive(Debug)]
37570pub struct OpGetqdiscDo<'r> {
37571    request: Request<'r>,
37572}
37573impl<'r> OpGetqdiscDo<'r> {
37574    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37575        Self::write_header(request.buf_mut(), header);
37576        Self { request: request }
37577    }
37578    pub fn encode_request<'buf>(
37579        buf: &'buf mut Vec<u8>,
37580        header: &Tcmsg,
37581    ) -> PushAttrs<&'buf mut Vec<u8>> {
37582        Self::write_header(buf, header);
37583        PushAttrs::new(buf)
37584    }
37585    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37586        PushAttrs::new(self.request.buf_mut())
37587    }
37588    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37589        PushAttrs::new(self.request.buf)
37590    }
37591    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37592        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37593        (
37594            Tcmsg::new_from_slice(header).unwrap_or_default(),
37595            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37596        )
37597    }
37598    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37599        prev.as_rec_mut().extend(header.as_slice());
37600    }
37601}
37602impl NetlinkRequest for OpGetqdiscDo<'_> {
37603    fn protocol(&self) -> Protocol {
37604        Protocol::Raw {
37605            protonum: 0u16,
37606            request_type: 38u16,
37607        }
37608    }
37609    fn flags(&self) -> u16 {
37610        self.request.flags
37611    }
37612    fn payload(&self) -> &[u8] {
37613        self.request.buf()
37614    }
37615    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37616    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37617        Self::decode_request(buf)
37618    }
37619    fn lookup(
37620        buf: &[u8],
37621        offset: usize,
37622        missing_type: Option<u16>,
37623    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37624        Self::decode_request(buf)
37625            .1
37626            .lookup_attr(offset, missing_type)
37627    }
37628}
37629#[doc = "Get / dump tc traffic class information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.nested_options_basic()](PushAttrs::nested_options_basic)\n- [.nested_options_bpf()](PushAttrs::nested_options_bpf)\n- [.nested_options_bfifo()](PushAttrs::nested_options_bfifo)\n- [.nested_options_cake()](PushAttrs::nested_options_cake)\n- [.nested_options_cbs()](PushAttrs::nested_options_cbs)\n- [.nested_options_cgroup()](PushAttrs::nested_options_cgroup)\n- [.nested_options_choke()](PushAttrs::nested_options_choke)\n- [.nested_options_clsact()](PushAttrs::nested_options_clsact)\n- [.nested_options_codel()](PushAttrs::nested_options_codel)\n- [.nested_options_drr()](PushAttrs::nested_options_drr)\n- [.nested_options_dualpi2()](PushAttrs::nested_options_dualpi2)\n- [.nested_options_etf()](PushAttrs::nested_options_etf)\n- [.nested_options_ets()](PushAttrs::nested_options_ets)\n- [.nested_options_flow()](PushAttrs::nested_options_flow)\n- [.nested_options_flower()](PushAttrs::nested_options_flower)\n- [.nested_options_fq()](PushAttrs::nested_options_fq)\n- [.nested_options_fq_codel()](PushAttrs::nested_options_fq_codel)\n- [.nested_options_fq_pie()](PushAttrs::nested_options_fq_pie)\n- [.nested_options_fw()](PushAttrs::nested_options_fw)\n- [.nested_options_gred()](PushAttrs::nested_options_gred)\n- [.nested_options_hfsc()](PushAttrs::nested_options_hfsc)\n- [.nested_options_hhf()](PushAttrs::nested_options_hhf)\n- [.nested_options_htb()](PushAttrs::nested_options_htb)\n- [.nested_options_ingress()](PushAttrs::nested_options_ingress)\n- [.nested_options_matchall()](PushAttrs::nested_options_matchall)\n- [.nested_options_mq()](PushAttrs::nested_options_mq)\n- [.nested_options_mqprio()](PushAttrs::nested_options_mqprio)\n- [.nested_options_multiq()](PushAttrs::nested_options_multiq)\n- [.nested_options_netem()](PushAttrs::nested_options_netem)\n- [.nested_options_pfifo()](PushAttrs::nested_options_pfifo)\n- [.nested_options_pfifo_fast()](PushAttrs::nested_options_pfifo_fast)\n- [.nested_options_pfifo_head_drop()](PushAttrs::nested_options_pfifo_head_drop)\n- [.nested_options_pie()](PushAttrs::nested_options_pie)\n- [.nested_options_plug()](PushAttrs::nested_options_plug)\n- [.nested_options_prio()](PushAttrs::nested_options_prio)\n- [.nested_options_qfq()](PushAttrs::nested_options_qfq)\n- [.nested_options_red()](PushAttrs::nested_options_red)\n- [.nested_options_route()](PushAttrs::nested_options_route)\n- [.nested_options_sfb()](PushAttrs::nested_options_sfb)\n- [.nested_options_sfq()](PushAttrs::nested_options_sfq)\n- [.nested_options_taprio()](PushAttrs::nested_options_taprio)\n- [.nested_options_tbf()](PushAttrs::nested_options_tbf)\n- [.nested_options_u32()](PushAttrs::nested_options_u32)\n- [.push_rate()](PushAttrs::push_rate)\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_ingress_block()](PushAttrs::push_ingress_block)\n- [.push_egress_block()](PushAttrs::push_egress_block)\n"]
37630#[derive(Debug)]
37631pub struct OpNewtclassDo<'r> {
37632    request: Request<'r>,
37633}
37634impl<'r> OpNewtclassDo<'r> {
37635    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37636        Self::write_header(request.buf_mut(), header);
37637        Self { request: request }
37638    }
37639    pub fn encode_request<'buf>(
37640        buf: &'buf mut Vec<u8>,
37641        header: &Tcmsg,
37642    ) -> PushAttrs<&'buf mut Vec<u8>> {
37643        Self::write_header(buf, header);
37644        PushAttrs::new(buf)
37645    }
37646    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37647        PushAttrs::new(self.request.buf_mut())
37648    }
37649    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37650        PushAttrs::new(self.request.buf)
37651    }
37652    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37653        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37654        (
37655            Tcmsg::new_from_slice(header).unwrap_or_default(),
37656            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37657        )
37658    }
37659    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37660        prev.as_rec_mut().extend(header.as_slice());
37661    }
37662}
37663impl NetlinkRequest for OpNewtclassDo<'_> {
37664    fn protocol(&self) -> Protocol {
37665        Protocol::Raw {
37666            protonum: 0u16,
37667            request_type: 40u16,
37668        }
37669    }
37670    fn flags(&self) -> u16 {
37671        self.request.flags
37672    }
37673    fn payload(&self) -> &[u8] {
37674        self.request.buf()
37675    }
37676    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37677    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37678        Self::decode_request(buf)
37679    }
37680    fn lookup(
37681        buf: &[u8],
37682        offset: usize,
37683        missing_type: Option<u16>,
37684    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37685        Self::decode_request(buf)
37686            .1
37687            .lookup_attr(offset, missing_type)
37688    }
37689}
37690#[doc = "Get / dump tc traffic class information\\.\n"]
37691#[derive(Debug)]
37692pub struct OpDeltclassDo<'r> {
37693    request: Request<'r>,
37694}
37695impl<'r> OpDeltclassDo<'r> {
37696    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37697        Self::write_header(request.buf_mut(), header);
37698        Self { request: request }
37699    }
37700    pub fn encode_request<'buf>(
37701        buf: &'buf mut Vec<u8>,
37702        header: &Tcmsg,
37703    ) -> PushAttrs<&'buf mut Vec<u8>> {
37704        Self::write_header(buf, header);
37705        PushAttrs::new(buf)
37706    }
37707    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37708        PushAttrs::new(self.request.buf_mut())
37709    }
37710    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37711        PushAttrs::new(self.request.buf)
37712    }
37713    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37714        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37715        (
37716            Tcmsg::new_from_slice(header).unwrap_or_default(),
37717            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37718        )
37719    }
37720    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37721        prev.as_rec_mut().extend(header.as_slice());
37722    }
37723}
37724impl NetlinkRequest for OpDeltclassDo<'_> {
37725    fn protocol(&self) -> Protocol {
37726        Protocol::Raw {
37727            protonum: 0u16,
37728            request_type: 41u16,
37729        }
37730    }
37731    fn flags(&self) -> u16 {
37732        self.request.flags
37733    }
37734    fn payload(&self) -> &[u8] {
37735        self.request.buf()
37736    }
37737    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37738    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37739        Self::decode_request(buf)
37740    }
37741    fn lookup(
37742        buf: &[u8],
37743        offset: usize,
37744        missing_type: Option<u16>,
37745    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37746        Self::decode_request(buf)
37747            .1
37748            .lookup_attr(offset, missing_type)
37749    }
37750}
37751#[doc = "Get / dump tc traffic class information\\.\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
37752#[derive(Debug)]
37753pub struct OpGettclassDo<'r> {
37754    request: Request<'r>,
37755}
37756impl<'r> OpGettclassDo<'r> {
37757    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37758        Self::write_header(request.buf_mut(), header);
37759        Self { request: request }
37760    }
37761    pub fn encode_request<'buf>(
37762        buf: &'buf mut Vec<u8>,
37763        header: &Tcmsg,
37764    ) -> PushAttrs<&'buf mut Vec<u8>> {
37765        Self::write_header(buf, header);
37766        PushAttrs::new(buf)
37767    }
37768    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37769        PushAttrs::new(self.request.buf_mut())
37770    }
37771    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37772        PushAttrs::new(self.request.buf)
37773    }
37774    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37775        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37776        (
37777            Tcmsg::new_from_slice(header).unwrap_or_default(),
37778            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37779        )
37780    }
37781    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37782        prev.as_rec_mut().extend(header.as_slice());
37783    }
37784}
37785impl NetlinkRequest for OpGettclassDo<'_> {
37786    fn protocol(&self) -> Protocol {
37787        Protocol::Raw {
37788            protonum: 0u16,
37789            request_type: 42u16,
37790        }
37791    }
37792    fn flags(&self) -> u16 {
37793        self.request.flags
37794    }
37795    fn payload(&self) -> &[u8] {
37796        self.request.buf()
37797    }
37798    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37799    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37800        Self::decode_request(buf)
37801    }
37802    fn lookup(
37803        buf: &[u8],
37804        offset: usize,
37805        missing_type: Option<u16>,
37806    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37807        Self::decode_request(buf)
37808            .1
37809            .lookup_attr(offset, missing_type)
37810    }
37811}
37812#[doc = "Get / dump tc filter information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.nested_options_basic()](PushAttrs::nested_options_basic)\n- [.nested_options_bpf()](PushAttrs::nested_options_bpf)\n- [.nested_options_bfifo()](PushAttrs::nested_options_bfifo)\n- [.nested_options_cake()](PushAttrs::nested_options_cake)\n- [.nested_options_cbs()](PushAttrs::nested_options_cbs)\n- [.nested_options_cgroup()](PushAttrs::nested_options_cgroup)\n- [.nested_options_choke()](PushAttrs::nested_options_choke)\n- [.nested_options_clsact()](PushAttrs::nested_options_clsact)\n- [.nested_options_codel()](PushAttrs::nested_options_codel)\n- [.nested_options_drr()](PushAttrs::nested_options_drr)\n- [.nested_options_dualpi2()](PushAttrs::nested_options_dualpi2)\n- [.nested_options_etf()](PushAttrs::nested_options_etf)\n- [.nested_options_ets()](PushAttrs::nested_options_ets)\n- [.nested_options_flow()](PushAttrs::nested_options_flow)\n- [.nested_options_flower()](PushAttrs::nested_options_flower)\n- [.nested_options_fq()](PushAttrs::nested_options_fq)\n- [.nested_options_fq_codel()](PushAttrs::nested_options_fq_codel)\n- [.nested_options_fq_pie()](PushAttrs::nested_options_fq_pie)\n- [.nested_options_fw()](PushAttrs::nested_options_fw)\n- [.nested_options_gred()](PushAttrs::nested_options_gred)\n- [.nested_options_hfsc()](PushAttrs::nested_options_hfsc)\n- [.nested_options_hhf()](PushAttrs::nested_options_hhf)\n- [.nested_options_htb()](PushAttrs::nested_options_htb)\n- [.nested_options_ingress()](PushAttrs::nested_options_ingress)\n- [.nested_options_matchall()](PushAttrs::nested_options_matchall)\n- [.nested_options_mq()](PushAttrs::nested_options_mq)\n- [.nested_options_mqprio()](PushAttrs::nested_options_mqprio)\n- [.nested_options_multiq()](PushAttrs::nested_options_multiq)\n- [.nested_options_netem()](PushAttrs::nested_options_netem)\n- [.nested_options_pfifo()](PushAttrs::nested_options_pfifo)\n- [.nested_options_pfifo_fast()](PushAttrs::nested_options_pfifo_fast)\n- [.nested_options_pfifo_head_drop()](PushAttrs::nested_options_pfifo_head_drop)\n- [.nested_options_pie()](PushAttrs::nested_options_pie)\n- [.nested_options_plug()](PushAttrs::nested_options_plug)\n- [.nested_options_prio()](PushAttrs::nested_options_prio)\n- [.nested_options_qfq()](PushAttrs::nested_options_qfq)\n- [.nested_options_red()](PushAttrs::nested_options_red)\n- [.nested_options_route()](PushAttrs::nested_options_route)\n- [.nested_options_sfb()](PushAttrs::nested_options_sfb)\n- [.nested_options_sfq()](PushAttrs::nested_options_sfq)\n- [.nested_options_taprio()](PushAttrs::nested_options_taprio)\n- [.nested_options_tbf()](PushAttrs::nested_options_tbf)\n- [.nested_options_u32()](PushAttrs::nested_options_u32)\n- [.push_rate()](PushAttrs::push_rate)\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_ingress_block()](PushAttrs::push_ingress_block)\n- [.push_egress_block()](PushAttrs::push_egress_block)\n"]
37813#[derive(Debug)]
37814pub struct OpNewtfilterDo<'r> {
37815    request: Request<'r>,
37816}
37817impl<'r> OpNewtfilterDo<'r> {
37818    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37819        Self::write_header(request.buf_mut(), header);
37820        Self { request: request }
37821    }
37822    pub fn encode_request<'buf>(
37823        buf: &'buf mut Vec<u8>,
37824        header: &Tcmsg,
37825    ) -> PushAttrs<&'buf mut Vec<u8>> {
37826        Self::write_header(buf, header);
37827        PushAttrs::new(buf)
37828    }
37829    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37830        PushAttrs::new(self.request.buf_mut())
37831    }
37832    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37833        PushAttrs::new(self.request.buf)
37834    }
37835    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37836        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37837        (
37838            Tcmsg::new_from_slice(header).unwrap_or_default(),
37839            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37840        )
37841    }
37842    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37843        prev.as_rec_mut().extend(header.as_slice());
37844    }
37845}
37846impl NetlinkRequest for OpNewtfilterDo<'_> {
37847    fn protocol(&self) -> Protocol {
37848        Protocol::Raw {
37849            protonum: 0u16,
37850            request_type: 44u16,
37851        }
37852    }
37853    fn flags(&self) -> u16 {
37854        self.request.flags
37855    }
37856    fn payload(&self) -> &[u8] {
37857        self.request.buf()
37858    }
37859    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37860    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37861        Self::decode_request(buf)
37862    }
37863    fn lookup(
37864        buf: &[u8],
37865        offset: usize,
37866        missing_type: Option<u16>,
37867    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37868        Self::decode_request(buf)
37869            .1
37870            .lookup_attr(offset, missing_type)
37871    }
37872}
37873#[doc = "Get / dump tc filter information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.push_chain()](PushAttrs::push_chain)\n"]
37874#[derive(Debug)]
37875pub struct OpDeltfilterDo<'r> {
37876    request: Request<'r>,
37877}
37878impl<'r> OpDeltfilterDo<'r> {
37879    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37880        Self::write_header(request.buf_mut(), header);
37881        Self { request: request }
37882    }
37883    pub fn encode_request<'buf>(
37884        buf: &'buf mut Vec<u8>,
37885        header: &Tcmsg,
37886    ) -> PushAttrs<&'buf mut Vec<u8>> {
37887        Self::write_header(buf, header);
37888        PushAttrs::new(buf)
37889    }
37890    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37891        PushAttrs::new(self.request.buf_mut())
37892    }
37893    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37894        PushAttrs::new(self.request.buf)
37895    }
37896    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37897        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37898        (
37899            Tcmsg::new_from_slice(header).unwrap_or_default(),
37900            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37901        )
37902    }
37903    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37904        prev.as_rec_mut().extend(header.as_slice());
37905    }
37906}
37907impl NetlinkRequest for OpDeltfilterDo<'_> {
37908    fn protocol(&self) -> Protocol {
37909        Protocol::Raw {
37910            protonum: 0u16,
37911            request_type: 45u16,
37912        }
37913    }
37914    fn flags(&self) -> u16 {
37915        self.request.flags
37916    }
37917    fn payload(&self) -> &[u8] {
37918        self.request.buf()
37919    }
37920    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37921    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37922        Self::decode_request(buf)
37923    }
37924    fn lookup(
37925        buf: &[u8],
37926        offset: usize,
37927        missing_type: Option<u16>,
37928    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37929        Self::decode_request(buf)
37930            .1
37931            .lookup_attr(offset, missing_type)
37932    }
37933}
37934#[doc = "Get / dump tc filter information\\.\nRequest attributes:\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_dump_flags()](PushAttrs::push_dump_flags)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
37935#[derive(Debug)]
37936pub struct OpGettfilterDump<'r> {
37937    request: Request<'r>,
37938}
37939impl<'r> OpGettfilterDump<'r> {
37940    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
37941        Self::write_header(request.buf_mut(), header);
37942        Self {
37943            request: request.set_dump(),
37944        }
37945    }
37946    pub fn encode_request<'buf>(
37947        buf: &'buf mut Vec<u8>,
37948        header: &Tcmsg,
37949    ) -> PushAttrs<&'buf mut Vec<u8>> {
37950        Self::write_header(buf, header);
37951        PushAttrs::new(buf)
37952    }
37953    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
37954        PushAttrs::new(self.request.buf_mut())
37955    }
37956    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
37957        PushAttrs::new(self.request.buf)
37958    }
37959    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
37960        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
37961        (
37962            Tcmsg::new_from_slice(header).unwrap_or_default(),
37963            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
37964        )
37965    }
37966    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
37967        prev.as_rec_mut().extend(header.as_slice());
37968    }
37969}
37970impl NetlinkRequest for OpGettfilterDump<'_> {
37971    fn protocol(&self) -> Protocol {
37972        Protocol::Raw {
37973            protonum: 0u16,
37974            request_type: 46u16,
37975        }
37976    }
37977    fn flags(&self) -> u16 {
37978        self.request.flags
37979    }
37980    fn payload(&self) -> &[u8] {
37981        self.request.buf()
37982    }
37983    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
37984    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
37985        Self::decode_request(buf)
37986    }
37987    fn lookup(
37988        buf: &[u8],
37989        offset: usize,
37990        missing_type: Option<u16>,
37991    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
37992        Self::decode_request(buf)
37993            .1
37994            .lookup_attr(offset, missing_type)
37995    }
37996}
37997#[doc = "Get / dump tc filter information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.push_chain()](PushAttrs::push_chain)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
37998#[derive(Debug)]
37999pub struct OpGettfilterDo<'r> {
38000    request: Request<'r>,
38001}
38002impl<'r> OpGettfilterDo<'r> {
38003    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
38004        Self::write_header(request.buf_mut(), header);
38005        Self { request: request }
38006    }
38007    pub fn encode_request<'buf>(
38008        buf: &'buf mut Vec<u8>,
38009        header: &Tcmsg,
38010    ) -> PushAttrs<&'buf mut Vec<u8>> {
38011        Self::write_header(buf, header);
38012        PushAttrs::new(buf)
38013    }
38014    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
38015        PushAttrs::new(self.request.buf_mut())
38016    }
38017    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
38018        PushAttrs::new(self.request.buf)
38019    }
38020    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
38021        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
38022        (
38023            Tcmsg::new_from_slice(header).unwrap_or_default(),
38024            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
38025        )
38026    }
38027    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
38028        prev.as_rec_mut().extend(header.as_slice());
38029    }
38030}
38031impl NetlinkRequest for OpGettfilterDo<'_> {
38032    fn protocol(&self) -> Protocol {
38033        Protocol::Raw {
38034            protonum: 0u16,
38035            request_type: 46u16,
38036        }
38037    }
38038    fn flags(&self) -> u16 {
38039        self.request.flags
38040    }
38041    fn payload(&self) -> &[u8] {
38042        self.request.buf()
38043    }
38044    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
38045    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
38046        Self::decode_request(buf)
38047    }
38048    fn lookup(
38049        buf: &[u8],
38050        offset: usize,
38051        missing_type: Option<u16>,
38052    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
38053        Self::decode_request(buf)
38054            .1
38055            .lookup_attr(offset, missing_type)
38056    }
38057}
38058#[doc = "Get / dump tc chain information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.nested_options_basic()](PushAttrs::nested_options_basic)\n- [.nested_options_bpf()](PushAttrs::nested_options_bpf)\n- [.nested_options_bfifo()](PushAttrs::nested_options_bfifo)\n- [.nested_options_cake()](PushAttrs::nested_options_cake)\n- [.nested_options_cbs()](PushAttrs::nested_options_cbs)\n- [.nested_options_cgroup()](PushAttrs::nested_options_cgroup)\n- [.nested_options_choke()](PushAttrs::nested_options_choke)\n- [.nested_options_clsact()](PushAttrs::nested_options_clsact)\n- [.nested_options_codel()](PushAttrs::nested_options_codel)\n- [.nested_options_drr()](PushAttrs::nested_options_drr)\n- [.nested_options_dualpi2()](PushAttrs::nested_options_dualpi2)\n- [.nested_options_etf()](PushAttrs::nested_options_etf)\n- [.nested_options_ets()](PushAttrs::nested_options_ets)\n- [.nested_options_flow()](PushAttrs::nested_options_flow)\n- [.nested_options_flower()](PushAttrs::nested_options_flower)\n- [.nested_options_fq()](PushAttrs::nested_options_fq)\n- [.nested_options_fq_codel()](PushAttrs::nested_options_fq_codel)\n- [.nested_options_fq_pie()](PushAttrs::nested_options_fq_pie)\n- [.nested_options_fw()](PushAttrs::nested_options_fw)\n- [.nested_options_gred()](PushAttrs::nested_options_gred)\n- [.nested_options_hfsc()](PushAttrs::nested_options_hfsc)\n- [.nested_options_hhf()](PushAttrs::nested_options_hhf)\n- [.nested_options_htb()](PushAttrs::nested_options_htb)\n- [.nested_options_ingress()](PushAttrs::nested_options_ingress)\n- [.nested_options_matchall()](PushAttrs::nested_options_matchall)\n- [.nested_options_mq()](PushAttrs::nested_options_mq)\n- [.nested_options_mqprio()](PushAttrs::nested_options_mqprio)\n- [.nested_options_multiq()](PushAttrs::nested_options_multiq)\n- [.nested_options_netem()](PushAttrs::nested_options_netem)\n- [.nested_options_pfifo()](PushAttrs::nested_options_pfifo)\n- [.nested_options_pfifo_fast()](PushAttrs::nested_options_pfifo_fast)\n- [.nested_options_pfifo_head_drop()](PushAttrs::nested_options_pfifo_head_drop)\n- [.nested_options_pie()](PushAttrs::nested_options_pie)\n- [.nested_options_plug()](PushAttrs::nested_options_plug)\n- [.nested_options_prio()](PushAttrs::nested_options_prio)\n- [.nested_options_qfq()](PushAttrs::nested_options_qfq)\n- [.nested_options_red()](PushAttrs::nested_options_red)\n- [.nested_options_route()](PushAttrs::nested_options_route)\n- [.nested_options_sfb()](PushAttrs::nested_options_sfb)\n- [.nested_options_sfq()](PushAttrs::nested_options_sfq)\n- [.nested_options_taprio()](PushAttrs::nested_options_taprio)\n- [.nested_options_tbf()](PushAttrs::nested_options_tbf)\n- [.nested_options_u32()](PushAttrs::nested_options_u32)\n- [.push_rate()](PushAttrs::push_rate)\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_ingress_block()](PushAttrs::push_ingress_block)\n- [.push_egress_block()](PushAttrs::push_egress_block)\n"]
38059#[derive(Debug)]
38060pub struct OpNewchainDo<'r> {
38061    request: Request<'r>,
38062}
38063impl<'r> OpNewchainDo<'r> {
38064    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
38065        Self::write_header(request.buf_mut(), header);
38066        Self { request: request }
38067    }
38068    pub fn encode_request<'buf>(
38069        buf: &'buf mut Vec<u8>,
38070        header: &Tcmsg,
38071    ) -> PushAttrs<&'buf mut Vec<u8>> {
38072        Self::write_header(buf, header);
38073        PushAttrs::new(buf)
38074    }
38075    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
38076        PushAttrs::new(self.request.buf_mut())
38077    }
38078    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
38079        PushAttrs::new(self.request.buf)
38080    }
38081    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
38082        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
38083        (
38084            Tcmsg::new_from_slice(header).unwrap_or_default(),
38085            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
38086        )
38087    }
38088    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
38089        prev.as_rec_mut().extend(header.as_slice());
38090    }
38091}
38092impl NetlinkRequest for OpNewchainDo<'_> {
38093    fn protocol(&self) -> Protocol {
38094        Protocol::Raw {
38095            protonum: 0u16,
38096            request_type: 100u16,
38097        }
38098    }
38099    fn flags(&self) -> u16 {
38100        self.request.flags
38101    }
38102    fn payload(&self) -> &[u8] {
38103        self.request.buf()
38104    }
38105    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
38106    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
38107        Self::decode_request(buf)
38108    }
38109    fn lookup(
38110        buf: &[u8],
38111        offset: usize,
38112        missing_type: Option<u16>,
38113    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
38114        Self::decode_request(buf)
38115            .1
38116            .lookup_attr(offset, missing_type)
38117    }
38118}
38119#[doc = "Get / dump tc chain information\\.\nRequest attributes:\n- [.push_chain()](PushAttrs::push_chain)\n"]
38120#[derive(Debug)]
38121pub struct OpDelchainDo<'r> {
38122    request: Request<'r>,
38123}
38124impl<'r> OpDelchainDo<'r> {
38125    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
38126        Self::write_header(request.buf_mut(), header);
38127        Self { request: request }
38128    }
38129    pub fn encode_request<'buf>(
38130        buf: &'buf mut Vec<u8>,
38131        header: &Tcmsg,
38132    ) -> PushAttrs<&'buf mut Vec<u8>> {
38133        Self::write_header(buf, header);
38134        PushAttrs::new(buf)
38135    }
38136    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
38137        PushAttrs::new(self.request.buf_mut())
38138    }
38139    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
38140        PushAttrs::new(self.request.buf)
38141    }
38142    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
38143        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
38144        (
38145            Tcmsg::new_from_slice(header).unwrap_or_default(),
38146            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
38147        )
38148    }
38149    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
38150        prev.as_rec_mut().extend(header.as_slice());
38151    }
38152}
38153impl NetlinkRequest for OpDelchainDo<'_> {
38154    fn protocol(&self) -> Protocol {
38155        Protocol::Raw {
38156            protonum: 0u16,
38157            request_type: 101u16,
38158        }
38159    }
38160    fn flags(&self) -> u16 {
38161        self.request.flags
38162    }
38163    fn payload(&self) -> &[u8] {
38164        self.request.buf()
38165    }
38166    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
38167    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
38168        Self::decode_request(buf)
38169    }
38170    fn lookup(
38171        buf: &[u8],
38172        offset: usize,
38173        missing_type: Option<u16>,
38174    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
38175        Self::decode_request(buf)
38176            .1
38177            .lookup_attr(offset, missing_type)
38178    }
38179}
38180#[doc = "Get / dump tc chain information\\.\nRequest attributes:\n- [.push_chain()](PushAttrs::push_chain)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
38181#[derive(Debug)]
38182pub struct OpGetchainDo<'r> {
38183    request: Request<'r>,
38184}
38185impl<'r> OpGetchainDo<'r> {
38186    pub fn new(mut request: Request<'r>, header: &Tcmsg) -> Self {
38187        Self::write_header(request.buf_mut(), header);
38188        Self { request: request }
38189    }
38190    pub fn encode_request<'buf>(
38191        buf: &'buf mut Vec<u8>,
38192        header: &Tcmsg,
38193    ) -> PushAttrs<&'buf mut Vec<u8>> {
38194        Self::write_header(buf, header);
38195        PushAttrs::new(buf)
38196    }
38197    pub fn encode(&mut self) -> PushAttrs<&mut Vec<u8>> {
38198        PushAttrs::new(self.request.buf_mut())
38199    }
38200    pub fn into_encoder(self) -> PushAttrs<RequestBuf<'r>> {
38201        PushAttrs::new(self.request.buf)
38202    }
38203    pub fn decode_request<'a>(buf: &'a [u8]) -> (Tcmsg, IterableAttrs<'a>) {
38204        let (header, attrs) = buf.split_at(buf.len().min(Tcmsg::len()));
38205        (
38206            Tcmsg::new_from_slice(header).unwrap_or_default(),
38207            IterableAttrs::with_loc(attrs, buf.as_ptr() as usize),
38208        )
38209    }
38210    fn write_header<Prev: Rec>(prev: &mut Prev, header: &Tcmsg) {
38211        prev.as_rec_mut().extend(header.as_slice());
38212    }
38213}
38214impl NetlinkRequest for OpGetchainDo<'_> {
38215    fn protocol(&self) -> Protocol {
38216        Protocol::Raw {
38217            protonum: 0u16,
38218            request_type: 102u16,
38219        }
38220    }
38221    fn flags(&self) -> u16 {
38222        self.request.flags
38223    }
38224    fn payload(&self) -> &[u8] {
38225        self.request.buf()
38226    }
38227    type ReplyType<'buf> = (Tcmsg, IterableAttrs<'buf>);
38228    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
38229        Self::decode_request(buf)
38230    }
38231    fn lookup(
38232        buf: &[u8],
38233        offset: usize,
38234        missing_type: Option<u16>,
38235    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
38236        Self::decode_request(buf)
38237            .1
38238            .lookup_attr(offset, missing_type)
38239    }
38240}
38241#[derive(Debug)]
38242pub struct ChainedFinal<'a> {
38243    inner: Chained<'a>,
38244}
38245#[derive(Debug)]
38246pub struct Chained<'a> {
38247    buf: RequestBuf<'a>,
38248    first_seq: u32,
38249    lookups: Vec<(&'static str, LookupFn)>,
38250    last_header_offset: usize,
38251    last_kind: Option<RequestInfo>,
38252}
38253impl<'a> ChainedFinal<'a> {
38254    pub fn into_chained(self) -> Chained<'a> {
38255        self.inner
38256    }
38257    pub fn buf(&self) -> &Vec<u8> {
38258        self.inner.buf()
38259    }
38260    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
38261        self.inner.buf_mut()
38262    }
38263    fn get_index(&self, seq: u32) -> Option<u32> {
38264        let min = self.inner.first_seq;
38265        let max = min.wrapping_add(self.inner.lookups.len() as u32);
38266        return if min <= max {
38267            (min..max).contains(&seq).then(|| seq - min)
38268        } else if min <= seq {
38269            Some(seq - min)
38270        } else if seq < max {
38271            Some(u32::MAX - min + seq)
38272        } else {
38273            None
38274        };
38275    }
38276}
38277impl crate::traits::NetlinkChained for ChainedFinal<'_> {
38278    fn protonum(&self) -> u16 {
38279        PROTONUM
38280    }
38281    fn payload(&self) -> &[u8] {
38282        self.buf()
38283    }
38284    fn chain_len(&self) -> usize {
38285        self.inner.lookups.len()
38286    }
38287    fn get_index(&self, seq: u32) -> Option<usize> {
38288        self.get_index(seq).map(|n| n as usize)
38289    }
38290    fn name(&self, index: usize) -> &'static str {
38291        self.inner.lookups[index].0
38292    }
38293    fn lookup(&self, index: usize) -> LookupFn {
38294        self.inner.lookups[index].1
38295    }
38296}
38297impl Chained<'static> {
38298    pub fn new(first_seq: u32) -> Self {
38299        Self::new_from_buf(Vec::new(), first_seq)
38300    }
38301    pub fn new_from_buf(buf: Vec<u8>, first_seq: u32) -> Self {
38302        Self {
38303            buf: RequestBuf::Own(buf),
38304            first_seq,
38305            lookups: Vec::new(),
38306            last_header_offset: 0,
38307            last_kind: None,
38308        }
38309    }
38310    pub fn into_buf(self) -> Vec<u8> {
38311        match self.buf {
38312            RequestBuf::Own(buf) => buf,
38313            _ => unreachable!(),
38314        }
38315    }
38316}
38317impl<'a> Chained<'a> {
38318    pub fn new_with_buf(buf: &'a mut Vec<u8>, first_seq: u32) -> Self {
38319        Self {
38320            buf: RequestBuf::Ref(buf),
38321            first_seq,
38322            lookups: Vec::new(),
38323            last_header_offset: 0,
38324            last_kind: None,
38325        }
38326    }
38327    pub fn finalize(mut self) -> ChainedFinal<'a> {
38328        self.update_header();
38329        ChainedFinal { inner: self }
38330    }
38331    pub fn request(&mut self) -> Request<'_> {
38332        self.update_header();
38333        self.last_header_offset = self.buf().len();
38334        self.buf_mut().extend_from_slice(Nlmsghdr::new().as_slice());
38335        let mut request = Request::new_extend(self.buf.buf_mut());
38336        self.last_kind = None;
38337        request.writeback = Some(&mut self.last_kind);
38338        request
38339    }
38340    pub fn buf(&self) -> &Vec<u8> {
38341        self.buf.buf()
38342    }
38343    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
38344        self.buf.buf_mut()
38345    }
38346    fn update_header(&mut self) {
38347        let Some(RequestInfo {
38348            protocol,
38349            flags,
38350            name,
38351            lookup,
38352        }) = self.last_kind
38353        else {
38354            if !self.buf().is_empty() {
38355                assert_eq!(self.last_header_offset + Nlmsghdr::len(), self.buf().len());
38356                self.buf.buf_mut().truncate(self.last_header_offset);
38357            }
38358            return;
38359        };
38360        let header_offset = self.last_header_offset;
38361        let request_type = match protocol {
38362            Protocol::Raw { request_type, .. } => request_type,
38363            Protocol::Generic(_) => unreachable!(),
38364        };
38365        let index = self.lookups.len();
38366        let seq = self.first_seq.wrapping_add(index as u32);
38367        self.lookups.push((name, lookup));
38368        let buf = self.buf_mut();
38369        align(buf);
38370        let header = Nlmsghdr {
38371            len: (buf.len() - header_offset) as u32,
38372            r#type: request_type,
38373            flags: flags | consts::NLM_F_REQUEST as u16 | consts::NLM_F_ACK as u16,
38374            seq,
38375            pid: 0,
38376        };
38377        buf[header_offset..(header_offset + 16)].clone_from_slice(header.as_slice());
38378    }
38379}
38380use crate::traits::LookupFn;
38381use crate::utils::RequestBuf;
38382#[derive(Debug)]
38383pub struct Request<'buf> {
38384    buf: RequestBuf<'buf>,
38385    flags: u16,
38386    writeback: Option<&'buf mut Option<RequestInfo>>,
38387}
38388#[allow(unused)]
38389#[derive(Debug, Clone)]
38390pub struct RequestInfo {
38391    protocol: Protocol,
38392    flags: u16,
38393    name: &'static str,
38394    lookup: LookupFn,
38395}
38396impl Request<'static> {
38397    pub fn new() -> Self {
38398        Self::new_from_buf(Vec::new())
38399    }
38400    pub fn new_from_buf(buf: Vec<u8>) -> Self {
38401        Self {
38402            flags: 0,
38403            buf: RequestBuf::Own(buf),
38404            writeback: None,
38405        }
38406    }
38407    pub fn into_buf(self) -> Vec<u8> {
38408        match self.buf {
38409            RequestBuf::Own(buf) => buf,
38410            _ => unreachable!(),
38411        }
38412    }
38413}
38414impl<'buf> Request<'buf> {
38415    pub fn new_with_buf(buf: &'buf mut Vec<u8>) -> Self {
38416        buf.clear();
38417        Self::new_extend(buf)
38418    }
38419    pub fn new_extend(buf: &'buf mut Vec<u8>) -> Self {
38420        Self {
38421            flags: 0,
38422            buf: RequestBuf::Ref(buf),
38423            writeback: None,
38424        }
38425    }
38426    fn do_writeback(&mut self, protocol: Protocol, name: &'static str, lookup: LookupFn) {
38427        let Some(writeback) = &mut self.writeback else {
38428            return;
38429        };
38430        **writeback = Some(RequestInfo {
38431            protocol,
38432            flags: self.flags,
38433            name,
38434            lookup,
38435        })
38436    }
38437    pub fn buf(&self) -> &Vec<u8> {
38438        self.buf.buf()
38439    }
38440    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
38441        self.buf.buf_mut()
38442    }
38443    #[doc = "Set `NLM_F_CREATE` flag"]
38444    pub fn set_create(mut self) -> Self {
38445        self.flags |= consts::NLM_F_CREATE as u16;
38446        self
38447    }
38448    #[doc = "Set `NLM_F_EXCL` flag"]
38449    pub fn set_excl(mut self) -> Self {
38450        self.flags |= consts::NLM_F_EXCL as u16;
38451        self
38452    }
38453    #[doc = "Set `NLM_F_REPLACE` flag"]
38454    pub fn set_replace(mut self) -> Self {
38455        self.flags |= consts::NLM_F_REPLACE as u16;
38456        self
38457    }
38458    #[doc = "Set `NLM_F_CREATE` and `NLM_F_REPLACE` flag"]
38459    pub fn set_change(self) -> Self {
38460        self.set_create().set_replace()
38461    }
38462    #[doc = "Set `NLM_F_APPEND` flag"]
38463    pub fn set_append(mut self) -> Self {
38464        self.flags |= consts::NLM_F_APPEND as u16;
38465        self
38466    }
38467    #[doc = "Set `self.flags |= flags`"]
38468    pub fn set_flags(mut self, flags: u16) -> Self {
38469        self.flags |= flags;
38470        self
38471    }
38472    #[doc = "Set `self.flags ^= self.flags & flags`"]
38473    pub fn unset_flags(mut self, flags: u16) -> Self {
38474        self.flags ^= self.flags & flags;
38475        self
38476    }
38477    #[doc = "Set `NLM_F_DUMP` flag"]
38478    fn set_dump(mut self) -> Self {
38479        self.flags |= consts::NLM_F_DUMP as u16;
38480        self
38481    }
38482    #[doc = "Create new tc qdisc\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.nested_options_basic()](PushAttrs::nested_options_basic)\n- [.nested_options_bpf()](PushAttrs::nested_options_bpf)\n- [.nested_options_bfifo()](PushAttrs::nested_options_bfifo)\n- [.nested_options_cake()](PushAttrs::nested_options_cake)\n- [.nested_options_cbs()](PushAttrs::nested_options_cbs)\n- [.nested_options_cgroup()](PushAttrs::nested_options_cgroup)\n- [.nested_options_choke()](PushAttrs::nested_options_choke)\n- [.nested_options_clsact()](PushAttrs::nested_options_clsact)\n- [.nested_options_codel()](PushAttrs::nested_options_codel)\n- [.nested_options_drr()](PushAttrs::nested_options_drr)\n- [.nested_options_dualpi2()](PushAttrs::nested_options_dualpi2)\n- [.nested_options_etf()](PushAttrs::nested_options_etf)\n- [.nested_options_ets()](PushAttrs::nested_options_ets)\n- [.nested_options_flow()](PushAttrs::nested_options_flow)\n- [.nested_options_flower()](PushAttrs::nested_options_flower)\n- [.nested_options_fq()](PushAttrs::nested_options_fq)\n- [.nested_options_fq_codel()](PushAttrs::nested_options_fq_codel)\n- [.nested_options_fq_pie()](PushAttrs::nested_options_fq_pie)\n- [.nested_options_fw()](PushAttrs::nested_options_fw)\n- [.nested_options_gred()](PushAttrs::nested_options_gred)\n- [.nested_options_hfsc()](PushAttrs::nested_options_hfsc)\n- [.nested_options_hhf()](PushAttrs::nested_options_hhf)\n- [.nested_options_htb()](PushAttrs::nested_options_htb)\n- [.nested_options_ingress()](PushAttrs::nested_options_ingress)\n- [.nested_options_matchall()](PushAttrs::nested_options_matchall)\n- [.nested_options_mq()](PushAttrs::nested_options_mq)\n- [.nested_options_mqprio()](PushAttrs::nested_options_mqprio)\n- [.nested_options_multiq()](PushAttrs::nested_options_multiq)\n- [.nested_options_netem()](PushAttrs::nested_options_netem)\n- [.nested_options_pfifo()](PushAttrs::nested_options_pfifo)\n- [.nested_options_pfifo_fast()](PushAttrs::nested_options_pfifo_fast)\n- [.nested_options_pfifo_head_drop()](PushAttrs::nested_options_pfifo_head_drop)\n- [.nested_options_pie()](PushAttrs::nested_options_pie)\n- [.nested_options_plug()](PushAttrs::nested_options_plug)\n- [.nested_options_prio()](PushAttrs::nested_options_prio)\n- [.nested_options_qfq()](PushAttrs::nested_options_qfq)\n- [.nested_options_red()](PushAttrs::nested_options_red)\n- [.nested_options_route()](PushAttrs::nested_options_route)\n- [.nested_options_sfb()](PushAttrs::nested_options_sfb)\n- [.nested_options_sfq()](PushAttrs::nested_options_sfq)\n- [.nested_options_taprio()](PushAttrs::nested_options_taprio)\n- [.nested_options_tbf()](PushAttrs::nested_options_tbf)\n- [.nested_options_u32()](PushAttrs::nested_options_u32)\n- [.push_rate()](PushAttrs::push_rate)\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_ingress_block()](PushAttrs::push_ingress_block)\n- [.push_egress_block()](PushAttrs::push_egress_block)\n"]
38483    pub fn op_newqdisc_do(self, header: &Tcmsg) -> OpNewqdiscDo<'buf> {
38484        let mut res = OpNewqdiscDo::new(self, header);
38485        res.request
38486            .do_writeback(res.protocol(), "op-newqdisc-do", OpNewqdiscDo::lookup);
38487        res
38488    }
38489    #[doc = "Delete existing tc qdisc\\.\n"]
38490    pub fn op_delqdisc_do(self, header: &Tcmsg) -> OpDelqdiscDo<'buf> {
38491        let mut res = OpDelqdiscDo::new(self, header);
38492        res.request
38493            .do_writeback(res.protocol(), "op-delqdisc-do", OpDelqdiscDo::lookup);
38494        res
38495    }
38496    #[doc = "Get / dump tc qdisc information\\.\nRequest attributes:\n- [.push_dump_invisible()](PushAttrs::push_dump_invisible)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
38497    pub fn op_getqdisc_dump(self, header: &Tcmsg) -> OpGetqdiscDump<'buf> {
38498        let mut res = OpGetqdiscDump::new(self, header);
38499        res.request
38500            .do_writeback(res.protocol(), "op-getqdisc-dump", OpGetqdiscDump::lookup);
38501        res
38502    }
38503    #[doc = "Get / dump tc qdisc information\\.\nRequest attributes:\n- [.push_dump_invisible()](PushAttrs::push_dump_invisible)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
38504    pub fn op_getqdisc_do(self, header: &Tcmsg) -> OpGetqdiscDo<'buf> {
38505        let mut res = OpGetqdiscDo::new(self, header);
38506        res.request
38507            .do_writeback(res.protocol(), "op-getqdisc-do", OpGetqdiscDo::lookup);
38508        res
38509    }
38510    #[doc = "Get / dump tc traffic class information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.nested_options_basic()](PushAttrs::nested_options_basic)\n- [.nested_options_bpf()](PushAttrs::nested_options_bpf)\n- [.nested_options_bfifo()](PushAttrs::nested_options_bfifo)\n- [.nested_options_cake()](PushAttrs::nested_options_cake)\n- [.nested_options_cbs()](PushAttrs::nested_options_cbs)\n- [.nested_options_cgroup()](PushAttrs::nested_options_cgroup)\n- [.nested_options_choke()](PushAttrs::nested_options_choke)\n- [.nested_options_clsact()](PushAttrs::nested_options_clsact)\n- [.nested_options_codel()](PushAttrs::nested_options_codel)\n- [.nested_options_drr()](PushAttrs::nested_options_drr)\n- [.nested_options_dualpi2()](PushAttrs::nested_options_dualpi2)\n- [.nested_options_etf()](PushAttrs::nested_options_etf)\n- [.nested_options_ets()](PushAttrs::nested_options_ets)\n- [.nested_options_flow()](PushAttrs::nested_options_flow)\n- [.nested_options_flower()](PushAttrs::nested_options_flower)\n- [.nested_options_fq()](PushAttrs::nested_options_fq)\n- [.nested_options_fq_codel()](PushAttrs::nested_options_fq_codel)\n- [.nested_options_fq_pie()](PushAttrs::nested_options_fq_pie)\n- [.nested_options_fw()](PushAttrs::nested_options_fw)\n- [.nested_options_gred()](PushAttrs::nested_options_gred)\n- [.nested_options_hfsc()](PushAttrs::nested_options_hfsc)\n- [.nested_options_hhf()](PushAttrs::nested_options_hhf)\n- [.nested_options_htb()](PushAttrs::nested_options_htb)\n- [.nested_options_ingress()](PushAttrs::nested_options_ingress)\n- [.nested_options_matchall()](PushAttrs::nested_options_matchall)\n- [.nested_options_mq()](PushAttrs::nested_options_mq)\n- [.nested_options_mqprio()](PushAttrs::nested_options_mqprio)\n- [.nested_options_multiq()](PushAttrs::nested_options_multiq)\n- [.nested_options_netem()](PushAttrs::nested_options_netem)\n- [.nested_options_pfifo()](PushAttrs::nested_options_pfifo)\n- [.nested_options_pfifo_fast()](PushAttrs::nested_options_pfifo_fast)\n- [.nested_options_pfifo_head_drop()](PushAttrs::nested_options_pfifo_head_drop)\n- [.nested_options_pie()](PushAttrs::nested_options_pie)\n- [.nested_options_plug()](PushAttrs::nested_options_plug)\n- [.nested_options_prio()](PushAttrs::nested_options_prio)\n- [.nested_options_qfq()](PushAttrs::nested_options_qfq)\n- [.nested_options_red()](PushAttrs::nested_options_red)\n- [.nested_options_route()](PushAttrs::nested_options_route)\n- [.nested_options_sfb()](PushAttrs::nested_options_sfb)\n- [.nested_options_sfq()](PushAttrs::nested_options_sfq)\n- [.nested_options_taprio()](PushAttrs::nested_options_taprio)\n- [.nested_options_tbf()](PushAttrs::nested_options_tbf)\n- [.nested_options_u32()](PushAttrs::nested_options_u32)\n- [.push_rate()](PushAttrs::push_rate)\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_ingress_block()](PushAttrs::push_ingress_block)\n- [.push_egress_block()](PushAttrs::push_egress_block)\n"]
38511    pub fn op_newtclass_do(self, header: &Tcmsg) -> OpNewtclassDo<'buf> {
38512        let mut res = OpNewtclassDo::new(self, header);
38513        res.request
38514            .do_writeback(res.protocol(), "op-newtclass-do", OpNewtclassDo::lookup);
38515        res
38516    }
38517    #[doc = "Get / dump tc traffic class information\\.\n"]
38518    pub fn op_deltclass_do(self, header: &Tcmsg) -> OpDeltclassDo<'buf> {
38519        let mut res = OpDeltclassDo::new(self, header);
38520        res.request
38521            .do_writeback(res.protocol(), "op-deltclass-do", OpDeltclassDo::lookup);
38522        res
38523    }
38524    #[doc = "Get / dump tc traffic class information\\.\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
38525    pub fn op_gettclass_do(self, header: &Tcmsg) -> OpGettclassDo<'buf> {
38526        let mut res = OpGettclassDo::new(self, header);
38527        res.request
38528            .do_writeback(res.protocol(), "op-gettclass-do", OpGettclassDo::lookup);
38529        res
38530    }
38531    #[doc = "Get / dump tc filter information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.nested_options_basic()](PushAttrs::nested_options_basic)\n- [.nested_options_bpf()](PushAttrs::nested_options_bpf)\n- [.nested_options_bfifo()](PushAttrs::nested_options_bfifo)\n- [.nested_options_cake()](PushAttrs::nested_options_cake)\n- [.nested_options_cbs()](PushAttrs::nested_options_cbs)\n- [.nested_options_cgroup()](PushAttrs::nested_options_cgroup)\n- [.nested_options_choke()](PushAttrs::nested_options_choke)\n- [.nested_options_clsact()](PushAttrs::nested_options_clsact)\n- [.nested_options_codel()](PushAttrs::nested_options_codel)\n- [.nested_options_drr()](PushAttrs::nested_options_drr)\n- [.nested_options_dualpi2()](PushAttrs::nested_options_dualpi2)\n- [.nested_options_etf()](PushAttrs::nested_options_etf)\n- [.nested_options_ets()](PushAttrs::nested_options_ets)\n- [.nested_options_flow()](PushAttrs::nested_options_flow)\n- [.nested_options_flower()](PushAttrs::nested_options_flower)\n- [.nested_options_fq()](PushAttrs::nested_options_fq)\n- [.nested_options_fq_codel()](PushAttrs::nested_options_fq_codel)\n- [.nested_options_fq_pie()](PushAttrs::nested_options_fq_pie)\n- [.nested_options_fw()](PushAttrs::nested_options_fw)\n- [.nested_options_gred()](PushAttrs::nested_options_gred)\n- [.nested_options_hfsc()](PushAttrs::nested_options_hfsc)\n- [.nested_options_hhf()](PushAttrs::nested_options_hhf)\n- [.nested_options_htb()](PushAttrs::nested_options_htb)\n- [.nested_options_ingress()](PushAttrs::nested_options_ingress)\n- [.nested_options_matchall()](PushAttrs::nested_options_matchall)\n- [.nested_options_mq()](PushAttrs::nested_options_mq)\n- [.nested_options_mqprio()](PushAttrs::nested_options_mqprio)\n- [.nested_options_multiq()](PushAttrs::nested_options_multiq)\n- [.nested_options_netem()](PushAttrs::nested_options_netem)\n- [.nested_options_pfifo()](PushAttrs::nested_options_pfifo)\n- [.nested_options_pfifo_fast()](PushAttrs::nested_options_pfifo_fast)\n- [.nested_options_pfifo_head_drop()](PushAttrs::nested_options_pfifo_head_drop)\n- [.nested_options_pie()](PushAttrs::nested_options_pie)\n- [.nested_options_plug()](PushAttrs::nested_options_plug)\n- [.nested_options_prio()](PushAttrs::nested_options_prio)\n- [.nested_options_qfq()](PushAttrs::nested_options_qfq)\n- [.nested_options_red()](PushAttrs::nested_options_red)\n- [.nested_options_route()](PushAttrs::nested_options_route)\n- [.nested_options_sfb()](PushAttrs::nested_options_sfb)\n- [.nested_options_sfq()](PushAttrs::nested_options_sfq)\n- [.nested_options_taprio()](PushAttrs::nested_options_taprio)\n- [.nested_options_tbf()](PushAttrs::nested_options_tbf)\n- [.nested_options_u32()](PushAttrs::nested_options_u32)\n- [.push_rate()](PushAttrs::push_rate)\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_ingress_block()](PushAttrs::push_ingress_block)\n- [.push_egress_block()](PushAttrs::push_egress_block)\n"]
38532    pub fn op_newtfilter_do(self, header: &Tcmsg) -> OpNewtfilterDo<'buf> {
38533        let mut res = OpNewtfilterDo::new(self, header);
38534        res.request
38535            .do_writeback(res.protocol(), "op-newtfilter-do", OpNewtfilterDo::lookup);
38536        res
38537    }
38538    #[doc = "Get / dump tc filter information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.push_chain()](PushAttrs::push_chain)\n"]
38539    pub fn op_deltfilter_do(self, header: &Tcmsg) -> OpDeltfilterDo<'buf> {
38540        let mut res = OpDeltfilterDo::new(self, header);
38541        res.request
38542            .do_writeback(res.protocol(), "op-deltfilter-do", OpDeltfilterDo::lookup);
38543        res
38544    }
38545    #[doc = "Get / dump tc filter information\\.\nRequest attributes:\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_dump_flags()](PushAttrs::push_dump_flags)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
38546    pub fn op_gettfilter_dump(self, header: &Tcmsg) -> OpGettfilterDump<'buf> {
38547        let mut res = OpGettfilterDump::new(self, header);
38548        res.request.do_writeback(
38549            res.protocol(),
38550            "op-gettfilter-dump",
38551            OpGettfilterDump::lookup,
38552        );
38553        res
38554    }
38555    #[doc = "Get / dump tc filter information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.push_chain()](PushAttrs::push_chain)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
38556    pub fn op_gettfilter_do(self, header: &Tcmsg) -> OpGettfilterDo<'buf> {
38557        let mut res = OpGettfilterDo::new(self, header);
38558        res.request
38559            .do_writeback(res.protocol(), "op-gettfilter-do", OpGettfilterDo::lookup);
38560        res
38561    }
38562    #[doc = "Get / dump tc chain information\\.\nRequest attributes:\n- [.push_kind()](PushAttrs::push_kind)\n- [.nested_options_basic()](PushAttrs::nested_options_basic)\n- [.nested_options_bpf()](PushAttrs::nested_options_bpf)\n- [.nested_options_bfifo()](PushAttrs::nested_options_bfifo)\n- [.nested_options_cake()](PushAttrs::nested_options_cake)\n- [.nested_options_cbs()](PushAttrs::nested_options_cbs)\n- [.nested_options_cgroup()](PushAttrs::nested_options_cgroup)\n- [.nested_options_choke()](PushAttrs::nested_options_choke)\n- [.nested_options_clsact()](PushAttrs::nested_options_clsact)\n- [.nested_options_codel()](PushAttrs::nested_options_codel)\n- [.nested_options_drr()](PushAttrs::nested_options_drr)\n- [.nested_options_dualpi2()](PushAttrs::nested_options_dualpi2)\n- [.nested_options_etf()](PushAttrs::nested_options_etf)\n- [.nested_options_ets()](PushAttrs::nested_options_ets)\n- [.nested_options_flow()](PushAttrs::nested_options_flow)\n- [.nested_options_flower()](PushAttrs::nested_options_flower)\n- [.nested_options_fq()](PushAttrs::nested_options_fq)\n- [.nested_options_fq_codel()](PushAttrs::nested_options_fq_codel)\n- [.nested_options_fq_pie()](PushAttrs::nested_options_fq_pie)\n- [.nested_options_fw()](PushAttrs::nested_options_fw)\n- [.nested_options_gred()](PushAttrs::nested_options_gred)\n- [.nested_options_hfsc()](PushAttrs::nested_options_hfsc)\n- [.nested_options_hhf()](PushAttrs::nested_options_hhf)\n- [.nested_options_htb()](PushAttrs::nested_options_htb)\n- [.nested_options_ingress()](PushAttrs::nested_options_ingress)\n- [.nested_options_matchall()](PushAttrs::nested_options_matchall)\n- [.nested_options_mq()](PushAttrs::nested_options_mq)\n- [.nested_options_mqprio()](PushAttrs::nested_options_mqprio)\n- [.nested_options_multiq()](PushAttrs::nested_options_multiq)\n- [.nested_options_netem()](PushAttrs::nested_options_netem)\n- [.nested_options_pfifo()](PushAttrs::nested_options_pfifo)\n- [.nested_options_pfifo_fast()](PushAttrs::nested_options_pfifo_fast)\n- [.nested_options_pfifo_head_drop()](PushAttrs::nested_options_pfifo_head_drop)\n- [.nested_options_pie()](PushAttrs::nested_options_pie)\n- [.nested_options_plug()](PushAttrs::nested_options_plug)\n- [.nested_options_prio()](PushAttrs::nested_options_prio)\n- [.nested_options_qfq()](PushAttrs::nested_options_qfq)\n- [.nested_options_red()](PushAttrs::nested_options_red)\n- [.nested_options_route()](PushAttrs::nested_options_route)\n- [.nested_options_sfb()](PushAttrs::nested_options_sfb)\n- [.nested_options_sfq()](PushAttrs::nested_options_sfq)\n- [.nested_options_taprio()](PushAttrs::nested_options_taprio)\n- [.nested_options_tbf()](PushAttrs::nested_options_tbf)\n- [.nested_options_u32()](PushAttrs::nested_options_u32)\n- [.push_rate()](PushAttrs::push_rate)\n- [.push_chain()](PushAttrs::push_chain)\n- [.push_ingress_block()](PushAttrs::push_ingress_block)\n- [.push_egress_block()](PushAttrs::push_egress_block)\n"]
38563    pub fn op_newchain_do(self, header: &Tcmsg) -> OpNewchainDo<'buf> {
38564        let mut res = OpNewchainDo::new(self, header);
38565        res.request
38566            .do_writeback(res.protocol(), "op-newchain-do", OpNewchainDo::lookup);
38567        res
38568    }
38569    #[doc = "Get / dump tc chain information\\.\nRequest attributes:\n- [.push_chain()](PushAttrs::push_chain)\n"]
38570    pub fn op_delchain_do(self, header: &Tcmsg) -> OpDelchainDo<'buf> {
38571        let mut res = OpDelchainDo::new(self, header);
38572        res.request
38573            .do_writeback(res.protocol(), "op-delchain-do", OpDelchainDo::lookup);
38574        res
38575    }
38576    #[doc = "Get / dump tc chain information\\.\nRequest attributes:\n- [.push_chain()](PushAttrs::push_chain)\n\nReply attributes:\n- [.get_kind()](IterableAttrs::get_kind)\n- [.get_options()](IterableAttrs::get_options)\n- [.get_stats()](IterableAttrs::get_stats)\n- [.get_xstats()](IterableAttrs::get_xstats)\n- [.get_rate()](IterableAttrs::get_rate)\n- [.get_fcnt()](IterableAttrs::get_fcnt)\n- [.get_stats2()](IterableAttrs::get_stats2)\n- [.get_stab()](IterableAttrs::get_stab)\n- [.get_chain()](IterableAttrs::get_chain)\n- [.get_ingress_block()](IterableAttrs::get_ingress_block)\n- [.get_egress_block()](IterableAttrs::get_egress_block)\n"]
38577    pub fn op_getchain_do(self, header: &Tcmsg) -> OpGetchainDo<'buf> {
38578        let mut res = OpGetchainDo::new(self, header);
38579        res.request
38580            .do_writeback(res.protocol(), "op-getchain-do", OpGetchainDo::lookup);
38581        res
38582    }
38583}
38584#[cfg(test)]
38585mod generated_tests {
38586    use super::*;
38587    #[test]
38588    fn tests() {
38589        let _ = IterableAttrs::get_chain;
38590        let _ = IterableAttrs::get_egress_block;
38591        let _ = IterableAttrs::get_fcnt;
38592        let _ = IterableAttrs::get_ingress_block;
38593        let _ = IterableAttrs::get_kind;
38594        let _ = IterableAttrs::get_options;
38595        let _ = IterableAttrs::get_rate;
38596        let _ = IterableAttrs::get_stab;
38597        let _ = IterableAttrs::get_stats2;
38598        let _ = IterableAttrs::get_stats;
38599        let _ = IterableAttrs::get_xstats;
38600        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_basic;
38601        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_bfifo;
38602        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_bpf;
38603        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_cake;
38604        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_cbs;
38605        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_cgroup;
38606        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_choke;
38607        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_clsact;
38608        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_codel;
38609        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_drr;
38610        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_dualpi2;
38611        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_etf;
38612        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_ets;
38613        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_flow;
38614        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_flower;
38615        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_fq;
38616        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_fq_codel;
38617        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_fq_pie;
38618        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_fw;
38619        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_gred;
38620        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_hfsc;
38621        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_hhf;
38622        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_htb;
38623        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_ingress;
38624        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_matchall;
38625        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_mq;
38626        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_mqprio;
38627        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_multiq;
38628        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_netem;
38629        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_pfifo;
38630        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_pfifo_fast;
38631        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_pfifo_head_drop;
38632        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_pie;
38633        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_plug;
38634        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_prio;
38635        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_qfq;
38636        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_red;
38637        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_route;
38638        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_sfb;
38639        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_sfq;
38640        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_taprio;
38641        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_tbf;
38642        let _ = PushAttrs::<&mut Vec<u8>>::nested_options_u32;
38643        let _ = PushAttrs::<&mut Vec<u8>>::push_chain;
38644        let _ = PushAttrs::<&mut Vec<u8>>::push_dump_flags;
38645        let _ = PushAttrs::<&mut Vec<u8>>::push_dump_invisible;
38646        let _ = PushAttrs::<&mut Vec<u8>>::push_egress_block;
38647        let _ = PushAttrs::<&mut Vec<u8>>::push_ingress_block;
38648        let _ = PushAttrs::<&mut Vec<u8>>::push_kind;
38649        let _ = PushAttrs::<&mut Vec<u8>>::push_rate;
38650    }
38651}