Skip to main content

netlink_bindings/rt-link/
mod.rs

1#![doc = "Link 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)]
10use crate::builtin::{PushBuiltinBitfield32, PushBuiltinNfgenmsg, PushDummy, PushNlmsghdr};
11use crate::{
12    consts,
13    traits::{NetlinkRequest, Protocol},
14    utils::*,
15};
16pub const PROTONAME: &CStr = c"rt-link";
17pub const PROTONUM: u16 = 0u16;
18#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
19#[derive(Debug, Clone, Copy)]
20pub enum IfinfoFlags {
21    Up = 1 << 0,
22    Broadcast = 1 << 1,
23    Debug = 1 << 2,
24    Loopback = 1 << 3,
25    PointToPoint = 1 << 4,
26    NoTrailers = 1 << 5,
27    Running = 1 << 6,
28    NoArp = 1 << 7,
29    Promisc = 1 << 8,
30    AllMulti = 1 << 9,
31    Master = 1 << 10,
32    Slave = 1 << 11,
33    Multicast = 1 << 12,
34    Portsel = 1 << 13,
35    AutoMedia = 1 << 14,
36    Dynamic = 1 << 15,
37    LowerUp = 1 << 16,
38    Dormant = 1 << 17,
39    Echo = 1 << 18,
40}
41impl IfinfoFlags {
42    pub fn from_value(value: u64) -> Option<Self> {
43        Some(match value {
44            n if n == 1 << 0 => Self::Up,
45            n if n == 1 << 1 => Self::Broadcast,
46            n if n == 1 << 2 => Self::Debug,
47            n if n == 1 << 3 => Self::Loopback,
48            n if n == 1 << 4 => Self::PointToPoint,
49            n if n == 1 << 5 => Self::NoTrailers,
50            n if n == 1 << 6 => Self::Running,
51            n if n == 1 << 7 => Self::NoArp,
52            n if n == 1 << 8 => Self::Promisc,
53            n if n == 1 << 9 => Self::AllMulti,
54            n if n == 1 << 10 => Self::Master,
55            n if n == 1 << 11 => Self::Slave,
56            n if n == 1 << 12 => Self::Multicast,
57            n if n == 1 << 13 => Self::Portsel,
58            n if n == 1 << 14 => Self::AutoMedia,
59            n if n == 1 << 15 => Self::Dynamic,
60            n if n == 1 << 16 => Self::LowerUp,
61            n if n == 1 << 17 => Self::Dormant,
62            n if n == 1 << 18 => Self::Echo,
63            _ => return None,
64        })
65    }
66}
67#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
68#[derive(Debug, Clone, Copy)]
69pub enum VlanProtocols {
70    _8021q = 33024,
71    _8021ad = 34984,
72}
73impl VlanProtocols {
74    pub fn from_value(value: u64) -> Option<Self> {
75        Some(match value {
76            33024 => Self::_8021q,
77            34984 => Self::_8021ad,
78            _ => return None,
79        })
80    }
81}
82#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
83#[derive(Debug, Clone, Copy)]
84pub enum Ipv4Devconf {
85    Forwarding = 0,
86    McForwarding = 1,
87    ProxyArp = 2,
88    AcceptRedirects = 3,
89    SecureRedirects = 4,
90    SendRedirects = 5,
91    SharedMedia = 6,
92    RpFilter = 7,
93    AcceptSourceRoute = 8,
94    BootpRelay = 9,
95    LogMartians = 10,
96    Tag = 11,
97    Arpfilter = 12,
98    MediumId = 13,
99    Noxfrm = 14,
100    Nopolicy = 15,
101    ForceIgmpVersion = 16,
102    ArpAnnounce = 17,
103    ArpIgnore = 18,
104    PromoteSecondaries = 19,
105    ArpAccept = 20,
106    ArpNotify = 21,
107    AcceptLocal = 22,
108    SrcVmark = 23,
109    ProxyArpPvlan = 24,
110    RouteLocalnet = 25,
111    Igmpv2UnsolicitedReportInterval = 26,
112    Igmpv3UnsolicitedReportInterval = 27,
113    IgnoreRoutesWithLinkdown = 28,
114    DropUnicastInL2Multicast = 29,
115    DropGratuitousArp = 30,
116    BcForwarding = 31,
117    ArpEvictNocarrier = 32,
118}
119impl Ipv4Devconf {
120    pub fn from_value(value: u64) -> Option<Self> {
121        Some(match value {
122            0 => Self::Forwarding,
123            1 => Self::McForwarding,
124            2 => Self::ProxyArp,
125            3 => Self::AcceptRedirects,
126            4 => Self::SecureRedirects,
127            5 => Self::SendRedirects,
128            6 => Self::SharedMedia,
129            7 => Self::RpFilter,
130            8 => Self::AcceptSourceRoute,
131            9 => Self::BootpRelay,
132            10 => Self::LogMartians,
133            11 => Self::Tag,
134            12 => Self::Arpfilter,
135            13 => Self::MediumId,
136            14 => Self::Noxfrm,
137            15 => Self::Nopolicy,
138            16 => Self::ForceIgmpVersion,
139            17 => Self::ArpAnnounce,
140            18 => Self::ArpIgnore,
141            19 => Self::PromoteSecondaries,
142            20 => Self::ArpAccept,
143            21 => Self::ArpNotify,
144            22 => Self::AcceptLocal,
145            23 => Self::SrcVmark,
146            24 => Self::ProxyArpPvlan,
147            25 => Self::RouteLocalnet,
148            26 => Self::Igmpv2UnsolicitedReportInterval,
149            27 => Self::Igmpv3UnsolicitedReportInterval,
150            28 => Self::IgnoreRoutesWithLinkdown,
151            29 => Self::DropUnicastInL2Multicast,
152            30 => Self::DropGratuitousArp,
153            31 => Self::BcForwarding,
154            32 => Self::ArpEvictNocarrier,
155            _ => return None,
156        })
157    }
158}
159#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
160#[derive(Debug, Clone, Copy)]
161pub enum Ipv6Devconf {
162    Forwarding = 0,
163    Hoplimit = 1,
164    Mtu6 = 2,
165    AcceptRa = 3,
166    AcceptRedirects = 4,
167    Autoconf = 5,
168    DadTransmits = 6,
169    RtrSolicits = 7,
170    RtrSolicitInterval = 8,
171    RtrSolicitDelay = 9,
172    UseTempaddr = 10,
173    TempValidLft = 11,
174    TempPreferedLft = 12,
175    RegenMaxRetry = 13,
176    MaxDesyncFactor = 14,
177    MaxAddresses = 15,
178    ForceMldVersion = 16,
179    AcceptRaDefrtr = 17,
180    AcceptRaPinfo = 18,
181    AcceptRaRtrPref = 19,
182    RtrProbeInterval = 20,
183    AcceptRaRtInfoMaxPlen = 21,
184    ProxyNdp = 22,
185    OptimisticDad = 23,
186    AcceptSourceRoute = 24,
187    McForwarding = 25,
188    DisableIpv6 = 26,
189    AcceptDad = 27,
190    ForceTllao = 28,
191    NdiscNotify = 29,
192    Mldv1UnsolicitedReportInterval = 30,
193    Mldv2UnsolicitedReportInterval = 31,
194    SuppressFragNdisc = 32,
195    AcceptRaFromLocal = 33,
196    UseOptimistic = 34,
197    AcceptRaMtu = 35,
198    StableSecret = 36,
199    UseOifAddrsOnly = 37,
200    AcceptRaMinHopLimit = 38,
201    IgnoreRoutesWithLinkdown = 39,
202    DropUnicastInL2Multicast = 40,
203    DropUnsolicitedNa = 41,
204    KeepAddrOnDown = 42,
205    RtrSolicitMaxInterval = 43,
206    Seg6Enabled = 44,
207    Seg6RequireHmac = 45,
208    EnhancedDad = 46,
209    AddrGenMode = 47,
210    DisablePolicy = 48,
211    AcceptRaRtInfoMinPlen = 49,
212    NdiscTclass = 50,
213    RplSegEnabled = 51,
214    RaDefrtrMetric = 52,
215    Ioam6Enabled = 53,
216    Ioam6Id = 54,
217    Ioam6IdWide = 55,
218    NdiscEvictNocarrier = 56,
219    AcceptUntrackedNa = 57,
220}
221impl Ipv6Devconf {
222    pub fn from_value(value: u64) -> Option<Self> {
223        Some(match value {
224            0 => Self::Forwarding,
225            1 => Self::Hoplimit,
226            2 => Self::Mtu6,
227            3 => Self::AcceptRa,
228            4 => Self::AcceptRedirects,
229            5 => Self::Autoconf,
230            6 => Self::DadTransmits,
231            7 => Self::RtrSolicits,
232            8 => Self::RtrSolicitInterval,
233            9 => Self::RtrSolicitDelay,
234            10 => Self::UseTempaddr,
235            11 => Self::TempValidLft,
236            12 => Self::TempPreferedLft,
237            13 => Self::RegenMaxRetry,
238            14 => Self::MaxDesyncFactor,
239            15 => Self::MaxAddresses,
240            16 => Self::ForceMldVersion,
241            17 => Self::AcceptRaDefrtr,
242            18 => Self::AcceptRaPinfo,
243            19 => Self::AcceptRaRtrPref,
244            20 => Self::RtrProbeInterval,
245            21 => Self::AcceptRaRtInfoMaxPlen,
246            22 => Self::ProxyNdp,
247            23 => Self::OptimisticDad,
248            24 => Self::AcceptSourceRoute,
249            25 => Self::McForwarding,
250            26 => Self::DisableIpv6,
251            27 => Self::AcceptDad,
252            28 => Self::ForceTllao,
253            29 => Self::NdiscNotify,
254            30 => Self::Mldv1UnsolicitedReportInterval,
255            31 => Self::Mldv2UnsolicitedReportInterval,
256            32 => Self::SuppressFragNdisc,
257            33 => Self::AcceptRaFromLocal,
258            34 => Self::UseOptimistic,
259            35 => Self::AcceptRaMtu,
260            36 => Self::StableSecret,
261            37 => Self::UseOifAddrsOnly,
262            38 => Self::AcceptRaMinHopLimit,
263            39 => Self::IgnoreRoutesWithLinkdown,
264            40 => Self::DropUnicastInL2Multicast,
265            41 => Self::DropUnsolicitedNa,
266            42 => Self::KeepAddrOnDown,
267            43 => Self::RtrSolicitMaxInterval,
268            44 => Self::Seg6Enabled,
269            45 => Self::Seg6RequireHmac,
270            46 => Self::EnhancedDad,
271            47 => Self::AddrGenMode,
272            48 => Self::DisablePolicy,
273            49 => Self::AcceptRaRtInfoMinPlen,
274            50 => Self::NdiscTclass,
275            51 => Self::RplSegEnabled,
276            52 => Self::RaDefrtrMetric,
277            53 => Self::Ioam6Enabled,
278            54 => Self::Ioam6Id,
279            55 => Self::Ioam6IdWide,
280            56 => Self::NdiscEvictNocarrier,
281            57 => Self::AcceptUntrackedNa,
282            _ => return None,
283        })
284    }
285}
286#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
287#[derive(Debug, Clone, Copy)]
288pub enum IflaIcmp6Stats {
289    Num = 0,
290    Inmsgs = 1,
291    Inerrors = 2,
292    Outmsgs = 3,
293    Outerrors = 4,
294    Csumerrors = 5,
295    Ratelimithost = 6,
296}
297impl IflaIcmp6Stats {
298    pub fn from_value(value: u64) -> Option<Self> {
299        Some(match value {
300            0 => Self::Num,
301            1 => Self::Inmsgs,
302            2 => Self::Inerrors,
303            3 => Self::Outmsgs,
304            4 => Self::Outerrors,
305            5 => Self::Csumerrors,
306            6 => Self::Ratelimithost,
307            _ => return None,
308        })
309    }
310}
311#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
312#[derive(Debug, Clone, Copy)]
313pub enum IflaInet6Stats {
314    Num = 0,
315    Inpkts = 1,
316    Inoctets = 2,
317    Indelivers = 3,
318    Outforwdatagrams = 4,
319    Outpkts = 5,
320    Outoctets = 6,
321    Inhdrerrors = 7,
322    Intoobigerrors = 8,
323    Innoroutes = 9,
324    Inaddrerrors = 10,
325    Inunknownprotos = 11,
326    Intruncatedpkts = 12,
327    Indiscards = 13,
328    Outdiscards = 14,
329    Outnoroutes = 15,
330    Reasmtimeout = 16,
331    Reasmreqds = 17,
332    Reasmoks = 18,
333    Reasmfails = 19,
334    Fragoks = 20,
335    Fragfails = 21,
336    Fragcreates = 22,
337    Inmcastpkts = 23,
338    Outmcastpkts = 24,
339    Inbcastpkts = 25,
340    Outbcastpkts = 26,
341    Inmcastoctets = 27,
342    Outmcastoctets = 28,
343    Inbcastoctets = 29,
344    Outbcastoctets = 30,
345    Csumerrors = 31,
346    Noectpkts = 32,
347    Ect1Pkts = 33,
348    Ect0Pkts = 34,
349    Cepkts = 35,
350    ReasmOverlaps = 36,
351}
352impl IflaInet6Stats {
353    pub fn from_value(value: u64) -> Option<Self> {
354        Some(match value {
355            0 => Self::Num,
356            1 => Self::Inpkts,
357            2 => Self::Inoctets,
358            3 => Self::Indelivers,
359            4 => Self::Outforwdatagrams,
360            5 => Self::Outpkts,
361            6 => Self::Outoctets,
362            7 => Self::Inhdrerrors,
363            8 => Self::Intoobigerrors,
364            9 => Self::Innoroutes,
365            10 => Self::Inaddrerrors,
366            11 => Self::Inunknownprotos,
367            12 => Self::Intruncatedpkts,
368            13 => Self::Indiscards,
369            14 => Self::Outdiscards,
370            15 => Self::Outnoroutes,
371            16 => Self::Reasmtimeout,
372            17 => Self::Reasmreqds,
373            18 => Self::Reasmoks,
374            19 => Self::Reasmfails,
375            20 => Self::Fragoks,
376            21 => Self::Fragfails,
377            22 => Self::Fragcreates,
378            23 => Self::Inmcastpkts,
379            24 => Self::Outmcastpkts,
380            25 => Self::Inbcastpkts,
381            26 => Self::Outbcastpkts,
382            27 => Self::Inmcastoctets,
383            28 => Self::Outmcastoctets,
384            29 => Self::Inbcastoctets,
385            30 => Self::Outbcastoctets,
386            31 => Self::Csumerrors,
387            32 => Self::Noectpkts,
388            33 => Self::Ect1Pkts,
389            34 => Self::Ect0Pkts,
390            35 => Self::Cepkts,
391            36 => Self::ReasmOverlaps,
392            _ => return None,
393        })
394    }
395}
396#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
397#[derive(Debug, Clone, Copy)]
398pub enum VlanFlags {
399    ReorderHdr = 1 << 0,
400    Gvrp = 1 << 1,
401    LooseBinding = 1 << 2,
402    Mvrp = 1 << 3,
403    BridgeBinding = 1 << 4,
404}
405impl VlanFlags {
406    pub fn from_value(value: u64) -> Option<Self> {
407        Some(match value {
408            n if n == 1 << 0 => Self::ReorderHdr,
409            n if n == 1 << 1 => Self::Gvrp,
410            n if n == 1 << 2 => Self::LooseBinding,
411            n if n == 1 << 3 => Self::Mvrp,
412            n if n == 1 << 4 => Self::BridgeBinding,
413            _ => return None,
414        })
415    }
416}
417#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
418#[derive(Debug, Clone, Copy)]
419pub enum IflaVfLinkStateEnum {
420    Auto = 0,
421    Enable = 1,
422    Disable = 2,
423}
424impl IflaVfLinkStateEnum {
425    pub fn from_value(value: u64) -> Option<Self> {
426        Some(match value {
427            0 => Self::Auto,
428            1 => Self::Enable,
429            2 => Self::Disable,
430            _ => return None,
431        })
432    }
433}
434#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
435#[derive(Debug, Clone, Copy)]
436pub enum RtextFilter {
437    Vf = 1 << 0,
438    Brvlan = 1 << 1,
439    BrvlanCompressed = 1 << 2,
440    SkipStats = 1 << 3,
441    Mrp = 1 << 4,
442    CfmConfig = 1 << 5,
443    CfmStatus = 1 << 6,
444    Mst = 1 << 7,
445}
446impl RtextFilter {
447    pub fn from_value(value: u64) -> Option<Self> {
448        Some(match value {
449            n if n == 1 << 0 => Self::Vf,
450            n if n == 1 << 1 => Self::Brvlan,
451            n if n == 1 << 2 => Self::BrvlanCompressed,
452            n if n == 1 << 3 => Self::SkipStats,
453            n if n == 1 << 4 => Self::Mrp,
454            n if n == 1 << 5 => Self::CfmConfig,
455            n if n == 1 << 6 => Self::CfmStatus,
456            n if n == 1 << 7 => Self::Mst,
457            _ => return None,
458        })
459    }
460}
461#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
462#[derive(Debug, Clone, Copy)]
463pub enum NetkitPolicy {
464    Forward = 0,
465    Blackhole = 2,
466}
467impl NetkitPolicy {
468    pub fn from_value(value: u64) -> Option<Self> {
469        Some(match value {
470            0 => Self::Forward,
471            2 => Self::Blackhole,
472            _ => return None,
473        })
474    }
475}
476#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
477#[derive(Debug, Clone, Copy)]
478pub enum NetkitMode {
479    L2 = 0,
480    L3 = 1,
481}
482impl NetkitMode {
483    pub fn from_value(value: u64) -> Option<Self> {
484        Some(match value {
485            0 => Self::L2,
486            1 => Self::L3,
487            _ => return None,
488        })
489    }
490}
491#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
492#[derive(Debug, Clone, Copy)]
493pub enum NetkitScrub {
494    None = 0,
495    Default = 1,
496}
497impl NetkitScrub {
498    pub fn from_value(value: u64) -> Option<Self> {
499        Some(match value {
500            0 => Self::None,
501            1 => Self::Default,
502            _ => return None,
503        })
504    }
505}
506#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
507#[derive(Debug, Clone, Copy)]
508pub enum OvpnMode {
509    P2p = 0,
510    Mp = 1,
511}
512impl OvpnMode {
513    pub fn from_value(value: u64) -> Option<Self> {
514        Some(match value {
515            0 => Self::P2p,
516            1 => Self::Mp,
517            _ => return None,
518        })
519    }
520}
521#[derive(Clone)]
522pub enum LinkAttrs<'a> {
523    Address(&'a [u8]),
524    Broadcast(&'a [u8]),
525    Ifname(&'a CStr),
526    Mtu(u32),
527    Link(u32),
528    Qdisc(&'a CStr),
529    Stats(PushRtnlLinkStats),
530    Cost(&'a CStr),
531    Priority(&'a CStr),
532    Master(u32),
533    Wireless(&'a CStr),
534    Protinfo(&'a CStr),
535    Txqlen(u32),
536    Map(PushRtnlLinkIfmap),
537    Weight(u32),
538    Operstate(u8),
539    Linkmode(u8),
540    Linkinfo(IterableLinkinfoAttrs<'a>),
541    NetNsPid(u32),
542    Ifalias(&'a CStr),
543    NumVf(u32),
544    VfinfoList(IterableVfinfoListAttrs<'a>),
545    Stats64(PushRtnlLinkStats64),
546    VfPorts(IterableVfPortsAttrs<'a>),
547    PortSelf(IterablePortSelfAttrs<'a>),
548    AfSpec(IterableAfSpecAttrs<'a>),
549    Group(u32),
550    NetNsFd(u32),
551    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
552    ExtMask(u32),
553    Promiscuity(u32),
554    NumTxQueues(u32),
555    NumRxQueues(u32),
556    Carrier(u8),
557    PhysPortId(&'a [u8]),
558    CarrierChanges(u32),
559    PhysSwitchId(&'a [u8]),
560    LinkNetnsid(i32),
561    PhysPortName(&'a CStr),
562    ProtoDown(u8),
563    GsoMaxSegs(u32),
564    GsoMaxSize(u32),
565    Pad(&'a [u8]),
566    Xdp(IterableXdpAttrs<'a>),
567    Event(u32),
568    NewNetnsid(i32),
569    TargetNetnsid(i32),
570    CarrierUpCount(u32),
571    CarrierDownCount(u32),
572    NewIfindex(i32),
573    MinMtu(u32),
574    MaxMtu(u32),
575    PropList(IterablePropListLinkAttrs<'a>),
576    AltIfname(&'a CStr),
577    PermAddress(&'a [u8]),
578    ProtoDownReason(&'a CStr),
579    ParentDevName(&'a CStr),
580    ParentDevBusName(&'a CStr),
581    GroMaxSize(u32),
582    TsoMaxSize(u32),
583    TsoMaxSegs(u32),
584    Allmulti(u32),
585    DevlinkPort(&'a [u8]),
586    GsoIpv4MaxSize(u32),
587    GroIpv4MaxSize(u32),
588    DpllPin(IterableLinkDpllPinAttrs<'a>),
589    #[doc = "EDT offload horizon supported by the device (in nsec)."]
590    MaxPacingOffloadHorizon(u32),
591    NetnsImmutable(u8),
592}
593impl<'a> IterableLinkAttrs<'a> {
594    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
595        let mut iter = self.clone();
596        iter.pos = 0;
597        for attr in iter {
598            if let LinkAttrs::Address(val) = attr? {
599                return Ok(val);
600            }
601        }
602        Err(ErrorContext::new_missing(
603            "LinkAttrs",
604            "Address",
605            self.orig_loc,
606            self.buf.as_ptr() as usize,
607        ))
608    }
609    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
610        let mut iter = self.clone();
611        iter.pos = 0;
612        for attr in iter {
613            if let LinkAttrs::Broadcast(val) = attr? {
614                return Ok(val);
615            }
616        }
617        Err(ErrorContext::new_missing(
618            "LinkAttrs",
619            "Broadcast",
620            self.orig_loc,
621            self.buf.as_ptr() as usize,
622        ))
623    }
624    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
625        let mut iter = self.clone();
626        iter.pos = 0;
627        for attr in iter {
628            if let LinkAttrs::Ifname(val) = attr? {
629                return Ok(val);
630            }
631        }
632        Err(ErrorContext::new_missing(
633            "LinkAttrs",
634            "Ifname",
635            self.orig_loc,
636            self.buf.as_ptr() as usize,
637        ))
638    }
639    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
640        let mut iter = self.clone();
641        iter.pos = 0;
642        for attr in iter {
643            if let LinkAttrs::Mtu(val) = attr? {
644                return Ok(val);
645            }
646        }
647        Err(ErrorContext::new_missing(
648            "LinkAttrs",
649            "Mtu",
650            self.orig_loc,
651            self.buf.as_ptr() as usize,
652        ))
653    }
654    pub fn get_link(&self) -> Result<u32, ErrorContext> {
655        let mut iter = self.clone();
656        iter.pos = 0;
657        for attr in iter {
658            if let LinkAttrs::Link(val) = attr? {
659                return Ok(val);
660            }
661        }
662        Err(ErrorContext::new_missing(
663            "LinkAttrs",
664            "Link",
665            self.orig_loc,
666            self.buf.as_ptr() as usize,
667        ))
668    }
669    pub fn get_qdisc(&self) -> Result<&'a CStr, ErrorContext> {
670        let mut iter = self.clone();
671        iter.pos = 0;
672        for attr in iter {
673            if let LinkAttrs::Qdisc(val) = attr? {
674                return Ok(val);
675            }
676        }
677        Err(ErrorContext::new_missing(
678            "LinkAttrs",
679            "Qdisc",
680            self.orig_loc,
681            self.buf.as_ptr() as usize,
682        ))
683    }
684    pub fn get_stats(&self) -> Result<PushRtnlLinkStats, ErrorContext> {
685        let mut iter = self.clone();
686        iter.pos = 0;
687        for attr in iter {
688            if let LinkAttrs::Stats(val) = attr? {
689                return Ok(val);
690            }
691        }
692        Err(ErrorContext::new_missing(
693            "LinkAttrs",
694            "Stats",
695            self.orig_loc,
696            self.buf.as_ptr() as usize,
697        ))
698    }
699    pub fn get_cost(&self) -> Result<&'a CStr, ErrorContext> {
700        let mut iter = self.clone();
701        iter.pos = 0;
702        for attr in iter {
703            if let LinkAttrs::Cost(val) = attr? {
704                return Ok(val);
705            }
706        }
707        Err(ErrorContext::new_missing(
708            "LinkAttrs",
709            "Cost",
710            self.orig_loc,
711            self.buf.as_ptr() as usize,
712        ))
713    }
714    pub fn get_priority(&self) -> Result<&'a CStr, ErrorContext> {
715        let mut iter = self.clone();
716        iter.pos = 0;
717        for attr in iter {
718            if let LinkAttrs::Priority(val) = attr? {
719                return Ok(val);
720            }
721        }
722        Err(ErrorContext::new_missing(
723            "LinkAttrs",
724            "Priority",
725            self.orig_loc,
726            self.buf.as_ptr() as usize,
727        ))
728    }
729    pub fn get_master(&self) -> Result<u32, ErrorContext> {
730        let mut iter = self.clone();
731        iter.pos = 0;
732        for attr in iter {
733            if let LinkAttrs::Master(val) = attr? {
734                return Ok(val);
735            }
736        }
737        Err(ErrorContext::new_missing(
738            "LinkAttrs",
739            "Master",
740            self.orig_loc,
741            self.buf.as_ptr() as usize,
742        ))
743    }
744    pub fn get_wireless(&self) -> Result<&'a CStr, ErrorContext> {
745        let mut iter = self.clone();
746        iter.pos = 0;
747        for attr in iter {
748            if let LinkAttrs::Wireless(val) = attr? {
749                return Ok(val);
750            }
751        }
752        Err(ErrorContext::new_missing(
753            "LinkAttrs",
754            "Wireless",
755            self.orig_loc,
756            self.buf.as_ptr() as usize,
757        ))
758    }
759    pub fn get_protinfo(&self) -> Result<&'a CStr, ErrorContext> {
760        let mut iter = self.clone();
761        iter.pos = 0;
762        for attr in iter {
763            if let LinkAttrs::Protinfo(val) = attr? {
764                return Ok(val);
765            }
766        }
767        Err(ErrorContext::new_missing(
768            "LinkAttrs",
769            "Protinfo",
770            self.orig_loc,
771            self.buf.as_ptr() as usize,
772        ))
773    }
774    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
775        let mut iter = self.clone();
776        iter.pos = 0;
777        for attr in iter {
778            if let LinkAttrs::Txqlen(val) = attr? {
779                return Ok(val);
780            }
781        }
782        Err(ErrorContext::new_missing(
783            "LinkAttrs",
784            "Txqlen",
785            self.orig_loc,
786            self.buf.as_ptr() as usize,
787        ))
788    }
789    pub fn get_map(&self) -> Result<PushRtnlLinkIfmap, ErrorContext> {
790        let mut iter = self.clone();
791        iter.pos = 0;
792        for attr in iter {
793            if let LinkAttrs::Map(val) = attr? {
794                return Ok(val);
795            }
796        }
797        Err(ErrorContext::new_missing(
798            "LinkAttrs",
799            "Map",
800            self.orig_loc,
801            self.buf.as_ptr() as usize,
802        ))
803    }
804    pub fn get_weight(&self) -> Result<u32, ErrorContext> {
805        let mut iter = self.clone();
806        iter.pos = 0;
807        for attr in iter {
808            if let LinkAttrs::Weight(val) = attr? {
809                return Ok(val);
810            }
811        }
812        Err(ErrorContext::new_missing(
813            "LinkAttrs",
814            "Weight",
815            self.orig_loc,
816            self.buf.as_ptr() as usize,
817        ))
818    }
819    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
820        let mut iter = self.clone();
821        iter.pos = 0;
822        for attr in iter {
823            if let LinkAttrs::Operstate(val) = attr? {
824                return Ok(val);
825            }
826        }
827        Err(ErrorContext::new_missing(
828            "LinkAttrs",
829            "Operstate",
830            self.orig_loc,
831            self.buf.as_ptr() as usize,
832        ))
833    }
834    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
835        let mut iter = self.clone();
836        iter.pos = 0;
837        for attr in iter {
838            if let LinkAttrs::Linkmode(val) = attr? {
839                return Ok(val);
840            }
841        }
842        Err(ErrorContext::new_missing(
843            "LinkAttrs",
844            "Linkmode",
845            self.orig_loc,
846            self.buf.as_ptr() as usize,
847        ))
848    }
849    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
850        let mut iter = self.clone();
851        iter.pos = 0;
852        for attr in iter {
853            if let LinkAttrs::Linkinfo(val) = attr? {
854                return Ok(val);
855            }
856        }
857        Err(ErrorContext::new_missing(
858            "LinkAttrs",
859            "Linkinfo",
860            self.orig_loc,
861            self.buf.as_ptr() as usize,
862        ))
863    }
864    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
865        let mut iter = self.clone();
866        iter.pos = 0;
867        for attr in iter {
868            if let LinkAttrs::NetNsPid(val) = attr? {
869                return Ok(val);
870            }
871        }
872        Err(ErrorContext::new_missing(
873            "LinkAttrs",
874            "NetNsPid",
875            self.orig_loc,
876            self.buf.as_ptr() as usize,
877        ))
878    }
879    pub fn get_ifalias(&self) -> Result<&'a CStr, ErrorContext> {
880        let mut iter = self.clone();
881        iter.pos = 0;
882        for attr in iter {
883            if let LinkAttrs::Ifalias(val) = attr? {
884                return Ok(val);
885            }
886        }
887        Err(ErrorContext::new_missing(
888            "LinkAttrs",
889            "Ifalias",
890            self.orig_loc,
891            self.buf.as_ptr() as usize,
892        ))
893    }
894    pub fn get_num_vf(&self) -> Result<u32, ErrorContext> {
895        let mut iter = self.clone();
896        iter.pos = 0;
897        for attr in iter {
898            if let LinkAttrs::NumVf(val) = attr? {
899                return Ok(val);
900            }
901        }
902        Err(ErrorContext::new_missing(
903            "LinkAttrs",
904            "NumVf",
905            self.orig_loc,
906            self.buf.as_ptr() as usize,
907        ))
908    }
909    pub fn get_vfinfo_list(&self) -> Result<IterableVfinfoListAttrs<'a>, ErrorContext> {
910        let mut iter = self.clone();
911        iter.pos = 0;
912        for attr in iter {
913            if let LinkAttrs::VfinfoList(val) = attr? {
914                return Ok(val);
915            }
916        }
917        Err(ErrorContext::new_missing(
918            "LinkAttrs",
919            "VfinfoList",
920            self.orig_loc,
921            self.buf.as_ptr() as usize,
922        ))
923    }
924    pub fn get_stats64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
925        let mut iter = self.clone();
926        iter.pos = 0;
927        for attr in iter {
928            if let LinkAttrs::Stats64(val) = attr? {
929                return Ok(val);
930            }
931        }
932        Err(ErrorContext::new_missing(
933            "LinkAttrs",
934            "Stats64",
935            self.orig_loc,
936            self.buf.as_ptr() as usize,
937        ))
938    }
939    pub fn get_vf_ports(&self) -> Result<IterableVfPortsAttrs<'a>, ErrorContext> {
940        let mut iter = self.clone();
941        iter.pos = 0;
942        for attr in iter {
943            if let LinkAttrs::VfPorts(val) = attr? {
944                return Ok(val);
945            }
946        }
947        Err(ErrorContext::new_missing(
948            "LinkAttrs",
949            "VfPorts",
950            self.orig_loc,
951            self.buf.as_ptr() as usize,
952        ))
953    }
954    pub fn get_port_self(&self) -> Result<IterablePortSelfAttrs<'a>, ErrorContext> {
955        let mut iter = self.clone();
956        iter.pos = 0;
957        for attr in iter {
958            if let LinkAttrs::PortSelf(val) = attr? {
959                return Ok(val);
960            }
961        }
962        Err(ErrorContext::new_missing(
963            "LinkAttrs",
964            "PortSelf",
965            self.orig_loc,
966            self.buf.as_ptr() as usize,
967        ))
968    }
969    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
970        let mut iter = self.clone();
971        iter.pos = 0;
972        for attr in iter {
973            if let LinkAttrs::AfSpec(val) = attr? {
974                return Ok(val);
975            }
976        }
977        Err(ErrorContext::new_missing(
978            "LinkAttrs",
979            "AfSpec",
980            self.orig_loc,
981            self.buf.as_ptr() as usize,
982        ))
983    }
984    pub fn get_group(&self) -> Result<u32, ErrorContext> {
985        let mut iter = self.clone();
986        iter.pos = 0;
987        for attr in iter {
988            if let LinkAttrs::Group(val) = attr? {
989                return Ok(val);
990            }
991        }
992        Err(ErrorContext::new_missing(
993            "LinkAttrs",
994            "Group",
995            self.orig_loc,
996            self.buf.as_ptr() as usize,
997        ))
998    }
999    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
1000        let mut iter = self.clone();
1001        iter.pos = 0;
1002        for attr in iter {
1003            if let LinkAttrs::NetNsFd(val) = attr? {
1004                return Ok(val);
1005            }
1006        }
1007        Err(ErrorContext::new_missing(
1008            "LinkAttrs",
1009            "NetNsFd",
1010            self.orig_loc,
1011            self.buf.as_ptr() as usize,
1012        ))
1013    }
1014    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
1015    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
1016        let mut iter = self.clone();
1017        iter.pos = 0;
1018        for attr in iter {
1019            if let LinkAttrs::ExtMask(val) = attr? {
1020                return Ok(val);
1021            }
1022        }
1023        Err(ErrorContext::new_missing(
1024            "LinkAttrs",
1025            "ExtMask",
1026            self.orig_loc,
1027            self.buf.as_ptr() as usize,
1028        ))
1029    }
1030    pub fn get_promiscuity(&self) -> Result<u32, ErrorContext> {
1031        let mut iter = self.clone();
1032        iter.pos = 0;
1033        for attr in iter {
1034            if let LinkAttrs::Promiscuity(val) = attr? {
1035                return Ok(val);
1036            }
1037        }
1038        Err(ErrorContext::new_missing(
1039            "LinkAttrs",
1040            "Promiscuity",
1041            self.orig_loc,
1042            self.buf.as_ptr() as usize,
1043        ))
1044    }
1045    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
1046        let mut iter = self.clone();
1047        iter.pos = 0;
1048        for attr in iter {
1049            if let LinkAttrs::NumTxQueues(val) = attr? {
1050                return Ok(val);
1051            }
1052        }
1053        Err(ErrorContext::new_missing(
1054            "LinkAttrs",
1055            "NumTxQueues",
1056            self.orig_loc,
1057            self.buf.as_ptr() as usize,
1058        ))
1059    }
1060    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
1061        let mut iter = self.clone();
1062        iter.pos = 0;
1063        for attr in iter {
1064            if let LinkAttrs::NumRxQueues(val) = attr? {
1065                return Ok(val);
1066            }
1067        }
1068        Err(ErrorContext::new_missing(
1069            "LinkAttrs",
1070            "NumRxQueues",
1071            self.orig_loc,
1072            self.buf.as_ptr() as usize,
1073        ))
1074    }
1075    pub fn get_carrier(&self) -> Result<u8, ErrorContext> {
1076        let mut iter = self.clone();
1077        iter.pos = 0;
1078        for attr in iter {
1079            if let LinkAttrs::Carrier(val) = attr? {
1080                return Ok(val);
1081            }
1082        }
1083        Err(ErrorContext::new_missing(
1084            "LinkAttrs",
1085            "Carrier",
1086            self.orig_loc,
1087            self.buf.as_ptr() as usize,
1088        ))
1089    }
1090    pub fn get_phys_port_id(&self) -> Result<&'a [u8], ErrorContext> {
1091        let mut iter = self.clone();
1092        iter.pos = 0;
1093        for attr in iter {
1094            if let LinkAttrs::PhysPortId(val) = attr? {
1095                return Ok(val);
1096            }
1097        }
1098        Err(ErrorContext::new_missing(
1099            "LinkAttrs",
1100            "PhysPortId",
1101            self.orig_loc,
1102            self.buf.as_ptr() as usize,
1103        ))
1104    }
1105    pub fn get_carrier_changes(&self) -> Result<u32, ErrorContext> {
1106        let mut iter = self.clone();
1107        iter.pos = 0;
1108        for attr in iter {
1109            if let LinkAttrs::CarrierChanges(val) = attr? {
1110                return Ok(val);
1111            }
1112        }
1113        Err(ErrorContext::new_missing(
1114            "LinkAttrs",
1115            "CarrierChanges",
1116            self.orig_loc,
1117            self.buf.as_ptr() as usize,
1118        ))
1119    }
1120    pub fn get_phys_switch_id(&self) -> Result<&'a [u8], ErrorContext> {
1121        let mut iter = self.clone();
1122        iter.pos = 0;
1123        for attr in iter {
1124            if let LinkAttrs::PhysSwitchId(val) = attr? {
1125                return Ok(val);
1126            }
1127        }
1128        Err(ErrorContext::new_missing(
1129            "LinkAttrs",
1130            "PhysSwitchId",
1131            self.orig_loc,
1132            self.buf.as_ptr() as usize,
1133        ))
1134    }
1135    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
1136        let mut iter = self.clone();
1137        iter.pos = 0;
1138        for attr in iter {
1139            if let LinkAttrs::LinkNetnsid(val) = attr? {
1140                return Ok(val);
1141            }
1142        }
1143        Err(ErrorContext::new_missing(
1144            "LinkAttrs",
1145            "LinkNetnsid",
1146            self.orig_loc,
1147            self.buf.as_ptr() as usize,
1148        ))
1149    }
1150    pub fn get_phys_port_name(&self) -> Result<&'a CStr, ErrorContext> {
1151        let mut iter = self.clone();
1152        iter.pos = 0;
1153        for attr in iter {
1154            if let LinkAttrs::PhysPortName(val) = attr? {
1155                return Ok(val);
1156            }
1157        }
1158        Err(ErrorContext::new_missing(
1159            "LinkAttrs",
1160            "PhysPortName",
1161            self.orig_loc,
1162            self.buf.as_ptr() as usize,
1163        ))
1164    }
1165    pub fn get_proto_down(&self) -> Result<u8, ErrorContext> {
1166        let mut iter = self.clone();
1167        iter.pos = 0;
1168        for attr in iter {
1169            if let LinkAttrs::ProtoDown(val) = attr? {
1170                return Ok(val);
1171            }
1172        }
1173        Err(ErrorContext::new_missing(
1174            "LinkAttrs",
1175            "ProtoDown",
1176            self.orig_loc,
1177            self.buf.as_ptr() as usize,
1178        ))
1179    }
1180    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
1181        let mut iter = self.clone();
1182        iter.pos = 0;
1183        for attr in iter {
1184            if let LinkAttrs::GsoMaxSegs(val) = attr? {
1185                return Ok(val);
1186            }
1187        }
1188        Err(ErrorContext::new_missing(
1189            "LinkAttrs",
1190            "GsoMaxSegs",
1191            self.orig_loc,
1192            self.buf.as_ptr() as usize,
1193        ))
1194    }
1195    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
1196        let mut iter = self.clone();
1197        iter.pos = 0;
1198        for attr in iter {
1199            if let LinkAttrs::GsoMaxSize(val) = attr? {
1200                return Ok(val);
1201            }
1202        }
1203        Err(ErrorContext::new_missing(
1204            "LinkAttrs",
1205            "GsoMaxSize",
1206            self.orig_loc,
1207            self.buf.as_ptr() as usize,
1208        ))
1209    }
1210    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
1211        let mut iter = self.clone();
1212        iter.pos = 0;
1213        for attr in iter {
1214            if let LinkAttrs::Pad(val) = attr? {
1215                return Ok(val);
1216            }
1217        }
1218        Err(ErrorContext::new_missing(
1219            "LinkAttrs",
1220            "Pad",
1221            self.orig_loc,
1222            self.buf.as_ptr() as usize,
1223        ))
1224    }
1225    pub fn get_xdp(&self) -> Result<IterableXdpAttrs<'a>, ErrorContext> {
1226        let mut iter = self.clone();
1227        iter.pos = 0;
1228        for attr in iter {
1229            if let LinkAttrs::Xdp(val) = attr? {
1230                return Ok(val);
1231            }
1232        }
1233        Err(ErrorContext::new_missing(
1234            "LinkAttrs",
1235            "Xdp",
1236            self.orig_loc,
1237            self.buf.as_ptr() as usize,
1238        ))
1239    }
1240    pub fn get_event(&self) -> Result<u32, ErrorContext> {
1241        let mut iter = self.clone();
1242        iter.pos = 0;
1243        for attr in iter {
1244            if let LinkAttrs::Event(val) = attr? {
1245                return Ok(val);
1246            }
1247        }
1248        Err(ErrorContext::new_missing(
1249            "LinkAttrs",
1250            "Event",
1251            self.orig_loc,
1252            self.buf.as_ptr() as usize,
1253        ))
1254    }
1255    pub fn get_new_netnsid(&self) -> Result<i32, ErrorContext> {
1256        let mut iter = self.clone();
1257        iter.pos = 0;
1258        for attr in iter {
1259            if let LinkAttrs::NewNetnsid(val) = attr? {
1260                return Ok(val);
1261            }
1262        }
1263        Err(ErrorContext::new_missing(
1264            "LinkAttrs",
1265            "NewNetnsid",
1266            self.orig_loc,
1267            self.buf.as_ptr() as usize,
1268        ))
1269    }
1270    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
1271        let mut iter = self.clone();
1272        iter.pos = 0;
1273        for attr in iter {
1274            if let LinkAttrs::TargetNetnsid(val) = attr? {
1275                return Ok(val);
1276            }
1277        }
1278        Err(ErrorContext::new_missing(
1279            "LinkAttrs",
1280            "TargetNetnsid",
1281            self.orig_loc,
1282            self.buf.as_ptr() as usize,
1283        ))
1284    }
1285    pub fn get_carrier_up_count(&self) -> Result<u32, ErrorContext> {
1286        let mut iter = self.clone();
1287        iter.pos = 0;
1288        for attr in iter {
1289            if let LinkAttrs::CarrierUpCount(val) = attr? {
1290                return Ok(val);
1291            }
1292        }
1293        Err(ErrorContext::new_missing(
1294            "LinkAttrs",
1295            "CarrierUpCount",
1296            self.orig_loc,
1297            self.buf.as_ptr() as usize,
1298        ))
1299    }
1300    pub fn get_carrier_down_count(&self) -> Result<u32, ErrorContext> {
1301        let mut iter = self.clone();
1302        iter.pos = 0;
1303        for attr in iter {
1304            if let LinkAttrs::CarrierDownCount(val) = attr? {
1305                return Ok(val);
1306            }
1307        }
1308        Err(ErrorContext::new_missing(
1309            "LinkAttrs",
1310            "CarrierDownCount",
1311            self.orig_loc,
1312            self.buf.as_ptr() as usize,
1313        ))
1314    }
1315    pub fn get_new_ifindex(&self) -> Result<i32, ErrorContext> {
1316        let mut iter = self.clone();
1317        iter.pos = 0;
1318        for attr in iter {
1319            if let LinkAttrs::NewIfindex(val) = attr? {
1320                return Ok(val);
1321            }
1322        }
1323        Err(ErrorContext::new_missing(
1324            "LinkAttrs",
1325            "NewIfindex",
1326            self.orig_loc,
1327            self.buf.as_ptr() as usize,
1328        ))
1329    }
1330    pub fn get_min_mtu(&self) -> Result<u32, ErrorContext> {
1331        let mut iter = self.clone();
1332        iter.pos = 0;
1333        for attr in iter {
1334            if let LinkAttrs::MinMtu(val) = attr? {
1335                return Ok(val);
1336            }
1337        }
1338        Err(ErrorContext::new_missing(
1339            "LinkAttrs",
1340            "MinMtu",
1341            self.orig_loc,
1342            self.buf.as_ptr() as usize,
1343        ))
1344    }
1345    pub fn get_max_mtu(&self) -> Result<u32, ErrorContext> {
1346        let mut iter = self.clone();
1347        iter.pos = 0;
1348        for attr in iter {
1349            if let LinkAttrs::MaxMtu(val) = attr? {
1350                return Ok(val);
1351            }
1352        }
1353        Err(ErrorContext::new_missing(
1354            "LinkAttrs",
1355            "MaxMtu",
1356            self.orig_loc,
1357            self.buf.as_ptr() as usize,
1358        ))
1359    }
1360    pub fn get_prop_list(&self) -> Result<IterablePropListLinkAttrs<'a>, ErrorContext> {
1361        let mut iter = self.clone();
1362        iter.pos = 0;
1363        for attr in iter {
1364            if let LinkAttrs::PropList(val) = attr? {
1365                return Ok(val);
1366            }
1367        }
1368        Err(ErrorContext::new_missing(
1369            "LinkAttrs",
1370            "PropList",
1371            self.orig_loc,
1372            self.buf.as_ptr() as usize,
1373        ))
1374    }
1375    pub fn get_alt_ifname(&self) -> Result<&'a CStr, ErrorContext> {
1376        let mut iter = self.clone();
1377        iter.pos = 0;
1378        for attr in iter {
1379            if let LinkAttrs::AltIfname(val) = attr? {
1380                return Ok(val);
1381            }
1382        }
1383        Err(ErrorContext::new_missing(
1384            "LinkAttrs",
1385            "AltIfname",
1386            self.orig_loc,
1387            self.buf.as_ptr() as usize,
1388        ))
1389    }
1390    pub fn get_perm_address(&self) -> Result<&'a [u8], ErrorContext> {
1391        let mut iter = self.clone();
1392        iter.pos = 0;
1393        for attr in iter {
1394            if let LinkAttrs::PermAddress(val) = attr? {
1395                return Ok(val);
1396            }
1397        }
1398        Err(ErrorContext::new_missing(
1399            "LinkAttrs",
1400            "PermAddress",
1401            self.orig_loc,
1402            self.buf.as_ptr() as usize,
1403        ))
1404    }
1405    pub fn get_proto_down_reason(&self) -> Result<&'a CStr, ErrorContext> {
1406        let mut iter = self.clone();
1407        iter.pos = 0;
1408        for attr in iter {
1409            if let LinkAttrs::ProtoDownReason(val) = attr? {
1410                return Ok(val);
1411            }
1412        }
1413        Err(ErrorContext::new_missing(
1414            "LinkAttrs",
1415            "ProtoDownReason",
1416            self.orig_loc,
1417            self.buf.as_ptr() as usize,
1418        ))
1419    }
1420    pub fn get_parent_dev_name(&self) -> Result<&'a CStr, ErrorContext> {
1421        let mut iter = self.clone();
1422        iter.pos = 0;
1423        for attr in iter {
1424            if let LinkAttrs::ParentDevName(val) = attr? {
1425                return Ok(val);
1426            }
1427        }
1428        Err(ErrorContext::new_missing(
1429            "LinkAttrs",
1430            "ParentDevName",
1431            self.orig_loc,
1432            self.buf.as_ptr() as usize,
1433        ))
1434    }
1435    pub fn get_parent_dev_bus_name(&self) -> Result<&'a CStr, ErrorContext> {
1436        let mut iter = self.clone();
1437        iter.pos = 0;
1438        for attr in iter {
1439            if let LinkAttrs::ParentDevBusName(val) = attr? {
1440                return Ok(val);
1441            }
1442        }
1443        Err(ErrorContext::new_missing(
1444            "LinkAttrs",
1445            "ParentDevBusName",
1446            self.orig_loc,
1447            self.buf.as_ptr() as usize,
1448        ))
1449    }
1450    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
1451        let mut iter = self.clone();
1452        iter.pos = 0;
1453        for attr in iter {
1454            if let LinkAttrs::GroMaxSize(val) = attr? {
1455                return Ok(val);
1456            }
1457        }
1458        Err(ErrorContext::new_missing(
1459            "LinkAttrs",
1460            "GroMaxSize",
1461            self.orig_loc,
1462            self.buf.as_ptr() as usize,
1463        ))
1464    }
1465    pub fn get_tso_max_size(&self) -> Result<u32, ErrorContext> {
1466        let mut iter = self.clone();
1467        iter.pos = 0;
1468        for attr in iter {
1469            if let LinkAttrs::TsoMaxSize(val) = attr? {
1470                return Ok(val);
1471            }
1472        }
1473        Err(ErrorContext::new_missing(
1474            "LinkAttrs",
1475            "TsoMaxSize",
1476            self.orig_loc,
1477            self.buf.as_ptr() as usize,
1478        ))
1479    }
1480    pub fn get_tso_max_segs(&self) -> Result<u32, ErrorContext> {
1481        let mut iter = self.clone();
1482        iter.pos = 0;
1483        for attr in iter {
1484            if let LinkAttrs::TsoMaxSegs(val) = attr? {
1485                return Ok(val);
1486            }
1487        }
1488        Err(ErrorContext::new_missing(
1489            "LinkAttrs",
1490            "TsoMaxSegs",
1491            self.orig_loc,
1492            self.buf.as_ptr() as usize,
1493        ))
1494    }
1495    pub fn get_allmulti(&self) -> Result<u32, ErrorContext> {
1496        let mut iter = self.clone();
1497        iter.pos = 0;
1498        for attr in iter {
1499            if let LinkAttrs::Allmulti(val) = attr? {
1500                return Ok(val);
1501            }
1502        }
1503        Err(ErrorContext::new_missing(
1504            "LinkAttrs",
1505            "Allmulti",
1506            self.orig_loc,
1507            self.buf.as_ptr() as usize,
1508        ))
1509    }
1510    pub fn get_devlink_port(&self) -> Result<&'a [u8], ErrorContext> {
1511        let mut iter = self.clone();
1512        iter.pos = 0;
1513        for attr in iter {
1514            if let LinkAttrs::DevlinkPort(val) = attr? {
1515                return Ok(val);
1516            }
1517        }
1518        Err(ErrorContext::new_missing(
1519            "LinkAttrs",
1520            "DevlinkPort",
1521            self.orig_loc,
1522            self.buf.as_ptr() as usize,
1523        ))
1524    }
1525    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
1526        let mut iter = self.clone();
1527        iter.pos = 0;
1528        for attr in iter {
1529            if let LinkAttrs::GsoIpv4MaxSize(val) = attr? {
1530                return Ok(val);
1531            }
1532        }
1533        Err(ErrorContext::new_missing(
1534            "LinkAttrs",
1535            "GsoIpv4MaxSize",
1536            self.orig_loc,
1537            self.buf.as_ptr() as usize,
1538        ))
1539    }
1540    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
1541        let mut iter = self.clone();
1542        iter.pos = 0;
1543        for attr in iter {
1544            if let LinkAttrs::GroIpv4MaxSize(val) = attr? {
1545                return Ok(val);
1546            }
1547        }
1548        Err(ErrorContext::new_missing(
1549            "LinkAttrs",
1550            "GroIpv4MaxSize",
1551            self.orig_loc,
1552            self.buf.as_ptr() as usize,
1553        ))
1554    }
1555    pub fn get_dpll_pin(&self) -> Result<IterableLinkDpllPinAttrs<'a>, ErrorContext> {
1556        let mut iter = self.clone();
1557        iter.pos = 0;
1558        for attr in iter {
1559            if let LinkAttrs::DpllPin(val) = attr? {
1560                return Ok(val);
1561            }
1562        }
1563        Err(ErrorContext::new_missing(
1564            "LinkAttrs",
1565            "DpllPin",
1566            self.orig_loc,
1567            self.buf.as_ptr() as usize,
1568        ))
1569    }
1570    #[doc = "EDT offload horizon supported by the device (in nsec)."]
1571    pub fn get_max_pacing_offload_horizon(&self) -> Result<u32, ErrorContext> {
1572        let mut iter = self.clone();
1573        iter.pos = 0;
1574        for attr in iter {
1575            if let LinkAttrs::MaxPacingOffloadHorizon(val) = attr? {
1576                return Ok(val);
1577            }
1578        }
1579        Err(ErrorContext::new_missing(
1580            "LinkAttrs",
1581            "MaxPacingOffloadHorizon",
1582            self.orig_loc,
1583            self.buf.as_ptr() as usize,
1584        ))
1585    }
1586    pub fn get_netns_immutable(&self) -> Result<u8, ErrorContext> {
1587        let mut iter = self.clone();
1588        iter.pos = 0;
1589        for attr in iter {
1590            if let LinkAttrs::NetnsImmutable(val) = attr? {
1591                return Ok(val);
1592            }
1593        }
1594        Err(ErrorContext::new_missing(
1595            "LinkAttrs",
1596            "NetnsImmutable",
1597            self.orig_loc,
1598            self.buf.as_ptr() as usize,
1599        ))
1600    }
1601}
1602impl LinkAttrs<'_> {
1603    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkAttrs<'a> {
1604        IterableLinkAttrs::with_loc(buf, buf.as_ptr() as usize)
1605    }
1606    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1607        let res = match r#type {
1608            1u16 => "Address",
1609            2u16 => "Broadcast",
1610            3u16 => "Ifname",
1611            4u16 => "Mtu",
1612            5u16 => "Link",
1613            6u16 => "Qdisc",
1614            7u16 => "Stats",
1615            8u16 => "Cost",
1616            9u16 => "Priority",
1617            10u16 => "Master",
1618            11u16 => "Wireless",
1619            12u16 => "Protinfo",
1620            13u16 => "Txqlen",
1621            14u16 => "Map",
1622            15u16 => "Weight",
1623            16u16 => "Operstate",
1624            17u16 => "Linkmode",
1625            18u16 => "Linkinfo",
1626            19u16 => "NetNsPid",
1627            20u16 => "Ifalias",
1628            21u16 => "NumVf",
1629            22u16 => "VfinfoList",
1630            23u16 => "Stats64",
1631            24u16 => "VfPorts",
1632            25u16 => "PortSelf",
1633            26u16 => "AfSpec",
1634            27u16 => "Group",
1635            28u16 => "NetNsFd",
1636            29u16 => "ExtMask",
1637            30u16 => "Promiscuity",
1638            31u16 => "NumTxQueues",
1639            32u16 => "NumRxQueues",
1640            33u16 => "Carrier",
1641            34u16 => "PhysPortId",
1642            35u16 => "CarrierChanges",
1643            36u16 => "PhysSwitchId",
1644            37u16 => "LinkNetnsid",
1645            38u16 => "PhysPortName",
1646            39u16 => "ProtoDown",
1647            40u16 => "GsoMaxSegs",
1648            41u16 => "GsoMaxSize",
1649            42u16 => "Pad",
1650            43u16 => "Xdp",
1651            44u16 => "Event",
1652            45u16 => "NewNetnsid",
1653            46u16 => "TargetNetnsid",
1654            47u16 => "CarrierUpCount",
1655            48u16 => "CarrierDownCount",
1656            49u16 => "NewIfindex",
1657            50u16 => "MinMtu",
1658            51u16 => "MaxMtu",
1659            52u16 => "PropList",
1660            53u16 => "AltIfname",
1661            54u16 => "PermAddress",
1662            55u16 => "ProtoDownReason",
1663            56u16 => "ParentDevName",
1664            57u16 => "ParentDevBusName",
1665            58u16 => "GroMaxSize",
1666            59u16 => "TsoMaxSize",
1667            60u16 => "TsoMaxSegs",
1668            61u16 => "Allmulti",
1669            62u16 => "DevlinkPort",
1670            63u16 => "GsoIpv4MaxSize",
1671            64u16 => "GroIpv4MaxSize",
1672            65u16 => "DpllPin",
1673            66u16 => "MaxPacingOffloadHorizon",
1674            67u16 => "NetnsImmutable",
1675            _ => return None,
1676        };
1677        Some(res)
1678    }
1679}
1680#[derive(Clone, Copy, Default)]
1681pub struct IterableLinkAttrs<'a> {
1682    buf: &'a [u8],
1683    pos: usize,
1684    orig_loc: usize,
1685}
1686impl<'a> IterableLinkAttrs<'a> {
1687    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1688        Self {
1689            buf,
1690            pos: 0,
1691            orig_loc,
1692        }
1693    }
1694    pub fn get_buf(&self) -> &'a [u8] {
1695        self.buf
1696    }
1697}
1698impl<'a> Iterator for IterableLinkAttrs<'a> {
1699    type Item = Result<LinkAttrs<'a>, ErrorContext>;
1700    fn next(&mut self) -> Option<Self::Item> {
1701        let pos = self.pos;
1702        let mut r#type;
1703        loop {
1704            r#type = None;
1705            if self.buf.len() == self.pos {
1706                return None;
1707            }
1708            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1709                break;
1710            };
1711            r#type = Some(header.r#type);
1712            let res = match header.r#type {
1713                1u16 => LinkAttrs::Address({
1714                    let res = Some(next);
1715                    let Some(val) = res else { break };
1716                    val
1717                }),
1718                2u16 => LinkAttrs::Broadcast({
1719                    let res = Some(next);
1720                    let Some(val) = res else { break };
1721                    val
1722                }),
1723                3u16 => LinkAttrs::Ifname({
1724                    let res = CStr::from_bytes_with_nul(next).ok();
1725                    let Some(val) = res else { break };
1726                    val
1727                }),
1728                4u16 => LinkAttrs::Mtu({
1729                    let res = parse_u32(next);
1730                    let Some(val) = res else { break };
1731                    val
1732                }),
1733                5u16 => LinkAttrs::Link({
1734                    let res = parse_u32(next);
1735                    let Some(val) = res else { break };
1736                    val
1737                }),
1738                6u16 => LinkAttrs::Qdisc({
1739                    let res = CStr::from_bytes_with_nul(next).ok();
1740                    let Some(val) = res else { break };
1741                    val
1742                }),
1743                7u16 => LinkAttrs::Stats({
1744                    let res = Some(PushRtnlLinkStats::new_from_zeroed(next));
1745                    let Some(val) = res else { break };
1746                    val
1747                }),
1748                8u16 => LinkAttrs::Cost({
1749                    let res = CStr::from_bytes_with_nul(next).ok();
1750                    let Some(val) = res else { break };
1751                    val
1752                }),
1753                9u16 => LinkAttrs::Priority({
1754                    let res = CStr::from_bytes_with_nul(next).ok();
1755                    let Some(val) = res else { break };
1756                    val
1757                }),
1758                10u16 => LinkAttrs::Master({
1759                    let res = parse_u32(next);
1760                    let Some(val) = res else { break };
1761                    val
1762                }),
1763                11u16 => LinkAttrs::Wireless({
1764                    let res = CStr::from_bytes_with_nul(next).ok();
1765                    let Some(val) = res else { break };
1766                    val
1767                }),
1768                12u16 => LinkAttrs::Protinfo({
1769                    let res = CStr::from_bytes_with_nul(next).ok();
1770                    let Some(val) = res else { break };
1771                    val
1772                }),
1773                13u16 => LinkAttrs::Txqlen({
1774                    let res = parse_u32(next);
1775                    let Some(val) = res else { break };
1776                    val
1777                }),
1778                14u16 => LinkAttrs::Map({
1779                    let res = PushRtnlLinkIfmap::new_from_slice(next);
1780                    let Some(val) = res else { break };
1781                    val
1782                }),
1783                15u16 => LinkAttrs::Weight({
1784                    let res = parse_u32(next);
1785                    let Some(val) = res else { break };
1786                    val
1787                }),
1788                16u16 => LinkAttrs::Operstate({
1789                    let res = parse_u8(next);
1790                    let Some(val) = res else { break };
1791                    val
1792                }),
1793                17u16 => LinkAttrs::Linkmode({
1794                    let res = parse_u8(next);
1795                    let Some(val) = res else { break };
1796                    val
1797                }),
1798                18u16 => LinkAttrs::Linkinfo({
1799                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
1800                    let Some(val) = res else { break };
1801                    val
1802                }),
1803                19u16 => LinkAttrs::NetNsPid({
1804                    let res = parse_u32(next);
1805                    let Some(val) = res else { break };
1806                    val
1807                }),
1808                20u16 => LinkAttrs::Ifalias({
1809                    let res = CStr::from_bytes_with_nul(next).ok();
1810                    let Some(val) = res else { break };
1811                    val
1812                }),
1813                21u16 => LinkAttrs::NumVf({
1814                    let res = parse_u32(next);
1815                    let Some(val) = res else { break };
1816                    val
1817                }),
1818                22u16 => LinkAttrs::VfinfoList({
1819                    let res = Some(IterableVfinfoListAttrs::with_loc(next, self.orig_loc));
1820                    let Some(val) = res else { break };
1821                    val
1822                }),
1823                23u16 => LinkAttrs::Stats64({
1824                    let res = Some(PushRtnlLinkStats64::new_from_zeroed(next));
1825                    let Some(val) = res else { break };
1826                    val
1827                }),
1828                24u16 => LinkAttrs::VfPorts({
1829                    let res = Some(IterableVfPortsAttrs::with_loc(next, self.orig_loc));
1830                    let Some(val) = res else { break };
1831                    val
1832                }),
1833                25u16 => LinkAttrs::PortSelf({
1834                    let res = Some(IterablePortSelfAttrs::with_loc(next, self.orig_loc));
1835                    let Some(val) = res else { break };
1836                    val
1837                }),
1838                26u16 => LinkAttrs::AfSpec({
1839                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
1840                    let Some(val) = res else { break };
1841                    val
1842                }),
1843                27u16 => LinkAttrs::Group({
1844                    let res = parse_u32(next);
1845                    let Some(val) = res else { break };
1846                    val
1847                }),
1848                28u16 => LinkAttrs::NetNsFd({
1849                    let res = parse_u32(next);
1850                    let Some(val) = res else { break };
1851                    val
1852                }),
1853                29u16 => LinkAttrs::ExtMask({
1854                    let res = parse_u32(next);
1855                    let Some(val) = res else { break };
1856                    val
1857                }),
1858                30u16 => LinkAttrs::Promiscuity({
1859                    let res = parse_u32(next);
1860                    let Some(val) = res else { break };
1861                    val
1862                }),
1863                31u16 => LinkAttrs::NumTxQueues({
1864                    let res = parse_u32(next);
1865                    let Some(val) = res else { break };
1866                    val
1867                }),
1868                32u16 => LinkAttrs::NumRxQueues({
1869                    let res = parse_u32(next);
1870                    let Some(val) = res else { break };
1871                    val
1872                }),
1873                33u16 => LinkAttrs::Carrier({
1874                    let res = parse_u8(next);
1875                    let Some(val) = res else { break };
1876                    val
1877                }),
1878                34u16 => LinkAttrs::PhysPortId({
1879                    let res = Some(next);
1880                    let Some(val) = res else { break };
1881                    val
1882                }),
1883                35u16 => LinkAttrs::CarrierChanges({
1884                    let res = parse_u32(next);
1885                    let Some(val) = res else { break };
1886                    val
1887                }),
1888                36u16 => LinkAttrs::PhysSwitchId({
1889                    let res = Some(next);
1890                    let Some(val) = res else { break };
1891                    val
1892                }),
1893                37u16 => LinkAttrs::LinkNetnsid({
1894                    let res = parse_i32(next);
1895                    let Some(val) = res else { break };
1896                    val
1897                }),
1898                38u16 => LinkAttrs::PhysPortName({
1899                    let res = CStr::from_bytes_with_nul(next).ok();
1900                    let Some(val) = res else { break };
1901                    val
1902                }),
1903                39u16 => LinkAttrs::ProtoDown({
1904                    let res = parse_u8(next);
1905                    let Some(val) = res else { break };
1906                    val
1907                }),
1908                40u16 => LinkAttrs::GsoMaxSegs({
1909                    let res = parse_u32(next);
1910                    let Some(val) = res else { break };
1911                    val
1912                }),
1913                41u16 => LinkAttrs::GsoMaxSize({
1914                    let res = parse_u32(next);
1915                    let Some(val) = res else { break };
1916                    val
1917                }),
1918                42u16 => LinkAttrs::Pad({
1919                    let res = Some(next);
1920                    let Some(val) = res else { break };
1921                    val
1922                }),
1923                43u16 => LinkAttrs::Xdp({
1924                    let res = Some(IterableXdpAttrs::with_loc(next, self.orig_loc));
1925                    let Some(val) = res else { break };
1926                    val
1927                }),
1928                44u16 => LinkAttrs::Event({
1929                    let res = parse_u32(next);
1930                    let Some(val) = res else { break };
1931                    val
1932                }),
1933                45u16 => LinkAttrs::NewNetnsid({
1934                    let res = parse_i32(next);
1935                    let Some(val) = res else { break };
1936                    val
1937                }),
1938                46u16 => LinkAttrs::TargetNetnsid({
1939                    let res = parse_i32(next);
1940                    let Some(val) = res else { break };
1941                    val
1942                }),
1943                47u16 => LinkAttrs::CarrierUpCount({
1944                    let res = parse_u32(next);
1945                    let Some(val) = res else { break };
1946                    val
1947                }),
1948                48u16 => LinkAttrs::CarrierDownCount({
1949                    let res = parse_u32(next);
1950                    let Some(val) = res else { break };
1951                    val
1952                }),
1953                49u16 => LinkAttrs::NewIfindex({
1954                    let res = parse_i32(next);
1955                    let Some(val) = res else { break };
1956                    val
1957                }),
1958                50u16 => LinkAttrs::MinMtu({
1959                    let res = parse_u32(next);
1960                    let Some(val) = res else { break };
1961                    val
1962                }),
1963                51u16 => LinkAttrs::MaxMtu({
1964                    let res = parse_u32(next);
1965                    let Some(val) = res else { break };
1966                    val
1967                }),
1968                52u16 => LinkAttrs::PropList({
1969                    let res = Some(IterablePropListLinkAttrs::with_loc(next, self.orig_loc));
1970                    let Some(val) = res else { break };
1971                    val
1972                }),
1973                53u16 => LinkAttrs::AltIfname({
1974                    let res = CStr::from_bytes_with_nul(next).ok();
1975                    let Some(val) = res else { break };
1976                    val
1977                }),
1978                54u16 => LinkAttrs::PermAddress({
1979                    let res = Some(next);
1980                    let Some(val) = res else { break };
1981                    val
1982                }),
1983                55u16 => LinkAttrs::ProtoDownReason({
1984                    let res = CStr::from_bytes_with_nul(next).ok();
1985                    let Some(val) = res else { break };
1986                    val
1987                }),
1988                56u16 => LinkAttrs::ParentDevName({
1989                    let res = CStr::from_bytes_with_nul(next).ok();
1990                    let Some(val) = res else { break };
1991                    val
1992                }),
1993                57u16 => LinkAttrs::ParentDevBusName({
1994                    let res = CStr::from_bytes_with_nul(next).ok();
1995                    let Some(val) = res else { break };
1996                    val
1997                }),
1998                58u16 => LinkAttrs::GroMaxSize({
1999                    let res = parse_u32(next);
2000                    let Some(val) = res else { break };
2001                    val
2002                }),
2003                59u16 => LinkAttrs::TsoMaxSize({
2004                    let res = parse_u32(next);
2005                    let Some(val) = res else { break };
2006                    val
2007                }),
2008                60u16 => LinkAttrs::TsoMaxSegs({
2009                    let res = parse_u32(next);
2010                    let Some(val) = res else { break };
2011                    val
2012                }),
2013                61u16 => LinkAttrs::Allmulti({
2014                    let res = parse_u32(next);
2015                    let Some(val) = res else { break };
2016                    val
2017                }),
2018                62u16 => LinkAttrs::DevlinkPort({
2019                    let res = Some(next);
2020                    let Some(val) = res else { break };
2021                    val
2022                }),
2023                63u16 => LinkAttrs::GsoIpv4MaxSize({
2024                    let res = parse_u32(next);
2025                    let Some(val) = res else { break };
2026                    val
2027                }),
2028                64u16 => LinkAttrs::GroIpv4MaxSize({
2029                    let res = parse_u32(next);
2030                    let Some(val) = res else { break };
2031                    val
2032                }),
2033                65u16 => LinkAttrs::DpllPin({
2034                    let res = Some(IterableLinkDpllPinAttrs::with_loc(next, self.orig_loc));
2035                    let Some(val) = res else { break };
2036                    val
2037                }),
2038                66u16 => LinkAttrs::MaxPacingOffloadHorizon({
2039                    let res = parse_u32(next);
2040                    let Some(val) = res else { break };
2041                    val
2042                }),
2043                67u16 => LinkAttrs::NetnsImmutable({
2044                    let res = parse_u8(next);
2045                    let Some(val) = res else { break };
2046                    val
2047                }),
2048                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2049                n => continue,
2050            };
2051            return Some(Ok(res));
2052        }
2053        Some(Err(ErrorContext::new(
2054            "LinkAttrs",
2055            r#type.and_then(|t| LinkAttrs::attr_from_type(t)),
2056            self.orig_loc,
2057            self.buf.as_ptr().wrapping_add(pos) as usize,
2058        )))
2059    }
2060}
2061impl<'a> std::fmt::Debug for IterableLinkAttrs<'_> {
2062    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2063        let mut fmt = f.debug_struct("LinkAttrs");
2064        for attr in self.clone() {
2065            let attr = match attr {
2066                Ok(a) => a,
2067                Err(err) => {
2068                    fmt.finish()?;
2069                    f.write_str("Err(")?;
2070                    err.fmt(f)?;
2071                    return f.write_str(")");
2072                }
2073            };
2074            match attr {
2075                LinkAttrs::Address(val) => fmt.field("Address", &val),
2076                LinkAttrs::Broadcast(val) => fmt.field("Broadcast", &val),
2077                LinkAttrs::Ifname(val) => fmt.field("Ifname", &val),
2078                LinkAttrs::Mtu(val) => fmt.field("Mtu", &val),
2079                LinkAttrs::Link(val) => fmt.field("Link", &val),
2080                LinkAttrs::Qdisc(val) => fmt.field("Qdisc", &val),
2081                LinkAttrs::Stats(val) => fmt.field("Stats", &val),
2082                LinkAttrs::Cost(val) => fmt.field("Cost", &val),
2083                LinkAttrs::Priority(val) => fmt.field("Priority", &val),
2084                LinkAttrs::Master(val) => fmt.field("Master", &val),
2085                LinkAttrs::Wireless(val) => fmt.field("Wireless", &val),
2086                LinkAttrs::Protinfo(val) => fmt.field("Protinfo", &val),
2087                LinkAttrs::Txqlen(val) => fmt.field("Txqlen", &val),
2088                LinkAttrs::Map(val) => fmt.field("Map", &val),
2089                LinkAttrs::Weight(val) => fmt.field("Weight", &val),
2090                LinkAttrs::Operstate(val) => fmt.field("Operstate", &val),
2091                LinkAttrs::Linkmode(val) => fmt.field("Linkmode", &val),
2092                LinkAttrs::Linkinfo(val) => fmt.field("Linkinfo", &val),
2093                LinkAttrs::NetNsPid(val) => fmt.field("NetNsPid", &val),
2094                LinkAttrs::Ifalias(val) => fmt.field("Ifalias", &val),
2095                LinkAttrs::NumVf(val) => fmt.field("NumVf", &val),
2096                LinkAttrs::VfinfoList(val) => fmt.field("VfinfoList", &val),
2097                LinkAttrs::Stats64(val) => fmt.field("Stats64", &val),
2098                LinkAttrs::VfPorts(val) => fmt.field("VfPorts", &val),
2099                LinkAttrs::PortSelf(val) => fmt.field("PortSelf", &val),
2100                LinkAttrs::AfSpec(val) => fmt.field("AfSpec", &val),
2101                LinkAttrs::Group(val) => fmt.field("Group", &val),
2102                LinkAttrs::NetNsFd(val) => fmt.field("NetNsFd", &val),
2103                LinkAttrs::ExtMask(val) => {
2104                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
2105                }
2106                LinkAttrs::Promiscuity(val) => fmt.field("Promiscuity", &val),
2107                LinkAttrs::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
2108                LinkAttrs::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
2109                LinkAttrs::Carrier(val) => fmt.field("Carrier", &val),
2110                LinkAttrs::PhysPortId(val) => fmt.field("PhysPortId", &val),
2111                LinkAttrs::CarrierChanges(val) => fmt.field("CarrierChanges", &val),
2112                LinkAttrs::PhysSwitchId(val) => fmt.field("PhysSwitchId", &val),
2113                LinkAttrs::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
2114                LinkAttrs::PhysPortName(val) => fmt.field("PhysPortName", &val),
2115                LinkAttrs::ProtoDown(val) => fmt.field("ProtoDown", &val),
2116                LinkAttrs::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
2117                LinkAttrs::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
2118                LinkAttrs::Pad(val) => fmt.field("Pad", &val),
2119                LinkAttrs::Xdp(val) => fmt.field("Xdp", &val),
2120                LinkAttrs::Event(val) => fmt.field("Event", &val),
2121                LinkAttrs::NewNetnsid(val) => fmt.field("NewNetnsid", &val),
2122                LinkAttrs::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
2123                LinkAttrs::CarrierUpCount(val) => fmt.field("CarrierUpCount", &val),
2124                LinkAttrs::CarrierDownCount(val) => fmt.field("CarrierDownCount", &val),
2125                LinkAttrs::NewIfindex(val) => fmt.field("NewIfindex", &val),
2126                LinkAttrs::MinMtu(val) => fmt.field("MinMtu", &val),
2127                LinkAttrs::MaxMtu(val) => fmt.field("MaxMtu", &val),
2128                LinkAttrs::PropList(val) => fmt.field("PropList", &val),
2129                LinkAttrs::AltIfname(val) => fmt.field("AltIfname", &val),
2130                LinkAttrs::PermAddress(val) => fmt.field("PermAddress", &val),
2131                LinkAttrs::ProtoDownReason(val) => fmt.field("ProtoDownReason", &val),
2132                LinkAttrs::ParentDevName(val) => fmt.field("ParentDevName", &val),
2133                LinkAttrs::ParentDevBusName(val) => fmt.field("ParentDevBusName", &val),
2134                LinkAttrs::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
2135                LinkAttrs::TsoMaxSize(val) => fmt.field("TsoMaxSize", &val),
2136                LinkAttrs::TsoMaxSegs(val) => fmt.field("TsoMaxSegs", &val),
2137                LinkAttrs::Allmulti(val) => fmt.field("Allmulti", &val),
2138                LinkAttrs::DevlinkPort(val) => fmt.field("DevlinkPort", &val),
2139                LinkAttrs::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
2140                LinkAttrs::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
2141                LinkAttrs::DpllPin(val) => fmt.field("DpllPin", &val),
2142                LinkAttrs::MaxPacingOffloadHorizon(val) => {
2143                    fmt.field("MaxPacingOffloadHorizon", &val)
2144                }
2145                LinkAttrs::NetnsImmutable(val) => fmt.field("NetnsImmutable", &val),
2146            };
2147        }
2148        fmt.finish()
2149    }
2150}
2151impl IterableLinkAttrs<'_> {
2152    pub fn lookup_attr(
2153        &self,
2154        offset: usize,
2155        missing_type: Option<u16>,
2156    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2157        let mut stack = Vec::new();
2158        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2159        if cur == offset {
2160            stack.push(("LinkAttrs", offset));
2161            return (
2162                stack,
2163                missing_type.and_then(|t| LinkAttrs::attr_from_type(t)),
2164            );
2165        }
2166        if cur > offset || cur + self.buf.len() < offset {
2167            return (stack, None);
2168        }
2169        let mut attrs = self.clone();
2170        let mut last_off = cur + attrs.pos;
2171        let mut missing = None;
2172        while let Some(attr) = attrs.next() {
2173            let Ok(attr) = attr else { break };
2174            match attr {
2175                LinkAttrs::Address(val) => {
2176                    if last_off == offset {
2177                        stack.push(("Address", last_off));
2178                        break;
2179                    }
2180                }
2181                LinkAttrs::Broadcast(val) => {
2182                    if last_off == offset {
2183                        stack.push(("Broadcast", last_off));
2184                        break;
2185                    }
2186                }
2187                LinkAttrs::Ifname(val) => {
2188                    if last_off == offset {
2189                        stack.push(("Ifname", last_off));
2190                        break;
2191                    }
2192                }
2193                LinkAttrs::Mtu(val) => {
2194                    if last_off == offset {
2195                        stack.push(("Mtu", last_off));
2196                        break;
2197                    }
2198                }
2199                LinkAttrs::Link(val) => {
2200                    if last_off == offset {
2201                        stack.push(("Link", last_off));
2202                        break;
2203                    }
2204                }
2205                LinkAttrs::Qdisc(val) => {
2206                    if last_off == offset {
2207                        stack.push(("Qdisc", last_off));
2208                        break;
2209                    }
2210                }
2211                LinkAttrs::Stats(val) => {
2212                    if last_off == offset {
2213                        stack.push(("Stats", last_off));
2214                        break;
2215                    }
2216                }
2217                LinkAttrs::Cost(val) => {
2218                    if last_off == offset {
2219                        stack.push(("Cost", last_off));
2220                        break;
2221                    }
2222                }
2223                LinkAttrs::Priority(val) => {
2224                    if last_off == offset {
2225                        stack.push(("Priority", last_off));
2226                        break;
2227                    }
2228                }
2229                LinkAttrs::Master(val) => {
2230                    if last_off == offset {
2231                        stack.push(("Master", last_off));
2232                        break;
2233                    }
2234                }
2235                LinkAttrs::Wireless(val) => {
2236                    if last_off == offset {
2237                        stack.push(("Wireless", last_off));
2238                        break;
2239                    }
2240                }
2241                LinkAttrs::Protinfo(val) => {
2242                    if last_off == offset {
2243                        stack.push(("Protinfo", last_off));
2244                        break;
2245                    }
2246                }
2247                LinkAttrs::Txqlen(val) => {
2248                    if last_off == offset {
2249                        stack.push(("Txqlen", last_off));
2250                        break;
2251                    }
2252                }
2253                LinkAttrs::Map(val) => {
2254                    if last_off == offset {
2255                        stack.push(("Map", last_off));
2256                        break;
2257                    }
2258                }
2259                LinkAttrs::Weight(val) => {
2260                    if last_off == offset {
2261                        stack.push(("Weight", last_off));
2262                        break;
2263                    }
2264                }
2265                LinkAttrs::Operstate(val) => {
2266                    if last_off == offset {
2267                        stack.push(("Operstate", last_off));
2268                        break;
2269                    }
2270                }
2271                LinkAttrs::Linkmode(val) => {
2272                    if last_off == offset {
2273                        stack.push(("Linkmode", last_off));
2274                        break;
2275                    }
2276                }
2277                LinkAttrs::Linkinfo(val) => {
2278                    (stack, missing) = val.lookup_attr(offset, missing_type);
2279                    if !stack.is_empty() {
2280                        break;
2281                    }
2282                }
2283                LinkAttrs::NetNsPid(val) => {
2284                    if last_off == offset {
2285                        stack.push(("NetNsPid", last_off));
2286                        break;
2287                    }
2288                }
2289                LinkAttrs::Ifalias(val) => {
2290                    if last_off == offset {
2291                        stack.push(("Ifalias", last_off));
2292                        break;
2293                    }
2294                }
2295                LinkAttrs::NumVf(val) => {
2296                    if last_off == offset {
2297                        stack.push(("NumVf", last_off));
2298                        break;
2299                    }
2300                }
2301                LinkAttrs::VfinfoList(val) => {
2302                    (stack, missing) = val.lookup_attr(offset, missing_type);
2303                    if !stack.is_empty() {
2304                        break;
2305                    }
2306                }
2307                LinkAttrs::Stats64(val) => {
2308                    if last_off == offset {
2309                        stack.push(("Stats64", last_off));
2310                        break;
2311                    }
2312                }
2313                LinkAttrs::VfPorts(val) => {
2314                    (stack, missing) = val.lookup_attr(offset, missing_type);
2315                    if !stack.is_empty() {
2316                        break;
2317                    }
2318                }
2319                LinkAttrs::PortSelf(val) => {
2320                    (stack, missing) = val.lookup_attr(offset, missing_type);
2321                    if !stack.is_empty() {
2322                        break;
2323                    }
2324                }
2325                LinkAttrs::AfSpec(val) => {
2326                    (stack, missing) = val.lookup_attr(offset, missing_type);
2327                    if !stack.is_empty() {
2328                        break;
2329                    }
2330                }
2331                LinkAttrs::Group(val) => {
2332                    if last_off == offset {
2333                        stack.push(("Group", last_off));
2334                        break;
2335                    }
2336                }
2337                LinkAttrs::NetNsFd(val) => {
2338                    if last_off == offset {
2339                        stack.push(("NetNsFd", last_off));
2340                        break;
2341                    }
2342                }
2343                LinkAttrs::ExtMask(val) => {
2344                    if last_off == offset {
2345                        stack.push(("ExtMask", last_off));
2346                        break;
2347                    }
2348                }
2349                LinkAttrs::Promiscuity(val) => {
2350                    if last_off == offset {
2351                        stack.push(("Promiscuity", last_off));
2352                        break;
2353                    }
2354                }
2355                LinkAttrs::NumTxQueues(val) => {
2356                    if last_off == offset {
2357                        stack.push(("NumTxQueues", last_off));
2358                        break;
2359                    }
2360                }
2361                LinkAttrs::NumRxQueues(val) => {
2362                    if last_off == offset {
2363                        stack.push(("NumRxQueues", last_off));
2364                        break;
2365                    }
2366                }
2367                LinkAttrs::Carrier(val) => {
2368                    if last_off == offset {
2369                        stack.push(("Carrier", last_off));
2370                        break;
2371                    }
2372                }
2373                LinkAttrs::PhysPortId(val) => {
2374                    if last_off == offset {
2375                        stack.push(("PhysPortId", last_off));
2376                        break;
2377                    }
2378                }
2379                LinkAttrs::CarrierChanges(val) => {
2380                    if last_off == offset {
2381                        stack.push(("CarrierChanges", last_off));
2382                        break;
2383                    }
2384                }
2385                LinkAttrs::PhysSwitchId(val) => {
2386                    if last_off == offset {
2387                        stack.push(("PhysSwitchId", last_off));
2388                        break;
2389                    }
2390                }
2391                LinkAttrs::LinkNetnsid(val) => {
2392                    if last_off == offset {
2393                        stack.push(("LinkNetnsid", last_off));
2394                        break;
2395                    }
2396                }
2397                LinkAttrs::PhysPortName(val) => {
2398                    if last_off == offset {
2399                        stack.push(("PhysPortName", last_off));
2400                        break;
2401                    }
2402                }
2403                LinkAttrs::ProtoDown(val) => {
2404                    if last_off == offset {
2405                        stack.push(("ProtoDown", last_off));
2406                        break;
2407                    }
2408                }
2409                LinkAttrs::GsoMaxSegs(val) => {
2410                    if last_off == offset {
2411                        stack.push(("GsoMaxSegs", last_off));
2412                        break;
2413                    }
2414                }
2415                LinkAttrs::GsoMaxSize(val) => {
2416                    if last_off == offset {
2417                        stack.push(("GsoMaxSize", last_off));
2418                        break;
2419                    }
2420                }
2421                LinkAttrs::Pad(val) => {
2422                    if last_off == offset {
2423                        stack.push(("Pad", last_off));
2424                        break;
2425                    }
2426                }
2427                LinkAttrs::Xdp(val) => {
2428                    (stack, missing) = val.lookup_attr(offset, missing_type);
2429                    if !stack.is_empty() {
2430                        break;
2431                    }
2432                }
2433                LinkAttrs::Event(val) => {
2434                    if last_off == offset {
2435                        stack.push(("Event", last_off));
2436                        break;
2437                    }
2438                }
2439                LinkAttrs::NewNetnsid(val) => {
2440                    if last_off == offset {
2441                        stack.push(("NewNetnsid", last_off));
2442                        break;
2443                    }
2444                }
2445                LinkAttrs::TargetNetnsid(val) => {
2446                    if last_off == offset {
2447                        stack.push(("TargetNetnsid", last_off));
2448                        break;
2449                    }
2450                }
2451                LinkAttrs::CarrierUpCount(val) => {
2452                    if last_off == offset {
2453                        stack.push(("CarrierUpCount", last_off));
2454                        break;
2455                    }
2456                }
2457                LinkAttrs::CarrierDownCount(val) => {
2458                    if last_off == offset {
2459                        stack.push(("CarrierDownCount", last_off));
2460                        break;
2461                    }
2462                }
2463                LinkAttrs::NewIfindex(val) => {
2464                    if last_off == offset {
2465                        stack.push(("NewIfindex", last_off));
2466                        break;
2467                    }
2468                }
2469                LinkAttrs::MinMtu(val) => {
2470                    if last_off == offset {
2471                        stack.push(("MinMtu", last_off));
2472                        break;
2473                    }
2474                }
2475                LinkAttrs::MaxMtu(val) => {
2476                    if last_off == offset {
2477                        stack.push(("MaxMtu", last_off));
2478                        break;
2479                    }
2480                }
2481                LinkAttrs::PropList(val) => {
2482                    (stack, missing) = val.lookup_attr(offset, missing_type);
2483                    if !stack.is_empty() {
2484                        break;
2485                    }
2486                }
2487                LinkAttrs::AltIfname(val) => {
2488                    if last_off == offset {
2489                        stack.push(("AltIfname", last_off));
2490                        break;
2491                    }
2492                }
2493                LinkAttrs::PermAddress(val) => {
2494                    if last_off == offset {
2495                        stack.push(("PermAddress", last_off));
2496                        break;
2497                    }
2498                }
2499                LinkAttrs::ProtoDownReason(val) => {
2500                    if last_off == offset {
2501                        stack.push(("ProtoDownReason", last_off));
2502                        break;
2503                    }
2504                }
2505                LinkAttrs::ParentDevName(val) => {
2506                    if last_off == offset {
2507                        stack.push(("ParentDevName", last_off));
2508                        break;
2509                    }
2510                }
2511                LinkAttrs::ParentDevBusName(val) => {
2512                    if last_off == offset {
2513                        stack.push(("ParentDevBusName", last_off));
2514                        break;
2515                    }
2516                }
2517                LinkAttrs::GroMaxSize(val) => {
2518                    if last_off == offset {
2519                        stack.push(("GroMaxSize", last_off));
2520                        break;
2521                    }
2522                }
2523                LinkAttrs::TsoMaxSize(val) => {
2524                    if last_off == offset {
2525                        stack.push(("TsoMaxSize", last_off));
2526                        break;
2527                    }
2528                }
2529                LinkAttrs::TsoMaxSegs(val) => {
2530                    if last_off == offset {
2531                        stack.push(("TsoMaxSegs", last_off));
2532                        break;
2533                    }
2534                }
2535                LinkAttrs::Allmulti(val) => {
2536                    if last_off == offset {
2537                        stack.push(("Allmulti", last_off));
2538                        break;
2539                    }
2540                }
2541                LinkAttrs::DevlinkPort(val) => {
2542                    if last_off == offset {
2543                        stack.push(("DevlinkPort", last_off));
2544                        break;
2545                    }
2546                }
2547                LinkAttrs::GsoIpv4MaxSize(val) => {
2548                    if last_off == offset {
2549                        stack.push(("GsoIpv4MaxSize", last_off));
2550                        break;
2551                    }
2552                }
2553                LinkAttrs::GroIpv4MaxSize(val) => {
2554                    if last_off == offset {
2555                        stack.push(("GroIpv4MaxSize", last_off));
2556                        break;
2557                    }
2558                }
2559                LinkAttrs::DpllPin(val) => {
2560                    (stack, missing) = val.lookup_attr(offset, missing_type);
2561                    if !stack.is_empty() {
2562                        break;
2563                    }
2564                }
2565                LinkAttrs::MaxPacingOffloadHorizon(val) => {
2566                    if last_off == offset {
2567                        stack.push(("MaxPacingOffloadHorizon", last_off));
2568                        break;
2569                    }
2570                }
2571                LinkAttrs::NetnsImmutable(val) => {
2572                    if last_off == offset {
2573                        stack.push(("NetnsImmutable", last_off));
2574                        break;
2575                    }
2576                }
2577                _ => {}
2578            };
2579            last_off = cur + attrs.pos;
2580        }
2581        if !stack.is_empty() {
2582            stack.push(("LinkAttrs", cur));
2583        }
2584        (stack, missing)
2585    }
2586}
2587#[derive(Clone)]
2588pub enum PropListLinkAttrs<'a> {
2589    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2590    AltIfname(&'a CStr),
2591}
2592impl<'a> IterablePropListLinkAttrs<'a> {
2593    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2594    pub fn get_alt_ifname(&self) -> MultiAttrIterable<Self, PropListLinkAttrs<'a>, &'a CStr> {
2595        MultiAttrIterable::new(self.clone(), |variant| {
2596            if let PropListLinkAttrs::AltIfname(val) = variant {
2597                Some(val)
2598            } else {
2599                None
2600            }
2601        })
2602    }
2603}
2604impl PropListLinkAttrs<'_> {
2605    pub fn new<'a>(buf: &'a [u8]) -> IterablePropListLinkAttrs<'a> {
2606        IterablePropListLinkAttrs::with_loc(buf, buf.as_ptr() as usize)
2607    }
2608    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2609        LinkAttrs::attr_from_type(r#type)
2610    }
2611}
2612#[derive(Clone, Copy, Default)]
2613pub struct IterablePropListLinkAttrs<'a> {
2614    buf: &'a [u8],
2615    pos: usize,
2616    orig_loc: usize,
2617}
2618impl<'a> IterablePropListLinkAttrs<'a> {
2619    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2620        Self {
2621            buf,
2622            pos: 0,
2623            orig_loc,
2624        }
2625    }
2626    pub fn get_buf(&self) -> &'a [u8] {
2627        self.buf
2628    }
2629}
2630impl<'a> Iterator for IterablePropListLinkAttrs<'a> {
2631    type Item = Result<PropListLinkAttrs<'a>, ErrorContext>;
2632    fn next(&mut self) -> Option<Self::Item> {
2633        let pos = self.pos;
2634        let mut r#type;
2635        loop {
2636            r#type = None;
2637            if self.buf.len() == self.pos {
2638                return None;
2639            }
2640            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2641                break;
2642            };
2643            r#type = Some(header.r#type);
2644            let res = match header.r#type {
2645                53u16 => PropListLinkAttrs::AltIfname({
2646                    let res = CStr::from_bytes_with_nul(next).ok();
2647                    let Some(val) = res else { break };
2648                    val
2649                }),
2650                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2651                n => continue,
2652            };
2653            return Some(Ok(res));
2654        }
2655        Some(Err(ErrorContext::new(
2656            "PropListLinkAttrs",
2657            r#type.and_then(|t| PropListLinkAttrs::attr_from_type(t)),
2658            self.orig_loc,
2659            self.buf.as_ptr().wrapping_add(pos) as usize,
2660        )))
2661    }
2662}
2663impl<'a> std::fmt::Debug for IterablePropListLinkAttrs<'_> {
2664    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2665        let mut fmt = f.debug_struct("PropListLinkAttrs");
2666        for attr in self.clone() {
2667            let attr = match attr {
2668                Ok(a) => a,
2669                Err(err) => {
2670                    fmt.finish()?;
2671                    f.write_str("Err(")?;
2672                    err.fmt(f)?;
2673                    return f.write_str(")");
2674                }
2675            };
2676            match attr {
2677                PropListLinkAttrs::AltIfname(val) => fmt.field("AltIfname", &val),
2678            };
2679        }
2680        fmt.finish()
2681    }
2682}
2683impl IterablePropListLinkAttrs<'_> {
2684    pub fn lookup_attr(
2685        &self,
2686        offset: usize,
2687        missing_type: Option<u16>,
2688    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2689        let mut stack = Vec::new();
2690        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2691        if cur == offset {
2692            stack.push(("PropListLinkAttrs", offset));
2693            return (
2694                stack,
2695                missing_type.and_then(|t| PropListLinkAttrs::attr_from_type(t)),
2696            );
2697        }
2698        if cur > offset || cur + self.buf.len() < offset {
2699            return (stack, None);
2700        }
2701        let mut attrs = self.clone();
2702        let mut last_off = cur + attrs.pos;
2703        while let Some(attr) = attrs.next() {
2704            let Ok(attr) = attr else { break };
2705            match attr {
2706                PropListLinkAttrs::AltIfname(val) => {
2707                    if last_off == offset {
2708                        stack.push(("AltIfname", last_off));
2709                        break;
2710                    }
2711                }
2712                _ => {}
2713            };
2714            last_off = cur + attrs.pos;
2715        }
2716        if !stack.is_empty() {
2717            stack.push(("PropListLinkAttrs", cur));
2718        }
2719        (stack, None)
2720    }
2721}
2722#[derive(Clone)]
2723pub enum AfSpecAttrs<'a> {
2724    Inet(IterableIflaAttrs<'a>),
2725    Inet6(IterableIfla6Attrs<'a>),
2726    Mctp(IterableMctpAttrs<'a>),
2727}
2728impl<'a> IterableAfSpecAttrs<'a> {
2729    pub fn get_inet(&self) -> Result<IterableIflaAttrs<'a>, ErrorContext> {
2730        let mut iter = self.clone();
2731        iter.pos = 0;
2732        for attr in iter {
2733            if let AfSpecAttrs::Inet(val) = attr? {
2734                return Ok(val);
2735            }
2736        }
2737        Err(ErrorContext::new_missing(
2738            "AfSpecAttrs",
2739            "Inet",
2740            self.orig_loc,
2741            self.buf.as_ptr() as usize,
2742        ))
2743    }
2744    pub fn get_inet6(&self) -> Result<IterableIfla6Attrs<'a>, ErrorContext> {
2745        let mut iter = self.clone();
2746        iter.pos = 0;
2747        for attr in iter {
2748            if let AfSpecAttrs::Inet6(val) = attr? {
2749                return Ok(val);
2750            }
2751        }
2752        Err(ErrorContext::new_missing(
2753            "AfSpecAttrs",
2754            "Inet6",
2755            self.orig_loc,
2756            self.buf.as_ptr() as usize,
2757        ))
2758    }
2759    pub fn get_mctp(&self) -> Result<IterableMctpAttrs<'a>, ErrorContext> {
2760        let mut iter = self.clone();
2761        iter.pos = 0;
2762        for attr in iter {
2763            if let AfSpecAttrs::Mctp(val) = attr? {
2764                return Ok(val);
2765            }
2766        }
2767        Err(ErrorContext::new_missing(
2768            "AfSpecAttrs",
2769            "Mctp",
2770            self.orig_loc,
2771            self.buf.as_ptr() as usize,
2772        ))
2773    }
2774}
2775impl AfSpecAttrs<'_> {
2776    pub fn new<'a>(buf: &'a [u8]) -> IterableAfSpecAttrs<'a> {
2777        IterableAfSpecAttrs::with_loc(buf, buf.as_ptr() as usize)
2778    }
2779    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2780        let res = match r#type {
2781            2u16 => "Inet",
2782            10u16 => "Inet6",
2783            45u16 => "Mctp",
2784            _ => return None,
2785        };
2786        Some(res)
2787    }
2788}
2789#[derive(Clone, Copy, Default)]
2790pub struct IterableAfSpecAttrs<'a> {
2791    buf: &'a [u8],
2792    pos: usize,
2793    orig_loc: usize,
2794}
2795impl<'a> IterableAfSpecAttrs<'a> {
2796    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2797        Self {
2798            buf,
2799            pos: 0,
2800            orig_loc,
2801        }
2802    }
2803    pub fn get_buf(&self) -> &'a [u8] {
2804        self.buf
2805    }
2806}
2807impl<'a> Iterator for IterableAfSpecAttrs<'a> {
2808    type Item = Result<AfSpecAttrs<'a>, ErrorContext>;
2809    fn next(&mut self) -> Option<Self::Item> {
2810        let pos = self.pos;
2811        let mut r#type;
2812        loop {
2813            r#type = None;
2814            if self.buf.len() == self.pos {
2815                return None;
2816            }
2817            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2818                break;
2819            };
2820            r#type = Some(header.r#type);
2821            let res = match header.r#type {
2822                2u16 => AfSpecAttrs::Inet({
2823                    let res = Some(IterableIflaAttrs::with_loc(next, self.orig_loc));
2824                    let Some(val) = res else { break };
2825                    val
2826                }),
2827                10u16 => AfSpecAttrs::Inet6({
2828                    let res = Some(IterableIfla6Attrs::with_loc(next, self.orig_loc));
2829                    let Some(val) = res else { break };
2830                    val
2831                }),
2832                45u16 => AfSpecAttrs::Mctp({
2833                    let res = Some(IterableMctpAttrs::with_loc(next, self.orig_loc));
2834                    let Some(val) = res else { break };
2835                    val
2836                }),
2837                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2838                n => continue,
2839            };
2840            return Some(Ok(res));
2841        }
2842        Some(Err(ErrorContext::new(
2843            "AfSpecAttrs",
2844            r#type.and_then(|t| AfSpecAttrs::attr_from_type(t)),
2845            self.orig_loc,
2846            self.buf.as_ptr().wrapping_add(pos) as usize,
2847        )))
2848    }
2849}
2850impl<'a> std::fmt::Debug for IterableAfSpecAttrs<'_> {
2851    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2852        let mut fmt = f.debug_struct("AfSpecAttrs");
2853        for attr in self.clone() {
2854            let attr = match attr {
2855                Ok(a) => a,
2856                Err(err) => {
2857                    fmt.finish()?;
2858                    f.write_str("Err(")?;
2859                    err.fmt(f)?;
2860                    return f.write_str(")");
2861                }
2862            };
2863            match attr {
2864                AfSpecAttrs::Inet(val) => fmt.field("Inet", &val),
2865                AfSpecAttrs::Inet6(val) => fmt.field("Inet6", &val),
2866                AfSpecAttrs::Mctp(val) => fmt.field("Mctp", &val),
2867            };
2868        }
2869        fmt.finish()
2870    }
2871}
2872impl IterableAfSpecAttrs<'_> {
2873    pub fn lookup_attr(
2874        &self,
2875        offset: usize,
2876        missing_type: Option<u16>,
2877    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2878        let mut stack = Vec::new();
2879        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2880        if cur == offset {
2881            stack.push(("AfSpecAttrs", offset));
2882            return (
2883                stack,
2884                missing_type.and_then(|t| AfSpecAttrs::attr_from_type(t)),
2885            );
2886        }
2887        if cur > offset || cur + self.buf.len() < offset {
2888            return (stack, None);
2889        }
2890        let mut attrs = self.clone();
2891        let mut last_off = cur + attrs.pos;
2892        let mut missing = None;
2893        while let Some(attr) = attrs.next() {
2894            let Ok(attr) = attr else { break };
2895            match attr {
2896                AfSpecAttrs::Inet(val) => {
2897                    (stack, missing) = val.lookup_attr(offset, missing_type);
2898                    if !stack.is_empty() {
2899                        break;
2900                    }
2901                }
2902                AfSpecAttrs::Inet6(val) => {
2903                    (stack, missing) = val.lookup_attr(offset, missing_type);
2904                    if !stack.is_empty() {
2905                        break;
2906                    }
2907                }
2908                AfSpecAttrs::Mctp(val) => {
2909                    (stack, missing) = val.lookup_attr(offset, missing_type);
2910                    if !stack.is_empty() {
2911                        break;
2912                    }
2913                }
2914                _ => {}
2915            };
2916            last_off = cur + attrs.pos;
2917        }
2918        if !stack.is_empty() {
2919            stack.push(("AfSpecAttrs", cur));
2920        }
2921        (stack, missing)
2922    }
2923}
2924#[derive(Clone)]
2925pub enum VfinfoListAttrs<'a> {
2926    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2927    Info(IterableVfinfoAttrs<'a>),
2928}
2929impl<'a> IterableVfinfoListAttrs<'a> {
2930    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2931    pub fn get_info(
2932        &self,
2933    ) -> MultiAttrIterable<Self, VfinfoListAttrs<'a>, IterableVfinfoAttrs<'a>> {
2934        MultiAttrIterable::new(self.clone(), |variant| {
2935            if let VfinfoListAttrs::Info(val) = variant {
2936                Some(val)
2937            } else {
2938                None
2939            }
2940        })
2941    }
2942}
2943impl VfinfoListAttrs<'_> {
2944    pub fn new<'a>(buf: &'a [u8]) -> IterableVfinfoListAttrs<'a> {
2945        IterableVfinfoListAttrs::with_loc(buf, buf.as_ptr() as usize)
2946    }
2947    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2948        let res = match r#type {
2949            1u16 => "Info",
2950            _ => return None,
2951        };
2952        Some(res)
2953    }
2954}
2955#[derive(Clone, Copy, Default)]
2956pub struct IterableVfinfoListAttrs<'a> {
2957    buf: &'a [u8],
2958    pos: usize,
2959    orig_loc: usize,
2960}
2961impl<'a> IterableVfinfoListAttrs<'a> {
2962    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2963        Self {
2964            buf,
2965            pos: 0,
2966            orig_loc,
2967        }
2968    }
2969    pub fn get_buf(&self) -> &'a [u8] {
2970        self.buf
2971    }
2972}
2973impl<'a> Iterator for IterableVfinfoListAttrs<'a> {
2974    type Item = Result<VfinfoListAttrs<'a>, ErrorContext>;
2975    fn next(&mut self) -> Option<Self::Item> {
2976        let pos = self.pos;
2977        let mut r#type;
2978        loop {
2979            r#type = None;
2980            if self.buf.len() == self.pos {
2981                return None;
2982            }
2983            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2984                break;
2985            };
2986            r#type = Some(header.r#type);
2987            let res = match header.r#type {
2988                1u16 => VfinfoListAttrs::Info({
2989                    let res = Some(IterableVfinfoAttrs::with_loc(next, self.orig_loc));
2990                    let Some(val) = res else { break };
2991                    val
2992                }),
2993                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2994                n => continue,
2995            };
2996            return Some(Ok(res));
2997        }
2998        Some(Err(ErrorContext::new(
2999            "VfinfoListAttrs",
3000            r#type.and_then(|t| VfinfoListAttrs::attr_from_type(t)),
3001            self.orig_loc,
3002            self.buf.as_ptr().wrapping_add(pos) as usize,
3003        )))
3004    }
3005}
3006impl<'a> std::fmt::Debug for IterableVfinfoListAttrs<'_> {
3007    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3008        let mut fmt = f.debug_struct("VfinfoListAttrs");
3009        for attr in self.clone() {
3010            let attr = match attr {
3011                Ok(a) => a,
3012                Err(err) => {
3013                    fmt.finish()?;
3014                    f.write_str("Err(")?;
3015                    err.fmt(f)?;
3016                    return f.write_str(")");
3017                }
3018            };
3019            match attr {
3020                VfinfoListAttrs::Info(val) => fmt.field("Info", &val),
3021            };
3022        }
3023        fmt.finish()
3024    }
3025}
3026impl IterableVfinfoListAttrs<'_> {
3027    pub fn lookup_attr(
3028        &self,
3029        offset: usize,
3030        missing_type: Option<u16>,
3031    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3032        let mut stack = Vec::new();
3033        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3034        if cur == offset {
3035            stack.push(("VfinfoListAttrs", offset));
3036            return (
3037                stack,
3038                missing_type.and_then(|t| VfinfoListAttrs::attr_from_type(t)),
3039            );
3040        }
3041        if cur > offset || cur + self.buf.len() < offset {
3042            return (stack, None);
3043        }
3044        let mut attrs = self.clone();
3045        let mut last_off = cur + attrs.pos;
3046        let mut missing = None;
3047        while let Some(attr) = attrs.next() {
3048            let Ok(attr) = attr else { break };
3049            match attr {
3050                VfinfoListAttrs::Info(val) => {
3051                    (stack, missing) = val.lookup_attr(offset, missing_type);
3052                    if !stack.is_empty() {
3053                        break;
3054                    }
3055                }
3056                _ => {}
3057            };
3058            last_off = cur + attrs.pos;
3059        }
3060        if !stack.is_empty() {
3061            stack.push(("VfinfoListAttrs", cur));
3062        }
3063        (stack, missing)
3064    }
3065}
3066#[derive(Clone)]
3067pub enum VfinfoAttrs<'a> {
3068    Mac(PushIflaVfMac),
3069    Vlan(PushIflaVfVlan),
3070    TxRate(PushIflaVfTxRate),
3071    Spoofchk(PushIflaVfSpoofchk),
3072    LinkState(PushIflaVfLinkState),
3073    Rate(PushIflaVfRate),
3074    RssQueryEn(PushIflaVfRssQueryEn),
3075    Stats(IterableVfStatsAttrs<'a>),
3076    Trust(PushIflaVfTrust),
3077    IbNodeGuid(PushIflaVfGuid),
3078    IbPortGuid(PushIflaVfGuid),
3079    VlanList(IterableVfVlanAttrs<'a>),
3080    Broadcast(&'a [u8]),
3081}
3082impl<'a> IterableVfinfoAttrs<'a> {
3083    pub fn get_mac(&self) -> Result<PushIflaVfMac, ErrorContext> {
3084        let mut iter = self.clone();
3085        iter.pos = 0;
3086        for attr in iter {
3087            if let VfinfoAttrs::Mac(val) = attr? {
3088                return Ok(val);
3089            }
3090        }
3091        Err(ErrorContext::new_missing(
3092            "VfinfoAttrs",
3093            "Mac",
3094            self.orig_loc,
3095            self.buf.as_ptr() as usize,
3096        ))
3097    }
3098    pub fn get_vlan(&self) -> Result<PushIflaVfVlan, ErrorContext> {
3099        let mut iter = self.clone();
3100        iter.pos = 0;
3101        for attr in iter {
3102            if let VfinfoAttrs::Vlan(val) = attr? {
3103                return Ok(val);
3104            }
3105        }
3106        Err(ErrorContext::new_missing(
3107            "VfinfoAttrs",
3108            "Vlan",
3109            self.orig_loc,
3110            self.buf.as_ptr() as usize,
3111        ))
3112    }
3113    pub fn get_tx_rate(&self) -> Result<PushIflaVfTxRate, ErrorContext> {
3114        let mut iter = self.clone();
3115        iter.pos = 0;
3116        for attr in iter {
3117            if let VfinfoAttrs::TxRate(val) = attr? {
3118                return Ok(val);
3119            }
3120        }
3121        Err(ErrorContext::new_missing(
3122            "VfinfoAttrs",
3123            "TxRate",
3124            self.orig_loc,
3125            self.buf.as_ptr() as usize,
3126        ))
3127    }
3128    pub fn get_spoofchk(&self) -> Result<PushIflaVfSpoofchk, ErrorContext> {
3129        let mut iter = self.clone();
3130        iter.pos = 0;
3131        for attr in iter {
3132            if let VfinfoAttrs::Spoofchk(val) = attr? {
3133                return Ok(val);
3134            }
3135        }
3136        Err(ErrorContext::new_missing(
3137            "VfinfoAttrs",
3138            "Spoofchk",
3139            self.orig_loc,
3140            self.buf.as_ptr() as usize,
3141        ))
3142    }
3143    pub fn get_link_state(&self) -> Result<PushIflaVfLinkState, ErrorContext> {
3144        let mut iter = self.clone();
3145        iter.pos = 0;
3146        for attr in iter {
3147            if let VfinfoAttrs::LinkState(val) = attr? {
3148                return Ok(val);
3149            }
3150        }
3151        Err(ErrorContext::new_missing(
3152            "VfinfoAttrs",
3153            "LinkState",
3154            self.orig_loc,
3155            self.buf.as_ptr() as usize,
3156        ))
3157    }
3158    pub fn get_rate(&self) -> Result<PushIflaVfRate, ErrorContext> {
3159        let mut iter = self.clone();
3160        iter.pos = 0;
3161        for attr in iter {
3162            if let VfinfoAttrs::Rate(val) = attr? {
3163                return Ok(val);
3164            }
3165        }
3166        Err(ErrorContext::new_missing(
3167            "VfinfoAttrs",
3168            "Rate",
3169            self.orig_loc,
3170            self.buf.as_ptr() as usize,
3171        ))
3172    }
3173    pub fn get_rss_query_en(&self) -> Result<PushIflaVfRssQueryEn, ErrorContext> {
3174        let mut iter = self.clone();
3175        iter.pos = 0;
3176        for attr in iter {
3177            if let VfinfoAttrs::RssQueryEn(val) = attr? {
3178                return Ok(val);
3179            }
3180        }
3181        Err(ErrorContext::new_missing(
3182            "VfinfoAttrs",
3183            "RssQueryEn",
3184            self.orig_loc,
3185            self.buf.as_ptr() as usize,
3186        ))
3187    }
3188    pub fn get_stats(&self) -> Result<IterableVfStatsAttrs<'a>, ErrorContext> {
3189        let mut iter = self.clone();
3190        iter.pos = 0;
3191        for attr in iter {
3192            if let VfinfoAttrs::Stats(val) = attr? {
3193                return Ok(val);
3194            }
3195        }
3196        Err(ErrorContext::new_missing(
3197            "VfinfoAttrs",
3198            "Stats",
3199            self.orig_loc,
3200            self.buf.as_ptr() as usize,
3201        ))
3202    }
3203    pub fn get_trust(&self) -> Result<PushIflaVfTrust, ErrorContext> {
3204        let mut iter = self.clone();
3205        iter.pos = 0;
3206        for attr in iter {
3207            if let VfinfoAttrs::Trust(val) = attr? {
3208                return Ok(val);
3209            }
3210        }
3211        Err(ErrorContext::new_missing(
3212            "VfinfoAttrs",
3213            "Trust",
3214            self.orig_loc,
3215            self.buf.as_ptr() as usize,
3216        ))
3217    }
3218    pub fn get_ib_node_guid(&self) -> Result<PushIflaVfGuid, ErrorContext> {
3219        let mut iter = self.clone();
3220        iter.pos = 0;
3221        for attr in iter {
3222            if let VfinfoAttrs::IbNodeGuid(val) = attr? {
3223                return Ok(val);
3224            }
3225        }
3226        Err(ErrorContext::new_missing(
3227            "VfinfoAttrs",
3228            "IbNodeGuid",
3229            self.orig_loc,
3230            self.buf.as_ptr() as usize,
3231        ))
3232    }
3233    pub fn get_ib_port_guid(&self) -> Result<PushIflaVfGuid, ErrorContext> {
3234        let mut iter = self.clone();
3235        iter.pos = 0;
3236        for attr in iter {
3237            if let VfinfoAttrs::IbPortGuid(val) = attr? {
3238                return Ok(val);
3239            }
3240        }
3241        Err(ErrorContext::new_missing(
3242            "VfinfoAttrs",
3243            "IbPortGuid",
3244            self.orig_loc,
3245            self.buf.as_ptr() as usize,
3246        ))
3247    }
3248    pub fn get_vlan_list(&self) -> Result<IterableVfVlanAttrs<'a>, ErrorContext> {
3249        let mut iter = self.clone();
3250        iter.pos = 0;
3251        for attr in iter {
3252            if let VfinfoAttrs::VlanList(val) = attr? {
3253                return Ok(val);
3254            }
3255        }
3256        Err(ErrorContext::new_missing(
3257            "VfinfoAttrs",
3258            "VlanList",
3259            self.orig_loc,
3260            self.buf.as_ptr() as usize,
3261        ))
3262    }
3263    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
3264        let mut iter = self.clone();
3265        iter.pos = 0;
3266        for attr in iter {
3267            if let VfinfoAttrs::Broadcast(val) = attr? {
3268                return Ok(val);
3269            }
3270        }
3271        Err(ErrorContext::new_missing(
3272            "VfinfoAttrs",
3273            "Broadcast",
3274            self.orig_loc,
3275            self.buf.as_ptr() as usize,
3276        ))
3277    }
3278}
3279impl VfinfoAttrs<'_> {
3280    pub fn new<'a>(buf: &'a [u8]) -> IterableVfinfoAttrs<'a> {
3281        IterableVfinfoAttrs::with_loc(buf, buf.as_ptr() as usize)
3282    }
3283    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3284        let res = match r#type {
3285            1u16 => "Mac",
3286            2u16 => "Vlan",
3287            3u16 => "TxRate",
3288            4u16 => "Spoofchk",
3289            5u16 => "LinkState",
3290            6u16 => "Rate",
3291            7u16 => "RssQueryEn",
3292            8u16 => "Stats",
3293            9u16 => "Trust",
3294            10u16 => "IbNodeGuid",
3295            11u16 => "IbPortGuid",
3296            12u16 => "VlanList",
3297            13u16 => "Broadcast",
3298            _ => return None,
3299        };
3300        Some(res)
3301    }
3302}
3303#[derive(Clone, Copy, Default)]
3304pub struct IterableVfinfoAttrs<'a> {
3305    buf: &'a [u8],
3306    pos: usize,
3307    orig_loc: usize,
3308}
3309impl<'a> IterableVfinfoAttrs<'a> {
3310    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3311        Self {
3312            buf,
3313            pos: 0,
3314            orig_loc,
3315        }
3316    }
3317    pub fn get_buf(&self) -> &'a [u8] {
3318        self.buf
3319    }
3320}
3321impl<'a> Iterator for IterableVfinfoAttrs<'a> {
3322    type Item = Result<VfinfoAttrs<'a>, ErrorContext>;
3323    fn next(&mut self) -> Option<Self::Item> {
3324        let pos = self.pos;
3325        let mut r#type;
3326        loop {
3327            r#type = None;
3328            if self.buf.len() == self.pos {
3329                return None;
3330            }
3331            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3332                break;
3333            };
3334            r#type = Some(header.r#type);
3335            let res = match header.r#type {
3336                1u16 => VfinfoAttrs::Mac({
3337                    let res = PushIflaVfMac::new_from_slice(next);
3338                    let Some(val) = res else { break };
3339                    val
3340                }),
3341                2u16 => VfinfoAttrs::Vlan({
3342                    let res = PushIflaVfVlan::new_from_slice(next);
3343                    let Some(val) = res else { break };
3344                    val
3345                }),
3346                3u16 => VfinfoAttrs::TxRate({
3347                    let res = PushIflaVfTxRate::new_from_slice(next);
3348                    let Some(val) = res else { break };
3349                    val
3350                }),
3351                4u16 => VfinfoAttrs::Spoofchk({
3352                    let res = PushIflaVfSpoofchk::new_from_slice(next);
3353                    let Some(val) = res else { break };
3354                    val
3355                }),
3356                5u16 => VfinfoAttrs::LinkState({
3357                    let res = PushIflaVfLinkState::new_from_slice(next);
3358                    let Some(val) = res else { break };
3359                    val
3360                }),
3361                6u16 => VfinfoAttrs::Rate({
3362                    let res = PushIflaVfRate::new_from_slice(next);
3363                    let Some(val) = res else { break };
3364                    val
3365                }),
3366                7u16 => VfinfoAttrs::RssQueryEn({
3367                    let res = PushIflaVfRssQueryEn::new_from_slice(next);
3368                    let Some(val) = res else { break };
3369                    val
3370                }),
3371                8u16 => VfinfoAttrs::Stats({
3372                    let res = Some(IterableVfStatsAttrs::with_loc(next, self.orig_loc));
3373                    let Some(val) = res else { break };
3374                    val
3375                }),
3376                9u16 => VfinfoAttrs::Trust({
3377                    let res = PushIflaVfTrust::new_from_slice(next);
3378                    let Some(val) = res else { break };
3379                    val
3380                }),
3381                10u16 => VfinfoAttrs::IbNodeGuid({
3382                    let res = PushIflaVfGuid::new_from_slice(next);
3383                    let Some(val) = res else { break };
3384                    val
3385                }),
3386                11u16 => VfinfoAttrs::IbPortGuid({
3387                    let res = PushIflaVfGuid::new_from_slice(next);
3388                    let Some(val) = res else { break };
3389                    val
3390                }),
3391                12u16 => VfinfoAttrs::VlanList({
3392                    let res = Some(IterableVfVlanAttrs::with_loc(next, self.orig_loc));
3393                    let Some(val) = res else { break };
3394                    val
3395                }),
3396                13u16 => VfinfoAttrs::Broadcast({
3397                    let res = Some(next);
3398                    let Some(val) = res else { break };
3399                    val
3400                }),
3401                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3402                n => continue,
3403            };
3404            return Some(Ok(res));
3405        }
3406        Some(Err(ErrorContext::new(
3407            "VfinfoAttrs",
3408            r#type.and_then(|t| VfinfoAttrs::attr_from_type(t)),
3409            self.orig_loc,
3410            self.buf.as_ptr().wrapping_add(pos) as usize,
3411        )))
3412    }
3413}
3414impl<'a> std::fmt::Debug for IterableVfinfoAttrs<'_> {
3415    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3416        let mut fmt = f.debug_struct("VfinfoAttrs");
3417        for attr in self.clone() {
3418            let attr = match attr {
3419                Ok(a) => a,
3420                Err(err) => {
3421                    fmt.finish()?;
3422                    f.write_str("Err(")?;
3423                    err.fmt(f)?;
3424                    return f.write_str(")");
3425                }
3426            };
3427            match attr {
3428                VfinfoAttrs::Mac(val) => fmt.field("Mac", &val),
3429                VfinfoAttrs::Vlan(val) => fmt.field("Vlan", &val),
3430                VfinfoAttrs::TxRate(val) => fmt.field("TxRate", &val),
3431                VfinfoAttrs::Spoofchk(val) => fmt.field("Spoofchk", &val),
3432                VfinfoAttrs::LinkState(val) => fmt.field("LinkState", &val),
3433                VfinfoAttrs::Rate(val) => fmt.field("Rate", &val),
3434                VfinfoAttrs::RssQueryEn(val) => fmt.field("RssQueryEn", &val),
3435                VfinfoAttrs::Stats(val) => fmt.field("Stats", &val),
3436                VfinfoAttrs::Trust(val) => fmt.field("Trust", &val),
3437                VfinfoAttrs::IbNodeGuid(val) => fmt.field("IbNodeGuid", &val),
3438                VfinfoAttrs::IbPortGuid(val) => fmt.field("IbPortGuid", &val),
3439                VfinfoAttrs::VlanList(val) => fmt.field("VlanList", &val),
3440                VfinfoAttrs::Broadcast(val) => fmt.field("Broadcast", &val),
3441            };
3442        }
3443        fmt.finish()
3444    }
3445}
3446impl IterableVfinfoAttrs<'_> {
3447    pub fn lookup_attr(
3448        &self,
3449        offset: usize,
3450        missing_type: Option<u16>,
3451    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3452        let mut stack = Vec::new();
3453        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3454        if cur == offset {
3455            stack.push(("VfinfoAttrs", offset));
3456            return (
3457                stack,
3458                missing_type.and_then(|t| VfinfoAttrs::attr_from_type(t)),
3459            );
3460        }
3461        if cur > offset || cur + self.buf.len() < offset {
3462            return (stack, None);
3463        }
3464        let mut attrs = self.clone();
3465        let mut last_off = cur + attrs.pos;
3466        let mut missing = None;
3467        while let Some(attr) = attrs.next() {
3468            let Ok(attr) = attr else { break };
3469            match attr {
3470                VfinfoAttrs::Mac(val) => {
3471                    if last_off == offset {
3472                        stack.push(("Mac", last_off));
3473                        break;
3474                    }
3475                }
3476                VfinfoAttrs::Vlan(val) => {
3477                    if last_off == offset {
3478                        stack.push(("Vlan", last_off));
3479                        break;
3480                    }
3481                }
3482                VfinfoAttrs::TxRate(val) => {
3483                    if last_off == offset {
3484                        stack.push(("TxRate", last_off));
3485                        break;
3486                    }
3487                }
3488                VfinfoAttrs::Spoofchk(val) => {
3489                    if last_off == offset {
3490                        stack.push(("Spoofchk", last_off));
3491                        break;
3492                    }
3493                }
3494                VfinfoAttrs::LinkState(val) => {
3495                    if last_off == offset {
3496                        stack.push(("LinkState", last_off));
3497                        break;
3498                    }
3499                }
3500                VfinfoAttrs::Rate(val) => {
3501                    if last_off == offset {
3502                        stack.push(("Rate", last_off));
3503                        break;
3504                    }
3505                }
3506                VfinfoAttrs::RssQueryEn(val) => {
3507                    if last_off == offset {
3508                        stack.push(("RssQueryEn", last_off));
3509                        break;
3510                    }
3511                }
3512                VfinfoAttrs::Stats(val) => {
3513                    (stack, missing) = val.lookup_attr(offset, missing_type);
3514                    if !stack.is_empty() {
3515                        break;
3516                    }
3517                }
3518                VfinfoAttrs::Trust(val) => {
3519                    if last_off == offset {
3520                        stack.push(("Trust", last_off));
3521                        break;
3522                    }
3523                }
3524                VfinfoAttrs::IbNodeGuid(val) => {
3525                    if last_off == offset {
3526                        stack.push(("IbNodeGuid", last_off));
3527                        break;
3528                    }
3529                }
3530                VfinfoAttrs::IbPortGuid(val) => {
3531                    if last_off == offset {
3532                        stack.push(("IbPortGuid", last_off));
3533                        break;
3534                    }
3535                }
3536                VfinfoAttrs::VlanList(val) => {
3537                    (stack, missing) = val.lookup_attr(offset, missing_type);
3538                    if !stack.is_empty() {
3539                        break;
3540                    }
3541                }
3542                VfinfoAttrs::Broadcast(val) => {
3543                    if last_off == offset {
3544                        stack.push(("Broadcast", last_off));
3545                        break;
3546                    }
3547                }
3548                _ => {}
3549            };
3550            last_off = cur + attrs.pos;
3551        }
3552        if !stack.is_empty() {
3553            stack.push(("VfinfoAttrs", cur));
3554        }
3555        (stack, missing)
3556    }
3557}
3558#[derive(Clone)]
3559pub enum VfStatsAttrs<'a> {
3560    RxPackets(u64),
3561    TxPackets(u64),
3562    RxBytes(u64),
3563    TxBytes(u64),
3564    Broadcast(u64),
3565    Multicast(u64),
3566    Pad(&'a [u8]),
3567    RxDropped(u64),
3568    TxDropped(u64),
3569}
3570impl<'a> IterableVfStatsAttrs<'a> {
3571    pub fn get_rx_packets(&self) -> Result<u64, ErrorContext> {
3572        let mut iter = self.clone();
3573        iter.pos = 0;
3574        for attr in iter {
3575            if let VfStatsAttrs::RxPackets(val) = attr? {
3576                return Ok(val);
3577            }
3578        }
3579        Err(ErrorContext::new_missing(
3580            "VfStatsAttrs",
3581            "RxPackets",
3582            self.orig_loc,
3583            self.buf.as_ptr() as usize,
3584        ))
3585    }
3586    pub fn get_tx_packets(&self) -> Result<u64, ErrorContext> {
3587        let mut iter = self.clone();
3588        iter.pos = 0;
3589        for attr in iter {
3590            if let VfStatsAttrs::TxPackets(val) = attr? {
3591                return Ok(val);
3592            }
3593        }
3594        Err(ErrorContext::new_missing(
3595            "VfStatsAttrs",
3596            "TxPackets",
3597            self.orig_loc,
3598            self.buf.as_ptr() as usize,
3599        ))
3600    }
3601    pub fn get_rx_bytes(&self) -> Result<u64, ErrorContext> {
3602        let mut iter = self.clone();
3603        iter.pos = 0;
3604        for attr in iter {
3605            if let VfStatsAttrs::RxBytes(val) = attr? {
3606                return Ok(val);
3607            }
3608        }
3609        Err(ErrorContext::new_missing(
3610            "VfStatsAttrs",
3611            "RxBytes",
3612            self.orig_loc,
3613            self.buf.as_ptr() as usize,
3614        ))
3615    }
3616    pub fn get_tx_bytes(&self) -> Result<u64, ErrorContext> {
3617        let mut iter = self.clone();
3618        iter.pos = 0;
3619        for attr in iter {
3620            if let VfStatsAttrs::TxBytes(val) = attr? {
3621                return Ok(val);
3622            }
3623        }
3624        Err(ErrorContext::new_missing(
3625            "VfStatsAttrs",
3626            "TxBytes",
3627            self.orig_loc,
3628            self.buf.as_ptr() as usize,
3629        ))
3630    }
3631    pub fn get_broadcast(&self) -> Result<u64, ErrorContext> {
3632        let mut iter = self.clone();
3633        iter.pos = 0;
3634        for attr in iter {
3635            if let VfStatsAttrs::Broadcast(val) = attr? {
3636                return Ok(val);
3637            }
3638        }
3639        Err(ErrorContext::new_missing(
3640            "VfStatsAttrs",
3641            "Broadcast",
3642            self.orig_loc,
3643            self.buf.as_ptr() as usize,
3644        ))
3645    }
3646    pub fn get_multicast(&self) -> Result<u64, ErrorContext> {
3647        let mut iter = self.clone();
3648        iter.pos = 0;
3649        for attr in iter {
3650            if let VfStatsAttrs::Multicast(val) = attr? {
3651                return Ok(val);
3652            }
3653        }
3654        Err(ErrorContext::new_missing(
3655            "VfStatsAttrs",
3656            "Multicast",
3657            self.orig_loc,
3658            self.buf.as_ptr() as usize,
3659        ))
3660    }
3661    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
3662        let mut iter = self.clone();
3663        iter.pos = 0;
3664        for attr in iter {
3665            if let VfStatsAttrs::Pad(val) = attr? {
3666                return Ok(val);
3667            }
3668        }
3669        Err(ErrorContext::new_missing(
3670            "VfStatsAttrs",
3671            "Pad",
3672            self.orig_loc,
3673            self.buf.as_ptr() as usize,
3674        ))
3675    }
3676    pub fn get_rx_dropped(&self) -> Result<u64, ErrorContext> {
3677        let mut iter = self.clone();
3678        iter.pos = 0;
3679        for attr in iter {
3680            if let VfStatsAttrs::RxDropped(val) = attr? {
3681                return Ok(val);
3682            }
3683        }
3684        Err(ErrorContext::new_missing(
3685            "VfStatsAttrs",
3686            "RxDropped",
3687            self.orig_loc,
3688            self.buf.as_ptr() as usize,
3689        ))
3690    }
3691    pub fn get_tx_dropped(&self) -> Result<u64, ErrorContext> {
3692        let mut iter = self.clone();
3693        iter.pos = 0;
3694        for attr in iter {
3695            if let VfStatsAttrs::TxDropped(val) = attr? {
3696                return Ok(val);
3697            }
3698        }
3699        Err(ErrorContext::new_missing(
3700            "VfStatsAttrs",
3701            "TxDropped",
3702            self.orig_loc,
3703            self.buf.as_ptr() as usize,
3704        ))
3705    }
3706}
3707impl VfStatsAttrs<'_> {
3708    pub fn new<'a>(buf: &'a [u8]) -> IterableVfStatsAttrs<'a> {
3709        IterableVfStatsAttrs::with_loc(buf, buf.as_ptr() as usize)
3710    }
3711    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3712        let res = match r#type {
3713            0u16 => "RxPackets",
3714            1u16 => "TxPackets",
3715            2u16 => "RxBytes",
3716            3u16 => "TxBytes",
3717            4u16 => "Broadcast",
3718            5u16 => "Multicast",
3719            6u16 => "Pad",
3720            7u16 => "RxDropped",
3721            8u16 => "TxDropped",
3722            _ => return None,
3723        };
3724        Some(res)
3725    }
3726}
3727#[derive(Clone, Copy, Default)]
3728pub struct IterableVfStatsAttrs<'a> {
3729    buf: &'a [u8],
3730    pos: usize,
3731    orig_loc: usize,
3732}
3733impl<'a> IterableVfStatsAttrs<'a> {
3734    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3735        Self {
3736            buf,
3737            pos: 0,
3738            orig_loc,
3739        }
3740    }
3741    pub fn get_buf(&self) -> &'a [u8] {
3742        self.buf
3743    }
3744}
3745impl<'a> Iterator for IterableVfStatsAttrs<'a> {
3746    type Item = Result<VfStatsAttrs<'a>, ErrorContext>;
3747    fn next(&mut self) -> Option<Self::Item> {
3748        let pos = self.pos;
3749        let mut r#type;
3750        loop {
3751            r#type = None;
3752            if self.buf.len() == self.pos {
3753                return None;
3754            }
3755            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3756                break;
3757            };
3758            r#type = Some(header.r#type);
3759            let res = match header.r#type {
3760                0u16 => VfStatsAttrs::RxPackets({
3761                    let res = parse_u64(next);
3762                    let Some(val) = res else { break };
3763                    val
3764                }),
3765                1u16 => VfStatsAttrs::TxPackets({
3766                    let res = parse_u64(next);
3767                    let Some(val) = res else { break };
3768                    val
3769                }),
3770                2u16 => VfStatsAttrs::RxBytes({
3771                    let res = parse_u64(next);
3772                    let Some(val) = res else { break };
3773                    val
3774                }),
3775                3u16 => VfStatsAttrs::TxBytes({
3776                    let res = parse_u64(next);
3777                    let Some(val) = res else { break };
3778                    val
3779                }),
3780                4u16 => VfStatsAttrs::Broadcast({
3781                    let res = parse_u64(next);
3782                    let Some(val) = res else { break };
3783                    val
3784                }),
3785                5u16 => VfStatsAttrs::Multicast({
3786                    let res = parse_u64(next);
3787                    let Some(val) = res else { break };
3788                    val
3789                }),
3790                6u16 => VfStatsAttrs::Pad({
3791                    let res = Some(next);
3792                    let Some(val) = res else { break };
3793                    val
3794                }),
3795                7u16 => VfStatsAttrs::RxDropped({
3796                    let res = parse_u64(next);
3797                    let Some(val) = res else { break };
3798                    val
3799                }),
3800                8u16 => VfStatsAttrs::TxDropped({
3801                    let res = parse_u64(next);
3802                    let Some(val) = res else { break };
3803                    val
3804                }),
3805                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3806                n => continue,
3807            };
3808            return Some(Ok(res));
3809        }
3810        Some(Err(ErrorContext::new(
3811            "VfStatsAttrs",
3812            r#type.and_then(|t| VfStatsAttrs::attr_from_type(t)),
3813            self.orig_loc,
3814            self.buf.as_ptr().wrapping_add(pos) as usize,
3815        )))
3816    }
3817}
3818impl<'a> std::fmt::Debug for IterableVfStatsAttrs<'_> {
3819    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3820        let mut fmt = f.debug_struct("VfStatsAttrs");
3821        for attr in self.clone() {
3822            let attr = match attr {
3823                Ok(a) => a,
3824                Err(err) => {
3825                    fmt.finish()?;
3826                    f.write_str("Err(")?;
3827                    err.fmt(f)?;
3828                    return f.write_str(")");
3829                }
3830            };
3831            match attr {
3832                VfStatsAttrs::RxPackets(val) => fmt.field("RxPackets", &val),
3833                VfStatsAttrs::TxPackets(val) => fmt.field("TxPackets", &val),
3834                VfStatsAttrs::RxBytes(val) => fmt.field("RxBytes", &val),
3835                VfStatsAttrs::TxBytes(val) => fmt.field("TxBytes", &val),
3836                VfStatsAttrs::Broadcast(val) => fmt.field("Broadcast", &val),
3837                VfStatsAttrs::Multicast(val) => fmt.field("Multicast", &val),
3838                VfStatsAttrs::Pad(val) => fmt.field("Pad", &val),
3839                VfStatsAttrs::RxDropped(val) => fmt.field("RxDropped", &val),
3840                VfStatsAttrs::TxDropped(val) => fmt.field("TxDropped", &val),
3841            };
3842        }
3843        fmt.finish()
3844    }
3845}
3846impl IterableVfStatsAttrs<'_> {
3847    pub fn lookup_attr(
3848        &self,
3849        offset: usize,
3850        missing_type: Option<u16>,
3851    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3852        let mut stack = Vec::new();
3853        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3854        if cur == offset {
3855            stack.push(("VfStatsAttrs", offset));
3856            return (
3857                stack,
3858                missing_type.and_then(|t| VfStatsAttrs::attr_from_type(t)),
3859            );
3860        }
3861        if cur > offset || cur + self.buf.len() < offset {
3862            return (stack, None);
3863        }
3864        let mut attrs = self.clone();
3865        let mut last_off = cur + attrs.pos;
3866        while let Some(attr) = attrs.next() {
3867            let Ok(attr) = attr else { break };
3868            match attr {
3869                VfStatsAttrs::RxPackets(val) => {
3870                    if last_off == offset {
3871                        stack.push(("RxPackets", last_off));
3872                        break;
3873                    }
3874                }
3875                VfStatsAttrs::TxPackets(val) => {
3876                    if last_off == offset {
3877                        stack.push(("TxPackets", last_off));
3878                        break;
3879                    }
3880                }
3881                VfStatsAttrs::RxBytes(val) => {
3882                    if last_off == offset {
3883                        stack.push(("RxBytes", last_off));
3884                        break;
3885                    }
3886                }
3887                VfStatsAttrs::TxBytes(val) => {
3888                    if last_off == offset {
3889                        stack.push(("TxBytes", last_off));
3890                        break;
3891                    }
3892                }
3893                VfStatsAttrs::Broadcast(val) => {
3894                    if last_off == offset {
3895                        stack.push(("Broadcast", last_off));
3896                        break;
3897                    }
3898                }
3899                VfStatsAttrs::Multicast(val) => {
3900                    if last_off == offset {
3901                        stack.push(("Multicast", last_off));
3902                        break;
3903                    }
3904                }
3905                VfStatsAttrs::Pad(val) => {
3906                    if last_off == offset {
3907                        stack.push(("Pad", last_off));
3908                        break;
3909                    }
3910                }
3911                VfStatsAttrs::RxDropped(val) => {
3912                    if last_off == offset {
3913                        stack.push(("RxDropped", last_off));
3914                        break;
3915                    }
3916                }
3917                VfStatsAttrs::TxDropped(val) => {
3918                    if last_off == offset {
3919                        stack.push(("TxDropped", last_off));
3920                        break;
3921                    }
3922                }
3923                _ => {}
3924            };
3925            last_off = cur + attrs.pos;
3926        }
3927        if !stack.is_empty() {
3928            stack.push(("VfStatsAttrs", cur));
3929        }
3930        (stack, None)
3931    }
3932}
3933#[derive(Clone)]
3934pub enum VfVlanAttrs {
3935    #[doc = "Attribute may repeat multiple times (treat it as array)"]
3936    Info(PushIflaVfVlanInfo),
3937}
3938impl<'a> IterableVfVlanAttrs<'a> {
3939    #[doc = "Attribute may repeat multiple times (treat it as array)"]
3940    pub fn get_info(&self) -> MultiAttrIterable<Self, VfVlanAttrs, PushIflaVfVlanInfo> {
3941        MultiAttrIterable::new(self.clone(), |variant| {
3942            if let VfVlanAttrs::Info(val) = variant {
3943                Some(val)
3944            } else {
3945                None
3946            }
3947        })
3948    }
3949}
3950impl VfVlanAttrs {
3951    pub fn new<'a>(buf: &'a [u8]) -> IterableVfVlanAttrs<'a> {
3952        IterableVfVlanAttrs::with_loc(buf, buf.as_ptr() as usize)
3953    }
3954    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3955        let res = match r#type {
3956            1u16 => "Info",
3957            _ => return None,
3958        };
3959        Some(res)
3960    }
3961}
3962#[derive(Clone, Copy, Default)]
3963pub struct IterableVfVlanAttrs<'a> {
3964    buf: &'a [u8],
3965    pos: usize,
3966    orig_loc: usize,
3967}
3968impl<'a> IterableVfVlanAttrs<'a> {
3969    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3970        Self {
3971            buf,
3972            pos: 0,
3973            orig_loc,
3974        }
3975    }
3976    pub fn get_buf(&self) -> &'a [u8] {
3977        self.buf
3978    }
3979}
3980impl<'a> Iterator for IterableVfVlanAttrs<'a> {
3981    type Item = Result<VfVlanAttrs, ErrorContext>;
3982    fn next(&mut self) -> Option<Self::Item> {
3983        let pos = self.pos;
3984        let mut r#type;
3985        loop {
3986            r#type = None;
3987            if self.buf.len() == self.pos {
3988                return None;
3989            }
3990            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3991                break;
3992            };
3993            r#type = Some(header.r#type);
3994            let res = match header.r#type {
3995                1u16 => VfVlanAttrs::Info({
3996                    let res = PushIflaVfVlanInfo::new_from_slice(next);
3997                    let Some(val) = res else { break };
3998                    val
3999                }),
4000                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4001                n => continue,
4002            };
4003            return Some(Ok(res));
4004        }
4005        Some(Err(ErrorContext::new(
4006            "VfVlanAttrs",
4007            r#type.and_then(|t| VfVlanAttrs::attr_from_type(t)),
4008            self.orig_loc,
4009            self.buf.as_ptr().wrapping_add(pos) as usize,
4010        )))
4011    }
4012}
4013impl std::fmt::Debug for IterableVfVlanAttrs<'_> {
4014    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4015        let mut fmt = f.debug_struct("VfVlanAttrs");
4016        for attr in self.clone() {
4017            let attr = match attr {
4018                Ok(a) => a,
4019                Err(err) => {
4020                    fmt.finish()?;
4021                    f.write_str("Err(")?;
4022                    err.fmt(f)?;
4023                    return f.write_str(")");
4024                }
4025            };
4026            match attr {
4027                VfVlanAttrs::Info(val) => fmt.field("Info", &val),
4028            };
4029        }
4030        fmt.finish()
4031    }
4032}
4033impl IterableVfVlanAttrs<'_> {
4034    pub fn lookup_attr(
4035        &self,
4036        offset: usize,
4037        missing_type: Option<u16>,
4038    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4039        let mut stack = Vec::new();
4040        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4041        if cur == offset {
4042            stack.push(("VfVlanAttrs", offset));
4043            return (
4044                stack,
4045                missing_type.and_then(|t| VfVlanAttrs::attr_from_type(t)),
4046            );
4047        }
4048        if cur > offset || cur + self.buf.len() < offset {
4049            return (stack, None);
4050        }
4051        let mut attrs = self.clone();
4052        let mut last_off = cur + attrs.pos;
4053        while let Some(attr) = attrs.next() {
4054            let Ok(attr) = attr else { break };
4055            match attr {
4056                VfVlanAttrs::Info(val) => {
4057                    if last_off == offset {
4058                        stack.push(("Info", last_off));
4059                        break;
4060                    }
4061                }
4062                _ => {}
4063            };
4064            last_off = cur + attrs.pos;
4065        }
4066        if !stack.is_empty() {
4067            stack.push(("VfVlanAttrs", cur));
4068        }
4069        (stack, None)
4070    }
4071}
4072#[derive(Clone)]
4073pub enum VfPortsAttrs {}
4074impl<'a> IterableVfPortsAttrs<'a> {}
4075impl VfPortsAttrs {
4076    pub fn new<'a>(buf: &'a [u8]) -> IterableVfPortsAttrs<'a> {
4077        IterableVfPortsAttrs::with_loc(buf, buf.as_ptr() as usize)
4078    }
4079    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4080        None
4081    }
4082}
4083#[derive(Clone, Copy, Default)]
4084pub struct IterableVfPortsAttrs<'a> {
4085    buf: &'a [u8],
4086    pos: usize,
4087    orig_loc: usize,
4088}
4089impl<'a> IterableVfPortsAttrs<'a> {
4090    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4091        Self {
4092            buf,
4093            pos: 0,
4094            orig_loc,
4095        }
4096    }
4097    pub fn get_buf(&self) -> &'a [u8] {
4098        self.buf
4099    }
4100}
4101impl<'a> Iterator for IterableVfPortsAttrs<'a> {
4102    type Item = Result<VfPortsAttrs, ErrorContext>;
4103    fn next(&mut self) -> Option<Self::Item> {
4104        let pos = self.pos;
4105        let mut r#type;
4106        loop {
4107            r#type = None;
4108            if self.buf.len() == self.pos {
4109                return None;
4110            }
4111            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
4112                break;
4113            };
4114            r#type = Some(header.r#type);
4115            let res = match header.r#type {
4116                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4117                n => continue,
4118            };
4119            return Some(Ok(res));
4120        }
4121        Some(Err(ErrorContext::new(
4122            "VfPortsAttrs",
4123            r#type.and_then(|t| VfPortsAttrs::attr_from_type(t)),
4124            self.orig_loc,
4125            self.buf.as_ptr().wrapping_add(pos) as usize,
4126        )))
4127    }
4128}
4129impl std::fmt::Debug for IterableVfPortsAttrs<'_> {
4130    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4131        let mut fmt = f.debug_struct("VfPortsAttrs");
4132        for attr in self.clone() {
4133            let attr = match attr {
4134                Ok(a) => a,
4135                Err(err) => {
4136                    fmt.finish()?;
4137                    f.write_str("Err(")?;
4138                    err.fmt(f)?;
4139                    return f.write_str(")");
4140                }
4141            };
4142            match attr {};
4143        }
4144        fmt.finish()
4145    }
4146}
4147impl IterableVfPortsAttrs<'_> {
4148    pub fn lookup_attr(
4149        &self,
4150        offset: usize,
4151        missing_type: Option<u16>,
4152    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4153        let mut stack = Vec::new();
4154        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4155        if cur == offset {
4156            stack.push(("VfPortsAttrs", offset));
4157            return (
4158                stack,
4159                missing_type.and_then(|t| VfPortsAttrs::attr_from_type(t)),
4160            );
4161        }
4162        (stack, None)
4163    }
4164}
4165#[derive(Clone)]
4166pub enum PortSelfAttrs {}
4167impl<'a> IterablePortSelfAttrs<'a> {}
4168impl PortSelfAttrs {
4169    pub fn new<'a>(buf: &'a [u8]) -> IterablePortSelfAttrs<'a> {
4170        IterablePortSelfAttrs::with_loc(buf, buf.as_ptr() as usize)
4171    }
4172    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4173        None
4174    }
4175}
4176#[derive(Clone, Copy, Default)]
4177pub struct IterablePortSelfAttrs<'a> {
4178    buf: &'a [u8],
4179    pos: usize,
4180    orig_loc: usize,
4181}
4182impl<'a> IterablePortSelfAttrs<'a> {
4183    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4184        Self {
4185            buf,
4186            pos: 0,
4187            orig_loc,
4188        }
4189    }
4190    pub fn get_buf(&self) -> &'a [u8] {
4191        self.buf
4192    }
4193}
4194impl<'a> Iterator for IterablePortSelfAttrs<'a> {
4195    type Item = Result<PortSelfAttrs, ErrorContext>;
4196    fn next(&mut self) -> Option<Self::Item> {
4197        let pos = self.pos;
4198        let mut r#type;
4199        loop {
4200            r#type = None;
4201            if self.buf.len() == self.pos {
4202                return None;
4203            }
4204            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
4205                break;
4206            };
4207            r#type = Some(header.r#type);
4208            let res = match header.r#type {
4209                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4210                n => continue,
4211            };
4212            return Some(Ok(res));
4213        }
4214        Some(Err(ErrorContext::new(
4215            "PortSelfAttrs",
4216            r#type.and_then(|t| PortSelfAttrs::attr_from_type(t)),
4217            self.orig_loc,
4218            self.buf.as_ptr().wrapping_add(pos) as usize,
4219        )))
4220    }
4221}
4222impl std::fmt::Debug for IterablePortSelfAttrs<'_> {
4223    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4224        let mut fmt = f.debug_struct("PortSelfAttrs");
4225        for attr in self.clone() {
4226            let attr = match attr {
4227                Ok(a) => a,
4228                Err(err) => {
4229                    fmt.finish()?;
4230                    f.write_str("Err(")?;
4231                    err.fmt(f)?;
4232                    return f.write_str(")");
4233                }
4234            };
4235            match attr {};
4236        }
4237        fmt.finish()
4238    }
4239}
4240impl IterablePortSelfAttrs<'_> {
4241    pub fn lookup_attr(
4242        &self,
4243        offset: usize,
4244        missing_type: Option<u16>,
4245    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4246        let mut stack = Vec::new();
4247        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4248        if cur == offset {
4249            stack.push(("PortSelfAttrs", offset));
4250            return (
4251                stack,
4252                missing_type.and_then(|t| PortSelfAttrs::attr_from_type(t)),
4253            );
4254        }
4255        (stack, None)
4256    }
4257}
4258#[derive(Clone)]
4259pub enum LinkinfoAttrs<'a> {
4260    Kind(&'a CStr),
4261    Data(LinkinfoDataMsg<'a>),
4262    Xstats(&'a [u8]),
4263    SlaveKind(&'a CStr),
4264    SlaveData(LinkinfoMemberDataMsg<'a>),
4265}
4266impl<'a> IterableLinkinfoAttrs<'a> {
4267    pub fn get_kind(&self) -> Result<&'a CStr, ErrorContext> {
4268        let mut iter = self.clone();
4269        iter.pos = 0;
4270        for attr in iter {
4271            if let LinkinfoAttrs::Kind(val) = attr? {
4272                return Ok(val);
4273            }
4274        }
4275        Err(ErrorContext::new_missing(
4276            "LinkinfoAttrs",
4277            "Kind",
4278            self.orig_loc,
4279            self.buf.as_ptr() as usize,
4280        ))
4281    }
4282    pub fn get_data(&self) -> Result<LinkinfoDataMsg<'a>, ErrorContext> {
4283        let mut iter = self.clone();
4284        iter.pos = 0;
4285        for attr in iter {
4286            if let LinkinfoAttrs::Data(val) = attr? {
4287                return Ok(val);
4288            }
4289        }
4290        Err(ErrorContext::new_missing(
4291            "LinkinfoAttrs",
4292            "Data",
4293            self.orig_loc,
4294            self.buf.as_ptr() as usize,
4295        ))
4296    }
4297    pub fn get_xstats(&self) -> Result<&'a [u8], ErrorContext> {
4298        let mut iter = self.clone();
4299        iter.pos = 0;
4300        for attr in iter {
4301            if let LinkinfoAttrs::Xstats(val) = attr? {
4302                return Ok(val);
4303            }
4304        }
4305        Err(ErrorContext::new_missing(
4306            "LinkinfoAttrs",
4307            "Xstats",
4308            self.orig_loc,
4309            self.buf.as_ptr() as usize,
4310        ))
4311    }
4312    pub fn get_slave_kind(&self) -> Result<&'a CStr, ErrorContext> {
4313        let mut iter = self.clone();
4314        iter.pos = 0;
4315        for attr in iter {
4316            if let LinkinfoAttrs::SlaveKind(val) = attr? {
4317                return Ok(val);
4318            }
4319        }
4320        Err(ErrorContext::new_missing(
4321            "LinkinfoAttrs",
4322            "SlaveKind",
4323            self.orig_loc,
4324            self.buf.as_ptr() as usize,
4325        ))
4326    }
4327    pub fn get_slave_data(&self) -> Result<LinkinfoMemberDataMsg<'a>, ErrorContext> {
4328        let mut iter = self.clone();
4329        iter.pos = 0;
4330        for attr in iter {
4331            if let LinkinfoAttrs::SlaveData(val) = attr? {
4332                return Ok(val);
4333            }
4334        }
4335        Err(ErrorContext::new_missing(
4336            "LinkinfoAttrs",
4337            "SlaveData",
4338            self.orig_loc,
4339            self.buf.as_ptr() as usize,
4340        ))
4341    }
4342}
4343#[derive(Debug, Clone)]
4344pub enum LinkinfoDataMsg<'a> {
4345    Bond(IterableLinkinfoBondAttrs<'a>),
4346    Bridge(IterableLinkinfoBridgeAttrs<'a>),
4347    Erspan(IterableLinkinfoGreAttrs<'a>),
4348    Gre(IterableLinkinfoGreAttrs<'a>),
4349    Gretap(IterableLinkinfoGreAttrs<'a>),
4350    Ip6gre(IterableLinkinfoGre6Attrs<'a>),
4351    Geneve(IterableLinkinfoGeneveAttrs<'a>),
4352    Ipip(IterableLinkinfoIptunAttrs<'a>),
4353    Ip6tnl(IterableLinkinfoIp6tnlAttrs<'a>),
4354    Sit(IterableLinkinfoIptunAttrs<'a>),
4355    Tun(IterableLinkinfoTunAttrs<'a>),
4356    Vlan(IterableLinkinfoVlanAttrs<'a>),
4357    Vrf(IterableLinkinfoVrfAttrs<'a>),
4358    Vti(IterableLinkinfoVtiAttrs<'a>),
4359    Vti6(IterableLinkinfoVti6Attrs<'a>),
4360    Netkit(IterableLinkinfoNetkitAttrs<'a>),
4361    Ovpn(IterableLinkinfoOvpnAttrs<'a>),
4362}
4363impl<'a> LinkinfoDataMsg<'a> {
4364    fn select_with_loc(selector: &'a CStr, buf: &'a [u8], loc: usize) -> Option<Self> {
4365        match selector.to_bytes() {
4366            b"bond" => Some(LinkinfoDataMsg::Bond(IterableLinkinfoBondAttrs::with_loc(
4367                buf, loc,
4368            ))),
4369            b"bridge" => Some(LinkinfoDataMsg::Bridge(
4370                IterableLinkinfoBridgeAttrs::with_loc(buf, loc),
4371            )),
4372            b"erspan" => Some(LinkinfoDataMsg::Erspan(IterableLinkinfoGreAttrs::with_loc(
4373                buf, loc,
4374            ))),
4375            b"gre" => Some(LinkinfoDataMsg::Gre(IterableLinkinfoGreAttrs::with_loc(
4376                buf, loc,
4377            ))),
4378            b"gretap" => Some(LinkinfoDataMsg::Gretap(IterableLinkinfoGreAttrs::with_loc(
4379                buf, loc,
4380            ))),
4381            b"ip6gre" => Some(LinkinfoDataMsg::Ip6gre(
4382                IterableLinkinfoGre6Attrs::with_loc(buf, loc),
4383            )),
4384            b"geneve" => Some(LinkinfoDataMsg::Geneve(
4385                IterableLinkinfoGeneveAttrs::with_loc(buf, loc),
4386            )),
4387            b"ipip" => Some(LinkinfoDataMsg::Ipip(IterableLinkinfoIptunAttrs::with_loc(
4388                buf, loc,
4389            ))),
4390            b"ip6tnl" => Some(LinkinfoDataMsg::Ip6tnl(
4391                IterableLinkinfoIp6tnlAttrs::with_loc(buf, loc),
4392            )),
4393            b"sit" => Some(LinkinfoDataMsg::Sit(IterableLinkinfoIptunAttrs::with_loc(
4394                buf, loc,
4395            ))),
4396            b"tun" => Some(LinkinfoDataMsg::Tun(IterableLinkinfoTunAttrs::with_loc(
4397                buf, loc,
4398            ))),
4399            b"vlan" => Some(LinkinfoDataMsg::Vlan(IterableLinkinfoVlanAttrs::with_loc(
4400                buf, loc,
4401            ))),
4402            b"vrf" => Some(LinkinfoDataMsg::Vrf(IterableLinkinfoVrfAttrs::with_loc(
4403                buf, loc,
4404            ))),
4405            b"vti" => Some(LinkinfoDataMsg::Vti(IterableLinkinfoVtiAttrs::with_loc(
4406                buf, loc,
4407            ))),
4408            b"vti6" => Some(LinkinfoDataMsg::Vti6(IterableLinkinfoVti6Attrs::with_loc(
4409                buf, loc,
4410            ))),
4411            b"netkit" => Some(LinkinfoDataMsg::Netkit(
4412                IterableLinkinfoNetkitAttrs::with_loc(buf, loc),
4413            )),
4414            b"ovpn" => Some(LinkinfoDataMsg::Ovpn(IterableLinkinfoOvpnAttrs::with_loc(
4415                buf, loc,
4416            ))),
4417            _ => None,
4418        }
4419    }
4420}
4421#[derive(Debug, Clone)]
4422pub enum LinkinfoMemberDataMsg<'a> {
4423    Bridge(IterableLinkinfoBrportAttrs<'a>),
4424    Bond(IterableBondSlaveAttrs<'a>),
4425}
4426impl<'a> LinkinfoMemberDataMsg<'a> {
4427    fn select_with_loc(selector: &'a CStr, buf: &'a [u8], loc: usize) -> Option<Self> {
4428        match selector.to_bytes() {
4429            b"bridge" => Some(LinkinfoMemberDataMsg::Bridge(
4430                IterableLinkinfoBrportAttrs::with_loc(buf, loc),
4431            )),
4432            b"bond" => Some(LinkinfoMemberDataMsg::Bond(
4433                IterableBondSlaveAttrs::with_loc(buf, loc),
4434            )),
4435            _ => None,
4436        }
4437    }
4438}
4439impl LinkinfoAttrs<'_> {
4440    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoAttrs<'a> {
4441        IterableLinkinfoAttrs::with_loc(buf, buf.as_ptr() as usize)
4442    }
4443    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4444        let res = match r#type {
4445            1u16 => "Kind",
4446            2u16 => "Data",
4447            3u16 => "Xstats",
4448            4u16 => "SlaveKind",
4449            5u16 => "SlaveData",
4450            _ => return None,
4451        };
4452        Some(res)
4453    }
4454}
4455#[derive(Clone, Copy, Default)]
4456pub struct IterableLinkinfoAttrs<'a> {
4457    buf: &'a [u8],
4458    pos: usize,
4459    orig_loc: usize,
4460}
4461impl<'a> IterableLinkinfoAttrs<'a> {
4462    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4463        Self {
4464            buf,
4465            pos: 0,
4466            orig_loc,
4467        }
4468    }
4469    pub fn get_buf(&self) -> &'a [u8] {
4470        self.buf
4471    }
4472}
4473impl<'a> Iterator for IterableLinkinfoAttrs<'a> {
4474    type Item = Result<LinkinfoAttrs<'a>, ErrorContext>;
4475    fn next(&mut self) -> Option<Self::Item> {
4476        let pos = self.pos;
4477        let mut r#type;
4478        loop {
4479            r#type = None;
4480            if self.buf.len() == self.pos {
4481                return None;
4482            }
4483            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
4484                break;
4485            };
4486            r#type = Some(header.r#type);
4487            let res = match header.r#type {
4488                1u16 => LinkinfoAttrs::Kind({
4489                    let res = CStr::from_bytes_with_nul(next).ok();
4490                    let Some(val) = res else { break };
4491                    val
4492                }),
4493                2u16 => LinkinfoAttrs::Data({
4494                    let res = {
4495                        let Ok(selector) = self.get_kind() else { break };
4496                        match LinkinfoDataMsg::select_with_loc(selector, next, self.orig_loc) {
4497                            Some(sub) => Some(sub),
4498                            None if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4499                            None => continue,
4500                        }
4501                    };
4502                    let Some(val) = res else { break };
4503                    val
4504                }),
4505                3u16 => LinkinfoAttrs::Xstats({
4506                    let res = Some(next);
4507                    let Some(val) = res else { break };
4508                    val
4509                }),
4510                4u16 => LinkinfoAttrs::SlaveKind({
4511                    let res = CStr::from_bytes_with_nul(next).ok();
4512                    let Some(val) = res else { break };
4513                    val
4514                }),
4515                5u16 => LinkinfoAttrs::SlaveData({
4516                    let res = {
4517                        let Ok(selector) = self.get_slave_kind() else {
4518                            break;
4519                        };
4520                        match LinkinfoMemberDataMsg::select_with_loc(selector, next, self.orig_loc)
4521                        {
4522                            Some(sub) => Some(sub),
4523                            None if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4524                            None => continue,
4525                        }
4526                    };
4527                    let Some(val) = res else { break };
4528                    val
4529                }),
4530                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4531                n => continue,
4532            };
4533            return Some(Ok(res));
4534        }
4535        Some(Err(ErrorContext::new(
4536            "LinkinfoAttrs",
4537            r#type.and_then(|t| LinkinfoAttrs::attr_from_type(t)),
4538            self.orig_loc,
4539            self.buf.as_ptr().wrapping_add(pos) as usize,
4540        )))
4541    }
4542}
4543impl<'a> std::fmt::Debug for IterableLinkinfoAttrs<'_> {
4544    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4545        let mut fmt = f.debug_struct("LinkinfoAttrs");
4546        for attr in self.clone() {
4547            let attr = match attr {
4548                Ok(a) => a,
4549                Err(err) => {
4550                    fmt.finish()?;
4551                    f.write_str("Err(")?;
4552                    err.fmt(f)?;
4553                    return f.write_str(")");
4554                }
4555            };
4556            match attr {
4557                LinkinfoAttrs::Kind(val) => fmt.field("Kind", &val),
4558                LinkinfoAttrs::Data(val) => fmt.field("Data", &val),
4559                LinkinfoAttrs::Xstats(val) => fmt.field("Xstats", &val),
4560                LinkinfoAttrs::SlaveKind(val) => fmt.field("SlaveKind", &val),
4561                LinkinfoAttrs::SlaveData(val) => fmt.field("SlaveData", &val),
4562            };
4563        }
4564        fmt.finish()
4565    }
4566}
4567impl IterableLinkinfoAttrs<'_> {
4568    pub fn lookup_attr(
4569        &self,
4570        offset: usize,
4571        missing_type: Option<u16>,
4572    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4573        let mut stack = Vec::new();
4574        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4575        if cur == offset {
4576            stack.push(("LinkinfoAttrs", offset));
4577            return (
4578                stack,
4579                missing_type.and_then(|t| LinkinfoAttrs::attr_from_type(t)),
4580            );
4581        }
4582        if cur > offset || cur + self.buf.len() < offset {
4583            return (stack, None);
4584        }
4585        let mut attrs = self.clone();
4586        let mut last_off = cur + attrs.pos;
4587        while let Some(attr) = attrs.next() {
4588            let Ok(attr) = attr else { break };
4589            match attr {
4590                LinkinfoAttrs::Kind(val) => {
4591                    if last_off == offset {
4592                        stack.push(("Kind", last_off));
4593                        break;
4594                    }
4595                }
4596                LinkinfoAttrs::Data(val) => {
4597                    if last_off == offset {
4598                        stack.push(("Data", last_off));
4599                        break;
4600                    }
4601                }
4602                LinkinfoAttrs::Xstats(val) => {
4603                    if last_off == offset {
4604                        stack.push(("Xstats", last_off));
4605                        break;
4606                    }
4607                }
4608                LinkinfoAttrs::SlaveKind(val) => {
4609                    if last_off == offset {
4610                        stack.push(("SlaveKind", last_off));
4611                        break;
4612                    }
4613                }
4614                LinkinfoAttrs::SlaveData(val) => {
4615                    if last_off == offset {
4616                        stack.push(("SlaveData", last_off));
4617                        break;
4618                    }
4619                }
4620                _ => {}
4621            };
4622            last_off = cur + attrs.pos;
4623        }
4624        if !stack.is_empty() {
4625            stack.push(("LinkinfoAttrs", cur));
4626        }
4627        (stack, None)
4628    }
4629}
4630#[derive(Clone)]
4631pub enum LinkinfoBondAttrs<'a> {
4632    Mode(u8),
4633    ActiveSlave(u32),
4634    Miimon(u32),
4635    Updelay(u32),
4636    Downdelay(u32),
4637    UseCarrier(u8),
4638    ArpInterval(u32),
4639    ArpIpTarget(IterableArrayIpv4Addr<'a>),
4640    ArpValidate(u32),
4641    ArpAllTargets(u32),
4642    Primary(u32),
4643    PrimaryReselect(u8),
4644    FailOverMac(u8),
4645    XmitHashPolicy(u8),
4646    ResendIgmp(u32),
4647    NumPeerNotif(u8),
4648    AllSlavesActive(u8),
4649    MinLinks(u32),
4650    LpInterval(u32),
4651    PacketsPerSlave(u32),
4652    AdLacpRate(u8),
4653    AdSelect(u8),
4654    AdInfo(IterableBondAdInfoAttrs<'a>),
4655    AdActorSysPrio(u16),
4656    AdUserPortKey(u16),
4657    AdActorSystem(&'a [u8]),
4658    TlbDynamicLb(u8),
4659    PeerNotifDelay(u32),
4660    AdLacpActive(u8),
4661    MissedMax(u8),
4662    NsIp6Target(IterableArrayBinary<'a>),
4663    CoupledControl(u8),
4664}
4665impl<'a> IterableLinkinfoBondAttrs<'a> {
4666    pub fn get_mode(&self) -> Result<u8, ErrorContext> {
4667        let mut iter = self.clone();
4668        iter.pos = 0;
4669        for attr in iter {
4670            if let LinkinfoBondAttrs::Mode(val) = attr? {
4671                return Ok(val);
4672            }
4673        }
4674        Err(ErrorContext::new_missing(
4675            "LinkinfoBondAttrs",
4676            "Mode",
4677            self.orig_loc,
4678            self.buf.as_ptr() as usize,
4679        ))
4680    }
4681    pub fn get_active_slave(&self) -> Result<u32, ErrorContext> {
4682        let mut iter = self.clone();
4683        iter.pos = 0;
4684        for attr in iter {
4685            if let LinkinfoBondAttrs::ActiveSlave(val) = attr? {
4686                return Ok(val);
4687            }
4688        }
4689        Err(ErrorContext::new_missing(
4690            "LinkinfoBondAttrs",
4691            "ActiveSlave",
4692            self.orig_loc,
4693            self.buf.as_ptr() as usize,
4694        ))
4695    }
4696    pub fn get_miimon(&self) -> Result<u32, ErrorContext> {
4697        let mut iter = self.clone();
4698        iter.pos = 0;
4699        for attr in iter {
4700            if let LinkinfoBondAttrs::Miimon(val) = attr? {
4701                return Ok(val);
4702            }
4703        }
4704        Err(ErrorContext::new_missing(
4705            "LinkinfoBondAttrs",
4706            "Miimon",
4707            self.orig_loc,
4708            self.buf.as_ptr() as usize,
4709        ))
4710    }
4711    pub fn get_updelay(&self) -> Result<u32, ErrorContext> {
4712        let mut iter = self.clone();
4713        iter.pos = 0;
4714        for attr in iter {
4715            if let LinkinfoBondAttrs::Updelay(val) = attr? {
4716                return Ok(val);
4717            }
4718        }
4719        Err(ErrorContext::new_missing(
4720            "LinkinfoBondAttrs",
4721            "Updelay",
4722            self.orig_loc,
4723            self.buf.as_ptr() as usize,
4724        ))
4725    }
4726    pub fn get_downdelay(&self) -> Result<u32, ErrorContext> {
4727        let mut iter = self.clone();
4728        iter.pos = 0;
4729        for attr in iter {
4730            if let LinkinfoBondAttrs::Downdelay(val) = attr? {
4731                return Ok(val);
4732            }
4733        }
4734        Err(ErrorContext::new_missing(
4735            "LinkinfoBondAttrs",
4736            "Downdelay",
4737            self.orig_loc,
4738            self.buf.as_ptr() as usize,
4739        ))
4740    }
4741    pub fn get_use_carrier(&self) -> Result<u8, ErrorContext> {
4742        let mut iter = self.clone();
4743        iter.pos = 0;
4744        for attr in iter {
4745            if let LinkinfoBondAttrs::UseCarrier(val) = attr? {
4746                return Ok(val);
4747            }
4748        }
4749        Err(ErrorContext::new_missing(
4750            "LinkinfoBondAttrs",
4751            "UseCarrier",
4752            self.orig_loc,
4753            self.buf.as_ptr() as usize,
4754        ))
4755    }
4756    pub fn get_arp_interval(&self) -> Result<u32, ErrorContext> {
4757        let mut iter = self.clone();
4758        iter.pos = 0;
4759        for attr in iter {
4760            if let LinkinfoBondAttrs::ArpInterval(val) = attr? {
4761                return Ok(val);
4762            }
4763        }
4764        Err(ErrorContext::new_missing(
4765            "LinkinfoBondAttrs",
4766            "ArpInterval",
4767            self.orig_loc,
4768            self.buf.as_ptr() as usize,
4769        ))
4770    }
4771    pub fn get_arp_ip_target(
4772        &self,
4773    ) -> Result<ArrayIterable<IterableArrayIpv4Addr<'a>, std::net::Ipv4Addr>, ErrorContext> {
4774        for attr in self.clone() {
4775            if let LinkinfoBondAttrs::ArpIpTarget(val) = attr? {
4776                return Ok(ArrayIterable::new(val));
4777            }
4778        }
4779        Err(ErrorContext::new_missing(
4780            "LinkinfoBondAttrs",
4781            "ArpIpTarget",
4782            self.orig_loc,
4783            self.buf.as_ptr() as usize,
4784        ))
4785    }
4786    pub fn get_arp_validate(&self) -> Result<u32, ErrorContext> {
4787        let mut iter = self.clone();
4788        iter.pos = 0;
4789        for attr in iter {
4790            if let LinkinfoBondAttrs::ArpValidate(val) = attr? {
4791                return Ok(val);
4792            }
4793        }
4794        Err(ErrorContext::new_missing(
4795            "LinkinfoBondAttrs",
4796            "ArpValidate",
4797            self.orig_loc,
4798            self.buf.as_ptr() as usize,
4799        ))
4800    }
4801    pub fn get_arp_all_targets(&self) -> Result<u32, ErrorContext> {
4802        let mut iter = self.clone();
4803        iter.pos = 0;
4804        for attr in iter {
4805            if let LinkinfoBondAttrs::ArpAllTargets(val) = attr? {
4806                return Ok(val);
4807            }
4808        }
4809        Err(ErrorContext::new_missing(
4810            "LinkinfoBondAttrs",
4811            "ArpAllTargets",
4812            self.orig_loc,
4813            self.buf.as_ptr() as usize,
4814        ))
4815    }
4816    pub fn get_primary(&self) -> Result<u32, ErrorContext> {
4817        let mut iter = self.clone();
4818        iter.pos = 0;
4819        for attr in iter {
4820            if let LinkinfoBondAttrs::Primary(val) = attr? {
4821                return Ok(val);
4822            }
4823        }
4824        Err(ErrorContext::new_missing(
4825            "LinkinfoBondAttrs",
4826            "Primary",
4827            self.orig_loc,
4828            self.buf.as_ptr() as usize,
4829        ))
4830    }
4831    pub fn get_primary_reselect(&self) -> Result<u8, ErrorContext> {
4832        let mut iter = self.clone();
4833        iter.pos = 0;
4834        for attr in iter {
4835            if let LinkinfoBondAttrs::PrimaryReselect(val) = attr? {
4836                return Ok(val);
4837            }
4838        }
4839        Err(ErrorContext::new_missing(
4840            "LinkinfoBondAttrs",
4841            "PrimaryReselect",
4842            self.orig_loc,
4843            self.buf.as_ptr() as usize,
4844        ))
4845    }
4846    pub fn get_fail_over_mac(&self) -> Result<u8, ErrorContext> {
4847        let mut iter = self.clone();
4848        iter.pos = 0;
4849        for attr in iter {
4850            if let LinkinfoBondAttrs::FailOverMac(val) = attr? {
4851                return Ok(val);
4852            }
4853        }
4854        Err(ErrorContext::new_missing(
4855            "LinkinfoBondAttrs",
4856            "FailOverMac",
4857            self.orig_loc,
4858            self.buf.as_ptr() as usize,
4859        ))
4860    }
4861    pub fn get_xmit_hash_policy(&self) -> Result<u8, ErrorContext> {
4862        let mut iter = self.clone();
4863        iter.pos = 0;
4864        for attr in iter {
4865            if let LinkinfoBondAttrs::XmitHashPolicy(val) = attr? {
4866                return Ok(val);
4867            }
4868        }
4869        Err(ErrorContext::new_missing(
4870            "LinkinfoBondAttrs",
4871            "XmitHashPolicy",
4872            self.orig_loc,
4873            self.buf.as_ptr() as usize,
4874        ))
4875    }
4876    pub fn get_resend_igmp(&self) -> Result<u32, ErrorContext> {
4877        let mut iter = self.clone();
4878        iter.pos = 0;
4879        for attr in iter {
4880            if let LinkinfoBondAttrs::ResendIgmp(val) = attr? {
4881                return Ok(val);
4882            }
4883        }
4884        Err(ErrorContext::new_missing(
4885            "LinkinfoBondAttrs",
4886            "ResendIgmp",
4887            self.orig_loc,
4888            self.buf.as_ptr() as usize,
4889        ))
4890    }
4891    pub fn get_num_peer_notif(&self) -> Result<u8, ErrorContext> {
4892        let mut iter = self.clone();
4893        iter.pos = 0;
4894        for attr in iter {
4895            if let LinkinfoBondAttrs::NumPeerNotif(val) = attr? {
4896                return Ok(val);
4897            }
4898        }
4899        Err(ErrorContext::new_missing(
4900            "LinkinfoBondAttrs",
4901            "NumPeerNotif",
4902            self.orig_loc,
4903            self.buf.as_ptr() as usize,
4904        ))
4905    }
4906    pub fn get_all_slaves_active(&self) -> Result<u8, ErrorContext> {
4907        let mut iter = self.clone();
4908        iter.pos = 0;
4909        for attr in iter {
4910            if let LinkinfoBondAttrs::AllSlavesActive(val) = attr? {
4911                return Ok(val);
4912            }
4913        }
4914        Err(ErrorContext::new_missing(
4915            "LinkinfoBondAttrs",
4916            "AllSlavesActive",
4917            self.orig_loc,
4918            self.buf.as_ptr() as usize,
4919        ))
4920    }
4921    pub fn get_min_links(&self) -> Result<u32, ErrorContext> {
4922        let mut iter = self.clone();
4923        iter.pos = 0;
4924        for attr in iter {
4925            if let LinkinfoBondAttrs::MinLinks(val) = attr? {
4926                return Ok(val);
4927            }
4928        }
4929        Err(ErrorContext::new_missing(
4930            "LinkinfoBondAttrs",
4931            "MinLinks",
4932            self.orig_loc,
4933            self.buf.as_ptr() as usize,
4934        ))
4935    }
4936    pub fn get_lp_interval(&self) -> Result<u32, ErrorContext> {
4937        let mut iter = self.clone();
4938        iter.pos = 0;
4939        for attr in iter {
4940            if let LinkinfoBondAttrs::LpInterval(val) = attr? {
4941                return Ok(val);
4942            }
4943        }
4944        Err(ErrorContext::new_missing(
4945            "LinkinfoBondAttrs",
4946            "LpInterval",
4947            self.orig_loc,
4948            self.buf.as_ptr() as usize,
4949        ))
4950    }
4951    pub fn get_packets_per_slave(&self) -> Result<u32, ErrorContext> {
4952        let mut iter = self.clone();
4953        iter.pos = 0;
4954        for attr in iter {
4955            if let LinkinfoBondAttrs::PacketsPerSlave(val) = attr? {
4956                return Ok(val);
4957            }
4958        }
4959        Err(ErrorContext::new_missing(
4960            "LinkinfoBondAttrs",
4961            "PacketsPerSlave",
4962            self.orig_loc,
4963            self.buf.as_ptr() as usize,
4964        ))
4965    }
4966    pub fn get_ad_lacp_rate(&self) -> Result<u8, ErrorContext> {
4967        let mut iter = self.clone();
4968        iter.pos = 0;
4969        for attr in iter {
4970            if let LinkinfoBondAttrs::AdLacpRate(val) = attr? {
4971                return Ok(val);
4972            }
4973        }
4974        Err(ErrorContext::new_missing(
4975            "LinkinfoBondAttrs",
4976            "AdLacpRate",
4977            self.orig_loc,
4978            self.buf.as_ptr() as usize,
4979        ))
4980    }
4981    pub fn get_ad_select(&self) -> Result<u8, ErrorContext> {
4982        let mut iter = self.clone();
4983        iter.pos = 0;
4984        for attr in iter {
4985            if let LinkinfoBondAttrs::AdSelect(val) = attr? {
4986                return Ok(val);
4987            }
4988        }
4989        Err(ErrorContext::new_missing(
4990            "LinkinfoBondAttrs",
4991            "AdSelect",
4992            self.orig_loc,
4993            self.buf.as_ptr() as usize,
4994        ))
4995    }
4996    pub fn get_ad_info(&self) -> Result<IterableBondAdInfoAttrs<'a>, ErrorContext> {
4997        let mut iter = self.clone();
4998        iter.pos = 0;
4999        for attr in iter {
5000            if let LinkinfoBondAttrs::AdInfo(val) = attr? {
5001                return Ok(val);
5002            }
5003        }
5004        Err(ErrorContext::new_missing(
5005            "LinkinfoBondAttrs",
5006            "AdInfo",
5007            self.orig_loc,
5008            self.buf.as_ptr() as usize,
5009        ))
5010    }
5011    pub fn get_ad_actor_sys_prio(&self) -> Result<u16, ErrorContext> {
5012        let mut iter = self.clone();
5013        iter.pos = 0;
5014        for attr in iter {
5015            if let LinkinfoBondAttrs::AdActorSysPrio(val) = attr? {
5016                return Ok(val);
5017            }
5018        }
5019        Err(ErrorContext::new_missing(
5020            "LinkinfoBondAttrs",
5021            "AdActorSysPrio",
5022            self.orig_loc,
5023            self.buf.as_ptr() as usize,
5024        ))
5025    }
5026    pub fn get_ad_user_port_key(&self) -> Result<u16, ErrorContext> {
5027        let mut iter = self.clone();
5028        iter.pos = 0;
5029        for attr in iter {
5030            if let LinkinfoBondAttrs::AdUserPortKey(val) = attr? {
5031                return Ok(val);
5032            }
5033        }
5034        Err(ErrorContext::new_missing(
5035            "LinkinfoBondAttrs",
5036            "AdUserPortKey",
5037            self.orig_loc,
5038            self.buf.as_ptr() as usize,
5039        ))
5040    }
5041    pub fn get_ad_actor_system(&self) -> Result<&'a [u8], ErrorContext> {
5042        let mut iter = self.clone();
5043        iter.pos = 0;
5044        for attr in iter {
5045            if let LinkinfoBondAttrs::AdActorSystem(val) = attr? {
5046                return Ok(val);
5047            }
5048        }
5049        Err(ErrorContext::new_missing(
5050            "LinkinfoBondAttrs",
5051            "AdActorSystem",
5052            self.orig_loc,
5053            self.buf.as_ptr() as usize,
5054        ))
5055    }
5056    pub fn get_tlb_dynamic_lb(&self) -> Result<u8, ErrorContext> {
5057        let mut iter = self.clone();
5058        iter.pos = 0;
5059        for attr in iter {
5060            if let LinkinfoBondAttrs::TlbDynamicLb(val) = attr? {
5061                return Ok(val);
5062            }
5063        }
5064        Err(ErrorContext::new_missing(
5065            "LinkinfoBondAttrs",
5066            "TlbDynamicLb",
5067            self.orig_loc,
5068            self.buf.as_ptr() as usize,
5069        ))
5070    }
5071    pub fn get_peer_notif_delay(&self) -> Result<u32, ErrorContext> {
5072        let mut iter = self.clone();
5073        iter.pos = 0;
5074        for attr in iter {
5075            if let LinkinfoBondAttrs::PeerNotifDelay(val) = attr? {
5076                return Ok(val);
5077            }
5078        }
5079        Err(ErrorContext::new_missing(
5080            "LinkinfoBondAttrs",
5081            "PeerNotifDelay",
5082            self.orig_loc,
5083            self.buf.as_ptr() as usize,
5084        ))
5085    }
5086    pub fn get_ad_lacp_active(&self) -> Result<u8, ErrorContext> {
5087        let mut iter = self.clone();
5088        iter.pos = 0;
5089        for attr in iter {
5090            if let LinkinfoBondAttrs::AdLacpActive(val) = attr? {
5091                return Ok(val);
5092            }
5093        }
5094        Err(ErrorContext::new_missing(
5095            "LinkinfoBondAttrs",
5096            "AdLacpActive",
5097            self.orig_loc,
5098            self.buf.as_ptr() as usize,
5099        ))
5100    }
5101    pub fn get_missed_max(&self) -> Result<u8, ErrorContext> {
5102        let mut iter = self.clone();
5103        iter.pos = 0;
5104        for attr in iter {
5105            if let LinkinfoBondAttrs::MissedMax(val) = attr? {
5106                return Ok(val);
5107            }
5108        }
5109        Err(ErrorContext::new_missing(
5110            "LinkinfoBondAttrs",
5111            "MissedMax",
5112            self.orig_loc,
5113            self.buf.as_ptr() as usize,
5114        ))
5115    }
5116    pub fn get_ns_ip6_target(
5117        &self,
5118    ) -> Result<ArrayIterable<IterableArrayBinary<'a>, &'a [u8]>, ErrorContext> {
5119        for attr in self.clone() {
5120            if let LinkinfoBondAttrs::NsIp6Target(val) = attr? {
5121                return Ok(ArrayIterable::new(val));
5122            }
5123        }
5124        Err(ErrorContext::new_missing(
5125            "LinkinfoBondAttrs",
5126            "NsIp6Target",
5127            self.orig_loc,
5128            self.buf.as_ptr() as usize,
5129        ))
5130    }
5131    pub fn get_coupled_control(&self) -> Result<u8, ErrorContext> {
5132        let mut iter = self.clone();
5133        iter.pos = 0;
5134        for attr in iter {
5135            if let LinkinfoBondAttrs::CoupledControl(val) = attr? {
5136                return Ok(val);
5137            }
5138        }
5139        Err(ErrorContext::new_missing(
5140            "LinkinfoBondAttrs",
5141            "CoupledControl",
5142            self.orig_loc,
5143            self.buf.as_ptr() as usize,
5144        ))
5145    }
5146}
5147#[derive(Clone, Copy, Default)]
5148pub struct IterableArrayIpv4Addr<'a> {
5149    buf: &'a [u8],
5150    pos: usize,
5151    orig_loc: usize,
5152}
5153impl<'a> IterableArrayIpv4Addr<'a> {
5154    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5155        Self {
5156            buf,
5157            pos: 0,
5158            orig_loc,
5159        }
5160    }
5161    pub fn get_buf(&self) -> &'a [u8] {
5162        self.buf
5163    }
5164}
5165impl<'a> Iterator for IterableArrayIpv4Addr<'a> {
5166    type Item = Result<std::net::Ipv4Addr, ErrorContext>;
5167    fn next(&mut self) -> Option<Self::Item> {
5168        if self.buf.len() == self.pos {
5169            return None;
5170        }
5171        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
5172            {
5173                let Some(res) = parse_be_u32(next).map(Ipv4Addr::from_bits) else {
5174                    break;
5175                };
5176                return Some(Ok(res));
5177            }
5178        }
5179        Some(Err(ErrorContext::new(
5180            "Ipv4Addr",
5181            None,
5182            self.orig_loc,
5183            self.buf.as_ptr().wrapping_add(self.pos) as usize,
5184        )))
5185    }
5186}
5187#[derive(Clone, Copy, Default)]
5188pub struct IterableArrayBinary<'a> {
5189    buf: &'a [u8],
5190    pos: usize,
5191    orig_loc: usize,
5192}
5193impl<'a> IterableArrayBinary<'a> {
5194    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5195        Self {
5196            buf,
5197            pos: 0,
5198            orig_loc,
5199        }
5200    }
5201    pub fn get_buf(&self) -> &'a [u8] {
5202        self.buf
5203    }
5204}
5205impl<'a> Iterator for IterableArrayBinary<'a> {
5206    type Item = Result<&'a [u8], ErrorContext>;
5207    fn next(&mut self) -> Option<Self::Item> {
5208        if self.buf.len() == self.pos {
5209            return None;
5210        }
5211        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
5212            {
5213                let Some(res) = Some(next) else { break };
5214                return Some(Ok(res));
5215            }
5216        }
5217        Some(Err(ErrorContext::new(
5218            "Binary",
5219            None,
5220            self.orig_loc,
5221            self.buf.as_ptr().wrapping_add(self.pos) as usize,
5222        )))
5223    }
5224}
5225impl LinkinfoBondAttrs<'_> {
5226    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoBondAttrs<'a> {
5227        IterableLinkinfoBondAttrs::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 => "Mode",
5232            2u16 => "ActiveSlave",
5233            3u16 => "Miimon",
5234            4u16 => "Updelay",
5235            5u16 => "Downdelay",
5236            6u16 => "UseCarrier",
5237            7u16 => "ArpInterval",
5238            8u16 => "ArpIpTarget",
5239            9u16 => "ArpValidate",
5240            10u16 => "ArpAllTargets",
5241            11u16 => "Primary",
5242            12u16 => "PrimaryReselect",
5243            13u16 => "FailOverMac",
5244            14u16 => "XmitHashPolicy",
5245            15u16 => "ResendIgmp",
5246            16u16 => "NumPeerNotif",
5247            17u16 => "AllSlavesActive",
5248            18u16 => "MinLinks",
5249            19u16 => "LpInterval",
5250            20u16 => "PacketsPerSlave",
5251            21u16 => "AdLacpRate",
5252            22u16 => "AdSelect",
5253            23u16 => "AdInfo",
5254            24u16 => "AdActorSysPrio",
5255            25u16 => "AdUserPortKey",
5256            26u16 => "AdActorSystem",
5257            27u16 => "TlbDynamicLb",
5258            28u16 => "PeerNotifDelay",
5259            29u16 => "AdLacpActive",
5260            30u16 => "MissedMax",
5261            31u16 => "NsIp6Target",
5262            32u16 => "CoupledControl",
5263            _ => return None,
5264        };
5265        Some(res)
5266    }
5267}
5268#[derive(Clone, Copy, Default)]
5269pub struct IterableLinkinfoBondAttrs<'a> {
5270    buf: &'a [u8],
5271    pos: usize,
5272    orig_loc: usize,
5273}
5274impl<'a> IterableLinkinfoBondAttrs<'a> {
5275    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5276        Self {
5277            buf,
5278            pos: 0,
5279            orig_loc,
5280        }
5281    }
5282    pub fn get_buf(&self) -> &'a [u8] {
5283        self.buf
5284    }
5285}
5286impl<'a> Iterator for IterableLinkinfoBondAttrs<'a> {
5287    type Item = Result<LinkinfoBondAttrs<'a>, ErrorContext>;
5288    fn next(&mut self) -> Option<Self::Item> {
5289        let pos = self.pos;
5290        let mut r#type;
5291        loop {
5292            r#type = None;
5293            if self.buf.len() == self.pos {
5294                return None;
5295            }
5296            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5297                break;
5298            };
5299            r#type = Some(header.r#type);
5300            let res = match header.r#type {
5301                1u16 => LinkinfoBondAttrs::Mode({
5302                    let res = parse_u8(next);
5303                    let Some(val) = res else { break };
5304                    val
5305                }),
5306                2u16 => LinkinfoBondAttrs::ActiveSlave({
5307                    let res = parse_u32(next);
5308                    let Some(val) = res else { break };
5309                    val
5310                }),
5311                3u16 => LinkinfoBondAttrs::Miimon({
5312                    let res = parse_u32(next);
5313                    let Some(val) = res else { break };
5314                    val
5315                }),
5316                4u16 => LinkinfoBondAttrs::Updelay({
5317                    let res = parse_u32(next);
5318                    let Some(val) = res else { break };
5319                    val
5320                }),
5321                5u16 => LinkinfoBondAttrs::Downdelay({
5322                    let res = parse_u32(next);
5323                    let Some(val) = res else { break };
5324                    val
5325                }),
5326                6u16 => LinkinfoBondAttrs::UseCarrier({
5327                    let res = parse_u8(next);
5328                    let Some(val) = res else { break };
5329                    val
5330                }),
5331                7u16 => LinkinfoBondAttrs::ArpInterval({
5332                    let res = parse_u32(next);
5333                    let Some(val) = res else { break };
5334                    val
5335                }),
5336                8u16 => LinkinfoBondAttrs::ArpIpTarget({
5337                    let res = Some(IterableArrayIpv4Addr::with_loc(next, self.orig_loc));
5338                    let Some(val) = res else { break };
5339                    val
5340                }),
5341                9u16 => LinkinfoBondAttrs::ArpValidate({
5342                    let res = parse_u32(next);
5343                    let Some(val) = res else { break };
5344                    val
5345                }),
5346                10u16 => LinkinfoBondAttrs::ArpAllTargets({
5347                    let res = parse_u32(next);
5348                    let Some(val) = res else { break };
5349                    val
5350                }),
5351                11u16 => LinkinfoBondAttrs::Primary({
5352                    let res = parse_u32(next);
5353                    let Some(val) = res else { break };
5354                    val
5355                }),
5356                12u16 => LinkinfoBondAttrs::PrimaryReselect({
5357                    let res = parse_u8(next);
5358                    let Some(val) = res else { break };
5359                    val
5360                }),
5361                13u16 => LinkinfoBondAttrs::FailOverMac({
5362                    let res = parse_u8(next);
5363                    let Some(val) = res else { break };
5364                    val
5365                }),
5366                14u16 => LinkinfoBondAttrs::XmitHashPolicy({
5367                    let res = parse_u8(next);
5368                    let Some(val) = res else { break };
5369                    val
5370                }),
5371                15u16 => LinkinfoBondAttrs::ResendIgmp({
5372                    let res = parse_u32(next);
5373                    let Some(val) = res else { break };
5374                    val
5375                }),
5376                16u16 => LinkinfoBondAttrs::NumPeerNotif({
5377                    let res = parse_u8(next);
5378                    let Some(val) = res else { break };
5379                    val
5380                }),
5381                17u16 => LinkinfoBondAttrs::AllSlavesActive({
5382                    let res = parse_u8(next);
5383                    let Some(val) = res else { break };
5384                    val
5385                }),
5386                18u16 => LinkinfoBondAttrs::MinLinks({
5387                    let res = parse_u32(next);
5388                    let Some(val) = res else { break };
5389                    val
5390                }),
5391                19u16 => LinkinfoBondAttrs::LpInterval({
5392                    let res = parse_u32(next);
5393                    let Some(val) = res else { break };
5394                    val
5395                }),
5396                20u16 => LinkinfoBondAttrs::PacketsPerSlave({
5397                    let res = parse_u32(next);
5398                    let Some(val) = res else { break };
5399                    val
5400                }),
5401                21u16 => LinkinfoBondAttrs::AdLacpRate({
5402                    let res = parse_u8(next);
5403                    let Some(val) = res else { break };
5404                    val
5405                }),
5406                22u16 => LinkinfoBondAttrs::AdSelect({
5407                    let res = parse_u8(next);
5408                    let Some(val) = res else { break };
5409                    val
5410                }),
5411                23u16 => LinkinfoBondAttrs::AdInfo({
5412                    let res = Some(IterableBondAdInfoAttrs::with_loc(next, self.orig_loc));
5413                    let Some(val) = res else { break };
5414                    val
5415                }),
5416                24u16 => LinkinfoBondAttrs::AdActorSysPrio({
5417                    let res = parse_u16(next);
5418                    let Some(val) = res else { break };
5419                    val
5420                }),
5421                25u16 => LinkinfoBondAttrs::AdUserPortKey({
5422                    let res = parse_u16(next);
5423                    let Some(val) = res else { break };
5424                    val
5425                }),
5426                26u16 => LinkinfoBondAttrs::AdActorSystem({
5427                    let res = Some(next);
5428                    let Some(val) = res else { break };
5429                    val
5430                }),
5431                27u16 => LinkinfoBondAttrs::TlbDynamicLb({
5432                    let res = parse_u8(next);
5433                    let Some(val) = res else { break };
5434                    val
5435                }),
5436                28u16 => LinkinfoBondAttrs::PeerNotifDelay({
5437                    let res = parse_u32(next);
5438                    let Some(val) = res else { break };
5439                    val
5440                }),
5441                29u16 => LinkinfoBondAttrs::AdLacpActive({
5442                    let res = parse_u8(next);
5443                    let Some(val) = res else { break };
5444                    val
5445                }),
5446                30u16 => LinkinfoBondAttrs::MissedMax({
5447                    let res = parse_u8(next);
5448                    let Some(val) = res else { break };
5449                    val
5450                }),
5451                31u16 => LinkinfoBondAttrs::NsIp6Target({
5452                    let res = Some(IterableArrayBinary::with_loc(next, self.orig_loc));
5453                    let Some(val) = res else { break };
5454                    val
5455                }),
5456                32u16 => LinkinfoBondAttrs::CoupledControl({
5457                    let res = parse_u8(next);
5458                    let Some(val) = res else { break };
5459                    val
5460                }),
5461                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5462                n => continue,
5463            };
5464            return Some(Ok(res));
5465        }
5466        Some(Err(ErrorContext::new(
5467            "LinkinfoBondAttrs",
5468            r#type.and_then(|t| LinkinfoBondAttrs::attr_from_type(t)),
5469            self.orig_loc,
5470            self.buf.as_ptr().wrapping_add(pos) as usize,
5471        )))
5472    }
5473}
5474impl std::fmt::Debug for IterableArrayIpv4Addr<'_> {
5475    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5476        fmt.debug_list()
5477            .entries(self.clone().map(FlattenErrorContext))
5478            .finish()
5479    }
5480}
5481impl std::fmt::Debug for IterableArrayBinary<'_> {
5482    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5483        fmt.debug_list()
5484            .entries(self.clone().map(FlattenErrorContext))
5485            .finish()
5486    }
5487}
5488impl<'a> std::fmt::Debug for IterableLinkinfoBondAttrs<'_> {
5489    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5490        let mut fmt = f.debug_struct("LinkinfoBondAttrs");
5491        for attr in self.clone() {
5492            let attr = match attr {
5493                Ok(a) => a,
5494                Err(err) => {
5495                    fmt.finish()?;
5496                    f.write_str("Err(")?;
5497                    err.fmt(f)?;
5498                    return f.write_str(")");
5499                }
5500            };
5501            match attr {
5502                LinkinfoBondAttrs::Mode(val) => fmt.field("Mode", &val),
5503                LinkinfoBondAttrs::ActiveSlave(val) => fmt.field("ActiveSlave", &val),
5504                LinkinfoBondAttrs::Miimon(val) => fmt.field("Miimon", &val),
5505                LinkinfoBondAttrs::Updelay(val) => fmt.field("Updelay", &val),
5506                LinkinfoBondAttrs::Downdelay(val) => fmt.field("Downdelay", &val),
5507                LinkinfoBondAttrs::UseCarrier(val) => fmt.field("UseCarrier", &val),
5508                LinkinfoBondAttrs::ArpInterval(val) => fmt.field("ArpInterval", &val),
5509                LinkinfoBondAttrs::ArpIpTarget(val) => fmt.field("ArpIpTarget", &val),
5510                LinkinfoBondAttrs::ArpValidate(val) => fmt.field("ArpValidate", &val),
5511                LinkinfoBondAttrs::ArpAllTargets(val) => fmt.field("ArpAllTargets", &val),
5512                LinkinfoBondAttrs::Primary(val) => fmt.field("Primary", &val),
5513                LinkinfoBondAttrs::PrimaryReselect(val) => fmt.field("PrimaryReselect", &val),
5514                LinkinfoBondAttrs::FailOverMac(val) => fmt.field("FailOverMac", &val),
5515                LinkinfoBondAttrs::XmitHashPolicy(val) => fmt.field("XmitHashPolicy", &val),
5516                LinkinfoBondAttrs::ResendIgmp(val) => fmt.field("ResendIgmp", &val),
5517                LinkinfoBondAttrs::NumPeerNotif(val) => fmt.field("NumPeerNotif", &val),
5518                LinkinfoBondAttrs::AllSlavesActive(val) => fmt.field("AllSlavesActive", &val),
5519                LinkinfoBondAttrs::MinLinks(val) => fmt.field("MinLinks", &val),
5520                LinkinfoBondAttrs::LpInterval(val) => fmt.field("LpInterval", &val),
5521                LinkinfoBondAttrs::PacketsPerSlave(val) => fmt.field("PacketsPerSlave", &val),
5522                LinkinfoBondAttrs::AdLacpRate(val) => fmt.field("AdLacpRate", &val),
5523                LinkinfoBondAttrs::AdSelect(val) => fmt.field("AdSelect", &val),
5524                LinkinfoBondAttrs::AdInfo(val) => fmt.field("AdInfo", &val),
5525                LinkinfoBondAttrs::AdActorSysPrio(val) => fmt.field("AdActorSysPrio", &val),
5526                LinkinfoBondAttrs::AdUserPortKey(val) => fmt.field("AdUserPortKey", &val),
5527                LinkinfoBondAttrs::AdActorSystem(val) => fmt.field("AdActorSystem", &val),
5528                LinkinfoBondAttrs::TlbDynamicLb(val) => fmt.field("TlbDynamicLb", &val),
5529                LinkinfoBondAttrs::PeerNotifDelay(val) => fmt.field("PeerNotifDelay", &val),
5530                LinkinfoBondAttrs::AdLacpActive(val) => fmt.field("AdLacpActive", &val),
5531                LinkinfoBondAttrs::MissedMax(val) => fmt.field("MissedMax", &val),
5532                LinkinfoBondAttrs::NsIp6Target(val) => fmt.field("NsIp6Target", &val),
5533                LinkinfoBondAttrs::CoupledControl(val) => fmt.field("CoupledControl", &val),
5534            };
5535        }
5536        fmt.finish()
5537    }
5538}
5539impl IterableLinkinfoBondAttrs<'_> {
5540    pub fn lookup_attr(
5541        &self,
5542        offset: usize,
5543        missing_type: Option<u16>,
5544    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5545        let mut stack = Vec::new();
5546        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5547        if cur == offset {
5548            stack.push(("LinkinfoBondAttrs", offset));
5549            return (
5550                stack,
5551                missing_type.and_then(|t| LinkinfoBondAttrs::attr_from_type(t)),
5552            );
5553        }
5554        if cur > offset || cur + self.buf.len() < offset {
5555            return (stack, None);
5556        }
5557        let mut attrs = self.clone();
5558        let mut last_off = cur + attrs.pos;
5559        let mut missing = None;
5560        while let Some(attr) = attrs.next() {
5561            let Ok(attr) = attr else { break };
5562            match attr {
5563                LinkinfoBondAttrs::Mode(val) => {
5564                    if last_off == offset {
5565                        stack.push(("Mode", last_off));
5566                        break;
5567                    }
5568                }
5569                LinkinfoBondAttrs::ActiveSlave(val) => {
5570                    if last_off == offset {
5571                        stack.push(("ActiveSlave", last_off));
5572                        break;
5573                    }
5574                }
5575                LinkinfoBondAttrs::Miimon(val) => {
5576                    if last_off == offset {
5577                        stack.push(("Miimon", last_off));
5578                        break;
5579                    }
5580                }
5581                LinkinfoBondAttrs::Updelay(val) => {
5582                    if last_off == offset {
5583                        stack.push(("Updelay", last_off));
5584                        break;
5585                    }
5586                }
5587                LinkinfoBondAttrs::Downdelay(val) => {
5588                    if last_off == offset {
5589                        stack.push(("Downdelay", last_off));
5590                        break;
5591                    }
5592                }
5593                LinkinfoBondAttrs::UseCarrier(val) => {
5594                    if last_off == offset {
5595                        stack.push(("UseCarrier", last_off));
5596                        break;
5597                    }
5598                }
5599                LinkinfoBondAttrs::ArpInterval(val) => {
5600                    if last_off == offset {
5601                        stack.push(("ArpInterval", last_off));
5602                        break;
5603                    }
5604                }
5605                LinkinfoBondAttrs::ArpIpTarget(val) => {
5606                    if last_off == offset {
5607                        stack.push(("ArpIpTarget", last_off));
5608                        break;
5609                    }
5610                }
5611                LinkinfoBondAttrs::ArpValidate(val) => {
5612                    if last_off == offset {
5613                        stack.push(("ArpValidate", last_off));
5614                        break;
5615                    }
5616                }
5617                LinkinfoBondAttrs::ArpAllTargets(val) => {
5618                    if last_off == offset {
5619                        stack.push(("ArpAllTargets", last_off));
5620                        break;
5621                    }
5622                }
5623                LinkinfoBondAttrs::Primary(val) => {
5624                    if last_off == offset {
5625                        stack.push(("Primary", last_off));
5626                        break;
5627                    }
5628                }
5629                LinkinfoBondAttrs::PrimaryReselect(val) => {
5630                    if last_off == offset {
5631                        stack.push(("PrimaryReselect", last_off));
5632                        break;
5633                    }
5634                }
5635                LinkinfoBondAttrs::FailOverMac(val) => {
5636                    if last_off == offset {
5637                        stack.push(("FailOverMac", last_off));
5638                        break;
5639                    }
5640                }
5641                LinkinfoBondAttrs::XmitHashPolicy(val) => {
5642                    if last_off == offset {
5643                        stack.push(("XmitHashPolicy", last_off));
5644                        break;
5645                    }
5646                }
5647                LinkinfoBondAttrs::ResendIgmp(val) => {
5648                    if last_off == offset {
5649                        stack.push(("ResendIgmp", last_off));
5650                        break;
5651                    }
5652                }
5653                LinkinfoBondAttrs::NumPeerNotif(val) => {
5654                    if last_off == offset {
5655                        stack.push(("NumPeerNotif", last_off));
5656                        break;
5657                    }
5658                }
5659                LinkinfoBondAttrs::AllSlavesActive(val) => {
5660                    if last_off == offset {
5661                        stack.push(("AllSlavesActive", last_off));
5662                        break;
5663                    }
5664                }
5665                LinkinfoBondAttrs::MinLinks(val) => {
5666                    if last_off == offset {
5667                        stack.push(("MinLinks", last_off));
5668                        break;
5669                    }
5670                }
5671                LinkinfoBondAttrs::LpInterval(val) => {
5672                    if last_off == offset {
5673                        stack.push(("LpInterval", last_off));
5674                        break;
5675                    }
5676                }
5677                LinkinfoBondAttrs::PacketsPerSlave(val) => {
5678                    if last_off == offset {
5679                        stack.push(("PacketsPerSlave", last_off));
5680                        break;
5681                    }
5682                }
5683                LinkinfoBondAttrs::AdLacpRate(val) => {
5684                    if last_off == offset {
5685                        stack.push(("AdLacpRate", last_off));
5686                        break;
5687                    }
5688                }
5689                LinkinfoBondAttrs::AdSelect(val) => {
5690                    if last_off == offset {
5691                        stack.push(("AdSelect", last_off));
5692                        break;
5693                    }
5694                }
5695                LinkinfoBondAttrs::AdInfo(val) => {
5696                    (stack, missing) = val.lookup_attr(offset, missing_type);
5697                    if !stack.is_empty() {
5698                        break;
5699                    }
5700                }
5701                LinkinfoBondAttrs::AdActorSysPrio(val) => {
5702                    if last_off == offset {
5703                        stack.push(("AdActorSysPrio", last_off));
5704                        break;
5705                    }
5706                }
5707                LinkinfoBondAttrs::AdUserPortKey(val) => {
5708                    if last_off == offset {
5709                        stack.push(("AdUserPortKey", last_off));
5710                        break;
5711                    }
5712                }
5713                LinkinfoBondAttrs::AdActorSystem(val) => {
5714                    if last_off == offset {
5715                        stack.push(("AdActorSystem", last_off));
5716                        break;
5717                    }
5718                }
5719                LinkinfoBondAttrs::TlbDynamicLb(val) => {
5720                    if last_off == offset {
5721                        stack.push(("TlbDynamicLb", last_off));
5722                        break;
5723                    }
5724                }
5725                LinkinfoBondAttrs::PeerNotifDelay(val) => {
5726                    if last_off == offset {
5727                        stack.push(("PeerNotifDelay", last_off));
5728                        break;
5729                    }
5730                }
5731                LinkinfoBondAttrs::AdLacpActive(val) => {
5732                    if last_off == offset {
5733                        stack.push(("AdLacpActive", last_off));
5734                        break;
5735                    }
5736                }
5737                LinkinfoBondAttrs::MissedMax(val) => {
5738                    if last_off == offset {
5739                        stack.push(("MissedMax", last_off));
5740                        break;
5741                    }
5742                }
5743                LinkinfoBondAttrs::NsIp6Target(val) => {
5744                    if last_off == offset {
5745                        stack.push(("NsIp6Target", last_off));
5746                        break;
5747                    }
5748                }
5749                LinkinfoBondAttrs::CoupledControl(val) => {
5750                    if last_off == offset {
5751                        stack.push(("CoupledControl", last_off));
5752                        break;
5753                    }
5754                }
5755                _ => {}
5756            };
5757            last_off = cur + attrs.pos;
5758        }
5759        if !stack.is_empty() {
5760            stack.push(("LinkinfoBondAttrs", cur));
5761        }
5762        (stack, missing)
5763    }
5764}
5765#[derive(Clone)]
5766pub enum BondAdInfoAttrs<'a> {
5767    Aggregator(u16),
5768    NumPorts(u16),
5769    ActorKey(u16),
5770    PartnerKey(u16),
5771    PartnerMac(&'a [u8]),
5772}
5773impl<'a> IterableBondAdInfoAttrs<'a> {
5774    pub fn get_aggregator(&self) -> Result<u16, ErrorContext> {
5775        let mut iter = self.clone();
5776        iter.pos = 0;
5777        for attr in iter {
5778            if let BondAdInfoAttrs::Aggregator(val) = attr? {
5779                return Ok(val);
5780            }
5781        }
5782        Err(ErrorContext::new_missing(
5783            "BondAdInfoAttrs",
5784            "Aggregator",
5785            self.orig_loc,
5786            self.buf.as_ptr() as usize,
5787        ))
5788    }
5789    pub fn get_num_ports(&self) -> Result<u16, ErrorContext> {
5790        let mut iter = self.clone();
5791        iter.pos = 0;
5792        for attr in iter {
5793            if let BondAdInfoAttrs::NumPorts(val) = attr? {
5794                return Ok(val);
5795            }
5796        }
5797        Err(ErrorContext::new_missing(
5798            "BondAdInfoAttrs",
5799            "NumPorts",
5800            self.orig_loc,
5801            self.buf.as_ptr() as usize,
5802        ))
5803    }
5804    pub fn get_actor_key(&self) -> Result<u16, ErrorContext> {
5805        let mut iter = self.clone();
5806        iter.pos = 0;
5807        for attr in iter {
5808            if let BondAdInfoAttrs::ActorKey(val) = attr? {
5809                return Ok(val);
5810            }
5811        }
5812        Err(ErrorContext::new_missing(
5813            "BondAdInfoAttrs",
5814            "ActorKey",
5815            self.orig_loc,
5816            self.buf.as_ptr() as usize,
5817        ))
5818    }
5819    pub fn get_partner_key(&self) -> Result<u16, ErrorContext> {
5820        let mut iter = self.clone();
5821        iter.pos = 0;
5822        for attr in iter {
5823            if let BondAdInfoAttrs::PartnerKey(val) = attr? {
5824                return Ok(val);
5825            }
5826        }
5827        Err(ErrorContext::new_missing(
5828            "BondAdInfoAttrs",
5829            "PartnerKey",
5830            self.orig_loc,
5831            self.buf.as_ptr() as usize,
5832        ))
5833    }
5834    pub fn get_partner_mac(&self) -> Result<&'a [u8], ErrorContext> {
5835        let mut iter = self.clone();
5836        iter.pos = 0;
5837        for attr in iter {
5838            if let BondAdInfoAttrs::PartnerMac(val) = attr? {
5839                return Ok(val);
5840            }
5841        }
5842        Err(ErrorContext::new_missing(
5843            "BondAdInfoAttrs",
5844            "PartnerMac",
5845            self.orig_loc,
5846            self.buf.as_ptr() as usize,
5847        ))
5848    }
5849}
5850impl BondAdInfoAttrs<'_> {
5851    pub fn new<'a>(buf: &'a [u8]) -> IterableBondAdInfoAttrs<'a> {
5852        IterableBondAdInfoAttrs::with_loc(buf, buf.as_ptr() as usize)
5853    }
5854    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5855        let res = match r#type {
5856            1u16 => "Aggregator",
5857            2u16 => "NumPorts",
5858            3u16 => "ActorKey",
5859            4u16 => "PartnerKey",
5860            5u16 => "PartnerMac",
5861            _ => return None,
5862        };
5863        Some(res)
5864    }
5865}
5866#[derive(Clone, Copy, Default)]
5867pub struct IterableBondAdInfoAttrs<'a> {
5868    buf: &'a [u8],
5869    pos: usize,
5870    orig_loc: usize,
5871}
5872impl<'a> IterableBondAdInfoAttrs<'a> {
5873    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5874        Self {
5875            buf,
5876            pos: 0,
5877            orig_loc,
5878        }
5879    }
5880    pub fn get_buf(&self) -> &'a [u8] {
5881        self.buf
5882    }
5883}
5884impl<'a> Iterator for IterableBondAdInfoAttrs<'a> {
5885    type Item = Result<BondAdInfoAttrs<'a>, ErrorContext>;
5886    fn next(&mut self) -> Option<Self::Item> {
5887        let pos = self.pos;
5888        let mut r#type;
5889        loop {
5890            r#type = None;
5891            if self.buf.len() == self.pos {
5892                return None;
5893            }
5894            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
5895                break;
5896            };
5897            r#type = Some(header.r#type);
5898            let res = match header.r#type {
5899                1u16 => BondAdInfoAttrs::Aggregator({
5900                    let res = parse_u16(next);
5901                    let Some(val) = res else { break };
5902                    val
5903                }),
5904                2u16 => BondAdInfoAttrs::NumPorts({
5905                    let res = parse_u16(next);
5906                    let Some(val) = res else { break };
5907                    val
5908                }),
5909                3u16 => BondAdInfoAttrs::ActorKey({
5910                    let res = parse_u16(next);
5911                    let Some(val) = res else { break };
5912                    val
5913                }),
5914                4u16 => BondAdInfoAttrs::PartnerKey({
5915                    let res = parse_u16(next);
5916                    let Some(val) = res else { break };
5917                    val
5918                }),
5919                5u16 => BondAdInfoAttrs::PartnerMac({
5920                    let res = Some(next);
5921                    let Some(val) = res else { break };
5922                    val
5923                }),
5924                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
5925                n => continue,
5926            };
5927            return Some(Ok(res));
5928        }
5929        Some(Err(ErrorContext::new(
5930            "BondAdInfoAttrs",
5931            r#type.and_then(|t| BondAdInfoAttrs::attr_from_type(t)),
5932            self.orig_loc,
5933            self.buf.as_ptr().wrapping_add(pos) as usize,
5934        )))
5935    }
5936}
5937impl<'a> std::fmt::Debug for IterableBondAdInfoAttrs<'_> {
5938    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5939        let mut fmt = f.debug_struct("BondAdInfoAttrs");
5940        for attr in self.clone() {
5941            let attr = match attr {
5942                Ok(a) => a,
5943                Err(err) => {
5944                    fmt.finish()?;
5945                    f.write_str("Err(")?;
5946                    err.fmt(f)?;
5947                    return f.write_str(")");
5948                }
5949            };
5950            match attr {
5951                BondAdInfoAttrs::Aggregator(val) => fmt.field("Aggregator", &val),
5952                BondAdInfoAttrs::NumPorts(val) => fmt.field("NumPorts", &val),
5953                BondAdInfoAttrs::ActorKey(val) => fmt.field("ActorKey", &val),
5954                BondAdInfoAttrs::PartnerKey(val) => fmt.field("PartnerKey", &val),
5955                BondAdInfoAttrs::PartnerMac(val) => fmt.field("PartnerMac", &val),
5956            };
5957        }
5958        fmt.finish()
5959    }
5960}
5961impl IterableBondAdInfoAttrs<'_> {
5962    pub fn lookup_attr(
5963        &self,
5964        offset: usize,
5965        missing_type: Option<u16>,
5966    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5967        let mut stack = Vec::new();
5968        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5969        if cur == offset {
5970            stack.push(("BondAdInfoAttrs", offset));
5971            return (
5972                stack,
5973                missing_type.and_then(|t| BondAdInfoAttrs::attr_from_type(t)),
5974            );
5975        }
5976        if cur > offset || cur + self.buf.len() < offset {
5977            return (stack, None);
5978        }
5979        let mut attrs = self.clone();
5980        let mut last_off = cur + attrs.pos;
5981        while let Some(attr) = attrs.next() {
5982            let Ok(attr) = attr else { break };
5983            match attr {
5984                BondAdInfoAttrs::Aggregator(val) => {
5985                    if last_off == offset {
5986                        stack.push(("Aggregator", last_off));
5987                        break;
5988                    }
5989                }
5990                BondAdInfoAttrs::NumPorts(val) => {
5991                    if last_off == offset {
5992                        stack.push(("NumPorts", last_off));
5993                        break;
5994                    }
5995                }
5996                BondAdInfoAttrs::ActorKey(val) => {
5997                    if last_off == offset {
5998                        stack.push(("ActorKey", last_off));
5999                        break;
6000                    }
6001                }
6002                BondAdInfoAttrs::PartnerKey(val) => {
6003                    if last_off == offset {
6004                        stack.push(("PartnerKey", last_off));
6005                        break;
6006                    }
6007                }
6008                BondAdInfoAttrs::PartnerMac(val) => {
6009                    if last_off == offset {
6010                        stack.push(("PartnerMac", last_off));
6011                        break;
6012                    }
6013                }
6014                _ => {}
6015            };
6016            last_off = cur + attrs.pos;
6017        }
6018        if !stack.is_empty() {
6019            stack.push(("BondAdInfoAttrs", cur));
6020        }
6021        (stack, None)
6022    }
6023}
6024#[derive(Clone)]
6025pub enum BondSlaveAttrs<'a> {
6026    State(u8),
6027    MiiStatus(u8),
6028    LinkFailureCount(u32),
6029    PermHwaddr(&'a [u8]),
6030    QueueId(u16),
6031    AdAggregatorId(u16),
6032    AdActorOperPortState(u8),
6033    AdPartnerOperPortState(u16),
6034    Prio(u32),
6035}
6036impl<'a> IterableBondSlaveAttrs<'a> {
6037    pub fn get_state(&self) -> Result<u8, ErrorContext> {
6038        let mut iter = self.clone();
6039        iter.pos = 0;
6040        for attr in iter {
6041            if let BondSlaveAttrs::State(val) = attr? {
6042                return Ok(val);
6043            }
6044        }
6045        Err(ErrorContext::new_missing(
6046            "BondSlaveAttrs",
6047            "State",
6048            self.orig_loc,
6049            self.buf.as_ptr() as usize,
6050        ))
6051    }
6052    pub fn get_mii_status(&self) -> Result<u8, ErrorContext> {
6053        let mut iter = self.clone();
6054        iter.pos = 0;
6055        for attr in iter {
6056            if let BondSlaveAttrs::MiiStatus(val) = attr? {
6057                return Ok(val);
6058            }
6059        }
6060        Err(ErrorContext::new_missing(
6061            "BondSlaveAttrs",
6062            "MiiStatus",
6063            self.orig_loc,
6064            self.buf.as_ptr() as usize,
6065        ))
6066    }
6067    pub fn get_link_failure_count(&self) -> Result<u32, ErrorContext> {
6068        let mut iter = self.clone();
6069        iter.pos = 0;
6070        for attr in iter {
6071            if let BondSlaveAttrs::LinkFailureCount(val) = attr? {
6072                return Ok(val);
6073            }
6074        }
6075        Err(ErrorContext::new_missing(
6076            "BondSlaveAttrs",
6077            "LinkFailureCount",
6078            self.orig_loc,
6079            self.buf.as_ptr() as usize,
6080        ))
6081    }
6082    pub fn get_perm_hwaddr(&self) -> Result<&'a [u8], ErrorContext> {
6083        let mut iter = self.clone();
6084        iter.pos = 0;
6085        for attr in iter {
6086            if let BondSlaveAttrs::PermHwaddr(val) = attr? {
6087                return Ok(val);
6088            }
6089        }
6090        Err(ErrorContext::new_missing(
6091            "BondSlaveAttrs",
6092            "PermHwaddr",
6093            self.orig_loc,
6094            self.buf.as_ptr() as usize,
6095        ))
6096    }
6097    pub fn get_queue_id(&self) -> Result<u16, ErrorContext> {
6098        let mut iter = self.clone();
6099        iter.pos = 0;
6100        for attr in iter {
6101            if let BondSlaveAttrs::QueueId(val) = attr? {
6102                return Ok(val);
6103            }
6104        }
6105        Err(ErrorContext::new_missing(
6106            "BondSlaveAttrs",
6107            "QueueId",
6108            self.orig_loc,
6109            self.buf.as_ptr() as usize,
6110        ))
6111    }
6112    pub fn get_ad_aggregator_id(&self) -> Result<u16, ErrorContext> {
6113        let mut iter = self.clone();
6114        iter.pos = 0;
6115        for attr in iter {
6116            if let BondSlaveAttrs::AdAggregatorId(val) = attr? {
6117                return Ok(val);
6118            }
6119        }
6120        Err(ErrorContext::new_missing(
6121            "BondSlaveAttrs",
6122            "AdAggregatorId",
6123            self.orig_loc,
6124            self.buf.as_ptr() as usize,
6125        ))
6126    }
6127    pub fn get_ad_actor_oper_port_state(&self) -> Result<u8, ErrorContext> {
6128        let mut iter = self.clone();
6129        iter.pos = 0;
6130        for attr in iter {
6131            if let BondSlaveAttrs::AdActorOperPortState(val) = attr? {
6132                return Ok(val);
6133            }
6134        }
6135        Err(ErrorContext::new_missing(
6136            "BondSlaveAttrs",
6137            "AdActorOperPortState",
6138            self.orig_loc,
6139            self.buf.as_ptr() as usize,
6140        ))
6141    }
6142    pub fn get_ad_partner_oper_port_state(&self) -> Result<u16, ErrorContext> {
6143        let mut iter = self.clone();
6144        iter.pos = 0;
6145        for attr in iter {
6146            if let BondSlaveAttrs::AdPartnerOperPortState(val) = attr? {
6147                return Ok(val);
6148            }
6149        }
6150        Err(ErrorContext::new_missing(
6151            "BondSlaveAttrs",
6152            "AdPartnerOperPortState",
6153            self.orig_loc,
6154            self.buf.as_ptr() as usize,
6155        ))
6156    }
6157    pub fn get_prio(&self) -> Result<u32, ErrorContext> {
6158        let mut iter = self.clone();
6159        iter.pos = 0;
6160        for attr in iter {
6161            if let BondSlaveAttrs::Prio(val) = attr? {
6162                return Ok(val);
6163            }
6164        }
6165        Err(ErrorContext::new_missing(
6166            "BondSlaveAttrs",
6167            "Prio",
6168            self.orig_loc,
6169            self.buf.as_ptr() as usize,
6170        ))
6171    }
6172}
6173impl BondSlaveAttrs<'_> {
6174    pub fn new<'a>(buf: &'a [u8]) -> IterableBondSlaveAttrs<'a> {
6175        IterableBondSlaveAttrs::with_loc(buf, buf.as_ptr() as usize)
6176    }
6177    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6178        let res = match r#type {
6179            1u16 => "State",
6180            2u16 => "MiiStatus",
6181            3u16 => "LinkFailureCount",
6182            4u16 => "PermHwaddr",
6183            5u16 => "QueueId",
6184            6u16 => "AdAggregatorId",
6185            7u16 => "AdActorOperPortState",
6186            8u16 => "AdPartnerOperPortState",
6187            9u16 => "Prio",
6188            _ => return None,
6189        };
6190        Some(res)
6191    }
6192}
6193#[derive(Clone, Copy, Default)]
6194pub struct IterableBondSlaveAttrs<'a> {
6195    buf: &'a [u8],
6196    pos: usize,
6197    orig_loc: usize,
6198}
6199impl<'a> IterableBondSlaveAttrs<'a> {
6200    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
6201        Self {
6202            buf,
6203            pos: 0,
6204            orig_loc,
6205        }
6206    }
6207    pub fn get_buf(&self) -> &'a [u8] {
6208        self.buf
6209    }
6210}
6211impl<'a> Iterator for IterableBondSlaveAttrs<'a> {
6212    type Item = Result<BondSlaveAttrs<'a>, ErrorContext>;
6213    fn next(&mut self) -> Option<Self::Item> {
6214        let pos = self.pos;
6215        let mut r#type;
6216        loop {
6217            r#type = None;
6218            if self.buf.len() == self.pos {
6219                return None;
6220            }
6221            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
6222                break;
6223            };
6224            r#type = Some(header.r#type);
6225            let res = match header.r#type {
6226                1u16 => BondSlaveAttrs::State({
6227                    let res = parse_u8(next);
6228                    let Some(val) = res else { break };
6229                    val
6230                }),
6231                2u16 => BondSlaveAttrs::MiiStatus({
6232                    let res = parse_u8(next);
6233                    let Some(val) = res else { break };
6234                    val
6235                }),
6236                3u16 => BondSlaveAttrs::LinkFailureCount({
6237                    let res = parse_u32(next);
6238                    let Some(val) = res else { break };
6239                    val
6240                }),
6241                4u16 => BondSlaveAttrs::PermHwaddr({
6242                    let res = Some(next);
6243                    let Some(val) = res else { break };
6244                    val
6245                }),
6246                5u16 => BondSlaveAttrs::QueueId({
6247                    let res = parse_u16(next);
6248                    let Some(val) = res else { break };
6249                    val
6250                }),
6251                6u16 => BondSlaveAttrs::AdAggregatorId({
6252                    let res = parse_u16(next);
6253                    let Some(val) = res else { break };
6254                    val
6255                }),
6256                7u16 => BondSlaveAttrs::AdActorOperPortState({
6257                    let res = parse_u8(next);
6258                    let Some(val) = res else { break };
6259                    val
6260                }),
6261                8u16 => BondSlaveAttrs::AdPartnerOperPortState({
6262                    let res = parse_u16(next);
6263                    let Some(val) = res else { break };
6264                    val
6265                }),
6266                9u16 => BondSlaveAttrs::Prio({
6267                    let res = parse_u32(next);
6268                    let Some(val) = res else { break };
6269                    val
6270                }),
6271                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
6272                n => continue,
6273            };
6274            return Some(Ok(res));
6275        }
6276        Some(Err(ErrorContext::new(
6277            "BondSlaveAttrs",
6278            r#type.and_then(|t| BondSlaveAttrs::attr_from_type(t)),
6279            self.orig_loc,
6280            self.buf.as_ptr().wrapping_add(pos) as usize,
6281        )))
6282    }
6283}
6284impl<'a> std::fmt::Debug for IterableBondSlaveAttrs<'_> {
6285    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6286        let mut fmt = f.debug_struct("BondSlaveAttrs");
6287        for attr in self.clone() {
6288            let attr = match attr {
6289                Ok(a) => a,
6290                Err(err) => {
6291                    fmt.finish()?;
6292                    f.write_str("Err(")?;
6293                    err.fmt(f)?;
6294                    return f.write_str(")");
6295                }
6296            };
6297            match attr {
6298                BondSlaveAttrs::State(val) => fmt.field("State", &val),
6299                BondSlaveAttrs::MiiStatus(val) => fmt.field("MiiStatus", &val),
6300                BondSlaveAttrs::LinkFailureCount(val) => fmt.field("LinkFailureCount", &val),
6301                BondSlaveAttrs::PermHwaddr(val) => fmt.field("PermHwaddr", &val),
6302                BondSlaveAttrs::QueueId(val) => fmt.field("QueueId", &val),
6303                BondSlaveAttrs::AdAggregatorId(val) => fmt.field("AdAggregatorId", &val),
6304                BondSlaveAttrs::AdActorOperPortState(val) => {
6305                    fmt.field("AdActorOperPortState", &val)
6306                }
6307                BondSlaveAttrs::AdPartnerOperPortState(val) => {
6308                    fmt.field("AdPartnerOperPortState", &val)
6309                }
6310                BondSlaveAttrs::Prio(val) => fmt.field("Prio", &val),
6311            };
6312        }
6313        fmt.finish()
6314    }
6315}
6316impl IterableBondSlaveAttrs<'_> {
6317    pub fn lookup_attr(
6318        &self,
6319        offset: usize,
6320        missing_type: Option<u16>,
6321    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6322        let mut stack = Vec::new();
6323        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6324        if cur == offset {
6325            stack.push(("BondSlaveAttrs", offset));
6326            return (
6327                stack,
6328                missing_type.and_then(|t| BondSlaveAttrs::attr_from_type(t)),
6329            );
6330        }
6331        if cur > offset || cur + self.buf.len() < offset {
6332            return (stack, None);
6333        }
6334        let mut attrs = self.clone();
6335        let mut last_off = cur + attrs.pos;
6336        while let Some(attr) = attrs.next() {
6337            let Ok(attr) = attr else { break };
6338            match attr {
6339                BondSlaveAttrs::State(val) => {
6340                    if last_off == offset {
6341                        stack.push(("State", last_off));
6342                        break;
6343                    }
6344                }
6345                BondSlaveAttrs::MiiStatus(val) => {
6346                    if last_off == offset {
6347                        stack.push(("MiiStatus", last_off));
6348                        break;
6349                    }
6350                }
6351                BondSlaveAttrs::LinkFailureCount(val) => {
6352                    if last_off == offset {
6353                        stack.push(("LinkFailureCount", last_off));
6354                        break;
6355                    }
6356                }
6357                BondSlaveAttrs::PermHwaddr(val) => {
6358                    if last_off == offset {
6359                        stack.push(("PermHwaddr", last_off));
6360                        break;
6361                    }
6362                }
6363                BondSlaveAttrs::QueueId(val) => {
6364                    if last_off == offset {
6365                        stack.push(("QueueId", last_off));
6366                        break;
6367                    }
6368                }
6369                BondSlaveAttrs::AdAggregatorId(val) => {
6370                    if last_off == offset {
6371                        stack.push(("AdAggregatorId", last_off));
6372                        break;
6373                    }
6374                }
6375                BondSlaveAttrs::AdActorOperPortState(val) => {
6376                    if last_off == offset {
6377                        stack.push(("AdActorOperPortState", last_off));
6378                        break;
6379                    }
6380                }
6381                BondSlaveAttrs::AdPartnerOperPortState(val) => {
6382                    if last_off == offset {
6383                        stack.push(("AdPartnerOperPortState", last_off));
6384                        break;
6385                    }
6386                }
6387                BondSlaveAttrs::Prio(val) => {
6388                    if last_off == offset {
6389                        stack.push(("Prio", last_off));
6390                        break;
6391                    }
6392                }
6393                _ => {}
6394            };
6395            last_off = cur + attrs.pos;
6396        }
6397        if !stack.is_empty() {
6398            stack.push(("BondSlaveAttrs", cur));
6399        }
6400        (stack, None)
6401    }
6402}
6403#[derive(Clone)]
6404pub enum LinkinfoBridgeAttrs<'a> {
6405    ForwardDelay(u32),
6406    HelloTime(u32),
6407    MaxAge(u32),
6408    AgeingTime(u32),
6409    StpState(u32),
6410    Priority(u16),
6411    VlanFiltering(u8),
6412    VlanProtocol(u16),
6413    GroupFwdMask(u16),
6414    RootId(PushIflaBridgeId),
6415    BridgeId(PushIflaBridgeId),
6416    RootPort(u16),
6417    RootPathCost(u32),
6418    TopologyChange(u8),
6419    TopologyChangeDetected(u8),
6420    HelloTimer(u64),
6421    TcnTimer(u64),
6422    TopologyChangeTimer(u64),
6423    GcTimer(u64),
6424    GroupAddr(&'a [u8]),
6425    FdbFlush(&'a [u8]),
6426    McastRouter(u8),
6427    McastSnooping(u8),
6428    McastQueryUseIfaddr(u8),
6429    McastQuerier(u8),
6430    McastHashElasticity(u32),
6431    McastHashMax(u32),
6432    McastLastMemberCnt(u32),
6433    McastStartupQueryCnt(u32),
6434    McastLastMemberIntvl(u64),
6435    McastMembershipIntvl(u64),
6436    McastQuerierIntvl(u64),
6437    McastQueryIntvl(u64),
6438    McastQueryResponseIntvl(u64),
6439    McastStartupQueryIntvl(u64),
6440    NfCallIptables(u8),
6441    NfCallIp6tables(u8),
6442    NfCallArptables(u8),
6443    VlanDefaultPvid(u16),
6444    Pad(&'a [u8]),
6445    VlanStatsEnabled(u8),
6446    McastStatsEnabled(u8),
6447    McastIgmpVersion(u8),
6448    McastMldVersion(u8),
6449    VlanStatsPerPort(u8),
6450    MultiBoolopt(PushBrBooloptMulti),
6451    McastQuerierState(&'a [u8]),
6452    FdbNLearned(u32),
6453    FdbMaxLearned(u32),
6454}
6455impl<'a> IterableLinkinfoBridgeAttrs<'a> {
6456    pub fn get_forward_delay(&self) -> Result<u32, ErrorContext> {
6457        let mut iter = self.clone();
6458        iter.pos = 0;
6459        for attr in iter {
6460            if let LinkinfoBridgeAttrs::ForwardDelay(val) = attr? {
6461                return Ok(val);
6462            }
6463        }
6464        Err(ErrorContext::new_missing(
6465            "LinkinfoBridgeAttrs",
6466            "ForwardDelay",
6467            self.orig_loc,
6468            self.buf.as_ptr() as usize,
6469        ))
6470    }
6471    pub fn get_hello_time(&self) -> Result<u32, ErrorContext> {
6472        let mut iter = self.clone();
6473        iter.pos = 0;
6474        for attr in iter {
6475            if let LinkinfoBridgeAttrs::HelloTime(val) = attr? {
6476                return Ok(val);
6477            }
6478        }
6479        Err(ErrorContext::new_missing(
6480            "LinkinfoBridgeAttrs",
6481            "HelloTime",
6482            self.orig_loc,
6483            self.buf.as_ptr() as usize,
6484        ))
6485    }
6486    pub fn get_max_age(&self) -> Result<u32, ErrorContext> {
6487        let mut iter = self.clone();
6488        iter.pos = 0;
6489        for attr in iter {
6490            if let LinkinfoBridgeAttrs::MaxAge(val) = attr? {
6491                return Ok(val);
6492            }
6493        }
6494        Err(ErrorContext::new_missing(
6495            "LinkinfoBridgeAttrs",
6496            "MaxAge",
6497            self.orig_loc,
6498            self.buf.as_ptr() as usize,
6499        ))
6500    }
6501    pub fn get_ageing_time(&self) -> Result<u32, ErrorContext> {
6502        let mut iter = self.clone();
6503        iter.pos = 0;
6504        for attr in iter {
6505            if let LinkinfoBridgeAttrs::AgeingTime(val) = attr? {
6506                return Ok(val);
6507            }
6508        }
6509        Err(ErrorContext::new_missing(
6510            "LinkinfoBridgeAttrs",
6511            "AgeingTime",
6512            self.orig_loc,
6513            self.buf.as_ptr() as usize,
6514        ))
6515    }
6516    pub fn get_stp_state(&self) -> Result<u32, ErrorContext> {
6517        let mut iter = self.clone();
6518        iter.pos = 0;
6519        for attr in iter {
6520            if let LinkinfoBridgeAttrs::StpState(val) = attr? {
6521                return Ok(val);
6522            }
6523        }
6524        Err(ErrorContext::new_missing(
6525            "LinkinfoBridgeAttrs",
6526            "StpState",
6527            self.orig_loc,
6528            self.buf.as_ptr() as usize,
6529        ))
6530    }
6531    pub fn get_priority(&self) -> Result<u16, ErrorContext> {
6532        let mut iter = self.clone();
6533        iter.pos = 0;
6534        for attr in iter {
6535            if let LinkinfoBridgeAttrs::Priority(val) = attr? {
6536                return Ok(val);
6537            }
6538        }
6539        Err(ErrorContext::new_missing(
6540            "LinkinfoBridgeAttrs",
6541            "Priority",
6542            self.orig_loc,
6543            self.buf.as_ptr() as usize,
6544        ))
6545    }
6546    pub fn get_vlan_filtering(&self) -> Result<u8, ErrorContext> {
6547        let mut iter = self.clone();
6548        iter.pos = 0;
6549        for attr in iter {
6550            if let LinkinfoBridgeAttrs::VlanFiltering(val) = attr? {
6551                return Ok(val);
6552            }
6553        }
6554        Err(ErrorContext::new_missing(
6555            "LinkinfoBridgeAttrs",
6556            "VlanFiltering",
6557            self.orig_loc,
6558            self.buf.as_ptr() as usize,
6559        ))
6560    }
6561    pub fn get_vlan_protocol(&self) -> Result<u16, ErrorContext> {
6562        let mut iter = self.clone();
6563        iter.pos = 0;
6564        for attr in iter {
6565            if let LinkinfoBridgeAttrs::VlanProtocol(val) = attr? {
6566                return Ok(val);
6567            }
6568        }
6569        Err(ErrorContext::new_missing(
6570            "LinkinfoBridgeAttrs",
6571            "VlanProtocol",
6572            self.orig_loc,
6573            self.buf.as_ptr() as usize,
6574        ))
6575    }
6576    pub fn get_group_fwd_mask(&self) -> Result<u16, ErrorContext> {
6577        let mut iter = self.clone();
6578        iter.pos = 0;
6579        for attr in iter {
6580            if let LinkinfoBridgeAttrs::GroupFwdMask(val) = attr? {
6581                return Ok(val);
6582            }
6583        }
6584        Err(ErrorContext::new_missing(
6585            "LinkinfoBridgeAttrs",
6586            "GroupFwdMask",
6587            self.orig_loc,
6588            self.buf.as_ptr() as usize,
6589        ))
6590    }
6591    pub fn get_root_id(&self) -> Result<PushIflaBridgeId, ErrorContext> {
6592        let mut iter = self.clone();
6593        iter.pos = 0;
6594        for attr in iter {
6595            if let LinkinfoBridgeAttrs::RootId(val) = attr? {
6596                return Ok(val);
6597            }
6598        }
6599        Err(ErrorContext::new_missing(
6600            "LinkinfoBridgeAttrs",
6601            "RootId",
6602            self.orig_loc,
6603            self.buf.as_ptr() as usize,
6604        ))
6605    }
6606    pub fn get_bridge_id(&self) -> Result<PushIflaBridgeId, ErrorContext> {
6607        let mut iter = self.clone();
6608        iter.pos = 0;
6609        for attr in iter {
6610            if let LinkinfoBridgeAttrs::BridgeId(val) = attr? {
6611                return Ok(val);
6612            }
6613        }
6614        Err(ErrorContext::new_missing(
6615            "LinkinfoBridgeAttrs",
6616            "BridgeId",
6617            self.orig_loc,
6618            self.buf.as_ptr() as usize,
6619        ))
6620    }
6621    pub fn get_root_port(&self) -> Result<u16, ErrorContext> {
6622        let mut iter = self.clone();
6623        iter.pos = 0;
6624        for attr in iter {
6625            if let LinkinfoBridgeAttrs::RootPort(val) = attr? {
6626                return Ok(val);
6627            }
6628        }
6629        Err(ErrorContext::new_missing(
6630            "LinkinfoBridgeAttrs",
6631            "RootPort",
6632            self.orig_loc,
6633            self.buf.as_ptr() as usize,
6634        ))
6635    }
6636    pub fn get_root_path_cost(&self) -> Result<u32, ErrorContext> {
6637        let mut iter = self.clone();
6638        iter.pos = 0;
6639        for attr in iter {
6640            if let LinkinfoBridgeAttrs::RootPathCost(val) = attr? {
6641                return Ok(val);
6642            }
6643        }
6644        Err(ErrorContext::new_missing(
6645            "LinkinfoBridgeAttrs",
6646            "RootPathCost",
6647            self.orig_loc,
6648            self.buf.as_ptr() as usize,
6649        ))
6650    }
6651    pub fn get_topology_change(&self) -> Result<u8, ErrorContext> {
6652        let mut iter = self.clone();
6653        iter.pos = 0;
6654        for attr in iter {
6655            if let LinkinfoBridgeAttrs::TopologyChange(val) = attr? {
6656                return Ok(val);
6657            }
6658        }
6659        Err(ErrorContext::new_missing(
6660            "LinkinfoBridgeAttrs",
6661            "TopologyChange",
6662            self.orig_loc,
6663            self.buf.as_ptr() as usize,
6664        ))
6665    }
6666    pub fn get_topology_change_detected(&self) -> Result<u8, ErrorContext> {
6667        let mut iter = self.clone();
6668        iter.pos = 0;
6669        for attr in iter {
6670            if let LinkinfoBridgeAttrs::TopologyChangeDetected(val) = attr? {
6671                return Ok(val);
6672            }
6673        }
6674        Err(ErrorContext::new_missing(
6675            "LinkinfoBridgeAttrs",
6676            "TopologyChangeDetected",
6677            self.orig_loc,
6678            self.buf.as_ptr() as usize,
6679        ))
6680    }
6681    pub fn get_hello_timer(&self) -> Result<u64, ErrorContext> {
6682        let mut iter = self.clone();
6683        iter.pos = 0;
6684        for attr in iter {
6685            if let LinkinfoBridgeAttrs::HelloTimer(val) = attr? {
6686                return Ok(val);
6687            }
6688        }
6689        Err(ErrorContext::new_missing(
6690            "LinkinfoBridgeAttrs",
6691            "HelloTimer",
6692            self.orig_loc,
6693            self.buf.as_ptr() as usize,
6694        ))
6695    }
6696    pub fn get_tcn_timer(&self) -> Result<u64, ErrorContext> {
6697        let mut iter = self.clone();
6698        iter.pos = 0;
6699        for attr in iter {
6700            if let LinkinfoBridgeAttrs::TcnTimer(val) = attr? {
6701                return Ok(val);
6702            }
6703        }
6704        Err(ErrorContext::new_missing(
6705            "LinkinfoBridgeAttrs",
6706            "TcnTimer",
6707            self.orig_loc,
6708            self.buf.as_ptr() as usize,
6709        ))
6710    }
6711    pub fn get_topology_change_timer(&self) -> Result<u64, ErrorContext> {
6712        let mut iter = self.clone();
6713        iter.pos = 0;
6714        for attr in iter {
6715            if let LinkinfoBridgeAttrs::TopologyChangeTimer(val) = attr? {
6716                return Ok(val);
6717            }
6718        }
6719        Err(ErrorContext::new_missing(
6720            "LinkinfoBridgeAttrs",
6721            "TopologyChangeTimer",
6722            self.orig_loc,
6723            self.buf.as_ptr() as usize,
6724        ))
6725    }
6726    pub fn get_gc_timer(&self) -> Result<u64, ErrorContext> {
6727        let mut iter = self.clone();
6728        iter.pos = 0;
6729        for attr in iter {
6730            if let LinkinfoBridgeAttrs::GcTimer(val) = attr? {
6731                return Ok(val);
6732            }
6733        }
6734        Err(ErrorContext::new_missing(
6735            "LinkinfoBridgeAttrs",
6736            "GcTimer",
6737            self.orig_loc,
6738            self.buf.as_ptr() as usize,
6739        ))
6740    }
6741    pub fn get_group_addr(&self) -> Result<&'a [u8], ErrorContext> {
6742        let mut iter = self.clone();
6743        iter.pos = 0;
6744        for attr in iter {
6745            if let LinkinfoBridgeAttrs::GroupAddr(val) = attr? {
6746                return Ok(val);
6747            }
6748        }
6749        Err(ErrorContext::new_missing(
6750            "LinkinfoBridgeAttrs",
6751            "GroupAddr",
6752            self.orig_loc,
6753            self.buf.as_ptr() as usize,
6754        ))
6755    }
6756    pub fn get_fdb_flush(&self) -> Result<&'a [u8], ErrorContext> {
6757        let mut iter = self.clone();
6758        iter.pos = 0;
6759        for attr in iter {
6760            if let LinkinfoBridgeAttrs::FdbFlush(val) = attr? {
6761                return Ok(val);
6762            }
6763        }
6764        Err(ErrorContext::new_missing(
6765            "LinkinfoBridgeAttrs",
6766            "FdbFlush",
6767            self.orig_loc,
6768            self.buf.as_ptr() as usize,
6769        ))
6770    }
6771    pub fn get_mcast_router(&self) -> Result<u8, ErrorContext> {
6772        let mut iter = self.clone();
6773        iter.pos = 0;
6774        for attr in iter {
6775            if let LinkinfoBridgeAttrs::McastRouter(val) = attr? {
6776                return Ok(val);
6777            }
6778        }
6779        Err(ErrorContext::new_missing(
6780            "LinkinfoBridgeAttrs",
6781            "McastRouter",
6782            self.orig_loc,
6783            self.buf.as_ptr() as usize,
6784        ))
6785    }
6786    pub fn get_mcast_snooping(&self) -> Result<u8, ErrorContext> {
6787        let mut iter = self.clone();
6788        iter.pos = 0;
6789        for attr in iter {
6790            if let LinkinfoBridgeAttrs::McastSnooping(val) = attr? {
6791                return Ok(val);
6792            }
6793        }
6794        Err(ErrorContext::new_missing(
6795            "LinkinfoBridgeAttrs",
6796            "McastSnooping",
6797            self.orig_loc,
6798            self.buf.as_ptr() as usize,
6799        ))
6800    }
6801    pub fn get_mcast_query_use_ifaddr(&self) -> Result<u8, ErrorContext> {
6802        let mut iter = self.clone();
6803        iter.pos = 0;
6804        for attr in iter {
6805            if let LinkinfoBridgeAttrs::McastQueryUseIfaddr(val) = attr? {
6806                return Ok(val);
6807            }
6808        }
6809        Err(ErrorContext::new_missing(
6810            "LinkinfoBridgeAttrs",
6811            "McastQueryUseIfaddr",
6812            self.orig_loc,
6813            self.buf.as_ptr() as usize,
6814        ))
6815    }
6816    pub fn get_mcast_querier(&self) -> Result<u8, ErrorContext> {
6817        let mut iter = self.clone();
6818        iter.pos = 0;
6819        for attr in iter {
6820            if let LinkinfoBridgeAttrs::McastQuerier(val) = attr? {
6821                return Ok(val);
6822            }
6823        }
6824        Err(ErrorContext::new_missing(
6825            "LinkinfoBridgeAttrs",
6826            "McastQuerier",
6827            self.orig_loc,
6828            self.buf.as_ptr() as usize,
6829        ))
6830    }
6831    pub fn get_mcast_hash_elasticity(&self) -> Result<u32, ErrorContext> {
6832        let mut iter = self.clone();
6833        iter.pos = 0;
6834        for attr in iter {
6835            if let LinkinfoBridgeAttrs::McastHashElasticity(val) = attr? {
6836                return Ok(val);
6837            }
6838        }
6839        Err(ErrorContext::new_missing(
6840            "LinkinfoBridgeAttrs",
6841            "McastHashElasticity",
6842            self.orig_loc,
6843            self.buf.as_ptr() as usize,
6844        ))
6845    }
6846    pub fn get_mcast_hash_max(&self) -> Result<u32, ErrorContext> {
6847        let mut iter = self.clone();
6848        iter.pos = 0;
6849        for attr in iter {
6850            if let LinkinfoBridgeAttrs::McastHashMax(val) = attr? {
6851                return Ok(val);
6852            }
6853        }
6854        Err(ErrorContext::new_missing(
6855            "LinkinfoBridgeAttrs",
6856            "McastHashMax",
6857            self.orig_loc,
6858            self.buf.as_ptr() as usize,
6859        ))
6860    }
6861    pub fn get_mcast_last_member_cnt(&self) -> Result<u32, ErrorContext> {
6862        let mut iter = self.clone();
6863        iter.pos = 0;
6864        for attr in iter {
6865            if let LinkinfoBridgeAttrs::McastLastMemberCnt(val) = attr? {
6866                return Ok(val);
6867            }
6868        }
6869        Err(ErrorContext::new_missing(
6870            "LinkinfoBridgeAttrs",
6871            "McastLastMemberCnt",
6872            self.orig_loc,
6873            self.buf.as_ptr() as usize,
6874        ))
6875    }
6876    pub fn get_mcast_startup_query_cnt(&self) -> Result<u32, ErrorContext> {
6877        let mut iter = self.clone();
6878        iter.pos = 0;
6879        for attr in iter {
6880            if let LinkinfoBridgeAttrs::McastStartupQueryCnt(val) = attr? {
6881                return Ok(val);
6882            }
6883        }
6884        Err(ErrorContext::new_missing(
6885            "LinkinfoBridgeAttrs",
6886            "McastStartupQueryCnt",
6887            self.orig_loc,
6888            self.buf.as_ptr() as usize,
6889        ))
6890    }
6891    pub fn get_mcast_last_member_intvl(&self) -> Result<u64, ErrorContext> {
6892        let mut iter = self.clone();
6893        iter.pos = 0;
6894        for attr in iter {
6895            if let LinkinfoBridgeAttrs::McastLastMemberIntvl(val) = attr? {
6896                return Ok(val);
6897            }
6898        }
6899        Err(ErrorContext::new_missing(
6900            "LinkinfoBridgeAttrs",
6901            "McastLastMemberIntvl",
6902            self.orig_loc,
6903            self.buf.as_ptr() as usize,
6904        ))
6905    }
6906    pub fn get_mcast_membership_intvl(&self) -> Result<u64, ErrorContext> {
6907        let mut iter = self.clone();
6908        iter.pos = 0;
6909        for attr in iter {
6910            if let LinkinfoBridgeAttrs::McastMembershipIntvl(val) = attr? {
6911                return Ok(val);
6912            }
6913        }
6914        Err(ErrorContext::new_missing(
6915            "LinkinfoBridgeAttrs",
6916            "McastMembershipIntvl",
6917            self.orig_loc,
6918            self.buf.as_ptr() as usize,
6919        ))
6920    }
6921    pub fn get_mcast_querier_intvl(&self) -> Result<u64, ErrorContext> {
6922        let mut iter = self.clone();
6923        iter.pos = 0;
6924        for attr in iter {
6925            if let LinkinfoBridgeAttrs::McastQuerierIntvl(val) = attr? {
6926                return Ok(val);
6927            }
6928        }
6929        Err(ErrorContext::new_missing(
6930            "LinkinfoBridgeAttrs",
6931            "McastQuerierIntvl",
6932            self.orig_loc,
6933            self.buf.as_ptr() as usize,
6934        ))
6935    }
6936    pub fn get_mcast_query_intvl(&self) -> Result<u64, ErrorContext> {
6937        let mut iter = self.clone();
6938        iter.pos = 0;
6939        for attr in iter {
6940            if let LinkinfoBridgeAttrs::McastQueryIntvl(val) = attr? {
6941                return Ok(val);
6942            }
6943        }
6944        Err(ErrorContext::new_missing(
6945            "LinkinfoBridgeAttrs",
6946            "McastQueryIntvl",
6947            self.orig_loc,
6948            self.buf.as_ptr() as usize,
6949        ))
6950    }
6951    pub fn get_mcast_query_response_intvl(&self) -> Result<u64, ErrorContext> {
6952        let mut iter = self.clone();
6953        iter.pos = 0;
6954        for attr in iter {
6955            if let LinkinfoBridgeAttrs::McastQueryResponseIntvl(val) = attr? {
6956                return Ok(val);
6957            }
6958        }
6959        Err(ErrorContext::new_missing(
6960            "LinkinfoBridgeAttrs",
6961            "McastQueryResponseIntvl",
6962            self.orig_loc,
6963            self.buf.as_ptr() as usize,
6964        ))
6965    }
6966    pub fn get_mcast_startup_query_intvl(&self) -> Result<u64, ErrorContext> {
6967        let mut iter = self.clone();
6968        iter.pos = 0;
6969        for attr in iter {
6970            if let LinkinfoBridgeAttrs::McastStartupQueryIntvl(val) = attr? {
6971                return Ok(val);
6972            }
6973        }
6974        Err(ErrorContext::new_missing(
6975            "LinkinfoBridgeAttrs",
6976            "McastStartupQueryIntvl",
6977            self.orig_loc,
6978            self.buf.as_ptr() as usize,
6979        ))
6980    }
6981    pub fn get_nf_call_iptables(&self) -> Result<u8, ErrorContext> {
6982        let mut iter = self.clone();
6983        iter.pos = 0;
6984        for attr in iter {
6985            if let LinkinfoBridgeAttrs::NfCallIptables(val) = attr? {
6986                return Ok(val);
6987            }
6988        }
6989        Err(ErrorContext::new_missing(
6990            "LinkinfoBridgeAttrs",
6991            "NfCallIptables",
6992            self.orig_loc,
6993            self.buf.as_ptr() as usize,
6994        ))
6995    }
6996    pub fn get_nf_call_ip6tables(&self) -> Result<u8, ErrorContext> {
6997        let mut iter = self.clone();
6998        iter.pos = 0;
6999        for attr in iter {
7000            if let LinkinfoBridgeAttrs::NfCallIp6tables(val) = attr? {
7001                return Ok(val);
7002            }
7003        }
7004        Err(ErrorContext::new_missing(
7005            "LinkinfoBridgeAttrs",
7006            "NfCallIp6tables",
7007            self.orig_loc,
7008            self.buf.as_ptr() as usize,
7009        ))
7010    }
7011    pub fn get_nf_call_arptables(&self) -> Result<u8, ErrorContext> {
7012        let mut iter = self.clone();
7013        iter.pos = 0;
7014        for attr in iter {
7015            if let LinkinfoBridgeAttrs::NfCallArptables(val) = attr? {
7016                return Ok(val);
7017            }
7018        }
7019        Err(ErrorContext::new_missing(
7020            "LinkinfoBridgeAttrs",
7021            "NfCallArptables",
7022            self.orig_loc,
7023            self.buf.as_ptr() as usize,
7024        ))
7025    }
7026    pub fn get_vlan_default_pvid(&self) -> Result<u16, ErrorContext> {
7027        let mut iter = self.clone();
7028        iter.pos = 0;
7029        for attr in iter {
7030            if let LinkinfoBridgeAttrs::VlanDefaultPvid(val) = attr? {
7031                return Ok(val);
7032            }
7033        }
7034        Err(ErrorContext::new_missing(
7035            "LinkinfoBridgeAttrs",
7036            "VlanDefaultPvid",
7037            self.orig_loc,
7038            self.buf.as_ptr() as usize,
7039        ))
7040    }
7041    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
7042        let mut iter = self.clone();
7043        iter.pos = 0;
7044        for attr in iter {
7045            if let LinkinfoBridgeAttrs::Pad(val) = attr? {
7046                return Ok(val);
7047            }
7048        }
7049        Err(ErrorContext::new_missing(
7050            "LinkinfoBridgeAttrs",
7051            "Pad",
7052            self.orig_loc,
7053            self.buf.as_ptr() as usize,
7054        ))
7055    }
7056    pub fn get_vlan_stats_enabled(&self) -> Result<u8, ErrorContext> {
7057        let mut iter = self.clone();
7058        iter.pos = 0;
7059        for attr in iter {
7060            if let LinkinfoBridgeAttrs::VlanStatsEnabled(val) = attr? {
7061                return Ok(val);
7062            }
7063        }
7064        Err(ErrorContext::new_missing(
7065            "LinkinfoBridgeAttrs",
7066            "VlanStatsEnabled",
7067            self.orig_loc,
7068            self.buf.as_ptr() as usize,
7069        ))
7070    }
7071    pub fn get_mcast_stats_enabled(&self) -> Result<u8, ErrorContext> {
7072        let mut iter = self.clone();
7073        iter.pos = 0;
7074        for attr in iter {
7075            if let LinkinfoBridgeAttrs::McastStatsEnabled(val) = attr? {
7076                return Ok(val);
7077            }
7078        }
7079        Err(ErrorContext::new_missing(
7080            "LinkinfoBridgeAttrs",
7081            "McastStatsEnabled",
7082            self.orig_loc,
7083            self.buf.as_ptr() as usize,
7084        ))
7085    }
7086    pub fn get_mcast_igmp_version(&self) -> Result<u8, ErrorContext> {
7087        let mut iter = self.clone();
7088        iter.pos = 0;
7089        for attr in iter {
7090            if let LinkinfoBridgeAttrs::McastIgmpVersion(val) = attr? {
7091                return Ok(val);
7092            }
7093        }
7094        Err(ErrorContext::new_missing(
7095            "LinkinfoBridgeAttrs",
7096            "McastIgmpVersion",
7097            self.orig_loc,
7098            self.buf.as_ptr() as usize,
7099        ))
7100    }
7101    pub fn get_mcast_mld_version(&self) -> Result<u8, ErrorContext> {
7102        let mut iter = self.clone();
7103        iter.pos = 0;
7104        for attr in iter {
7105            if let LinkinfoBridgeAttrs::McastMldVersion(val) = attr? {
7106                return Ok(val);
7107            }
7108        }
7109        Err(ErrorContext::new_missing(
7110            "LinkinfoBridgeAttrs",
7111            "McastMldVersion",
7112            self.orig_loc,
7113            self.buf.as_ptr() as usize,
7114        ))
7115    }
7116    pub fn get_vlan_stats_per_port(&self) -> Result<u8, ErrorContext> {
7117        let mut iter = self.clone();
7118        iter.pos = 0;
7119        for attr in iter {
7120            if let LinkinfoBridgeAttrs::VlanStatsPerPort(val) = attr? {
7121                return Ok(val);
7122            }
7123        }
7124        Err(ErrorContext::new_missing(
7125            "LinkinfoBridgeAttrs",
7126            "VlanStatsPerPort",
7127            self.orig_loc,
7128            self.buf.as_ptr() as usize,
7129        ))
7130    }
7131    pub fn get_multi_boolopt(&self) -> Result<PushBrBooloptMulti, ErrorContext> {
7132        let mut iter = self.clone();
7133        iter.pos = 0;
7134        for attr in iter {
7135            if let LinkinfoBridgeAttrs::MultiBoolopt(val) = attr? {
7136                return Ok(val);
7137            }
7138        }
7139        Err(ErrorContext::new_missing(
7140            "LinkinfoBridgeAttrs",
7141            "MultiBoolopt",
7142            self.orig_loc,
7143            self.buf.as_ptr() as usize,
7144        ))
7145    }
7146    pub fn get_mcast_querier_state(&self) -> Result<&'a [u8], ErrorContext> {
7147        let mut iter = self.clone();
7148        iter.pos = 0;
7149        for attr in iter {
7150            if let LinkinfoBridgeAttrs::McastQuerierState(val) = attr? {
7151                return Ok(val);
7152            }
7153        }
7154        Err(ErrorContext::new_missing(
7155            "LinkinfoBridgeAttrs",
7156            "McastQuerierState",
7157            self.orig_loc,
7158            self.buf.as_ptr() as usize,
7159        ))
7160    }
7161    pub fn get_fdb_n_learned(&self) -> Result<u32, ErrorContext> {
7162        let mut iter = self.clone();
7163        iter.pos = 0;
7164        for attr in iter {
7165            if let LinkinfoBridgeAttrs::FdbNLearned(val) = attr? {
7166                return Ok(val);
7167            }
7168        }
7169        Err(ErrorContext::new_missing(
7170            "LinkinfoBridgeAttrs",
7171            "FdbNLearned",
7172            self.orig_loc,
7173            self.buf.as_ptr() as usize,
7174        ))
7175    }
7176    pub fn get_fdb_max_learned(&self) -> Result<u32, ErrorContext> {
7177        let mut iter = self.clone();
7178        iter.pos = 0;
7179        for attr in iter {
7180            if let LinkinfoBridgeAttrs::FdbMaxLearned(val) = attr? {
7181                return Ok(val);
7182            }
7183        }
7184        Err(ErrorContext::new_missing(
7185            "LinkinfoBridgeAttrs",
7186            "FdbMaxLearned",
7187            self.orig_loc,
7188            self.buf.as_ptr() as usize,
7189        ))
7190    }
7191}
7192impl LinkinfoBridgeAttrs<'_> {
7193    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoBridgeAttrs<'a> {
7194        IterableLinkinfoBridgeAttrs::with_loc(buf, buf.as_ptr() as usize)
7195    }
7196    fn attr_from_type(r#type: u16) -> Option<&'static str> {
7197        let res = match r#type {
7198            1u16 => "ForwardDelay",
7199            2u16 => "HelloTime",
7200            3u16 => "MaxAge",
7201            4u16 => "AgeingTime",
7202            5u16 => "StpState",
7203            6u16 => "Priority",
7204            7u16 => "VlanFiltering",
7205            8u16 => "VlanProtocol",
7206            9u16 => "GroupFwdMask",
7207            10u16 => "RootId",
7208            11u16 => "BridgeId",
7209            12u16 => "RootPort",
7210            13u16 => "RootPathCost",
7211            14u16 => "TopologyChange",
7212            15u16 => "TopologyChangeDetected",
7213            16u16 => "HelloTimer",
7214            17u16 => "TcnTimer",
7215            18u16 => "TopologyChangeTimer",
7216            19u16 => "GcTimer",
7217            20u16 => "GroupAddr",
7218            21u16 => "FdbFlush",
7219            22u16 => "McastRouter",
7220            23u16 => "McastSnooping",
7221            24u16 => "McastQueryUseIfaddr",
7222            25u16 => "McastQuerier",
7223            26u16 => "McastHashElasticity",
7224            27u16 => "McastHashMax",
7225            28u16 => "McastLastMemberCnt",
7226            29u16 => "McastStartupQueryCnt",
7227            30u16 => "McastLastMemberIntvl",
7228            31u16 => "McastMembershipIntvl",
7229            32u16 => "McastQuerierIntvl",
7230            33u16 => "McastQueryIntvl",
7231            34u16 => "McastQueryResponseIntvl",
7232            35u16 => "McastStartupQueryIntvl",
7233            36u16 => "NfCallIptables",
7234            37u16 => "NfCallIp6tables",
7235            38u16 => "NfCallArptables",
7236            39u16 => "VlanDefaultPvid",
7237            40u16 => "Pad",
7238            41u16 => "VlanStatsEnabled",
7239            42u16 => "McastStatsEnabled",
7240            43u16 => "McastIgmpVersion",
7241            44u16 => "McastMldVersion",
7242            45u16 => "VlanStatsPerPort",
7243            46u16 => "MultiBoolopt",
7244            47u16 => "McastQuerierState",
7245            48u16 => "FdbNLearned",
7246            49u16 => "FdbMaxLearned",
7247            _ => return None,
7248        };
7249        Some(res)
7250    }
7251}
7252#[derive(Clone, Copy, Default)]
7253pub struct IterableLinkinfoBridgeAttrs<'a> {
7254    buf: &'a [u8],
7255    pos: usize,
7256    orig_loc: usize,
7257}
7258impl<'a> IterableLinkinfoBridgeAttrs<'a> {
7259    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
7260        Self {
7261            buf,
7262            pos: 0,
7263            orig_loc,
7264        }
7265    }
7266    pub fn get_buf(&self) -> &'a [u8] {
7267        self.buf
7268    }
7269}
7270impl<'a> Iterator for IterableLinkinfoBridgeAttrs<'a> {
7271    type Item = Result<LinkinfoBridgeAttrs<'a>, ErrorContext>;
7272    fn next(&mut self) -> Option<Self::Item> {
7273        let pos = self.pos;
7274        let mut r#type;
7275        loop {
7276            r#type = None;
7277            if self.buf.len() == self.pos {
7278                return None;
7279            }
7280            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
7281                break;
7282            };
7283            r#type = Some(header.r#type);
7284            let res = match header.r#type {
7285                1u16 => LinkinfoBridgeAttrs::ForwardDelay({
7286                    let res = parse_u32(next);
7287                    let Some(val) = res else { break };
7288                    val
7289                }),
7290                2u16 => LinkinfoBridgeAttrs::HelloTime({
7291                    let res = parse_u32(next);
7292                    let Some(val) = res else { break };
7293                    val
7294                }),
7295                3u16 => LinkinfoBridgeAttrs::MaxAge({
7296                    let res = parse_u32(next);
7297                    let Some(val) = res else { break };
7298                    val
7299                }),
7300                4u16 => LinkinfoBridgeAttrs::AgeingTime({
7301                    let res = parse_u32(next);
7302                    let Some(val) = res else { break };
7303                    val
7304                }),
7305                5u16 => LinkinfoBridgeAttrs::StpState({
7306                    let res = parse_u32(next);
7307                    let Some(val) = res else { break };
7308                    val
7309                }),
7310                6u16 => LinkinfoBridgeAttrs::Priority({
7311                    let res = parse_u16(next);
7312                    let Some(val) = res else { break };
7313                    val
7314                }),
7315                7u16 => LinkinfoBridgeAttrs::VlanFiltering({
7316                    let res = parse_u8(next);
7317                    let Some(val) = res else { break };
7318                    val
7319                }),
7320                8u16 => LinkinfoBridgeAttrs::VlanProtocol({
7321                    let res = parse_u16(next);
7322                    let Some(val) = res else { break };
7323                    val
7324                }),
7325                9u16 => LinkinfoBridgeAttrs::GroupFwdMask({
7326                    let res = parse_u16(next);
7327                    let Some(val) = res else { break };
7328                    val
7329                }),
7330                10u16 => LinkinfoBridgeAttrs::RootId({
7331                    let res = PushIflaBridgeId::new_from_slice(next);
7332                    let Some(val) = res else { break };
7333                    val
7334                }),
7335                11u16 => LinkinfoBridgeAttrs::BridgeId({
7336                    let res = PushIflaBridgeId::new_from_slice(next);
7337                    let Some(val) = res else { break };
7338                    val
7339                }),
7340                12u16 => LinkinfoBridgeAttrs::RootPort({
7341                    let res = parse_u16(next);
7342                    let Some(val) = res else { break };
7343                    val
7344                }),
7345                13u16 => LinkinfoBridgeAttrs::RootPathCost({
7346                    let res = parse_u32(next);
7347                    let Some(val) = res else { break };
7348                    val
7349                }),
7350                14u16 => LinkinfoBridgeAttrs::TopologyChange({
7351                    let res = parse_u8(next);
7352                    let Some(val) = res else { break };
7353                    val
7354                }),
7355                15u16 => LinkinfoBridgeAttrs::TopologyChangeDetected({
7356                    let res = parse_u8(next);
7357                    let Some(val) = res else { break };
7358                    val
7359                }),
7360                16u16 => LinkinfoBridgeAttrs::HelloTimer({
7361                    let res = parse_u64(next);
7362                    let Some(val) = res else { break };
7363                    val
7364                }),
7365                17u16 => LinkinfoBridgeAttrs::TcnTimer({
7366                    let res = parse_u64(next);
7367                    let Some(val) = res else { break };
7368                    val
7369                }),
7370                18u16 => LinkinfoBridgeAttrs::TopologyChangeTimer({
7371                    let res = parse_u64(next);
7372                    let Some(val) = res else { break };
7373                    val
7374                }),
7375                19u16 => LinkinfoBridgeAttrs::GcTimer({
7376                    let res = parse_u64(next);
7377                    let Some(val) = res else { break };
7378                    val
7379                }),
7380                20u16 => LinkinfoBridgeAttrs::GroupAddr({
7381                    let res = Some(next);
7382                    let Some(val) = res else { break };
7383                    val
7384                }),
7385                21u16 => LinkinfoBridgeAttrs::FdbFlush({
7386                    let res = Some(next);
7387                    let Some(val) = res else { break };
7388                    val
7389                }),
7390                22u16 => LinkinfoBridgeAttrs::McastRouter({
7391                    let res = parse_u8(next);
7392                    let Some(val) = res else { break };
7393                    val
7394                }),
7395                23u16 => LinkinfoBridgeAttrs::McastSnooping({
7396                    let res = parse_u8(next);
7397                    let Some(val) = res else { break };
7398                    val
7399                }),
7400                24u16 => LinkinfoBridgeAttrs::McastQueryUseIfaddr({
7401                    let res = parse_u8(next);
7402                    let Some(val) = res else { break };
7403                    val
7404                }),
7405                25u16 => LinkinfoBridgeAttrs::McastQuerier({
7406                    let res = parse_u8(next);
7407                    let Some(val) = res else { break };
7408                    val
7409                }),
7410                26u16 => LinkinfoBridgeAttrs::McastHashElasticity({
7411                    let res = parse_u32(next);
7412                    let Some(val) = res else { break };
7413                    val
7414                }),
7415                27u16 => LinkinfoBridgeAttrs::McastHashMax({
7416                    let res = parse_u32(next);
7417                    let Some(val) = res else { break };
7418                    val
7419                }),
7420                28u16 => LinkinfoBridgeAttrs::McastLastMemberCnt({
7421                    let res = parse_u32(next);
7422                    let Some(val) = res else { break };
7423                    val
7424                }),
7425                29u16 => LinkinfoBridgeAttrs::McastStartupQueryCnt({
7426                    let res = parse_u32(next);
7427                    let Some(val) = res else { break };
7428                    val
7429                }),
7430                30u16 => LinkinfoBridgeAttrs::McastLastMemberIntvl({
7431                    let res = parse_u64(next);
7432                    let Some(val) = res else { break };
7433                    val
7434                }),
7435                31u16 => LinkinfoBridgeAttrs::McastMembershipIntvl({
7436                    let res = parse_u64(next);
7437                    let Some(val) = res else { break };
7438                    val
7439                }),
7440                32u16 => LinkinfoBridgeAttrs::McastQuerierIntvl({
7441                    let res = parse_u64(next);
7442                    let Some(val) = res else { break };
7443                    val
7444                }),
7445                33u16 => LinkinfoBridgeAttrs::McastQueryIntvl({
7446                    let res = parse_u64(next);
7447                    let Some(val) = res else { break };
7448                    val
7449                }),
7450                34u16 => LinkinfoBridgeAttrs::McastQueryResponseIntvl({
7451                    let res = parse_u64(next);
7452                    let Some(val) = res else { break };
7453                    val
7454                }),
7455                35u16 => LinkinfoBridgeAttrs::McastStartupQueryIntvl({
7456                    let res = parse_u64(next);
7457                    let Some(val) = res else { break };
7458                    val
7459                }),
7460                36u16 => LinkinfoBridgeAttrs::NfCallIptables({
7461                    let res = parse_u8(next);
7462                    let Some(val) = res else { break };
7463                    val
7464                }),
7465                37u16 => LinkinfoBridgeAttrs::NfCallIp6tables({
7466                    let res = parse_u8(next);
7467                    let Some(val) = res else { break };
7468                    val
7469                }),
7470                38u16 => LinkinfoBridgeAttrs::NfCallArptables({
7471                    let res = parse_u8(next);
7472                    let Some(val) = res else { break };
7473                    val
7474                }),
7475                39u16 => LinkinfoBridgeAttrs::VlanDefaultPvid({
7476                    let res = parse_u16(next);
7477                    let Some(val) = res else { break };
7478                    val
7479                }),
7480                40u16 => LinkinfoBridgeAttrs::Pad({
7481                    let res = Some(next);
7482                    let Some(val) = res else { break };
7483                    val
7484                }),
7485                41u16 => LinkinfoBridgeAttrs::VlanStatsEnabled({
7486                    let res = parse_u8(next);
7487                    let Some(val) = res else { break };
7488                    val
7489                }),
7490                42u16 => LinkinfoBridgeAttrs::McastStatsEnabled({
7491                    let res = parse_u8(next);
7492                    let Some(val) = res else { break };
7493                    val
7494                }),
7495                43u16 => LinkinfoBridgeAttrs::McastIgmpVersion({
7496                    let res = parse_u8(next);
7497                    let Some(val) = res else { break };
7498                    val
7499                }),
7500                44u16 => LinkinfoBridgeAttrs::McastMldVersion({
7501                    let res = parse_u8(next);
7502                    let Some(val) = res else { break };
7503                    val
7504                }),
7505                45u16 => LinkinfoBridgeAttrs::VlanStatsPerPort({
7506                    let res = parse_u8(next);
7507                    let Some(val) = res else { break };
7508                    val
7509                }),
7510                46u16 => LinkinfoBridgeAttrs::MultiBoolopt({
7511                    let res = PushBrBooloptMulti::new_from_slice(next);
7512                    let Some(val) = res else { break };
7513                    val
7514                }),
7515                47u16 => LinkinfoBridgeAttrs::McastQuerierState({
7516                    let res = Some(next);
7517                    let Some(val) = res else { break };
7518                    val
7519                }),
7520                48u16 => LinkinfoBridgeAttrs::FdbNLearned({
7521                    let res = parse_u32(next);
7522                    let Some(val) = res else { break };
7523                    val
7524                }),
7525                49u16 => LinkinfoBridgeAttrs::FdbMaxLearned({
7526                    let res = parse_u32(next);
7527                    let Some(val) = res else { break };
7528                    val
7529                }),
7530                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
7531                n => continue,
7532            };
7533            return Some(Ok(res));
7534        }
7535        Some(Err(ErrorContext::new(
7536            "LinkinfoBridgeAttrs",
7537            r#type.and_then(|t| LinkinfoBridgeAttrs::attr_from_type(t)),
7538            self.orig_loc,
7539            self.buf.as_ptr().wrapping_add(pos) as usize,
7540        )))
7541    }
7542}
7543impl<'a> std::fmt::Debug for IterableLinkinfoBridgeAttrs<'_> {
7544    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7545        let mut fmt = f.debug_struct("LinkinfoBridgeAttrs");
7546        for attr in self.clone() {
7547            let attr = match attr {
7548                Ok(a) => a,
7549                Err(err) => {
7550                    fmt.finish()?;
7551                    f.write_str("Err(")?;
7552                    err.fmt(f)?;
7553                    return f.write_str(")");
7554                }
7555            };
7556            match attr {
7557                LinkinfoBridgeAttrs::ForwardDelay(val) => fmt.field("ForwardDelay", &val),
7558                LinkinfoBridgeAttrs::HelloTime(val) => fmt.field("HelloTime", &val),
7559                LinkinfoBridgeAttrs::MaxAge(val) => fmt.field("MaxAge", &val),
7560                LinkinfoBridgeAttrs::AgeingTime(val) => fmt.field("AgeingTime", &val),
7561                LinkinfoBridgeAttrs::StpState(val) => fmt.field("StpState", &val),
7562                LinkinfoBridgeAttrs::Priority(val) => fmt.field("Priority", &val),
7563                LinkinfoBridgeAttrs::VlanFiltering(val) => fmt.field("VlanFiltering", &val),
7564                LinkinfoBridgeAttrs::VlanProtocol(val) => fmt.field("VlanProtocol", &val),
7565                LinkinfoBridgeAttrs::GroupFwdMask(val) => fmt.field("GroupFwdMask", &val),
7566                LinkinfoBridgeAttrs::RootId(val) => fmt.field("RootId", &val),
7567                LinkinfoBridgeAttrs::BridgeId(val) => fmt.field("BridgeId", &val),
7568                LinkinfoBridgeAttrs::RootPort(val) => fmt.field("RootPort", &val),
7569                LinkinfoBridgeAttrs::RootPathCost(val) => fmt.field("RootPathCost", &val),
7570                LinkinfoBridgeAttrs::TopologyChange(val) => fmt.field("TopologyChange", &val),
7571                LinkinfoBridgeAttrs::TopologyChangeDetected(val) => {
7572                    fmt.field("TopologyChangeDetected", &val)
7573                }
7574                LinkinfoBridgeAttrs::HelloTimer(val) => fmt.field("HelloTimer", &val),
7575                LinkinfoBridgeAttrs::TcnTimer(val) => fmt.field("TcnTimer", &val),
7576                LinkinfoBridgeAttrs::TopologyChangeTimer(val) => {
7577                    fmt.field("TopologyChangeTimer", &val)
7578                }
7579                LinkinfoBridgeAttrs::GcTimer(val) => fmt.field("GcTimer", &val),
7580                LinkinfoBridgeAttrs::GroupAddr(val) => fmt.field("GroupAddr", &val),
7581                LinkinfoBridgeAttrs::FdbFlush(val) => fmt.field("FdbFlush", &val),
7582                LinkinfoBridgeAttrs::McastRouter(val) => fmt.field("McastRouter", &val),
7583                LinkinfoBridgeAttrs::McastSnooping(val) => fmt.field("McastSnooping", &val),
7584                LinkinfoBridgeAttrs::McastQueryUseIfaddr(val) => {
7585                    fmt.field("McastQueryUseIfaddr", &val)
7586                }
7587                LinkinfoBridgeAttrs::McastQuerier(val) => fmt.field("McastQuerier", &val),
7588                LinkinfoBridgeAttrs::McastHashElasticity(val) => {
7589                    fmt.field("McastHashElasticity", &val)
7590                }
7591                LinkinfoBridgeAttrs::McastHashMax(val) => fmt.field("McastHashMax", &val),
7592                LinkinfoBridgeAttrs::McastLastMemberCnt(val) => {
7593                    fmt.field("McastLastMemberCnt", &val)
7594                }
7595                LinkinfoBridgeAttrs::McastStartupQueryCnt(val) => {
7596                    fmt.field("McastStartupQueryCnt", &val)
7597                }
7598                LinkinfoBridgeAttrs::McastLastMemberIntvl(val) => {
7599                    fmt.field("McastLastMemberIntvl", &val)
7600                }
7601                LinkinfoBridgeAttrs::McastMembershipIntvl(val) => {
7602                    fmt.field("McastMembershipIntvl", &val)
7603                }
7604                LinkinfoBridgeAttrs::McastQuerierIntvl(val) => fmt.field("McastQuerierIntvl", &val),
7605                LinkinfoBridgeAttrs::McastQueryIntvl(val) => fmt.field("McastQueryIntvl", &val),
7606                LinkinfoBridgeAttrs::McastQueryResponseIntvl(val) => {
7607                    fmt.field("McastQueryResponseIntvl", &val)
7608                }
7609                LinkinfoBridgeAttrs::McastStartupQueryIntvl(val) => {
7610                    fmt.field("McastStartupQueryIntvl", &val)
7611                }
7612                LinkinfoBridgeAttrs::NfCallIptables(val) => fmt.field("NfCallIptables", &val),
7613                LinkinfoBridgeAttrs::NfCallIp6tables(val) => fmt.field("NfCallIp6tables", &val),
7614                LinkinfoBridgeAttrs::NfCallArptables(val) => fmt.field("NfCallArptables", &val),
7615                LinkinfoBridgeAttrs::VlanDefaultPvid(val) => fmt.field("VlanDefaultPvid", &val),
7616                LinkinfoBridgeAttrs::Pad(val) => fmt.field("Pad", &val),
7617                LinkinfoBridgeAttrs::VlanStatsEnabled(val) => fmt.field("VlanStatsEnabled", &val),
7618                LinkinfoBridgeAttrs::McastStatsEnabled(val) => fmt.field("McastStatsEnabled", &val),
7619                LinkinfoBridgeAttrs::McastIgmpVersion(val) => fmt.field("McastIgmpVersion", &val),
7620                LinkinfoBridgeAttrs::McastMldVersion(val) => fmt.field("McastMldVersion", &val),
7621                LinkinfoBridgeAttrs::VlanStatsPerPort(val) => fmt.field("VlanStatsPerPort", &val),
7622                LinkinfoBridgeAttrs::MultiBoolopt(val) => fmt.field("MultiBoolopt", &val),
7623                LinkinfoBridgeAttrs::McastQuerierState(val) => fmt.field("McastQuerierState", &val),
7624                LinkinfoBridgeAttrs::FdbNLearned(val) => fmt.field("FdbNLearned", &val),
7625                LinkinfoBridgeAttrs::FdbMaxLearned(val) => fmt.field("FdbMaxLearned", &val),
7626            };
7627        }
7628        fmt.finish()
7629    }
7630}
7631impl IterableLinkinfoBridgeAttrs<'_> {
7632    pub fn lookup_attr(
7633        &self,
7634        offset: usize,
7635        missing_type: Option<u16>,
7636    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
7637        let mut stack = Vec::new();
7638        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
7639        if cur == offset {
7640            stack.push(("LinkinfoBridgeAttrs", offset));
7641            return (
7642                stack,
7643                missing_type.and_then(|t| LinkinfoBridgeAttrs::attr_from_type(t)),
7644            );
7645        }
7646        if cur > offset || cur + self.buf.len() < offset {
7647            return (stack, None);
7648        }
7649        let mut attrs = self.clone();
7650        let mut last_off = cur + attrs.pos;
7651        while let Some(attr) = attrs.next() {
7652            let Ok(attr) = attr else { break };
7653            match attr {
7654                LinkinfoBridgeAttrs::ForwardDelay(val) => {
7655                    if last_off == offset {
7656                        stack.push(("ForwardDelay", last_off));
7657                        break;
7658                    }
7659                }
7660                LinkinfoBridgeAttrs::HelloTime(val) => {
7661                    if last_off == offset {
7662                        stack.push(("HelloTime", last_off));
7663                        break;
7664                    }
7665                }
7666                LinkinfoBridgeAttrs::MaxAge(val) => {
7667                    if last_off == offset {
7668                        stack.push(("MaxAge", last_off));
7669                        break;
7670                    }
7671                }
7672                LinkinfoBridgeAttrs::AgeingTime(val) => {
7673                    if last_off == offset {
7674                        stack.push(("AgeingTime", last_off));
7675                        break;
7676                    }
7677                }
7678                LinkinfoBridgeAttrs::StpState(val) => {
7679                    if last_off == offset {
7680                        stack.push(("StpState", last_off));
7681                        break;
7682                    }
7683                }
7684                LinkinfoBridgeAttrs::Priority(val) => {
7685                    if last_off == offset {
7686                        stack.push(("Priority", last_off));
7687                        break;
7688                    }
7689                }
7690                LinkinfoBridgeAttrs::VlanFiltering(val) => {
7691                    if last_off == offset {
7692                        stack.push(("VlanFiltering", last_off));
7693                        break;
7694                    }
7695                }
7696                LinkinfoBridgeAttrs::VlanProtocol(val) => {
7697                    if last_off == offset {
7698                        stack.push(("VlanProtocol", last_off));
7699                        break;
7700                    }
7701                }
7702                LinkinfoBridgeAttrs::GroupFwdMask(val) => {
7703                    if last_off == offset {
7704                        stack.push(("GroupFwdMask", last_off));
7705                        break;
7706                    }
7707                }
7708                LinkinfoBridgeAttrs::RootId(val) => {
7709                    if last_off == offset {
7710                        stack.push(("RootId", last_off));
7711                        break;
7712                    }
7713                }
7714                LinkinfoBridgeAttrs::BridgeId(val) => {
7715                    if last_off == offset {
7716                        stack.push(("BridgeId", last_off));
7717                        break;
7718                    }
7719                }
7720                LinkinfoBridgeAttrs::RootPort(val) => {
7721                    if last_off == offset {
7722                        stack.push(("RootPort", last_off));
7723                        break;
7724                    }
7725                }
7726                LinkinfoBridgeAttrs::RootPathCost(val) => {
7727                    if last_off == offset {
7728                        stack.push(("RootPathCost", last_off));
7729                        break;
7730                    }
7731                }
7732                LinkinfoBridgeAttrs::TopologyChange(val) => {
7733                    if last_off == offset {
7734                        stack.push(("TopologyChange", last_off));
7735                        break;
7736                    }
7737                }
7738                LinkinfoBridgeAttrs::TopologyChangeDetected(val) => {
7739                    if last_off == offset {
7740                        stack.push(("TopologyChangeDetected", last_off));
7741                        break;
7742                    }
7743                }
7744                LinkinfoBridgeAttrs::HelloTimer(val) => {
7745                    if last_off == offset {
7746                        stack.push(("HelloTimer", last_off));
7747                        break;
7748                    }
7749                }
7750                LinkinfoBridgeAttrs::TcnTimer(val) => {
7751                    if last_off == offset {
7752                        stack.push(("TcnTimer", last_off));
7753                        break;
7754                    }
7755                }
7756                LinkinfoBridgeAttrs::TopologyChangeTimer(val) => {
7757                    if last_off == offset {
7758                        stack.push(("TopologyChangeTimer", last_off));
7759                        break;
7760                    }
7761                }
7762                LinkinfoBridgeAttrs::GcTimer(val) => {
7763                    if last_off == offset {
7764                        stack.push(("GcTimer", last_off));
7765                        break;
7766                    }
7767                }
7768                LinkinfoBridgeAttrs::GroupAddr(val) => {
7769                    if last_off == offset {
7770                        stack.push(("GroupAddr", last_off));
7771                        break;
7772                    }
7773                }
7774                LinkinfoBridgeAttrs::FdbFlush(val) => {
7775                    if last_off == offset {
7776                        stack.push(("FdbFlush", last_off));
7777                        break;
7778                    }
7779                }
7780                LinkinfoBridgeAttrs::McastRouter(val) => {
7781                    if last_off == offset {
7782                        stack.push(("McastRouter", last_off));
7783                        break;
7784                    }
7785                }
7786                LinkinfoBridgeAttrs::McastSnooping(val) => {
7787                    if last_off == offset {
7788                        stack.push(("McastSnooping", last_off));
7789                        break;
7790                    }
7791                }
7792                LinkinfoBridgeAttrs::McastQueryUseIfaddr(val) => {
7793                    if last_off == offset {
7794                        stack.push(("McastQueryUseIfaddr", last_off));
7795                        break;
7796                    }
7797                }
7798                LinkinfoBridgeAttrs::McastQuerier(val) => {
7799                    if last_off == offset {
7800                        stack.push(("McastQuerier", last_off));
7801                        break;
7802                    }
7803                }
7804                LinkinfoBridgeAttrs::McastHashElasticity(val) => {
7805                    if last_off == offset {
7806                        stack.push(("McastHashElasticity", last_off));
7807                        break;
7808                    }
7809                }
7810                LinkinfoBridgeAttrs::McastHashMax(val) => {
7811                    if last_off == offset {
7812                        stack.push(("McastHashMax", last_off));
7813                        break;
7814                    }
7815                }
7816                LinkinfoBridgeAttrs::McastLastMemberCnt(val) => {
7817                    if last_off == offset {
7818                        stack.push(("McastLastMemberCnt", last_off));
7819                        break;
7820                    }
7821                }
7822                LinkinfoBridgeAttrs::McastStartupQueryCnt(val) => {
7823                    if last_off == offset {
7824                        stack.push(("McastStartupQueryCnt", last_off));
7825                        break;
7826                    }
7827                }
7828                LinkinfoBridgeAttrs::McastLastMemberIntvl(val) => {
7829                    if last_off == offset {
7830                        stack.push(("McastLastMemberIntvl", last_off));
7831                        break;
7832                    }
7833                }
7834                LinkinfoBridgeAttrs::McastMembershipIntvl(val) => {
7835                    if last_off == offset {
7836                        stack.push(("McastMembershipIntvl", last_off));
7837                        break;
7838                    }
7839                }
7840                LinkinfoBridgeAttrs::McastQuerierIntvl(val) => {
7841                    if last_off == offset {
7842                        stack.push(("McastQuerierIntvl", last_off));
7843                        break;
7844                    }
7845                }
7846                LinkinfoBridgeAttrs::McastQueryIntvl(val) => {
7847                    if last_off == offset {
7848                        stack.push(("McastQueryIntvl", last_off));
7849                        break;
7850                    }
7851                }
7852                LinkinfoBridgeAttrs::McastQueryResponseIntvl(val) => {
7853                    if last_off == offset {
7854                        stack.push(("McastQueryResponseIntvl", last_off));
7855                        break;
7856                    }
7857                }
7858                LinkinfoBridgeAttrs::McastStartupQueryIntvl(val) => {
7859                    if last_off == offset {
7860                        stack.push(("McastStartupQueryIntvl", last_off));
7861                        break;
7862                    }
7863                }
7864                LinkinfoBridgeAttrs::NfCallIptables(val) => {
7865                    if last_off == offset {
7866                        stack.push(("NfCallIptables", last_off));
7867                        break;
7868                    }
7869                }
7870                LinkinfoBridgeAttrs::NfCallIp6tables(val) => {
7871                    if last_off == offset {
7872                        stack.push(("NfCallIp6tables", last_off));
7873                        break;
7874                    }
7875                }
7876                LinkinfoBridgeAttrs::NfCallArptables(val) => {
7877                    if last_off == offset {
7878                        stack.push(("NfCallArptables", last_off));
7879                        break;
7880                    }
7881                }
7882                LinkinfoBridgeAttrs::VlanDefaultPvid(val) => {
7883                    if last_off == offset {
7884                        stack.push(("VlanDefaultPvid", last_off));
7885                        break;
7886                    }
7887                }
7888                LinkinfoBridgeAttrs::Pad(val) => {
7889                    if last_off == offset {
7890                        stack.push(("Pad", last_off));
7891                        break;
7892                    }
7893                }
7894                LinkinfoBridgeAttrs::VlanStatsEnabled(val) => {
7895                    if last_off == offset {
7896                        stack.push(("VlanStatsEnabled", last_off));
7897                        break;
7898                    }
7899                }
7900                LinkinfoBridgeAttrs::McastStatsEnabled(val) => {
7901                    if last_off == offset {
7902                        stack.push(("McastStatsEnabled", last_off));
7903                        break;
7904                    }
7905                }
7906                LinkinfoBridgeAttrs::McastIgmpVersion(val) => {
7907                    if last_off == offset {
7908                        stack.push(("McastIgmpVersion", last_off));
7909                        break;
7910                    }
7911                }
7912                LinkinfoBridgeAttrs::McastMldVersion(val) => {
7913                    if last_off == offset {
7914                        stack.push(("McastMldVersion", last_off));
7915                        break;
7916                    }
7917                }
7918                LinkinfoBridgeAttrs::VlanStatsPerPort(val) => {
7919                    if last_off == offset {
7920                        stack.push(("VlanStatsPerPort", last_off));
7921                        break;
7922                    }
7923                }
7924                LinkinfoBridgeAttrs::MultiBoolopt(val) => {
7925                    if last_off == offset {
7926                        stack.push(("MultiBoolopt", last_off));
7927                        break;
7928                    }
7929                }
7930                LinkinfoBridgeAttrs::McastQuerierState(val) => {
7931                    if last_off == offset {
7932                        stack.push(("McastQuerierState", last_off));
7933                        break;
7934                    }
7935                }
7936                LinkinfoBridgeAttrs::FdbNLearned(val) => {
7937                    if last_off == offset {
7938                        stack.push(("FdbNLearned", last_off));
7939                        break;
7940                    }
7941                }
7942                LinkinfoBridgeAttrs::FdbMaxLearned(val) => {
7943                    if last_off == offset {
7944                        stack.push(("FdbMaxLearned", last_off));
7945                        break;
7946                    }
7947                }
7948                _ => {}
7949            };
7950            last_off = cur + attrs.pos;
7951        }
7952        if !stack.is_empty() {
7953            stack.push(("LinkinfoBridgeAttrs", cur));
7954        }
7955        (stack, None)
7956    }
7957}
7958#[derive(Clone)]
7959pub enum LinkinfoBrportAttrs<'a> {
7960    State(u8),
7961    Priority(u16),
7962    Cost(u32),
7963    Mode(()),
7964    Guard(()),
7965    Protect(()),
7966    FastLeave(()),
7967    Learning(()),
7968    UnicastFlood(()),
7969    Proxyarp(()),
7970    LearningSync(()),
7971    ProxyarpWifi(()),
7972    RootId(PushIflaBridgeId),
7973    BridgeId(PushIflaBridgeId),
7974    DesignatedPort(u16),
7975    DesignatedCost(u16),
7976    Id(u16),
7977    No(u16),
7978    TopologyChangeAck(u8),
7979    ConfigPending(u8),
7980    MessageAgeTimer(u64),
7981    ForwardDelayTimer(u64),
7982    HoldTimer(u64),
7983    Flush(()),
7984    MulticastRouter(u8),
7985    Pad(&'a [u8]),
7986    McastFlood(()),
7987    McastToUcast(()),
7988    VlanTunnel(()),
7989    BcastFlood(()),
7990    GroupFwdMask(u16),
7991    NeighSuppress(()),
7992    Isolated(()),
7993    BackupPort(u32),
7994    MrpRingOpen(()),
7995    MrpInOpen(()),
7996    McastEhtHostsLimit(u32),
7997    McastEhtHostsCnt(u32),
7998    Locked(()),
7999    Mab(()),
8000    McastNGroups(u32),
8001    McastMaxGroups(u32),
8002    NeighVlanSuppress(()),
8003    BackupNhid(u32),
8004}
8005impl<'a> IterableLinkinfoBrportAttrs<'a> {
8006    pub fn get_state(&self) -> Result<u8, ErrorContext> {
8007        let mut iter = self.clone();
8008        iter.pos = 0;
8009        for attr in iter {
8010            if let LinkinfoBrportAttrs::State(val) = attr? {
8011                return Ok(val);
8012            }
8013        }
8014        Err(ErrorContext::new_missing(
8015            "LinkinfoBrportAttrs",
8016            "State",
8017            self.orig_loc,
8018            self.buf.as_ptr() as usize,
8019        ))
8020    }
8021    pub fn get_priority(&self) -> Result<u16, ErrorContext> {
8022        let mut iter = self.clone();
8023        iter.pos = 0;
8024        for attr in iter {
8025            if let LinkinfoBrportAttrs::Priority(val) = attr? {
8026                return Ok(val);
8027            }
8028        }
8029        Err(ErrorContext::new_missing(
8030            "LinkinfoBrportAttrs",
8031            "Priority",
8032            self.orig_loc,
8033            self.buf.as_ptr() as usize,
8034        ))
8035    }
8036    pub fn get_cost(&self) -> Result<u32, ErrorContext> {
8037        let mut iter = self.clone();
8038        iter.pos = 0;
8039        for attr in iter {
8040            if let LinkinfoBrportAttrs::Cost(val) = attr? {
8041                return Ok(val);
8042            }
8043        }
8044        Err(ErrorContext::new_missing(
8045            "LinkinfoBrportAttrs",
8046            "Cost",
8047            self.orig_loc,
8048            self.buf.as_ptr() as usize,
8049        ))
8050    }
8051    pub fn get_mode(&self) -> Result<(), ErrorContext> {
8052        let mut iter = self.clone();
8053        iter.pos = 0;
8054        for attr in iter {
8055            if let LinkinfoBrportAttrs::Mode(val) = attr? {
8056                return Ok(val);
8057            }
8058        }
8059        Err(ErrorContext::new_missing(
8060            "LinkinfoBrportAttrs",
8061            "Mode",
8062            self.orig_loc,
8063            self.buf.as_ptr() as usize,
8064        ))
8065    }
8066    pub fn get_guard(&self) -> Result<(), ErrorContext> {
8067        let mut iter = self.clone();
8068        iter.pos = 0;
8069        for attr in iter {
8070            if let LinkinfoBrportAttrs::Guard(val) = attr? {
8071                return Ok(val);
8072            }
8073        }
8074        Err(ErrorContext::new_missing(
8075            "LinkinfoBrportAttrs",
8076            "Guard",
8077            self.orig_loc,
8078            self.buf.as_ptr() as usize,
8079        ))
8080    }
8081    pub fn get_protect(&self) -> Result<(), ErrorContext> {
8082        let mut iter = self.clone();
8083        iter.pos = 0;
8084        for attr in iter {
8085            if let LinkinfoBrportAttrs::Protect(val) = attr? {
8086                return Ok(val);
8087            }
8088        }
8089        Err(ErrorContext::new_missing(
8090            "LinkinfoBrportAttrs",
8091            "Protect",
8092            self.orig_loc,
8093            self.buf.as_ptr() as usize,
8094        ))
8095    }
8096    pub fn get_fast_leave(&self) -> Result<(), ErrorContext> {
8097        let mut iter = self.clone();
8098        iter.pos = 0;
8099        for attr in iter {
8100            if let LinkinfoBrportAttrs::FastLeave(val) = attr? {
8101                return Ok(val);
8102            }
8103        }
8104        Err(ErrorContext::new_missing(
8105            "LinkinfoBrportAttrs",
8106            "FastLeave",
8107            self.orig_loc,
8108            self.buf.as_ptr() as usize,
8109        ))
8110    }
8111    pub fn get_learning(&self) -> Result<(), ErrorContext> {
8112        let mut iter = self.clone();
8113        iter.pos = 0;
8114        for attr in iter {
8115            if let LinkinfoBrportAttrs::Learning(val) = attr? {
8116                return Ok(val);
8117            }
8118        }
8119        Err(ErrorContext::new_missing(
8120            "LinkinfoBrportAttrs",
8121            "Learning",
8122            self.orig_loc,
8123            self.buf.as_ptr() as usize,
8124        ))
8125    }
8126    pub fn get_unicast_flood(&self) -> Result<(), ErrorContext> {
8127        let mut iter = self.clone();
8128        iter.pos = 0;
8129        for attr in iter {
8130            if let LinkinfoBrportAttrs::UnicastFlood(val) = attr? {
8131                return Ok(val);
8132            }
8133        }
8134        Err(ErrorContext::new_missing(
8135            "LinkinfoBrportAttrs",
8136            "UnicastFlood",
8137            self.orig_loc,
8138            self.buf.as_ptr() as usize,
8139        ))
8140    }
8141    pub fn get_proxyarp(&self) -> Result<(), ErrorContext> {
8142        let mut iter = self.clone();
8143        iter.pos = 0;
8144        for attr in iter {
8145            if let LinkinfoBrportAttrs::Proxyarp(val) = attr? {
8146                return Ok(val);
8147            }
8148        }
8149        Err(ErrorContext::new_missing(
8150            "LinkinfoBrportAttrs",
8151            "Proxyarp",
8152            self.orig_loc,
8153            self.buf.as_ptr() as usize,
8154        ))
8155    }
8156    pub fn get_learning_sync(&self) -> Result<(), ErrorContext> {
8157        let mut iter = self.clone();
8158        iter.pos = 0;
8159        for attr in iter {
8160            if let LinkinfoBrportAttrs::LearningSync(val) = attr? {
8161                return Ok(val);
8162            }
8163        }
8164        Err(ErrorContext::new_missing(
8165            "LinkinfoBrportAttrs",
8166            "LearningSync",
8167            self.orig_loc,
8168            self.buf.as_ptr() as usize,
8169        ))
8170    }
8171    pub fn get_proxyarp_wifi(&self) -> Result<(), ErrorContext> {
8172        let mut iter = self.clone();
8173        iter.pos = 0;
8174        for attr in iter {
8175            if let LinkinfoBrportAttrs::ProxyarpWifi(val) = attr? {
8176                return Ok(val);
8177            }
8178        }
8179        Err(ErrorContext::new_missing(
8180            "LinkinfoBrportAttrs",
8181            "ProxyarpWifi",
8182            self.orig_loc,
8183            self.buf.as_ptr() as usize,
8184        ))
8185    }
8186    pub fn get_root_id(&self) -> Result<PushIflaBridgeId, ErrorContext> {
8187        let mut iter = self.clone();
8188        iter.pos = 0;
8189        for attr in iter {
8190            if let LinkinfoBrportAttrs::RootId(val) = attr? {
8191                return Ok(val);
8192            }
8193        }
8194        Err(ErrorContext::new_missing(
8195            "LinkinfoBrportAttrs",
8196            "RootId",
8197            self.orig_loc,
8198            self.buf.as_ptr() as usize,
8199        ))
8200    }
8201    pub fn get_bridge_id(&self) -> Result<PushIflaBridgeId, ErrorContext> {
8202        let mut iter = self.clone();
8203        iter.pos = 0;
8204        for attr in iter {
8205            if let LinkinfoBrportAttrs::BridgeId(val) = attr? {
8206                return Ok(val);
8207            }
8208        }
8209        Err(ErrorContext::new_missing(
8210            "LinkinfoBrportAttrs",
8211            "BridgeId",
8212            self.orig_loc,
8213            self.buf.as_ptr() as usize,
8214        ))
8215    }
8216    pub fn get_designated_port(&self) -> Result<u16, ErrorContext> {
8217        let mut iter = self.clone();
8218        iter.pos = 0;
8219        for attr in iter {
8220            if let LinkinfoBrportAttrs::DesignatedPort(val) = attr? {
8221                return Ok(val);
8222            }
8223        }
8224        Err(ErrorContext::new_missing(
8225            "LinkinfoBrportAttrs",
8226            "DesignatedPort",
8227            self.orig_loc,
8228            self.buf.as_ptr() as usize,
8229        ))
8230    }
8231    pub fn get_designated_cost(&self) -> Result<u16, ErrorContext> {
8232        let mut iter = self.clone();
8233        iter.pos = 0;
8234        for attr in iter {
8235            if let LinkinfoBrportAttrs::DesignatedCost(val) = attr? {
8236                return Ok(val);
8237            }
8238        }
8239        Err(ErrorContext::new_missing(
8240            "LinkinfoBrportAttrs",
8241            "DesignatedCost",
8242            self.orig_loc,
8243            self.buf.as_ptr() as usize,
8244        ))
8245    }
8246    pub fn get_id(&self) -> Result<u16, ErrorContext> {
8247        let mut iter = self.clone();
8248        iter.pos = 0;
8249        for attr in iter {
8250            if let LinkinfoBrportAttrs::Id(val) = attr? {
8251                return Ok(val);
8252            }
8253        }
8254        Err(ErrorContext::new_missing(
8255            "LinkinfoBrportAttrs",
8256            "Id",
8257            self.orig_loc,
8258            self.buf.as_ptr() as usize,
8259        ))
8260    }
8261    pub fn get_no(&self) -> Result<u16, ErrorContext> {
8262        let mut iter = self.clone();
8263        iter.pos = 0;
8264        for attr in iter {
8265            if let LinkinfoBrportAttrs::No(val) = attr? {
8266                return Ok(val);
8267            }
8268        }
8269        Err(ErrorContext::new_missing(
8270            "LinkinfoBrportAttrs",
8271            "No",
8272            self.orig_loc,
8273            self.buf.as_ptr() as usize,
8274        ))
8275    }
8276    pub fn get_topology_change_ack(&self) -> Result<u8, ErrorContext> {
8277        let mut iter = self.clone();
8278        iter.pos = 0;
8279        for attr in iter {
8280            if let LinkinfoBrportAttrs::TopologyChangeAck(val) = attr? {
8281                return Ok(val);
8282            }
8283        }
8284        Err(ErrorContext::new_missing(
8285            "LinkinfoBrportAttrs",
8286            "TopologyChangeAck",
8287            self.orig_loc,
8288            self.buf.as_ptr() as usize,
8289        ))
8290    }
8291    pub fn get_config_pending(&self) -> Result<u8, ErrorContext> {
8292        let mut iter = self.clone();
8293        iter.pos = 0;
8294        for attr in iter {
8295            if let LinkinfoBrportAttrs::ConfigPending(val) = attr? {
8296                return Ok(val);
8297            }
8298        }
8299        Err(ErrorContext::new_missing(
8300            "LinkinfoBrportAttrs",
8301            "ConfigPending",
8302            self.orig_loc,
8303            self.buf.as_ptr() as usize,
8304        ))
8305    }
8306    pub fn get_message_age_timer(&self) -> Result<u64, ErrorContext> {
8307        let mut iter = self.clone();
8308        iter.pos = 0;
8309        for attr in iter {
8310            if let LinkinfoBrportAttrs::MessageAgeTimer(val) = attr? {
8311                return Ok(val);
8312            }
8313        }
8314        Err(ErrorContext::new_missing(
8315            "LinkinfoBrportAttrs",
8316            "MessageAgeTimer",
8317            self.orig_loc,
8318            self.buf.as_ptr() as usize,
8319        ))
8320    }
8321    pub fn get_forward_delay_timer(&self) -> Result<u64, ErrorContext> {
8322        let mut iter = self.clone();
8323        iter.pos = 0;
8324        for attr in iter {
8325            if let LinkinfoBrportAttrs::ForwardDelayTimer(val) = attr? {
8326                return Ok(val);
8327            }
8328        }
8329        Err(ErrorContext::new_missing(
8330            "LinkinfoBrportAttrs",
8331            "ForwardDelayTimer",
8332            self.orig_loc,
8333            self.buf.as_ptr() as usize,
8334        ))
8335    }
8336    pub fn get_hold_timer(&self) -> Result<u64, ErrorContext> {
8337        let mut iter = self.clone();
8338        iter.pos = 0;
8339        for attr in iter {
8340            if let LinkinfoBrportAttrs::HoldTimer(val) = attr? {
8341                return Ok(val);
8342            }
8343        }
8344        Err(ErrorContext::new_missing(
8345            "LinkinfoBrportAttrs",
8346            "HoldTimer",
8347            self.orig_loc,
8348            self.buf.as_ptr() as usize,
8349        ))
8350    }
8351    pub fn get_flush(&self) -> Result<(), ErrorContext> {
8352        let mut iter = self.clone();
8353        iter.pos = 0;
8354        for attr in iter {
8355            if let LinkinfoBrportAttrs::Flush(val) = attr? {
8356                return Ok(val);
8357            }
8358        }
8359        Err(ErrorContext::new_missing(
8360            "LinkinfoBrportAttrs",
8361            "Flush",
8362            self.orig_loc,
8363            self.buf.as_ptr() as usize,
8364        ))
8365    }
8366    pub fn get_multicast_router(&self) -> Result<u8, ErrorContext> {
8367        let mut iter = self.clone();
8368        iter.pos = 0;
8369        for attr in iter {
8370            if let LinkinfoBrportAttrs::MulticastRouter(val) = attr? {
8371                return Ok(val);
8372            }
8373        }
8374        Err(ErrorContext::new_missing(
8375            "LinkinfoBrportAttrs",
8376            "MulticastRouter",
8377            self.orig_loc,
8378            self.buf.as_ptr() as usize,
8379        ))
8380    }
8381    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
8382        let mut iter = self.clone();
8383        iter.pos = 0;
8384        for attr in iter {
8385            if let LinkinfoBrportAttrs::Pad(val) = attr? {
8386                return Ok(val);
8387            }
8388        }
8389        Err(ErrorContext::new_missing(
8390            "LinkinfoBrportAttrs",
8391            "Pad",
8392            self.orig_loc,
8393            self.buf.as_ptr() as usize,
8394        ))
8395    }
8396    pub fn get_mcast_flood(&self) -> Result<(), ErrorContext> {
8397        let mut iter = self.clone();
8398        iter.pos = 0;
8399        for attr in iter {
8400            if let LinkinfoBrportAttrs::McastFlood(val) = attr? {
8401                return Ok(val);
8402            }
8403        }
8404        Err(ErrorContext::new_missing(
8405            "LinkinfoBrportAttrs",
8406            "McastFlood",
8407            self.orig_loc,
8408            self.buf.as_ptr() as usize,
8409        ))
8410    }
8411    pub fn get_mcast_to_ucast(&self) -> Result<(), ErrorContext> {
8412        let mut iter = self.clone();
8413        iter.pos = 0;
8414        for attr in iter {
8415            if let LinkinfoBrportAttrs::McastToUcast(val) = attr? {
8416                return Ok(val);
8417            }
8418        }
8419        Err(ErrorContext::new_missing(
8420            "LinkinfoBrportAttrs",
8421            "McastToUcast",
8422            self.orig_loc,
8423            self.buf.as_ptr() as usize,
8424        ))
8425    }
8426    pub fn get_vlan_tunnel(&self) -> Result<(), ErrorContext> {
8427        let mut iter = self.clone();
8428        iter.pos = 0;
8429        for attr in iter {
8430            if let LinkinfoBrportAttrs::VlanTunnel(val) = attr? {
8431                return Ok(val);
8432            }
8433        }
8434        Err(ErrorContext::new_missing(
8435            "LinkinfoBrportAttrs",
8436            "VlanTunnel",
8437            self.orig_loc,
8438            self.buf.as_ptr() as usize,
8439        ))
8440    }
8441    pub fn get_bcast_flood(&self) -> Result<(), ErrorContext> {
8442        let mut iter = self.clone();
8443        iter.pos = 0;
8444        for attr in iter {
8445            if let LinkinfoBrportAttrs::BcastFlood(val) = attr? {
8446                return Ok(val);
8447            }
8448        }
8449        Err(ErrorContext::new_missing(
8450            "LinkinfoBrportAttrs",
8451            "BcastFlood",
8452            self.orig_loc,
8453            self.buf.as_ptr() as usize,
8454        ))
8455    }
8456    pub fn get_group_fwd_mask(&self) -> Result<u16, ErrorContext> {
8457        let mut iter = self.clone();
8458        iter.pos = 0;
8459        for attr in iter {
8460            if let LinkinfoBrportAttrs::GroupFwdMask(val) = attr? {
8461                return Ok(val);
8462            }
8463        }
8464        Err(ErrorContext::new_missing(
8465            "LinkinfoBrportAttrs",
8466            "GroupFwdMask",
8467            self.orig_loc,
8468            self.buf.as_ptr() as usize,
8469        ))
8470    }
8471    pub fn get_neigh_suppress(&self) -> Result<(), ErrorContext> {
8472        let mut iter = self.clone();
8473        iter.pos = 0;
8474        for attr in iter {
8475            if let LinkinfoBrportAttrs::NeighSuppress(val) = attr? {
8476                return Ok(val);
8477            }
8478        }
8479        Err(ErrorContext::new_missing(
8480            "LinkinfoBrportAttrs",
8481            "NeighSuppress",
8482            self.orig_loc,
8483            self.buf.as_ptr() as usize,
8484        ))
8485    }
8486    pub fn get_isolated(&self) -> Result<(), ErrorContext> {
8487        let mut iter = self.clone();
8488        iter.pos = 0;
8489        for attr in iter {
8490            if let LinkinfoBrportAttrs::Isolated(val) = attr? {
8491                return Ok(val);
8492            }
8493        }
8494        Err(ErrorContext::new_missing(
8495            "LinkinfoBrportAttrs",
8496            "Isolated",
8497            self.orig_loc,
8498            self.buf.as_ptr() as usize,
8499        ))
8500    }
8501    pub fn get_backup_port(&self) -> Result<u32, ErrorContext> {
8502        let mut iter = self.clone();
8503        iter.pos = 0;
8504        for attr in iter {
8505            if let LinkinfoBrportAttrs::BackupPort(val) = attr? {
8506                return Ok(val);
8507            }
8508        }
8509        Err(ErrorContext::new_missing(
8510            "LinkinfoBrportAttrs",
8511            "BackupPort",
8512            self.orig_loc,
8513            self.buf.as_ptr() as usize,
8514        ))
8515    }
8516    pub fn get_mrp_ring_open(&self) -> Result<(), ErrorContext> {
8517        let mut iter = self.clone();
8518        iter.pos = 0;
8519        for attr in iter {
8520            if let LinkinfoBrportAttrs::MrpRingOpen(val) = attr? {
8521                return Ok(val);
8522            }
8523        }
8524        Err(ErrorContext::new_missing(
8525            "LinkinfoBrportAttrs",
8526            "MrpRingOpen",
8527            self.orig_loc,
8528            self.buf.as_ptr() as usize,
8529        ))
8530    }
8531    pub fn get_mrp_in_open(&self) -> Result<(), ErrorContext> {
8532        let mut iter = self.clone();
8533        iter.pos = 0;
8534        for attr in iter {
8535            if let LinkinfoBrportAttrs::MrpInOpen(val) = attr? {
8536                return Ok(val);
8537            }
8538        }
8539        Err(ErrorContext::new_missing(
8540            "LinkinfoBrportAttrs",
8541            "MrpInOpen",
8542            self.orig_loc,
8543            self.buf.as_ptr() as usize,
8544        ))
8545    }
8546    pub fn get_mcast_eht_hosts_limit(&self) -> Result<u32, ErrorContext> {
8547        let mut iter = self.clone();
8548        iter.pos = 0;
8549        for attr in iter {
8550            if let LinkinfoBrportAttrs::McastEhtHostsLimit(val) = attr? {
8551                return Ok(val);
8552            }
8553        }
8554        Err(ErrorContext::new_missing(
8555            "LinkinfoBrportAttrs",
8556            "McastEhtHostsLimit",
8557            self.orig_loc,
8558            self.buf.as_ptr() as usize,
8559        ))
8560    }
8561    pub fn get_mcast_eht_hosts_cnt(&self) -> Result<u32, ErrorContext> {
8562        let mut iter = self.clone();
8563        iter.pos = 0;
8564        for attr in iter {
8565            if let LinkinfoBrportAttrs::McastEhtHostsCnt(val) = attr? {
8566                return Ok(val);
8567            }
8568        }
8569        Err(ErrorContext::new_missing(
8570            "LinkinfoBrportAttrs",
8571            "McastEhtHostsCnt",
8572            self.orig_loc,
8573            self.buf.as_ptr() as usize,
8574        ))
8575    }
8576    pub fn get_locked(&self) -> Result<(), ErrorContext> {
8577        let mut iter = self.clone();
8578        iter.pos = 0;
8579        for attr in iter {
8580            if let LinkinfoBrportAttrs::Locked(val) = attr? {
8581                return Ok(val);
8582            }
8583        }
8584        Err(ErrorContext::new_missing(
8585            "LinkinfoBrportAttrs",
8586            "Locked",
8587            self.orig_loc,
8588            self.buf.as_ptr() as usize,
8589        ))
8590    }
8591    pub fn get_mab(&self) -> Result<(), ErrorContext> {
8592        let mut iter = self.clone();
8593        iter.pos = 0;
8594        for attr in iter {
8595            if let LinkinfoBrportAttrs::Mab(val) = attr? {
8596                return Ok(val);
8597            }
8598        }
8599        Err(ErrorContext::new_missing(
8600            "LinkinfoBrportAttrs",
8601            "Mab",
8602            self.orig_loc,
8603            self.buf.as_ptr() as usize,
8604        ))
8605    }
8606    pub fn get_mcast_n_groups(&self) -> Result<u32, ErrorContext> {
8607        let mut iter = self.clone();
8608        iter.pos = 0;
8609        for attr in iter {
8610            if let LinkinfoBrportAttrs::McastNGroups(val) = attr? {
8611                return Ok(val);
8612            }
8613        }
8614        Err(ErrorContext::new_missing(
8615            "LinkinfoBrportAttrs",
8616            "McastNGroups",
8617            self.orig_loc,
8618            self.buf.as_ptr() as usize,
8619        ))
8620    }
8621    pub fn get_mcast_max_groups(&self) -> Result<u32, ErrorContext> {
8622        let mut iter = self.clone();
8623        iter.pos = 0;
8624        for attr in iter {
8625            if let LinkinfoBrportAttrs::McastMaxGroups(val) = attr? {
8626                return Ok(val);
8627            }
8628        }
8629        Err(ErrorContext::new_missing(
8630            "LinkinfoBrportAttrs",
8631            "McastMaxGroups",
8632            self.orig_loc,
8633            self.buf.as_ptr() as usize,
8634        ))
8635    }
8636    pub fn get_neigh_vlan_suppress(&self) -> Result<(), ErrorContext> {
8637        let mut iter = self.clone();
8638        iter.pos = 0;
8639        for attr in iter {
8640            if let LinkinfoBrportAttrs::NeighVlanSuppress(val) = attr? {
8641                return Ok(val);
8642            }
8643        }
8644        Err(ErrorContext::new_missing(
8645            "LinkinfoBrportAttrs",
8646            "NeighVlanSuppress",
8647            self.orig_loc,
8648            self.buf.as_ptr() as usize,
8649        ))
8650    }
8651    pub fn get_backup_nhid(&self) -> Result<u32, ErrorContext> {
8652        let mut iter = self.clone();
8653        iter.pos = 0;
8654        for attr in iter {
8655            if let LinkinfoBrportAttrs::BackupNhid(val) = attr? {
8656                return Ok(val);
8657            }
8658        }
8659        Err(ErrorContext::new_missing(
8660            "LinkinfoBrportAttrs",
8661            "BackupNhid",
8662            self.orig_loc,
8663            self.buf.as_ptr() as usize,
8664        ))
8665    }
8666}
8667impl LinkinfoBrportAttrs<'_> {
8668    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoBrportAttrs<'a> {
8669        IterableLinkinfoBrportAttrs::with_loc(buf, buf.as_ptr() as usize)
8670    }
8671    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8672        let res = match r#type {
8673            1u16 => "State",
8674            2u16 => "Priority",
8675            3u16 => "Cost",
8676            4u16 => "Mode",
8677            5u16 => "Guard",
8678            6u16 => "Protect",
8679            7u16 => "FastLeave",
8680            8u16 => "Learning",
8681            9u16 => "UnicastFlood",
8682            10u16 => "Proxyarp",
8683            11u16 => "LearningSync",
8684            12u16 => "ProxyarpWifi",
8685            13u16 => "RootId",
8686            14u16 => "BridgeId",
8687            15u16 => "DesignatedPort",
8688            16u16 => "DesignatedCost",
8689            17u16 => "Id",
8690            18u16 => "No",
8691            19u16 => "TopologyChangeAck",
8692            20u16 => "ConfigPending",
8693            21u16 => "MessageAgeTimer",
8694            22u16 => "ForwardDelayTimer",
8695            23u16 => "HoldTimer",
8696            24u16 => "Flush",
8697            25u16 => "MulticastRouter",
8698            26u16 => "Pad",
8699            27u16 => "McastFlood",
8700            28u16 => "McastToUcast",
8701            29u16 => "VlanTunnel",
8702            30u16 => "BcastFlood",
8703            31u16 => "GroupFwdMask",
8704            32u16 => "NeighSuppress",
8705            33u16 => "Isolated",
8706            34u16 => "BackupPort",
8707            35u16 => "MrpRingOpen",
8708            36u16 => "MrpInOpen",
8709            37u16 => "McastEhtHostsLimit",
8710            38u16 => "McastEhtHostsCnt",
8711            39u16 => "Locked",
8712            40u16 => "Mab",
8713            41u16 => "McastNGroups",
8714            42u16 => "McastMaxGroups",
8715            43u16 => "NeighVlanSuppress",
8716            44u16 => "BackupNhid",
8717            _ => return None,
8718        };
8719        Some(res)
8720    }
8721}
8722#[derive(Clone, Copy, Default)]
8723pub struct IterableLinkinfoBrportAttrs<'a> {
8724    buf: &'a [u8],
8725    pos: usize,
8726    orig_loc: usize,
8727}
8728impl<'a> IterableLinkinfoBrportAttrs<'a> {
8729    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8730        Self {
8731            buf,
8732            pos: 0,
8733            orig_loc,
8734        }
8735    }
8736    pub fn get_buf(&self) -> &'a [u8] {
8737        self.buf
8738    }
8739}
8740impl<'a> Iterator for IterableLinkinfoBrportAttrs<'a> {
8741    type Item = Result<LinkinfoBrportAttrs<'a>, ErrorContext>;
8742    fn next(&mut self) -> Option<Self::Item> {
8743        let pos = self.pos;
8744        let mut r#type;
8745        loop {
8746            r#type = None;
8747            if self.buf.len() == self.pos {
8748                return None;
8749            }
8750            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
8751                break;
8752            };
8753            r#type = Some(header.r#type);
8754            let res = match header.r#type {
8755                1u16 => LinkinfoBrportAttrs::State({
8756                    let res = parse_u8(next);
8757                    let Some(val) = res else { break };
8758                    val
8759                }),
8760                2u16 => LinkinfoBrportAttrs::Priority({
8761                    let res = parse_u16(next);
8762                    let Some(val) = res else { break };
8763                    val
8764                }),
8765                3u16 => LinkinfoBrportAttrs::Cost({
8766                    let res = parse_u32(next);
8767                    let Some(val) = res else { break };
8768                    val
8769                }),
8770                4u16 => LinkinfoBrportAttrs::Mode(()),
8771                5u16 => LinkinfoBrportAttrs::Guard(()),
8772                6u16 => LinkinfoBrportAttrs::Protect(()),
8773                7u16 => LinkinfoBrportAttrs::FastLeave(()),
8774                8u16 => LinkinfoBrportAttrs::Learning(()),
8775                9u16 => LinkinfoBrportAttrs::UnicastFlood(()),
8776                10u16 => LinkinfoBrportAttrs::Proxyarp(()),
8777                11u16 => LinkinfoBrportAttrs::LearningSync(()),
8778                12u16 => LinkinfoBrportAttrs::ProxyarpWifi(()),
8779                13u16 => LinkinfoBrportAttrs::RootId({
8780                    let res = PushIflaBridgeId::new_from_slice(next);
8781                    let Some(val) = res else { break };
8782                    val
8783                }),
8784                14u16 => LinkinfoBrportAttrs::BridgeId({
8785                    let res = PushIflaBridgeId::new_from_slice(next);
8786                    let Some(val) = res else { break };
8787                    val
8788                }),
8789                15u16 => LinkinfoBrportAttrs::DesignatedPort({
8790                    let res = parse_u16(next);
8791                    let Some(val) = res else { break };
8792                    val
8793                }),
8794                16u16 => LinkinfoBrportAttrs::DesignatedCost({
8795                    let res = parse_u16(next);
8796                    let Some(val) = res else { break };
8797                    val
8798                }),
8799                17u16 => LinkinfoBrportAttrs::Id({
8800                    let res = parse_u16(next);
8801                    let Some(val) = res else { break };
8802                    val
8803                }),
8804                18u16 => LinkinfoBrportAttrs::No({
8805                    let res = parse_u16(next);
8806                    let Some(val) = res else { break };
8807                    val
8808                }),
8809                19u16 => LinkinfoBrportAttrs::TopologyChangeAck({
8810                    let res = parse_u8(next);
8811                    let Some(val) = res else { break };
8812                    val
8813                }),
8814                20u16 => LinkinfoBrportAttrs::ConfigPending({
8815                    let res = parse_u8(next);
8816                    let Some(val) = res else { break };
8817                    val
8818                }),
8819                21u16 => LinkinfoBrportAttrs::MessageAgeTimer({
8820                    let res = parse_u64(next);
8821                    let Some(val) = res else { break };
8822                    val
8823                }),
8824                22u16 => LinkinfoBrportAttrs::ForwardDelayTimer({
8825                    let res = parse_u64(next);
8826                    let Some(val) = res else { break };
8827                    val
8828                }),
8829                23u16 => LinkinfoBrportAttrs::HoldTimer({
8830                    let res = parse_u64(next);
8831                    let Some(val) = res else { break };
8832                    val
8833                }),
8834                24u16 => LinkinfoBrportAttrs::Flush(()),
8835                25u16 => LinkinfoBrportAttrs::MulticastRouter({
8836                    let res = parse_u8(next);
8837                    let Some(val) = res else { break };
8838                    val
8839                }),
8840                26u16 => LinkinfoBrportAttrs::Pad({
8841                    let res = Some(next);
8842                    let Some(val) = res else { break };
8843                    val
8844                }),
8845                27u16 => LinkinfoBrportAttrs::McastFlood(()),
8846                28u16 => LinkinfoBrportAttrs::McastToUcast(()),
8847                29u16 => LinkinfoBrportAttrs::VlanTunnel(()),
8848                30u16 => LinkinfoBrportAttrs::BcastFlood(()),
8849                31u16 => LinkinfoBrportAttrs::GroupFwdMask({
8850                    let res = parse_u16(next);
8851                    let Some(val) = res else { break };
8852                    val
8853                }),
8854                32u16 => LinkinfoBrportAttrs::NeighSuppress(()),
8855                33u16 => LinkinfoBrportAttrs::Isolated(()),
8856                34u16 => LinkinfoBrportAttrs::BackupPort({
8857                    let res = parse_u32(next);
8858                    let Some(val) = res else { break };
8859                    val
8860                }),
8861                35u16 => LinkinfoBrportAttrs::MrpRingOpen(()),
8862                36u16 => LinkinfoBrportAttrs::MrpInOpen(()),
8863                37u16 => LinkinfoBrportAttrs::McastEhtHostsLimit({
8864                    let res = parse_u32(next);
8865                    let Some(val) = res else { break };
8866                    val
8867                }),
8868                38u16 => LinkinfoBrportAttrs::McastEhtHostsCnt({
8869                    let res = parse_u32(next);
8870                    let Some(val) = res else { break };
8871                    val
8872                }),
8873                39u16 => LinkinfoBrportAttrs::Locked(()),
8874                40u16 => LinkinfoBrportAttrs::Mab(()),
8875                41u16 => LinkinfoBrportAttrs::McastNGroups({
8876                    let res = parse_u32(next);
8877                    let Some(val) = res else { break };
8878                    val
8879                }),
8880                42u16 => LinkinfoBrportAttrs::McastMaxGroups({
8881                    let res = parse_u32(next);
8882                    let Some(val) = res else { break };
8883                    val
8884                }),
8885                43u16 => LinkinfoBrportAttrs::NeighVlanSuppress(()),
8886                44u16 => LinkinfoBrportAttrs::BackupNhid({
8887                    let res = parse_u32(next);
8888                    let Some(val) = res else { break };
8889                    val
8890                }),
8891                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
8892                n => continue,
8893            };
8894            return Some(Ok(res));
8895        }
8896        Some(Err(ErrorContext::new(
8897            "LinkinfoBrportAttrs",
8898            r#type.and_then(|t| LinkinfoBrportAttrs::attr_from_type(t)),
8899            self.orig_loc,
8900            self.buf.as_ptr().wrapping_add(pos) as usize,
8901        )))
8902    }
8903}
8904impl<'a> std::fmt::Debug for IterableLinkinfoBrportAttrs<'_> {
8905    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8906        let mut fmt = f.debug_struct("LinkinfoBrportAttrs");
8907        for attr in self.clone() {
8908            let attr = match attr {
8909                Ok(a) => a,
8910                Err(err) => {
8911                    fmt.finish()?;
8912                    f.write_str("Err(")?;
8913                    err.fmt(f)?;
8914                    return f.write_str(")");
8915                }
8916            };
8917            match attr {
8918                LinkinfoBrportAttrs::State(val) => fmt.field("State", &val),
8919                LinkinfoBrportAttrs::Priority(val) => fmt.field("Priority", &val),
8920                LinkinfoBrportAttrs::Cost(val) => fmt.field("Cost", &val),
8921                LinkinfoBrportAttrs::Mode(val) => fmt.field("Mode", &val),
8922                LinkinfoBrportAttrs::Guard(val) => fmt.field("Guard", &val),
8923                LinkinfoBrportAttrs::Protect(val) => fmt.field("Protect", &val),
8924                LinkinfoBrportAttrs::FastLeave(val) => fmt.field("FastLeave", &val),
8925                LinkinfoBrportAttrs::Learning(val) => fmt.field("Learning", &val),
8926                LinkinfoBrportAttrs::UnicastFlood(val) => fmt.field("UnicastFlood", &val),
8927                LinkinfoBrportAttrs::Proxyarp(val) => fmt.field("Proxyarp", &val),
8928                LinkinfoBrportAttrs::LearningSync(val) => fmt.field("LearningSync", &val),
8929                LinkinfoBrportAttrs::ProxyarpWifi(val) => fmt.field("ProxyarpWifi", &val),
8930                LinkinfoBrportAttrs::RootId(val) => fmt.field("RootId", &val),
8931                LinkinfoBrportAttrs::BridgeId(val) => fmt.field("BridgeId", &val),
8932                LinkinfoBrportAttrs::DesignatedPort(val) => fmt.field("DesignatedPort", &val),
8933                LinkinfoBrportAttrs::DesignatedCost(val) => fmt.field("DesignatedCost", &val),
8934                LinkinfoBrportAttrs::Id(val) => fmt.field("Id", &val),
8935                LinkinfoBrportAttrs::No(val) => fmt.field("No", &val),
8936                LinkinfoBrportAttrs::TopologyChangeAck(val) => fmt.field("TopologyChangeAck", &val),
8937                LinkinfoBrportAttrs::ConfigPending(val) => fmt.field("ConfigPending", &val),
8938                LinkinfoBrportAttrs::MessageAgeTimer(val) => fmt.field("MessageAgeTimer", &val),
8939                LinkinfoBrportAttrs::ForwardDelayTimer(val) => fmt.field("ForwardDelayTimer", &val),
8940                LinkinfoBrportAttrs::HoldTimer(val) => fmt.field("HoldTimer", &val),
8941                LinkinfoBrportAttrs::Flush(val) => fmt.field("Flush", &val),
8942                LinkinfoBrportAttrs::MulticastRouter(val) => fmt.field("MulticastRouter", &val),
8943                LinkinfoBrportAttrs::Pad(val) => fmt.field("Pad", &val),
8944                LinkinfoBrportAttrs::McastFlood(val) => fmt.field("McastFlood", &val),
8945                LinkinfoBrportAttrs::McastToUcast(val) => fmt.field("McastToUcast", &val),
8946                LinkinfoBrportAttrs::VlanTunnel(val) => fmt.field("VlanTunnel", &val),
8947                LinkinfoBrportAttrs::BcastFlood(val) => fmt.field("BcastFlood", &val),
8948                LinkinfoBrportAttrs::GroupFwdMask(val) => fmt.field("GroupFwdMask", &val),
8949                LinkinfoBrportAttrs::NeighSuppress(val) => fmt.field("NeighSuppress", &val),
8950                LinkinfoBrportAttrs::Isolated(val) => fmt.field("Isolated", &val),
8951                LinkinfoBrportAttrs::BackupPort(val) => fmt.field("BackupPort", &val),
8952                LinkinfoBrportAttrs::MrpRingOpen(val) => fmt.field("MrpRingOpen", &val),
8953                LinkinfoBrportAttrs::MrpInOpen(val) => fmt.field("MrpInOpen", &val),
8954                LinkinfoBrportAttrs::McastEhtHostsLimit(val) => {
8955                    fmt.field("McastEhtHostsLimit", &val)
8956                }
8957                LinkinfoBrportAttrs::McastEhtHostsCnt(val) => fmt.field("McastEhtHostsCnt", &val),
8958                LinkinfoBrportAttrs::Locked(val) => fmt.field("Locked", &val),
8959                LinkinfoBrportAttrs::Mab(val) => fmt.field("Mab", &val),
8960                LinkinfoBrportAttrs::McastNGroups(val) => fmt.field("McastNGroups", &val),
8961                LinkinfoBrportAttrs::McastMaxGroups(val) => fmt.field("McastMaxGroups", &val),
8962                LinkinfoBrportAttrs::NeighVlanSuppress(val) => fmt.field("NeighVlanSuppress", &val),
8963                LinkinfoBrportAttrs::BackupNhid(val) => fmt.field("BackupNhid", &val),
8964            };
8965        }
8966        fmt.finish()
8967    }
8968}
8969impl IterableLinkinfoBrportAttrs<'_> {
8970    pub fn lookup_attr(
8971        &self,
8972        offset: usize,
8973        missing_type: Option<u16>,
8974    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8975        let mut stack = Vec::new();
8976        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8977        if cur == offset {
8978            stack.push(("LinkinfoBrportAttrs", offset));
8979            return (
8980                stack,
8981                missing_type.and_then(|t| LinkinfoBrportAttrs::attr_from_type(t)),
8982            );
8983        }
8984        if cur > offset || cur + self.buf.len() < offset {
8985            return (stack, None);
8986        }
8987        let mut attrs = self.clone();
8988        let mut last_off = cur + attrs.pos;
8989        while let Some(attr) = attrs.next() {
8990            let Ok(attr) = attr else { break };
8991            match attr {
8992                LinkinfoBrportAttrs::State(val) => {
8993                    if last_off == offset {
8994                        stack.push(("State", last_off));
8995                        break;
8996                    }
8997                }
8998                LinkinfoBrportAttrs::Priority(val) => {
8999                    if last_off == offset {
9000                        stack.push(("Priority", last_off));
9001                        break;
9002                    }
9003                }
9004                LinkinfoBrportAttrs::Cost(val) => {
9005                    if last_off == offset {
9006                        stack.push(("Cost", last_off));
9007                        break;
9008                    }
9009                }
9010                LinkinfoBrportAttrs::Mode(val) => {
9011                    if last_off == offset {
9012                        stack.push(("Mode", last_off));
9013                        break;
9014                    }
9015                }
9016                LinkinfoBrportAttrs::Guard(val) => {
9017                    if last_off == offset {
9018                        stack.push(("Guard", last_off));
9019                        break;
9020                    }
9021                }
9022                LinkinfoBrportAttrs::Protect(val) => {
9023                    if last_off == offset {
9024                        stack.push(("Protect", last_off));
9025                        break;
9026                    }
9027                }
9028                LinkinfoBrportAttrs::FastLeave(val) => {
9029                    if last_off == offset {
9030                        stack.push(("FastLeave", last_off));
9031                        break;
9032                    }
9033                }
9034                LinkinfoBrportAttrs::Learning(val) => {
9035                    if last_off == offset {
9036                        stack.push(("Learning", last_off));
9037                        break;
9038                    }
9039                }
9040                LinkinfoBrportAttrs::UnicastFlood(val) => {
9041                    if last_off == offset {
9042                        stack.push(("UnicastFlood", last_off));
9043                        break;
9044                    }
9045                }
9046                LinkinfoBrportAttrs::Proxyarp(val) => {
9047                    if last_off == offset {
9048                        stack.push(("Proxyarp", last_off));
9049                        break;
9050                    }
9051                }
9052                LinkinfoBrportAttrs::LearningSync(val) => {
9053                    if last_off == offset {
9054                        stack.push(("LearningSync", last_off));
9055                        break;
9056                    }
9057                }
9058                LinkinfoBrportAttrs::ProxyarpWifi(val) => {
9059                    if last_off == offset {
9060                        stack.push(("ProxyarpWifi", last_off));
9061                        break;
9062                    }
9063                }
9064                LinkinfoBrportAttrs::RootId(val) => {
9065                    if last_off == offset {
9066                        stack.push(("RootId", last_off));
9067                        break;
9068                    }
9069                }
9070                LinkinfoBrportAttrs::BridgeId(val) => {
9071                    if last_off == offset {
9072                        stack.push(("BridgeId", last_off));
9073                        break;
9074                    }
9075                }
9076                LinkinfoBrportAttrs::DesignatedPort(val) => {
9077                    if last_off == offset {
9078                        stack.push(("DesignatedPort", last_off));
9079                        break;
9080                    }
9081                }
9082                LinkinfoBrportAttrs::DesignatedCost(val) => {
9083                    if last_off == offset {
9084                        stack.push(("DesignatedCost", last_off));
9085                        break;
9086                    }
9087                }
9088                LinkinfoBrportAttrs::Id(val) => {
9089                    if last_off == offset {
9090                        stack.push(("Id", last_off));
9091                        break;
9092                    }
9093                }
9094                LinkinfoBrportAttrs::No(val) => {
9095                    if last_off == offset {
9096                        stack.push(("No", last_off));
9097                        break;
9098                    }
9099                }
9100                LinkinfoBrportAttrs::TopologyChangeAck(val) => {
9101                    if last_off == offset {
9102                        stack.push(("TopologyChangeAck", last_off));
9103                        break;
9104                    }
9105                }
9106                LinkinfoBrportAttrs::ConfigPending(val) => {
9107                    if last_off == offset {
9108                        stack.push(("ConfigPending", last_off));
9109                        break;
9110                    }
9111                }
9112                LinkinfoBrportAttrs::MessageAgeTimer(val) => {
9113                    if last_off == offset {
9114                        stack.push(("MessageAgeTimer", last_off));
9115                        break;
9116                    }
9117                }
9118                LinkinfoBrportAttrs::ForwardDelayTimer(val) => {
9119                    if last_off == offset {
9120                        stack.push(("ForwardDelayTimer", last_off));
9121                        break;
9122                    }
9123                }
9124                LinkinfoBrportAttrs::HoldTimer(val) => {
9125                    if last_off == offset {
9126                        stack.push(("HoldTimer", last_off));
9127                        break;
9128                    }
9129                }
9130                LinkinfoBrportAttrs::Flush(val) => {
9131                    if last_off == offset {
9132                        stack.push(("Flush", last_off));
9133                        break;
9134                    }
9135                }
9136                LinkinfoBrportAttrs::MulticastRouter(val) => {
9137                    if last_off == offset {
9138                        stack.push(("MulticastRouter", last_off));
9139                        break;
9140                    }
9141                }
9142                LinkinfoBrportAttrs::Pad(val) => {
9143                    if last_off == offset {
9144                        stack.push(("Pad", last_off));
9145                        break;
9146                    }
9147                }
9148                LinkinfoBrportAttrs::McastFlood(val) => {
9149                    if last_off == offset {
9150                        stack.push(("McastFlood", last_off));
9151                        break;
9152                    }
9153                }
9154                LinkinfoBrportAttrs::McastToUcast(val) => {
9155                    if last_off == offset {
9156                        stack.push(("McastToUcast", last_off));
9157                        break;
9158                    }
9159                }
9160                LinkinfoBrportAttrs::VlanTunnel(val) => {
9161                    if last_off == offset {
9162                        stack.push(("VlanTunnel", last_off));
9163                        break;
9164                    }
9165                }
9166                LinkinfoBrportAttrs::BcastFlood(val) => {
9167                    if last_off == offset {
9168                        stack.push(("BcastFlood", last_off));
9169                        break;
9170                    }
9171                }
9172                LinkinfoBrportAttrs::GroupFwdMask(val) => {
9173                    if last_off == offset {
9174                        stack.push(("GroupFwdMask", last_off));
9175                        break;
9176                    }
9177                }
9178                LinkinfoBrportAttrs::NeighSuppress(val) => {
9179                    if last_off == offset {
9180                        stack.push(("NeighSuppress", last_off));
9181                        break;
9182                    }
9183                }
9184                LinkinfoBrportAttrs::Isolated(val) => {
9185                    if last_off == offset {
9186                        stack.push(("Isolated", last_off));
9187                        break;
9188                    }
9189                }
9190                LinkinfoBrportAttrs::BackupPort(val) => {
9191                    if last_off == offset {
9192                        stack.push(("BackupPort", last_off));
9193                        break;
9194                    }
9195                }
9196                LinkinfoBrportAttrs::MrpRingOpen(val) => {
9197                    if last_off == offset {
9198                        stack.push(("MrpRingOpen", last_off));
9199                        break;
9200                    }
9201                }
9202                LinkinfoBrportAttrs::MrpInOpen(val) => {
9203                    if last_off == offset {
9204                        stack.push(("MrpInOpen", last_off));
9205                        break;
9206                    }
9207                }
9208                LinkinfoBrportAttrs::McastEhtHostsLimit(val) => {
9209                    if last_off == offset {
9210                        stack.push(("McastEhtHostsLimit", last_off));
9211                        break;
9212                    }
9213                }
9214                LinkinfoBrportAttrs::McastEhtHostsCnt(val) => {
9215                    if last_off == offset {
9216                        stack.push(("McastEhtHostsCnt", last_off));
9217                        break;
9218                    }
9219                }
9220                LinkinfoBrportAttrs::Locked(val) => {
9221                    if last_off == offset {
9222                        stack.push(("Locked", last_off));
9223                        break;
9224                    }
9225                }
9226                LinkinfoBrportAttrs::Mab(val) => {
9227                    if last_off == offset {
9228                        stack.push(("Mab", last_off));
9229                        break;
9230                    }
9231                }
9232                LinkinfoBrportAttrs::McastNGroups(val) => {
9233                    if last_off == offset {
9234                        stack.push(("McastNGroups", last_off));
9235                        break;
9236                    }
9237                }
9238                LinkinfoBrportAttrs::McastMaxGroups(val) => {
9239                    if last_off == offset {
9240                        stack.push(("McastMaxGroups", last_off));
9241                        break;
9242                    }
9243                }
9244                LinkinfoBrportAttrs::NeighVlanSuppress(val) => {
9245                    if last_off == offset {
9246                        stack.push(("NeighVlanSuppress", last_off));
9247                        break;
9248                    }
9249                }
9250                LinkinfoBrportAttrs::BackupNhid(val) => {
9251                    if last_off == offset {
9252                        stack.push(("BackupNhid", last_off));
9253                        break;
9254                    }
9255                }
9256                _ => {}
9257            };
9258            last_off = cur + attrs.pos;
9259        }
9260        if !stack.is_empty() {
9261            stack.push(("LinkinfoBrportAttrs", cur));
9262        }
9263        (stack, None)
9264    }
9265}
9266#[derive(Clone)]
9267pub enum LinkinfoGreAttrs<'a> {
9268    Link(u32),
9269    Iflags(u16),
9270    Oflags(u16),
9271    Ikey(u32),
9272    Okey(u32),
9273    Local(&'a [u8]),
9274    Remote(&'a [u8]),
9275    Ttl(u8),
9276    Tos(u8),
9277    Pmtudisc(u8),
9278    EncapLimit(u8),
9279    Flowinfo(u32),
9280    Flags(u32),
9281    EncapType(u16),
9282    EncapFlags(u16),
9283    EncapSport(u16),
9284    EncapDport(u16),
9285    CollectMetadata(()),
9286    IgnoreDf(u8),
9287    Fwmark(u32),
9288    ErspanIndex(u32),
9289    ErspanVer(u8),
9290    ErspanDir(u8),
9291    ErspanHwid(u16),
9292}
9293impl<'a> IterableLinkinfoGreAttrs<'a> {
9294    pub fn get_link(&self) -> Result<u32, ErrorContext> {
9295        let mut iter = self.clone();
9296        iter.pos = 0;
9297        for attr in iter {
9298            if let LinkinfoGreAttrs::Link(val) = attr? {
9299                return Ok(val);
9300            }
9301        }
9302        Err(ErrorContext::new_missing(
9303            "LinkinfoGreAttrs",
9304            "Link",
9305            self.orig_loc,
9306            self.buf.as_ptr() as usize,
9307        ))
9308    }
9309    pub fn get_iflags(&self) -> Result<u16, ErrorContext> {
9310        let mut iter = self.clone();
9311        iter.pos = 0;
9312        for attr in iter {
9313            if let LinkinfoGreAttrs::Iflags(val) = attr? {
9314                return Ok(val);
9315            }
9316        }
9317        Err(ErrorContext::new_missing(
9318            "LinkinfoGreAttrs",
9319            "Iflags",
9320            self.orig_loc,
9321            self.buf.as_ptr() as usize,
9322        ))
9323    }
9324    pub fn get_oflags(&self) -> Result<u16, ErrorContext> {
9325        let mut iter = self.clone();
9326        iter.pos = 0;
9327        for attr in iter {
9328            if let LinkinfoGreAttrs::Oflags(val) = attr? {
9329                return Ok(val);
9330            }
9331        }
9332        Err(ErrorContext::new_missing(
9333            "LinkinfoGreAttrs",
9334            "Oflags",
9335            self.orig_loc,
9336            self.buf.as_ptr() as usize,
9337        ))
9338    }
9339    pub fn get_ikey(&self) -> Result<u32, ErrorContext> {
9340        let mut iter = self.clone();
9341        iter.pos = 0;
9342        for attr in iter {
9343            if let LinkinfoGreAttrs::Ikey(val) = attr? {
9344                return Ok(val);
9345            }
9346        }
9347        Err(ErrorContext::new_missing(
9348            "LinkinfoGreAttrs",
9349            "Ikey",
9350            self.orig_loc,
9351            self.buf.as_ptr() as usize,
9352        ))
9353    }
9354    pub fn get_okey(&self) -> Result<u32, ErrorContext> {
9355        let mut iter = self.clone();
9356        iter.pos = 0;
9357        for attr in iter {
9358            if let LinkinfoGreAttrs::Okey(val) = attr? {
9359                return Ok(val);
9360            }
9361        }
9362        Err(ErrorContext::new_missing(
9363            "LinkinfoGreAttrs",
9364            "Okey",
9365            self.orig_loc,
9366            self.buf.as_ptr() as usize,
9367        ))
9368    }
9369    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
9370        let mut iter = self.clone();
9371        iter.pos = 0;
9372        for attr in iter {
9373            if let LinkinfoGreAttrs::Local(val) = attr? {
9374                return Ok(val);
9375            }
9376        }
9377        Err(ErrorContext::new_missing(
9378            "LinkinfoGreAttrs",
9379            "Local",
9380            self.orig_loc,
9381            self.buf.as_ptr() as usize,
9382        ))
9383    }
9384    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
9385        let mut iter = self.clone();
9386        iter.pos = 0;
9387        for attr in iter {
9388            if let LinkinfoGreAttrs::Remote(val) = attr? {
9389                return Ok(val);
9390            }
9391        }
9392        Err(ErrorContext::new_missing(
9393            "LinkinfoGreAttrs",
9394            "Remote",
9395            self.orig_loc,
9396            self.buf.as_ptr() as usize,
9397        ))
9398    }
9399    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
9400        let mut iter = self.clone();
9401        iter.pos = 0;
9402        for attr in iter {
9403            if let LinkinfoGreAttrs::Ttl(val) = attr? {
9404                return Ok(val);
9405            }
9406        }
9407        Err(ErrorContext::new_missing(
9408            "LinkinfoGreAttrs",
9409            "Ttl",
9410            self.orig_loc,
9411            self.buf.as_ptr() as usize,
9412        ))
9413    }
9414    pub fn get_tos(&self) -> Result<u8, ErrorContext> {
9415        let mut iter = self.clone();
9416        iter.pos = 0;
9417        for attr in iter {
9418            if let LinkinfoGreAttrs::Tos(val) = attr? {
9419                return Ok(val);
9420            }
9421        }
9422        Err(ErrorContext::new_missing(
9423            "LinkinfoGreAttrs",
9424            "Tos",
9425            self.orig_loc,
9426            self.buf.as_ptr() as usize,
9427        ))
9428    }
9429    pub fn get_pmtudisc(&self) -> Result<u8, ErrorContext> {
9430        let mut iter = self.clone();
9431        iter.pos = 0;
9432        for attr in iter {
9433            if let LinkinfoGreAttrs::Pmtudisc(val) = attr? {
9434                return Ok(val);
9435            }
9436        }
9437        Err(ErrorContext::new_missing(
9438            "LinkinfoGreAttrs",
9439            "Pmtudisc",
9440            self.orig_loc,
9441            self.buf.as_ptr() as usize,
9442        ))
9443    }
9444    pub fn get_encap_limit(&self) -> Result<u8, ErrorContext> {
9445        let mut iter = self.clone();
9446        iter.pos = 0;
9447        for attr in iter {
9448            if let LinkinfoGreAttrs::EncapLimit(val) = attr? {
9449                return Ok(val);
9450            }
9451        }
9452        Err(ErrorContext::new_missing(
9453            "LinkinfoGreAttrs",
9454            "EncapLimit",
9455            self.orig_loc,
9456            self.buf.as_ptr() as usize,
9457        ))
9458    }
9459    pub fn get_flowinfo(&self) -> Result<u32, ErrorContext> {
9460        let mut iter = self.clone();
9461        iter.pos = 0;
9462        for attr in iter {
9463            if let LinkinfoGreAttrs::Flowinfo(val) = attr? {
9464                return Ok(val);
9465            }
9466        }
9467        Err(ErrorContext::new_missing(
9468            "LinkinfoGreAttrs",
9469            "Flowinfo",
9470            self.orig_loc,
9471            self.buf.as_ptr() as usize,
9472        ))
9473    }
9474    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
9475        let mut iter = self.clone();
9476        iter.pos = 0;
9477        for attr in iter {
9478            if let LinkinfoGreAttrs::Flags(val) = attr? {
9479                return Ok(val);
9480            }
9481        }
9482        Err(ErrorContext::new_missing(
9483            "LinkinfoGreAttrs",
9484            "Flags",
9485            self.orig_loc,
9486            self.buf.as_ptr() as usize,
9487        ))
9488    }
9489    pub fn get_encap_type(&self) -> Result<u16, ErrorContext> {
9490        let mut iter = self.clone();
9491        iter.pos = 0;
9492        for attr in iter {
9493            if let LinkinfoGreAttrs::EncapType(val) = attr? {
9494                return Ok(val);
9495            }
9496        }
9497        Err(ErrorContext::new_missing(
9498            "LinkinfoGreAttrs",
9499            "EncapType",
9500            self.orig_loc,
9501            self.buf.as_ptr() as usize,
9502        ))
9503    }
9504    pub fn get_encap_flags(&self) -> Result<u16, ErrorContext> {
9505        let mut iter = self.clone();
9506        iter.pos = 0;
9507        for attr in iter {
9508            if let LinkinfoGreAttrs::EncapFlags(val) = attr? {
9509                return Ok(val);
9510            }
9511        }
9512        Err(ErrorContext::new_missing(
9513            "LinkinfoGreAttrs",
9514            "EncapFlags",
9515            self.orig_loc,
9516            self.buf.as_ptr() as usize,
9517        ))
9518    }
9519    pub fn get_encap_sport(&self) -> Result<u16, ErrorContext> {
9520        let mut iter = self.clone();
9521        iter.pos = 0;
9522        for attr in iter {
9523            if let LinkinfoGreAttrs::EncapSport(val) = attr? {
9524                return Ok(val);
9525            }
9526        }
9527        Err(ErrorContext::new_missing(
9528            "LinkinfoGreAttrs",
9529            "EncapSport",
9530            self.orig_loc,
9531            self.buf.as_ptr() as usize,
9532        ))
9533    }
9534    pub fn get_encap_dport(&self) -> Result<u16, ErrorContext> {
9535        let mut iter = self.clone();
9536        iter.pos = 0;
9537        for attr in iter {
9538            if let LinkinfoGreAttrs::EncapDport(val) = attr? {
9539                return Ok(val);
9540            }
9541        }
9542        Err(ErrorContext::new_missing(
9543            "LinkinfoGreAttrs",
9544            "EncapDport",
9545            self.orig_loc,
9546            self.buf.as_ptr() as usize,
9547        ))
9548    }
9549    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
9550        let mut iter = self.clone();
9551        iter.pos = 0;
9552        for attr in iter {
9553            if let LinkinfoGreAttrs::CollectMetadata(val) = attr? {
9554                return Ok(val);
9555            }
9556        }
9557        Err(ErrorContext::new_missing(
9558            "LinkinfoGreAttrs",
9559            "CollectMetadata",
9560            self.orig_loc,
9561            self.buf.as_ptr() as usize,
9562        ))
9563    }
9564    pub fn get_ignore_df(&self) -> Result<u8, ErrorContext> {
9565        let mut iter = self.clone();
9566        iter.pos = 0;
9567        for attr in iter {
9568            if let LinkinfoGreAttrs::IgnoreDf(val) = attr? {
9569                return Ok(val);
9570            }
9571        }
9572        Err(ErrorContext::new_missing(
9573            "LinkinfoGreAttrs",
9574            "IgnoreDf",
9575            self.orig_loc,
9576            self.buf.as_ptr() as usize,
9577        ))
9578    }
9579    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
9580        let mut iter = self.clone();
9581        iter.pos = 0;
9582        for attr in iter {
9583            if let LinkinfoGreAttrs::Fwmark(val) = attr? {
9584                return Ok(val);
9585            }
9586        }
9587        Err(ErrorContext::new_missing(
9588            "LinkinfoGreAttrs",
9589            "Fwmark",
9590            self.orig_loc,
9591            self.buf.as_ptr() as usize,
9592        ))
9593    }
9594    pub fn get_erspan_index(&self) -> Result<u32, ErrorContext> {
9595        let mut iter = self.clone();
9596        iter.pos = 0;
9597        for attr in iter {
9598            if let LinkinfoGreAttrs::ErspanIndex(val) = attr? {
9599                return Ok(val);
9600            }
9601        }
9602        Err(ErrorContext::new_missing(
9603            "LinkinfoGreAttrs",
9604            "ErspanIndex",
9605            self.orig_loc,
9606            self.buf.as_ptr() as usize,
9607        ))
9608    }
9609    pub fn get_erspan_ver(&self) -> Result<u8, ErrorContext> {
9610        let mut iter = self.clone();
9611        iter.pos = 0;
9612        for attr in iter {
9613            if let LinkinfoGreAttrs::ErspanVer(val) = attr? {
9614                return Ok(val);
9615            }
9616        }
9617        Err(ErrorContext::new_missing(
9618            "LinkinfoGreAttrs",
9619            "ErspanVer",
9620            self.orig_loc,
9621            self.buf.as_ptr() as usize,
9622        ))
9623    }
9624    pub fn get_erspan_dir(&self) -> Result<u8, ErrorContext> {
9625        let mut iter = self.clone();
9626        iter.pos = 0;
9627        for attr in iter {
9628            if let LinkinfoGreAttrs::ErspanDir(val) = attr? {
9629                return Ok(val);
9630            }
9631        }
9632        Err(ErrorContext::new_missing(
9633            "LinkinfoGreAttrs",
9634            "ErspanDir",
9635            self.orig_loc,
9636            self.buf.as_ptr() as usize,
9637        ))
9638    }
9639    pub fn get_erspan_hwid(&self) -> Result<u16, ErrorContext> {
9640        let mut iter = self.clone();
9641        iter.pos = 0;
9642        for attr in iter {
9643            if let LinkinfoGreAttrs::ErspanHwid(val) = attr? {
9644                return Ok(val);
9645            }
9646        }
9647        Err(ErrorContext::new_missing(
9648            "LinkinfoGreAttrs",
9649            "ErspanHwid",
9650            self.orig_loc,
9651            self.buf.as_ptr() as usize,
9652        ))
9653    }
9654}
9655impl LinkinfoGreAttrs<'_> {
9656    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoGreAttrs<'a> {
9657        IterableLinkinfoGreAttrs::with_loc(buf, buf.as_ptr() as usize)
9658    }
9659    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9660        let res = match r#type {
9661            1u16 => "Link",
9662            2u16 => "Iflags",
9663            3u16 => "Oflags",
9664            4u16 => "Ikey",
9665            5u16 => "Okey",
9666            6u16 => "Local",
9667            7u16 => "Remote",
9668            8u16 => "Ttl",
9669            9u16 => "Tos",
9670            10u16 => "Pmtudisc",
9671            11u16 => "EncapLimit",
9672            12u16 => "Flowinfo",
9673            13u16 => "Flags",
9674            14u16 => "EncapType",
9675            15u16 => "EncapFlags",
9676            16u16 => "EncapSport",
9677            17u16 => "EncapDport",
9678            18u16 => "CollectMetadata",
9679            19u16 => "IgnoreDf",
9680            20u16 => "Fwmark",
9681            21u16 => "ErspanIndex",
9682            22u16 => "ErspanVer",
9683            23u16 => "ErspanDir",
9684            24u16 => "ErspanHwid",
9685            _ => return None,
9686        };
9687        Some(res)
9688    }
9689}
9690#[derive(Clone, Copy, Default)]
9691pub struct IterableLinkinfoGreAttrs<'a> {
9692    buf: &'a [u8],
9693    pos: usize,
9694    orig_loc: usize,
9695}
9696impl<'a> IterableLinkinfoGreAttrs<'a> {
9697    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9698        Self {
9699            buf,
9700            pos: 0,
9701            orig_loc,
9702        }
9703    }
9704    pub fn get_buf(&self) -> &'a [u8] {
9705        self.buf
9706    }
9707}
9708impl<'a> Iterator for IterableLinkinfoGreAttrs<'a> {
9709    type Item = Result<LinkinfoGreAttrs<'a>, ErrorContext>;
9710    fn next(&mut self) -> Option<Self::Item> {
9711        let pos = self.pos;
9712        let mut r#type;
9713        loop {
9714            r#type = None;
9715            if self.buf.len() == self.pos {
9716                return None;
9717            }
9718            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
9719                break;
9720            };
9721            r#type = Some(header.r#type);
9722            let res = match header.r#type {
9723                1u16 => LinkinfoGreAttrs::Link({
9724                    let res = parse_u32(next);
9725                    let Some(val) = res else { break };
9726                    val
9727                }),
9728                2u16 => LinkinfoGreAttrs::Iflags({
9729                    let res = parse_be_u16(next);
9730                    let Some(val) = res else { break };
9731                    val
9732                }),
9733                3u16 => LinkinfoGreAttrs::Oflags({
9734                    let res = parse_be_u16(next);
9735                    let Some(val) = res else { break };
9736                    val
9737                }),
9738                4u16 => LinkinfoGreAttrs::Ikey({
9739                    let res = parse_be_u32(next);
9740                    let Some(val) = res else { break };
9741                    val
9742                }),
9743                5u16 => LinkinfoGreAttrs::Okey({
9744                    let res = parse_be_u32(next);
9745                    let Some(val) = res else { break };
9746                    val
9747                }),
9748                6u16 => LinkinfoGreAttrs::Local({
9749                    let res = Some(next);
9750                    let Some(val) = res else { break };
9751                    val
9752                }),
9753                7u16 => LinkinfoGreAttrs::Remote({
9754                    let res = Some(next);
9755                    let Some(val) = res else { break };
9756                    val
9757                }),
9758                8u16 => LinkinfoGreAttrs::Ttl({
9759                    let res = parse_u8(next);
9760                    let Some(val) = res else { break };
9761                    val
9762                }),
9763                9u16 => LinkinfoGreAttrs::Tos({
9764                    let res = parse_u8(next);
9765                    let Some(val) = res else { break };
9766                    val
9767                }),
9768                10u16 => LinkinfoGreAttrs::Pmtudisc({
9769                    let res = parse_u8(next);
9770                    let Some(val) = res else { break };
9771                    val
9772                }),
9773                11u16 => LinkinfoGreAttrs::EncapLimit({
9774                    let res = parse_u8(next);
9775                    let Some(val) = res else { break };
9776                    val
9777                }),
9778                12u16 => LinkinfoGreAttrs::Flowinfo({
9779                    let res = parse_be_u32(next);
9780                    let Some(val) = res else { break };
9781                    val
9782                }),
9783                13u16 => LinkinfoGreAttrs::Flags({
9784                    let res = parse_u32(next);
9785                    let Some(val) = res else { break };
9786                    val
9787                }),
9788                14u16 => LinkinfoGreAttrs::EncapType({
9789                    let res = parse_u16(next);
9790                    let Some(val) = res else { break };
9791                    val
9792                }),
9793                15u16 => LinkinfoGreAttrs::EncapFlags({
9794                    let res = parse_u16(next);
9795                    let Some(val) = res else { break };
9796                    val
9797                }),
9798                16u16 => LinkinfoGreAttrs::EncapSport({
9799                    let res = parse_be_u16(next);
9800                    let Some(val) = res else { break };
9801                    val
9802                }),
9803                17u16 => LinkinfoGreAttrs::EncapDport({
9804                    let res = parse_be_u16(next);
9805                    let Some(val) = res else { break };
9806                    val
9807                }),
9808                18u16 => LinkinfoGreAttrs::CollectMetadata(()),
9809                19u16 => LinkinfoGreAttrs::IgnoreDf({
9810                    let res = parse_u8(next);
9811                    let Some(val) = res else { break };
9812                    val
9813                }),
9814                20u16 => LinkinfoGreAttrs::Fwmark({
9815                    let res = parse_u32(next);
9816                    let Some(val) = res else { break };
9817                    val
9818                }),
9819                21u16 => LinkinfoGreAttrs::ErspanIndex({
9820                    let res = parse_u32(next);
9821                    let Some(val) = res else { break };
9822                    val
9823                }),
9824                22u16 => LinkinfoGreAttrs::ErspanVer({
9825                    let res = parse_u8(next);
9826                    let Some(val) = res else { break };
9827                    val
9828                }),
9829                23u16 => LinkinfoGreAttrs::ErspanDir({
9830                    let res = parse_u8(next);
9831                    let Some(val) = res else { break };
9832                    val
9833                }),
9834                24u16 => LinkinfoGreAttrs::ErspanHwid({
9835                    let res = parse_u16(next);
9836                    let Some(val) = res else { break };
9837                    val
9838                }),
9839                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
9840                n => continue,
9841            };
9842            return Some(Ok(res));
9843        }
9844        Some(Err(ErrorContext::new(
9845            "LinkinfoGreAttrs",
9846            r#type.and_then(|t| LinkinfoGreAttrs::attr_from_type(t)),
9847            self.orig_loc,
9848            self.buf.as_ptr().wrapping_add(pos) as usize,
9849        )))
9850    }
9851}
9852impl<'a> std::fmt::Debug for IterableLinkinfoGreAttrs<'_> {
9853    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9854        let mut fmt = f.debug_struct("LinkinfoGreAttrs");
9855        for attr in self.clone() {
9856            let attr = match attr {
9857                Ok(a) => a,
9858                Err(err) => {
9859                    fmt.finish()?;
9860                    f.write_str("Err(")?;
9861                    err.fmt(f)?;
9862                    return f.write_str(")");
9863                }
9864            };
9865            match attr {
9866                LinkinfoGreAttrs::Link(val) => fmt.field("Link", &val),
9867                LinkinfoGreAttrs::Iflags(val) => fmt.field("Iflags", &val),
9868                LinkinfoGreAttrs::Oflags(val) => fmt.field("Oflags", &val),
9869                LinkinfoGreAttrs::Ikey(val) => fmt.field("Ikey", &val),
9870                LinkinfoGreAttrs::Okey(val) => fmt.field("Okey", &val),
9871                LinkinfoGreAttrs::Local(val) => fmt.field("Local", &val),
9872                LinkinfoGreAttrs::Remote(val) => fmt.field("Remote", &val),
9873                LinkinfoGreAttrs::Ttl(val) => fmt.field("Ttl", &val),
9874                LinkinfoGreAttrs::Tos(val) => fmt.field("Tos", &val),
9875                LinkinfoGreAttrs::Pmtudisc(val) => fmt.field("Pmtudisc", &val),
9876                LinkinfoGreAttrs::EncapLimit(val) => fmt.field("EncapLimit", &val),
9877                LinkinfoGreAttrs::Flowinfo(val) => fmt.field("Flowinfo", &val),
9878                LinkinfoGreAttrs::Flags(val) => fmt.field("Flags", &val),
9879                LinkinfoGreAttrs::EncapType(val) => fmt.field("EncapType", &val),
9880                LinkinfoGreAttrs::EncapFlags(val) => fmt.field("EncapFlags", &val),
9881                LinkinfoGreAttrs::EncapSport(val) => fmt.field("EncapSport", &val),
9882                LinkinfoGreAttrs::EncapDport(val) => fmt.field("EncapDport", &val),
9883                LinkinfoGreAttrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
9884                LinkinfoGreAttrs::IgnoreDf(val) => fmt.field("IgnoreDf", &val),
9885                LinkinfoGreAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
9886                LinkinfoGreAttrs::ErspanIndex(val) => fmt.field("ErspanIndex", &val),
9887                LinkinfoGreAttrs::ErspanVer(val) => fmt.field("ErspanVer", &val),
9888                LinkinfoGreAttrs::ErspanDir(val) => fmt.field("ErspanDir", &val),
9889                LinkinfoGreAttrs::ErspanHwid(val) => fmt.field("ErspanHwid", &val),
9890            };
9891        }
9892        fmt.finish()
9893    }
9894}
9895impl IterableLinkinfoGreAttrs<'_> {
9896    pub fn lookup_attr(
9897        &self,
9898        offset: usize,
9899        missing_type: Option<u16>,
9900    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9901        let mut stack = Vec::new();
9902        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9903        if cur == offset {
9904            stack.push(("LinkinfoGreAttrs", offset));
9905            return (
9906                stack,
9907                missing_type.and_then(|t| LinkinfoGreAttrs::attr_from_type(t)),
9908            );
9909        }
9910        if cur > offset || cur + self.buf.len() < offset {
9911            return (stack, None);
9912        }
9913        let mut attrs = self.clone();
9914        let mut last_off = cur + attrs.pos;
9915        while let Some(attr) = attrs.next() {
9916            let Ok(attr) = attr else { break };
9917            match attr {
9918                LinkinfoGreAttrs::Link(val) => {
9919                    if last_off == offset {
9920                        stack.push(("Link", last_off));
9921                        break;
9922                    }
9923                }
9924                LinkinfoGreAttrs::Iflags(val) => {
9925                    if last_off == offset {
9926                        stack.push(("Iflags", last_off));
9927                        break;
9928                    }
9929                }
9930                LinkinfoGreAttrs::Oflags(val) => {
9931                    if last_off == offset {
9932                        stack.push(("Oflags", last_off));
9933                        break;
9934                    }
9935                }
9936                LinkinfoGreAttrs::Ikey(val) => {
9937                    if last_off == offset {
9938                        stack.push(("Ikey", last_off));
9939                        break;
9940                    }
9941                }
9942                LinkinfoGreAttrs::Okey(val) => {
9943                    if last_off == offset {
9944                        stack.push(("Okey", last_off));
9945                        break;
9946                    }
9947                }
9948                LinkinfoGreAttrs::Local(val) => {
9949                    if last_off == offset {
9950                        stack.push(("Local", last_off));
9951                        break;
9952                    }
9953                }
9954                LinkinfoGreAttrs::Remote(val) => {
9955                    if last_off == offset {
9956                        stack.push(("Remote", last_off));
9957                        break;
9958                    }
9959                }
9960                LinkinfoGreAttrs::Ttl(val) => {
9961                    if last_off == offset {
9962                        stack.push(("Ttl", last_off));
9963                        break;
9964                    }
9965                }
9966                LinkinfoGreAttrs::Tos(val) => {
9967                    if last_off == offset {
9968                        stack.push(("Tos", last_off));
9969                        break;
9970                    }
9971                }
9972                LinkinfoGreAttrs::Pmtudisc(val) => {
9973                    if last_off == offset {
9974                        stack.push(("Pmtudisc", last_off));
9975                        break;
9976                    }
9977                }
9978                LinkinfoGreAttrs::EncapLimit(val) => {
9979                    if last_off == offset {
9980                        stack.push(("EncapLimit", last_off));
9981                        break;
9982                    }
9983                }
9984                LinkinfoGreAttrs::Flowinfo(val) => {
9985                    if last_off == offset {
9986                        stack.push(("Flowinfo", last_off));
9987                        break;
9988                    }
9989                }
9990                LinkinfoGreAttrs::Flags(val) => {
9991                    if last_off == offset {
9992                        stack.push(("Flags", last_off));
9993                        break;
9994                    }
9995                }
9996                LinkinfoGreAttrs::EncapType(val) => {
9997                    if last_off == offset {
9998                        stack.push(("EncapType", last_off));
9999                        break;
10000                    }
10001                }
10002                LinkinfoGreAttrs::EncapFlags(val) => {
10003                    if last_off == offset {
10004                        stack.push(("EncapFlags", last_off));
10005                        break;
10006                    }
10007                }
10008                LinkinfoGreAttrs::EncapSport(val) => {
10009                    if last_off == offset {
10010                        stack.push(("EncapSport", last_off));
10011                        break;
10012                    }
10013                }
10014                LinkinfoGreAttrs::EncapDport(val) => {
10015                    if last_off == offset {
10016                        stack.push(("EncapDport", last_off));
10017                        break;
10018                    }
10019                }
10020                LinkinfoGreAttrs::CollectMetadata(val) => {
10021                    if last_off == offset {
10022                        stack.push(("CollectMetadata", last_off));
10023                        break;
10024                    }
10025                }
10026                LinkinfoGreAttrs::IgnoreDf(val) => {
10027                    if last_off == offset {
10028                        stack.push(("IgnoreDf", last_off));
10029                        break;
10030                    }
10031                }
10032                LinkinfoGreAttrs::Fwmark(val) => {
10033                    if last_off == offset {
10034                        stack.push(("Fwmark", last_off));
10035                        break;
10036                    }
10037                }
10038                LinkinfoGreAttrs::ErspanIndex(val) => {
10039                    if last_off == offset {
10040                        stack.push(("ErspanIndex", last_off));
10041                        break;
10042                    }
10043                }
10044                LinkinfoGreAttrs::ErspanVer(val) => {
10045                    if last_off == offset {
10046                        stack.push(("ErspanVer", last_off));
10047                        break;
10048                    }
10049                }
10050                LinkinfoGreAttrs::ErspanDir(val) => {
10051                    if last_off == offset {
10052                        stack.push(("ErspanDir", last_off));
10053                        break;
10054                    }
10055                }
10056                LinkinfoGreAttrs::ErspanHwid(val) => {
10057                    if last_off == offset {
10058                        stack.push(("ErspanHwid", last_off));
10059                        break;
10060                    }
10061                }
10062                _ => {}
10063            };
10064            last_off = cur + attrs.pos;
10065        }
10066        if !stack.is_empty() {
10067            stack.push(("LinkinfoGreAttrs", cur));
10068        }
10069        (stack, None)
10070    }
10071}
10072#[derive(Clone)]
10073pub enum LinkinfoGre6Attrs<'a> {
10074    Link(u32),
10075    Iflags(u16),
10076    Oflags(u16),
10077    Ikey(u32),
10078    Okey(u32),
10079    Local(&'a [u8]),
10080    Remote(&'a [u8]),
10081    Ttl(u8),
10082    EncapLimit(u8),
10083    Flowinfo(u32),
10084    Flags(u32),
10085    EncapType(u16),
10086    EncapFlags(u16),
10087    EncapSport(u16),
10088    EncapDport(u16),
10089    CollectMetadata(()),
10090    Fwmark(u32),
10091    ErspanIndex(u32),
10092    ErspanVer(u8),
10093    ErspanDir(u8),
10094    ErspanHwid(u16),
10095}
10096impl<'a> IterableLinkinfoGre6Attrs<'a> {
10097    pub fn get_link(&self) -> Result<u32, ErrorContext> {
10098        let mut iter = self.clone();
10099        iter.pos = 0;
10100        for attr in iter {
10101            if let LinkinfoGre6Attrs::Link(val) = attr? {
10102                return Ok(val);
10103            }
10104        }
10105        Err(ErrorContext::new_missing(
10106            "LinkinfoGre6Attrs",
10107            "Link",
10108            self.orig_loc,
10109            self.buf.as_ptr() as usize,
10110        ))
10111    }
10112    pub fn get_iflags(&self) -> Result<u16, ErrorContext> {
10113        let mut iter = self.clone();
10114        iter.pos = 0;
10115        for attr in iter {
10116            if let LinkinfoGre6Attrs::Iflags(val) = attr? {
10117                return Ok(val);
10118            }
10119        }
10120        Err(ErrorContext::new_missing(
10121            "LinkinfoGre6Attrs",
10122            "Iflags",
10123            self.orig_loc,
10124            self.buf.as_ptr() as usize,
10125        ))
10126    }
10127    pub fn get_oflags(&self) -> Result<u16, ErrorContext> {
10128        let mut iter = self.clone();
10129        iter.pos = 0;
10130        for attr in iter {
10131            if let LinkinfoGre6Attrs::Oflags(val) = attr? {
10132                return Ok(val);
10133            }
10134        }
10135        Err(ErrorContext::new_missing(
10136            "LinkinfoGre6Attrs",
10137            "Oflags",
10138            self.orig_loc,
10139            self.buf.as_ptr() as usize,
10140        ))
10141    }
10142    pub fn get_ikey(&self) -> Result<u32, ErrorContext> {
10143        let mut iter = self.clone();
10144        iter.pos = 0;
10145        for attr in iter {
10146            if let LinkinfoGre6Attrs::Ikey(val) = attr? {
10147                return Ok(val);
10148            }
10149        }
10150        Err(ErrorContext::new_missing(
10151            "LinkinfoGre6Attrs",
10152            "Ikey",
10153            self.orig_loc,
10154            self.buf.as_ptr() as usize,
10155        ))
10156    }
10157    pub fn get_okey(&self) -> Result<u32, ErrorContext> {
10158        let mut iter = self.clone();
10159        iter.pos = 0;
10160        for attr in iter {
10161            if let LinkinfoGre6Attrs::Okey(val) = attr? {
10162                return Ok(val);
10163            }
10164        }
10165        Err(ErrorContext::new_missing(
10166            "LinkinfoGre6Attrs",
10167            "Okey",
10168            self.orig_loc,
10169            self.buf.as_ptr() as usize,
10170        ))
10171    }
10172    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
10173        let mut iter = self.clone();
10174        iter.pos = 0;
10175        for attr in iter {
10176            if let LinkinfoGre6Attrs::Local(val) = attr? {
10177                return Ok(val);
10178            }
10179        }
10180        Err(ErrorContext::new_missing(
10181            "LinkinfoGre6Attrs",
10182            "Local",
10183            self.orig_loc,
10184            self.buf.as_ptr() as usize,
10185        ))
10186    }
10187    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
10188        let mut iter = self.clone();
10189        iter.pos = 0;
10190        for attr in iter {
10191            if let LinkinfoGre6Attrs::Remote(val) = attr? {
10192                return Ok(val);
10193            }
10194        }
10195        Err(ErrorContext::new_missing(
10196            "LinkinfoGre6Attrs",
10197            "Remote",
10198            self.orig_loc,
10199            self.buf.as_ptr() as usize,
10200        ))
10201    }
10202    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
10203        let mut iter = self.clone();
10204        iter.pos = 0;
10205        for attr in iter {
10206            if let LinkinfoGre6Attrs::Ttl(val) = attr? {
10207                return Ok(val);
10208            }
10209        }
10210        Err(ErrorContext::new_missing(
10211            "LinkinfoGre6Attrs",
10212            "Ttl",
10213            self.orig_loc,
10214            self.buf.as_ptr() as usize,
10215        ))
10216    }
10217    pub fn get_encap_limit(&self) -> Result<u8, ErrorContext> {
10218        let mut iter = self.clone();
10219        iter.pos = 0;
10220        for attr in iter {
10221            if let LinkinfoGre6Attrs::EncapLimit(val) = attr? {
10222                return Ok(val);
10223            }
10224        }
10225        Err(ErrorContext::new_missing(
10226            "LinkinfoGre6Attrs",
10227            "EncapLimit",
10228            self.orig_loc,
10229            self.buf.as_ptr() as usize,
10230        ))
10231    }
10232    pub fn get_flowinfo(&self) -> Result<u32, ErrorContext> {
10233        let mut iter = self.clone();
10234        iter.pos = 0;
10235        for attr in iter {
10236            if let LinkinfoGre6Attrs::Flowinfo(val) = attr? {
10237                return Ok(val);
10238            }
10239        }
10240        Err(ErrorContext::new_missing(
10241            "LinkinfoGre6Attrs",
10242            "Flowinfo",
10243            self.orig_loc,
10244            self.buf.as_ptr() as usize,
10245        ))
10246    }
10247    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
10248        let mut iter = self.clone();
10249        iter.pos = 0;
10250        for attr in iter {
10251            if let LinkinfoGre6Attrs::Flags(val) = attr? {
10252                return Ok(val);
10253            }
10254        }
10255        Err(ErrorContext::new_missing(
10256            "LinkinfoGre6Attrs",
10257            "Flags",
10258            self.orig_loc,
10259            self.buf.as_ptr() as usize,
10260        ))
10261    }
10262    pub fn get_encap_type(&self) -> Result<u16, ErrorContext> {
10263        let mut iter = self.clone();
10264        iter.pos = 0;
10265        for attr in iter {
10266            if let LinkinfoGre6Attrs::EncapType(val) = attr? {
10267                return Ok(val);
10268            }
10269        }
10270        Err(ErrorContext::new_missing(
10271            "LinkinfoGre6Attrs",
10272            "EncapType",
10273            self.orig_loc,
10274            self.buf.as_ptr() as usize,
10275        ))
10276    }
10277    pub fn get_encap_flags(&self) -> Result<u16, ErrorContext> {
10278        let mut iter = self.clone();
10279        iter.pos = 0;
10280        for attr in iter {
10281            if let LinkinfoGre6Attrs::EncapFlags(val) = attr? {
10282                return Ok(val);
10283            }
10284        }
10285        Err(ErrorContext::new_missing(
10286            "LinkinfoGre6Attrs",
10287            "EncapFlags",
10288            self.orig_loc,
10289            self.buf.as_ptr() as usize,
10290        ))
10291    }
10292    pub fn get_encap_sport(&self) -> Result<u16, ErrorContext> {
10293        let mut iter = self.clone();
10294        iter.pos = 0;
10295        for attr in iter {
10296            if let LinkinfoGre6Attrs::EncapSport(val) = attr? {
10297                return Ok(val);
10298            }
10299        }
10300        Err(ErrorContext::new_missing(
10301            "LinkinfoGre6Attrs",
10302            "EncapSport",
10303            self.orig_loc,
10304            self.buf.as_ptr() as usize,
10305        ))
10306    }
10307    pub fn get_encap_dport(&self) -> Result<u16, ErrorContext> {
10308        let mut iter = self.clone();
10309        iter.pos = 0;
10310        for attr in iter {
10311            if let LinkinfoGre6Attrs::EncapDport(val) = attr? {
10312                return Ok(val);
10313            }
10314        }
10315        Err(ErrorContext::new_missing(
10316            "LinkinfoGre6Attrs",
10317            "EncapDport",
10318            self.orig_loc,
10319            self.buf.as_ptr() as usize,
10320        ))
10321    }
10322    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
10323        let mut iter = self.clone();
10324        iter.pos = 0;
10325        for attr in iter {
10326            if let LinkinfoGre6Attrs::CollectMetadata(val) = attr? {
10327                return Ok(val);
10328            }
10329        }
10330        Err(ErrorContext::new_missing(
10331            "LinkinfoGre6Attrs",
10332            "CollectMetadata",
10333            self.orig_loc,
10334            self.buf.as_ptr() as usize,
10335        ))
10336    }
10337    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
10338        let mut iter = self.clone();
10339        iter.pos = 0;
10340        for attr in iter {
10341            if let LinkinfoGre6Attrs::Fwmark(val) = attr? {
10342                return Ok(val);
10343            }
10344        }
10345        Err(ErrorContext::new_missing(
10346            "LinkinfoGre6Attrs",
10347            "Fwmark",
10348            self.orig_loc,
10349            self.buf.as_ptr() as usize,
10350        ))
10351    }
10352    pub fn get_erspan_index(&self) -> Result<u32, ErrorContext> {
10353        let mut iter = self.clone();
10354        iter.pos = 0;
10355        for attr in iter {
10356            if let LinkinfoGre6Attrs::ErspanIndex(val) = attr? {
10357                return Ok(val);
10358            }
10359        }
10360        Err(ErrorContext::new_missing(
10361            "LinkinfoGre6Attrs",
10362            "ErspanIndex",
10363            self.orig_loc,
10364            self.buf.as_ptr() as usize,
10365        ))
10366    }
10367    pub fn get_erspan_ver(&self) -> Result<u8, ErrorContext> {
10368        let mut iter = self.clone();
10369        iter.pos = 0;
10370        for attr in iter {
10371            if let LinkinfoGre6Attrs::ErspanVer(val) = attr? {
10372                return Ok(val);
10373            }
10374        }
10375        Err(ErrorContext::new_missing(
10376            "LinkinfoGre6Attrs",
10377            "ErspanVer",
10378            self.orig_loc,
10379            self.buf.as_ptr() as usize,
10380        ))
10381    }
10382    pub fn get_erspan_dir(&self) -> Result<u8, ErrorContext> {
10383        let mut iter = self.clone();
10384        iter.pos = 0;
10385        for attr in iter {
10386            if let LinkinfoGre6Attrs::ErspanDir(val) = attr? {
10387                return Ok(val);
10388            }
10389        }
10390        Err(ErrorContext::new_missing(
10391            "LinkinfoGre6Attrs",
10392            "ErspanDir",
10393            self.orig_loc,
10394            self.buf.as_ptr() as usize,
10395        ))
10396    }
10397    pub fn get_erspan_hwid(&self) -> Result<u16, ErrorContext> {
10398        let mut iter = self.clone();
10399        iter.pos = 0;
10400        for attr in iter {
10401            if let LinkinfoGre6Attrs::ErspanHwid(val) = attr? {
10402                return Ok(val);
10403            }
10404        }
10405        Err(ErrorContext::new_missing(
10406            "LinkinfoGre6Attrs",
10407            "ErspanHwid",
10408            self.orig_loc,
10409            self.buf.as_ptr() as usize,
10410        ))
10411    }
10412}
10413impl LinkinfoGre6Attrs<'_> {
10414    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoGre6Attrs<'a> {
10415        IterableLinkinfoGre6Attrs::with_loc(buf, buf.as_ptr() as usize)
10416    }
10417    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10418        LinkinfoGreAttrs::attr_from_type(r#type)
10419    }
10420}
10421#[derive(Clone, Copy, Default)]
10422pub struct IterableLinkinfoGre6Attrs<'a> {
10423    buf: &'a [u8],
10424    pos: usize,
10425    orig_loc: usize,
10426}
10427impl<'a> IterableLinkinfoGre6Attrs<'a> {
10428    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10429        Self {
10430            buf,
10431            pos: 0,
10432            orig_loc,
10433        }
10434    }
10435    pub fn get_buf(&self) -> &'a [u8] {
10436        self.buf
10437    }
10438}
10439impl<'a> Iterator for IterableLinkinfoGre6Attrs<'a> {
10440    type Item = Result<LinkinfoGre6Attrs<'a>, ErrorContext>;
10441    fn next(&mut self) -> Option<Self::Item> {
10442        let pos = self.pos;
10443        let mut r#type;
10444        loop {
10445            r#type = None;
10446            if self.buf.len() == self.pos {
10447                return None;
10448            }
10449            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
10450                break;
10451            };
10452            r#type = Some(header.r#type);
10453            let res = match header.r#type {
10454                1u16 => LinkinfoGre6Attrs::Link({
10455                    let res = parse_u32(next);
10456                    let Some(val) = res else { break };
10457                    val
10458                }),
10459                2u16 => LinkinfoGre6Attrs::Iflags({
10460                    let res = parse_be_u16(next);
10461                    let Some(val) = res else { break };
10462                    val
10463                }),
10464                3u16 => LinkinfoGre6Attrs::Oflags({
10465                    let res = parse_be_u16(next);
10466                    let Some(val) = res else { break };
10467                    val
10468                }),
10469                4u16 => LinkinfoGre6Attrs::Ikey({
10470                    let res = parse_be_u32(next);
10471                    let Some(val) = res else { break };
10472                    val
10473                }),
10474                5u16 => LinkinfoGre6Attrs::Okey({
10475                    let res = parse_be_u32(next);
10476                    let Some(val) = res else { break };
10477                    val
10478                }),
10479                6u16 => LinkinfoGre6Attrs::Local({
10480                    let res = Some(next);
10481                    let Some(val) = res else { break };
10482                    val
10483                }),
10484                7u16 => LinkinfoGre6Attrs::Remote({
10485                    let res = Some(next);
10486                    let Some(val) = res else { break };
10487                    val
10488                }),
10489                8u16 => LinkinfoGre6Attrs::Ttl({
10490                    let res = parse_u8(next);
10491                    let Some(val) = res else { break };
10492                    val
10493                }),
10494                11u16 => LinkinfoGre6Attrs::EncapLimit({
10495                    let res = parse_u8(next);
10496                    let Some(val) = res else { break };
10497                    val
10498                }),
10499                12u16 => LinkinfoGre6Attrs::Flowinfo({
10500                    let res = parse_be_u32(next);
10501                    let Some(val) = res else { break };
10502                    val
10503                }),
10504                13u16 => LinkinfoGre6Attrs::Flags({
10505                    let res = parse_u32(next);
10506                    let Some(val) = res else { break };
10507                    val
10508                }),
10509                14u16 => LinkinfoGre6Attrs::EncapType({
10510                    let res = parse_u16(next);
10511                    let Some(val) = res else { break };
10512                    val
10513                }),
10514                15u16 => LinkinfoGre6Attrs::EncapFlags({
10515                    let res = parse_u16(next);
10516                    let Some(val) = res else { break };
10517                    val
10518                }),
10519                16u16 => LinkinfoGre6Attrs::EncapSport({
10520                    let res = parse_be_u16(next);
10521                    let Some(val) = res else { break };
10522                    val
10523                }),
10524                17u16 => LinkinfoGre6Attrs::EncapDport({
10525                    let res = parse_be_u16(next);
10526                    let Some(val) = res else { break };
10527                    val
10528                }),
10529                18u16 => LinkinfoGre6Attrs::CollectMetadata(()),
10530                20u16 => LinkinfoGre6Attrs::Fwmark({
10531                    let res = parse_u32(next);
10532                    let Some(val) = res else { break };
10533                    val
10534                }),
10535                21u16 => LinkinfoGre6Attrs::ErspanIndex({
10536                    let res = parse_u32(next);
10537                    let Some(val) = res else { break };
10538                    val
10539                }),
10540                22u16 => LinkinfoGre6Attrs::ErspanVer({
10541                    let res = parse_u8(next);
10542                    let Some(val) = res else { break };
10543                    val
10544                }),
10545                23u16 => LinkinfoGre6Attrs::ErspanDir({
10546                    let res = parse_u8(next);
10547                    let Some(val) = res else { break };
10548                    val
10549                }),
10550                24u16 => LinkinfoGre6Attrs::ErspanHwid({
10551                    let res = parse_u16(next);
10552                    let Some(val) = res else { break };
10553                    val
10554                }),
10555                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
10556                n => continue,
10557            };
10558            return Some(Ok(res));
10559        }
10560        Some(Err(ErrorContext::new(
10561            "LinkinfoGre6Attrs",
10562            r#type.and_then(|t| LinkinfoGre6Attrs::attr_from_type(t)),
10563            self.orig_loc,
10564            self.buf.as_ptr().wrapping_add(pos) as usize,
10565        )))
10566    }
10567}
10568impl<'a> std::fmt::Debug for IterableLinkinfoGre6Attrs<'_> {
10569    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10570        let mut fmt = f.debug_struct("LinkinfoGre6Attrs");
10571        for attr in self.clone() {
10572            let attr = match attr {
10573                Ok(a) => a,
10574                Err(err) => {
10575                    fmt.finish()?;
10576                    f.write_str("Err(")?;
10577                    err.fmt(f)?;
10578                    return f.write_str(")");
10579                }
10580            };
10581            match attr {
10582                LinkinfoGre6Attrs::Link(val) => fmt.field("Link", &val),
10583                LinkinfoGre6Attrs::Iflags(val) => fmt.field("Iflags", &val),
10584                LinkinfoGre6Attrs::Oflags(val) => fmt.field("Oflags", &val),
10585                LinkinfoGre6Attrs::Ikey(val) => fmt.field("Ikey", &val),
10586                LinkinfoGre6Attrs::Okey(val) => fmt.field("Okey", &val),
10587                LinkinfoGre6Attrs::Local(val) => fmt.field("Local", &val),
10588                LinkinfoGre6Attrs::Remote(val) => fmt.field("Remote", &val),
10589                LinkinfoGre6Attrs::Ttl(val) => fmt.field("Ttl", &val),
10590                LinkinfoGre6Attrs::EncapLimit(val) => fmt.field("EncapLimit", &val),
10591                LinkinfoGre6Attrs::Flowinfo(val) => fmt.field("Flowinfo", &val),
10592                LinkinfoGre6Attrs::Flags(val) => fmt.field("Flags", &val),
10593                LinkinfoGre6Attrs::EncapType(val) => fmt.field("EncapType", &val),
10594                LinkinfoGre6Attrs::EncapFlags(val) => fmt.field("EncapFlags", &val),
10595                LinkinfoGre6Attrs::EncapSport(val) => fmt.field("EncapSport", &val),
10596                LinkinfoGre6Attrs::EncapDport(val) => fmt.field("EncapDport", &val),
10597                LinkinfoGre6Attrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
10598                LinkinfoGre6Attrs::Fwmark(val) => fmt.field("Fwmark", &val),
10599                LinkinfoGre6Attrs::ErspanIndex(val) => fmt.field("ErspanIndex", &val),
10600                LinkinfoGre6Attrs::ErspanVer(val) => fmt.field("ErspanVer", &val),
10601                LinkinfoGre6Attrs::ErspanDir(val) => fmt.field("ErspanDir", &val),
10602                LinkinfoGre6Attrs::ErspanHwid(val) => fmt.field("ErspanHwid", &val),
10603            };
10604        }
10605        fmt.finish()
10606    }
10607}
10608impl IterableLinkinfoGre6Attrs<'_> {
10609    pub fn lookup_attr(
10610        &self,
10611        offset: usize,
10612        missing_type: Option<u16>,
10613    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10614        let mut stack = Vec::new();
10615        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10616        if cur == offset {
10617            stack.push(("LinkinfoGre6Attrs", offset));
10618            return (
10619                stack,
10620                missing_type.and_then(|t| LinkinfoGre6Attrs::attr_from_type(t)),
10621            );
10622        }
10623        if cur > offset || cur + self.buf.len() < offset {
10624            return (stack, None);
10625        }
10626        let mut attrs = self.clone();
10627        let mut last_off = cur + attrs.pos;
10628        while let Some(attr) = attrs.next() {
10629            let Ok(attr) = attr else { break };
10630            match attr {
10631                LinkinfoGre6Attrs::Link(val) => {
10632                    if last_off == offset {
10633                        stack.push(("Link", last_off));
10634                        break;
10635                    }
10636                }
10637                LinkinfoGre6Attrs::Iflags(val) => {
10638                    if last_off == offset {
10639                        stack.push(("Iflags", last_off));
10640                        break;
10641                    }
10642                }
10643                LinkinfoGre6Attrs::Oflags(val) => {
10644                    if last_off == offset {
10645                        stack.push(("Oflags", last_off));
10646                        break;
10647                    }
10648                }
10649                LinkinfoGre6Attrs::Ikey(val) => {
10650                    if last_off == offset {
10651                        stack.push(("Ikey", last_off));
10652                        break;
10653                    }
10654                }
10655                LinkinfoGre6Attrs::Okey(val) => {
10656                    if last_off == offset {
10657                        stack.push(("Okey", last_off));
10658                        break;
10659                    }
10660                }
10661                LinkinfoGre6Attrs::Local(val) => {
10662                    if last_off == offset {
10663                        stack.push(("Local", last_off));
10664                        break;
10665                    }
10666                }
10667                LinkinfoGre6Attrs::Remote(val) => {
10668                    if last_off == offset {
10669                        stack.push(("Remote", last_off));
10670                        break;
10671                    }
10672                }
10673                LinkinfoGre6Attrs::Ttl(val) => {
10674                    if last_off == offset {
10675                        stack.push(("Ttl", last_off));
10676                        break;
10677                    }
10678                }
10679                LinkinfoGre6Attrs::EncapLimit(val) => {
10680                    if last_off == offset {
10681                        stack.push(("EncapLimit", last_off));
10682                        break;
10683                    }
10684                }
10685                LinkinfoGre6Attrs::Flowinfo(val) => {
10686                    if last_off == offset {
10687                        stack.push(("Flowinfo", last_off));
10688                        break;
10689                    }
10690                }
10691                LinkinfoGre6Attrs::Flags(val) => {
10692                    if last_off == offset {
10693                        stack.push(("Flags", last_off));
10694                        break;
10695                    }
10696                }
10697                LinkinfoGre6Attrs::EncapType(val) => {
10698                    if last_off == offset {
10699                        stack.push(("EncapType", last_off));
10700                        break;
10701                    }
10702                }
10703                LinkinfoGre6Attrs::EncapFlags(val) => {
10704                    if last_off == offset {
10705                        stack.push(("EncapFlags", last_off));
10706                        break;
10707                    }
10708                }
10709                LinkinfoGre6Attrs::EncapSport(val) => {
10710                    if last_off == offset {
10711                        stack.push(("EncapSport", last_off));
10712                        break;
10713                    }
10714                }
10715                LinkinfoGre6Attrs::EncapDport(val) => {
10716                    if last_off == offset {
10717                        stack.push(("EncapDport", last_off));
10718                        break;
10719                    }
10720                }
10721                LinkinfoGre6Attrs::CollectMetadata(val) => {
10722                    if last_off == offset {
10723                        stack.push(("CollectMetadata", last_off));
10724                        break;
10725                    }
10726                }
10727                LinkinfoGre6Attrs::Fwmark(val) => {
10728                    if last_off == offset {
10729                        stack.push(("Fwmark", last_off));
10730                        break;
10731                    }
10732                }
10733                LinkinfoGre6Attrs::ErspanIndex(val) => {
10734                    if last_off == offset {
10735                        stack.push(("ErspanIndex", last_off));
10736                        break;
10737                    }
10738                }
10739                LinkinfoGre6Attrs::ErspanVer(val) => {
10740                    if last_off == offset {
10741                        stack.push(("ErspanVer", last_off));
10742                        break;
10743                    }
10744                }
10745                LinkinfoGre6Attrs::ErspanDir(val) => {
10746                    if last_off == offset {
10747                        stack.push(("ErspanDir", last_off));
10748                        break;
10749                    }
10750                }
10751                LinkinfoGre6Attrs::ErspanHwid(val) => {
10752                    if last_off == offset {
10753                        stack.push(("ErspanHwid", last_off));
10754                        break;
10755                    }
10756                }
10757                _ => {}
10758            };
10759            last_off = cur + attrs.pos;
10760        }
10761        if !stack.is_empty() {
10762            stack.push(("LinkinfoGre6Attrs", cur));
10763        }
10764        (stack, None)
10765    }
10766}
10767#[derive(Clone)]
10768pub enum LinkinfoVtiAttrs<'a> {
10769    Link(u32),
10770    Ikey(u32),
10771    Okey(u32),
10772    Local(&'a [u8]),
10773    Remote(&'a [u8]),
10774    Fwmark(u32),
10775}
10776impl<'a> IterableLinkinfoVtiAttrs<'a> {
10777    pub fn get_link(&self) -> Result<u32, ErrorContext> {
10778        let mut iter = self.clone();
10779        iter.pos = 0;
10780        for attr in iter {
10781            if let LinkinfoVtiAttrs::Link(val) = attr? {
10782                return Ok(val);
10783            }
10784        }
10785        Err(ErrorContext::new_missing(
10786            "LinkinfoVtiAttrs",
10787            "Link",
10788            self.orig_loc,
10789            self.buf.as_ptr() as usize,
10790        ))
10791    }
10792    pub fn get_ikey(&self) -> Result<u32, ErrorContext> {
10793        let mut iter = self.clone();
10794        iter.pos = 0;
10795        for attr in iter {
10796            if let LinkinfoVtiAttrs::Ikey(val) = attr? {
10797                return Ok(val);
10798            }
10799        }
10800        Err(ErrorContext::new_missing(
10801            "LinkinfoVtiAttrs",
10802            "Ikey",
10803            self.orig_loc,
10804            self.buf.as_ptr() as usize,
10805        ))
10806    }
10807    pub fn get_okey(&self) -> Result<u32, ErrorContext> {
10808        let mut iter = self.clone();
10809        iter.pos = 0;
10810        for attr in iter {
10811            if let LinkinfoVtiAttrs::Okey(val) = attr? {
10812                return Ok(val);
10813            }
10814        }
10815        Err(ErrorContext::new_missing(
10816            "LinkinfoVtiAttrs",
10817            "Okey",
10818            self.orig_loc,
10819            self.buf.as_ptr() as usize,
10820        ))
10821    }
10822    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
10823        let mut iter = self.clone();
10824        iter.pos = 0;
10825        for attr in iter {
10826            if let LinkinfoVtiAttrs::Local(val) = attr? {
10827                return Ok(val);
10828            }
10829        }
10830        Err(ErrorContext::new_missing(
10831            "LinkinfoVtiAttrs",
10832            "Local",
10833            self.orig_loc,
10834            self.buf.as_ptr() as usize,
10835        ))
10836    }
10837    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
10838        let mut iter = self.clone();
10839        iter.pos = 0;
10840        for attr in iter {
10841            if let LinkinfoVtiAttrs::Remote(val) = attr? {
10842                return Ok(val);
10843            }
10844        }
10845        Err(ErrorContext::new_missing(
10846            "LinkinfoVtiAttrs",
10847            "Remote",
10848            self.orig_loc,
10849            self.buf.as_ptr() as usize,
10850        ))
10851    }
10852    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
10853        let mut iter = self.clone();
10854        iter.pos = 0;
10855        for attr in iter {
10856            if let LinkinfoVtiAttrs::Fwmark(val) = attr? {
10857                return Ok(val);
10858            }
10859        }
10860        Err(ErrorContext::new_missing(
10861            "LinkinfoVtiAttrs",
10862            "Fwmark",
10863            self.orig_loc,
10864            self.buf.as_ptr() as usize,
10865        ))
10866    }
10867}
10868impl LinkinfoVtiAttrs<'_> {
10869    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoVtiAttrs<'a> {
10870        IterableLinkinfoVtiAttrs::with_loc(buf, buf.as_ptr() as usize)
10871    }
10872    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10873        let res = match r#type {
10874            1u16 => "Link",
10875            2u16 => "Ikey",
10876            3u16 => "Okey",
10877            4u16 => "Local",
10878            5u16 => "Remote",
10879            6u16 => "Fwmark",
10880            _ => return None,
10881        };
10882        Some(res)
10883    }
10884}
10885#[derive(Clone, Copy, Default)]
10886pub struct IterableLinkinfoVtiAttrs<'a> {
10887    buf: &'a [u8],
10888    pos: usize,
10889    orig_loc: usize,
10890}
10891impl<'a> IterableLinkinfoVtiAttrs<'a> {
10892    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10893        Self {
10894            buf,
10895            pos: 0,
10896            orig_loc,
10897        }
10898    }
10899    pub fn get_buf(&self) -> &'a [u8] {
10900        self.buf
10901    }
10902}
10903impl<'a> Iterator for IterableLinkinfoVtiAttrs<'a> {
10904    type Item = Result<LinkinfoVtiAttrs<'a>, ErrorContext>;
10905    fn next(&mut self) -> Option<Self::Item> {
10906        let pos = self.pos;
10907        let mut r#type;
10908        loop {
10909            r#type = None;
10910            if self.buf.len() == self.pos {
10911                return None;
10912            }
10913            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
10914                break;
10915            };
10916            r#type = Some(header.r#type);
10917            let res = match header.r#type {
10918                1u16 => LinkinfoVtiAttrs::Link({
10919                    let res = parse_u32(next);
10920                    let Some(val) = res else { break };
10921                    val
10922                }),
10923                2u16 => LinkinfoVtiAttrs::Ikey({
10924                    let res = parse_be_u32(next);
10925                    let Some(val) = res else { break };
10926                    val
10927                }),
10928                3u16 => LinkinfoVtiAttrs::Okey({
10929                    let res = parse_be_u32(next);
10930                    let Some(val) = res else { break };
10931                    val
10932                }),
10933                4u16 => LinkinfoVtiAttrs::Local({
10934                    let res = Some(next);
10935                    let Some(val) = res else { break };
10936                    val
10937                }),
10938                5u16 => LinkinfoVtiAttrs::Remote({
10939                    let res = Some(next);
10940                    let Some(val) = res else { break };
10941                    val
10942                }),
10943                6u16 => LinkinfoVtiAttrs::Fwmark({
10944                    let res = parse_u32(next);
10945                    let Some(val) = res else { break };
10946                    val
10947                }),
10948                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
10949                n => continue,
10950            };
10951            return Some(Ok(res));
10952        }
10953        Some(Err(ErrorContext::new(
10954            "LinkinfoVtiAttrs",
10955            r#type.and_then(|t| LinkinfoVtiAttrs::attr_from_type(t)),
10956            self.orig_loc,
10957            self.buf.as_ptr().wrapping_add(pos) as usize,
10958        )))
10959    }
10960}
10961impl<'a> std::fmt::Debug for IterableLinkinfoVtiAttrs<'_> {
10962    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10963        let mut fmt = f.debug_struct("LinkinfoVtiAttrs");
10964        for attr in self.clone() {
10965            let attr = match attr {
10966                Ok(a) => a,
10967                Err(err) => {
10968                    fmt.finish()?;
10969                    f.write_str("Err(")?;
10970                    err.fmt(f)?;
10971                    return f.write_str(")");
10972                }
10973            };
10974            match attr {
10975                LinkinfoVtiAttrs::Link(val) => fmt.field("Link", &val),
10976                LinkinfoVtiAttrs::Ikey(val) => fmt.field("Ikey", &val),
10977                LinkinfoVtiAttrs::Okey(val) => fmt.field("Okey", &val),
10978                LinkinfoVtiAttrs::Local(val) => fmt.field("Local", &val),
10979                LinkinfoVtiAttrs::Remote(val) => fmt.field("Remote", &val),
10980                LinkinfoVtiAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
10981            };
10982        }
10983        fmt.finish()
10984    }
10985}
10986impl IterableLinkinfoVtiAttrs<'_> {
10987    pub fn lookup_attr(
10988        &self,
10989        offset: usize,
10990        missing_type: Option<u16>,
10991    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10992        let mut stack = Vec::new();
10993        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10994        if cur == offset {
10995            stack.push(("LinkinfoVtiAttrs", offset));
10996            return (
10997                stack,
10998                missing_type.and_then(|t| LinkinfoVtiAttrs::attr_from_type(t)),
10999            );
11000        }
11001        if cur > offset || cur + self.buf.len() < offset {
11002            return (stack, None);
11003        }
11004        let mut attrs = self.clone();
11005        let mut last_off = cur + attrs.pos;
11006        while let Some(attr) = attrs.next() {
11007            let Ok(attr) = attr else { break };
11008            match attr {
11009                LinkinfoVtiAttrs::Link(val) => {
11010                    if last_off == offset {
11011                        stack.push(("Link", last_off));
11012                        break;
11013                    }
11014                }
11015                LinkinfoVtiAttrs::Ikey(val) => {
11016                    if last_off == offset {
11017                        stack.push(("Ikey", last_off));
11018                        break;
11019                    }
11020                }
11021                LinkinfoVtiAttrs::Okey(val) => {
11022                    if last_off == offset {
11023                        stack.push(("Okey", last_off));
11024                        break;
11025                    }
11026                }
11027                LinkinfoVtiAttrs::Local(val) => {
11028                    if last_off == offset {
11029                        stack.push(("Local", last_off));
11030                        break;
11031                    }
11032                }
11033                LinkinfoVtiAttrs::Remote(val) => {
11034                    if last_off == offset {
11035                        stack.push(("Remote", last_off));
11036                        break;
11037                    }
11038                }
11039                LinkinfoVtiAttrs::Fwmark(val) => {
11040                    if last_off == offset {
11041                        stack.push(("Fwmark", last_off));
11042                        break;
11043                    }
11044                }
11045                _ => {}
11046            };
11047            last_off = cur + attrs.pos;
11048        }
11049        if !stack.is_empty() {
11050            stack.push(("LinkinfoVtiAttrs", cur));
11051        }
11052        (stack, None)
11053    }
11054}
11055#[derive(Clone)]
11056pub enum LinkinfoVti6Attrs<'a> {
11057    Link(u32),
11058    Ikey(u32),
11059    Okey(u32),
11060    Local(&'a [u8]),
11061    Remote(&'a [u8]),
11062    Fwmark(u32),
11063}
11064impl<'a> IterableLinkinfoVti6Attrs<'a> {
11065    pub fn get_link(&self) -> Result<u32, ErrorContext> {
11066        let mut iter = self.clone();
11067        iter.pos = 0;
11068        for attr in iter {
11069            if let LinkinfoVti6Attrs::Link(val) = attr? {
11070                return Ok(val);
11071            }
11072        }
11073        Err(ErrorContext::new_missing(
11074            "LinkinfoVti6Attrs",
11075            "Link",
11076            self.orig_loc,
11077            self.buf.as_ptr() as usize,
11078        ))
11079    }
11080    pub fn get_ikey(&self) -> Result<u32, ErrorContext> {
11081        let mut iter = self.clone();
11082        iter.pos = 0;
11083        for attr in iter {
11084            if let LinkinfoVti6Attrs::Ikey(val) = attr? {
11085                return Ok(val);
11086            }
11087        }
11088        Err(ErrorContext::new_missing(
11089            "LinkinfoVti6Attrs",
11090            "Ikey",
11091            self.orig_loc,
11092            self.buf.as_ptr() as usize,
11093        ))
11094    }
11095    pub fn get_okey(&self) -> Result<u32, ErrorContext> {
11096        let mut iter = self.clone();
11097        iter.pos = 0;
11098        for attr in iter {
11099            if let LinkinfoVti6Attrs::Okey(val) = attr? {
11100                return Ok(val);
11101            }
11102        }
11103        Err(ErrorContext::new_missing(
11104            "LinkinfoVti6Attrs",
11105            "Okey",
11106            self.orig_loc,
11107            self.buf.as_ptr() as usize,
11108        ))
11109    }
11110    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
11111        let mut iter = self.clone();
11112        iter.pos = 0;
11113        for attr in iter {
11114            if let LinkinfoVti6Attrs::Local(val) = attr? {
11115                return Ok(val);
11116            }
11117        }
11118        Err(ErrorContext::new_missing(
11119            "LinkinfoVti6Attrs",
11120            "Local",
11121            self.orig_loc,
11122            self.buf.as_ptr() as usize,
11123        ))
11124    }
11125    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
11126        let mut iter = self.clone();
11127        iter.pos = 0;
11128        for attr in iter {
11129            if let LinkinfoVti6Attrs::Remote(val) = attr? {
11130                return Ok(val);
11131            }
11132        }
11133        Err(ErrorContext::new_missing(
11134            "LinkinfoVti6Attrs",
11135            "Remote",
11136            self.orig_loc,
11137            self.buf.as_ptr() as usize,
11138        ))
11139    }
11140    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
11141        let mut iter = self.clone();
11142        iter.pos = 0;
11143        for attr in iter {
11144            if let LinkinfoVti6Attrs::Fwmark(val) = attr? {
11145                return Ok(val);
11146            }
11147        }
11148        Err(ErrorContext::new_missing(
11149            "LinkinfoVti6Attrs",
11150            "Fwmark",
11151            self.orig_loc,
11152            self.buf.as_ptr() as usize,
11153        ))
11154    }
11155}
11156impl LinkinfoVti6Attrs<'_> {
11157    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoVti6Attrs<'a> {
11158        IterableLinkinfoVti6Attrs::with_loc(buf, buf.as_ptr() as usize)
11159    }
11160    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11161        LinkinfoVtiAttrs::attr_from_type(r#type)
11162    }
11163}
11164#[derive(Clone, Copy, Default)]
11165pub struct IterableLinkinfoVti6Attrs<'a> {
11166    buf: &'a [u8],
11167    pos: usize,
11168    orig_loc: usize,
11169}
11170impl<'a> IterableLinkinfoVti6Attrs<'a> {
11171    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11172        Self {
11173            buf,
11174            pos: 0,
11175            orig_loc,
11176        }
11177    }
11178    pub fn get_buf(&self) -> &'a [u8] {
11179        self.buf
11180    }
11181}
11182impl<'a> Iterator for IterableLinkinfoVti6Attrs<'a> {
11183    type Item = Result<LinkinfoVti6Attrs<'a>, ErrorContext>;
11184    fn next(&mut self) -> Option<Self::Item> {
11185        let pos = self.pos;
11186        let mut r#type;
11187        loop {
11188            r#type = None;
11189            if self.buf.len() == self.pos {
11190                return None;
11191            }
11192            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11193                break;
11194            };
11195            r#type = Some(header.r#type);
11196            let res = match header.r#type {
11197                1u16 => LinkinfoVti6Attrs::Link({
11198                    let res = parse_u32(next);
11199                    let Some(val) = res else { break };
11200                    val
11201                }),
11202                2u16 => LinkinfoVti6Attrs::Ikey({
11203                    let res = parse_be_u32(next);
11204                    let Some(val) = res else { break };
11205                    val
11206                }),
11207                3u16 => LinkinfoVti6Attrs::Okey({
11208                    let res = parse_be_u32(next);
11209                    let Some(val) = res else { break };
11210                    val
11211                }),
11212                4u16 => LinkinfoVti6Attrs::Local({
11213                    let res = Some(next);
11214                    let Some(val) = res else { break };
11215                    val
11216                }),
11217                5u16 => LinkinfoVti6Attrs::Remote({
11218                    let res = Some(next);
11219                    let Some(val) = res else { break };
11220                    val
11221                }),
11222                6u16 => LinkinfoVti6Attrs::Fwmark({
11223                    let res = parse_u32(next);
11224                    let Some(val) = res else { break };
11225                    val
11226                }),
11227                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11228                n => continue,
11229            };
11230            return Some(Ok(res));
11231        }
11232        Some(Err(ErrorContext::new(
11233            "LinkinfoVti6Attrs",
11234            r#type.and_then(|t| LinkinfoVti6Attrs::attr_from_type(t)),
11235            self.orig_loc,
11236            self.buf.as_ptr().wrapping_add(pos) as usize,
11237        )))
11238    }
11239}
11240impl<'a> std::fmt::Debug for IterableLinkinfoVti6Attrs<'_> {
11241    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11242        let mut fmt = f.debug_struct("LinkinfoVti6Attrs");
11243        for attr in self.clone() {
11244            let attr = match attr {
11245                Ok(a) => a,
11246                Err(err) => {
11247                    fmt.finish()?;
11248                    f.write_str("Err(")?;
11249                    err.fmt(f)?;
11250                    return f.write_str(")");
11251                }
11252            };
11253            match attr {
11254                LinkinfoVti6Attrs::Link(val) => fmt.field("Link", &val),
11255                LinkinfoVti6Attrs::Ikey(val) => fmt.field("Ikey", &val),
11256                LinkinfoVti6Attrs::Okey(val) => fmt.field("Okey", &val),
11257                LinkinfoVti6Attrs::Local(val) => fmt.field("Local", &val),
11258                LinkinfoVti6Attrs::Remote(val) => fmt.field("Remote", &val),
11259                LinkinfoVti6Attrs::Fwmark(val) => fmt.field("Fwmark", &val),
11260            };
11261        }
11262        fmt.finish()
11263    }
11264}
11265impl IterableLinkinfoVti6Attrs<'_> {
11266    pub fn lookup_attr(
11267        &self,
11268        offset: usize,
11269        missing_type: Option<u16>,
11270    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11271        let mut stack = Vec::new();
11272        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11273        if cur == offset {
11274            stack.push(("LinkinfoVti6Attrs", offset));
11275            return (
11276                stack,
11277                missing_type.and_then(|t| LinkinfoVti6Attrs::attr_from_type(t)),
11278            );
11279        }
11280        if cur > offset || cur + self.buf.len() < offset {
11281            return (stack, None);
11282        }
11283        let mut attrs = self.clone();
11284        let mut last_off = cur + attrs.pos;
11285        while let Some(attr) = attrs.next() {
11286            let Ok(attr) = attr else { break };
11287            match attr {
11288                LinkinfoVti6Attrs::Link(val) => {
11289                    if last_off == offset {
11290                        stack.push(("Link", last_off));
11291                        break;
11292                    }
11293                }
11294                LinkinfoVti6Attrs::Ikey(val) => {
11295                    if last_off == offset {
11296                        stack.push(("Ikey", last_off));
11297                        break;
11298                    }
11299                }
11300                LinkinfoVti6Attrs::Okey(val) => {
11301                    if last_off == offset {
11302                        stack.push(("Okey", last_off));
11303                        break;
11304                    }
11305                }
11306                LinkinfoVti6Attrs::Local(val) => {
11307                    if last_off == offset {
11308                        stack.push(("Local", last_off));
11309                        break;
11310                    }
11311                }
11312                LinkinfoVti6Attrs::Remote(val) => {
11313                    if last_off == offset {
11314                        stack.push(("Remote", last_off));
11315                        break;
11316                    }
11317                }
11318                LinkinfoVti6Attrs::Fwmark(val) => {
11319                    if last_off == offset {
11320                        stack.push(("Fwmark", last_off));
11321                        break;
11322                    }
11323                }
11324                _ => {}
11325            };
11326            last_off = cur + attrs.pos;
11327        }
11328        if !stack.is_empty() {
11329            stack.push(("LinkinfoVti6Attrs", cur));
11330        }
11331        (stack, None)
11332    }
11333}
11334#[derive(Clone)]
11335pub enum LinkinfoGeneveAttrs<'a> {
11336    Id(u32),
11337    Remote(&'a [u8]),
11338    Ttl(u8),
11339    Tos(u8),
11340    Port(u16),
11341    CollectMetadata(()),
11342    Remote6(&'a [u8]),
11343    UdpCsum(u8),
11344    UdpZeroCsum6Tx(u8),
11345    UdpZeroCsum6Rx(u8),
11346    Label(u32),
11347    TtlInherit(u8),
11348    Df(u8),
11349    InnerProtoInherit(()),
11350    PortRange(PushIflaGenevePortRange),
11351}
11352impl<'a> IterableLinkinfoGeneveAttrs<'a> {
11353    pub fn get_id(&self) -> Result<u32, ErrorContext> {
11354        let mut iter = self.clone();
11355        iter.pos = 0;
11356        for attr in iter {
11357            if let LinkinfoGeneveAttrs::Id(val) = attr? {
11358                return Ok(val);
11359            }
11360        }
11361        Err(ErrorContext::new_missing(
11362            "LinkinfoGeneveAttrs",
11363            "Id",
11364            self.orig_loc,
11365            self.buf.as_ptr() as usize,
11366        ))
11367    }
11368    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
11369        let mut iter = self.clone();
11370        iter.pos = 0;
11371        for attr in iter {
11372            if let LinkinfoGeneveAttrs::Remote(val) = attr? {
11373                return Ok(val);
11374            }
11375        }
11376        Err(ErrorContext::new_missing(
11377            "LinkinfoGeneveAttrs",
11378            "Remote",
11379            self.orig_loc,
11380            self.buf.as_ptr() as usize,
11381        ))
11382    }
11383    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
11384        let mut iter = self.clone();
11385        iter.pos = 0;
11386        for attr in iter {
11387            if let LinkinfoGeneveAttrs::Ttl(val) = attr? {
11388                return Ok(val);
11389            }
11390        }
11391        Err(ErrorContext::new_missing(
11392            "LinkinfoGeneveAttrs",
11393            "Ttl",
11394            self.orig_loc,
11395            self.buf.as_ptr() as usize,
11396        ))
11397    }
11398    pub fn get_tos(&self) -> Result<u8, ErrorContext> {
11399        let mut iter = self.clone();
11400        iter.pos = 0;
11401        for attr in iter {
11402            if let LinkinfoGeneveAttrs::Tos(val) = attr? {
11403                return Ok(val);
11404            }
11405        }
11406        Err(ErrorContext::new_missing(
11407            "LinkinfoGeneveAttrs",
11408            "Tos",
11409            self.orig_loc,
11410            self.buf.as_ptr() as usize,
11411        ))
11412    }
11413    pub fn get_port(&self) -> Result<u16, ErrorContext> {
11414        let mut iter = self.clone();
11415        iter.pos = 0;
11416        for attr in iter {
11417            if let LinkinfoGeneveAttrs::Port(val) = attr? {
11418                return Ok(val);
11419            }
11420        }
11421        Err(ErrorContext::new_missing(
11422            "LinkinfoGeneveAttrs",
11423            "Port",
11424            self.orig_loc,
11425            self.buf.as_ptr() as usize,
11426        ))
11427    }
11428    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
11429        let mut iter = self.clone();
11430        iter.pos = 0;
11431        for attr in iter {
11432            if let LinkinfoGeneveAttrs::CollectMetadata(val) = attr? {
11433                return Ok(val);
11434            }
11435        }
11436        Err(ErrorContext::new_missing(
11437            "LinkinfoGeneveAttrs",
11438            "CollectMetadata",
11439            self.orig_loc,
11440            self.buf.as_ptr() as usize,
11441        ))
11442    }
11443    pub fn get_remote6(&self) -> Result<&'a [u8], ErrorContext> {
11444        let mut iter = self.clone();
11445        iter.pos = 0;
11446        for attr in iter {
11447            if let LinkinfoGeneveAttrs::Remote6(val) = attr? {
11448                return Ok(val);
11449            }
11450        }
11451        Err(ErrorContext::new_missing(
11452            "LinkinfoGeneveAttrs",
11453            "Remote6",
11454            self.orig_loc,
11455            self.buf.as_ptr() as usize,
11456        ))
11457    }
11458    pub fn get_udp_csum(&self) -> Result<u8, ErrorContext> {
11459        let mut iter = self.clone();
11460        iter.pos = 0;
11461        for attr in iter {
11462            if let LinkinfoGeneveAttrs::UdpCsum(val) = attr? {
11463                return Ok(val);
11464            }
11465        }
11466        Err(ErrorContext::new_missing(
11467            "LinkinfoGeneveAttrs",
11468            "UdpCsum",
11469            self.orig_loc,
11470            self.buf.as_ptr() as usize,
11471        ))
11472    }
11473    pub fn get_udp_zero_csum6_tx(&self) -> Result<u8, ErrorContext> {
11474        let mut iter = self.clone();
11475        iter.pos = 0;
11476        for attr in iter {
11477            if let LinkinfoGeneveAttrs::UdpZeroCsum6Tx(val) = attr? {
11478                return Ok(val);
11479            }
11480        }
11481        Err(ErrorContext::new_missing(
11482            "LinkinfoGeneveAttrs",
11483            "UdpZeroCsum6Tx",
11484            self.orig_loc,
11485            self.buf.as_ptr() as usize,
11486        ))
11487    }
11488    pub fn get_udp_zero_csum6_rx(&self) -> Result<u8, ErrorContext> {
11489        let mut iter = self.clone();
11490        iter.pos = 0;
11491        for attr in iter {
11492            if let LinkinfoGeneveAttrs::UdpZeroCsum6Rx(val) = attr? {
11493                return Ok(val);
11494            }
11495        }
11496        Err(ErrorContext::new_missing(
11497            "LinkinfoGeneveAttrs",
11498            "UdpZeroCsum6Rx",
11499            self.orig_loc,
11500            self.buf.as_ptr() as usize,
11501        ))
11502    }
11503    pub fn get_label(&self) -> Result<u32, ErrorContext> {
11504        let mut iter = self.clone();
11505        iter.pos = 0;
11506        for attr in iter {
11507            if let LinkinfoGeneveAttrs::Label(val) = attr? {
11508                return Ok(val);
11509            }
11510        }
11511        Err(ErrorContext::new_missing(
11512            "LinkinfoGeneveAttrs",
11513            "Label",
11514            self.orig_loc,
11515            self.buf.as_ptr() as usize,
11516        ))
11517    }
11518    pub fn get_ttl_inherit(&self) -> Result<u8, ErrorContext> {
11519        let mut iter = self.clone();
11520        iter.pos = 0;
11521        for attr in iter {
11522            if let LinkinfoGeneveAttrs::TtlInherit(val) = attr? {
11523                return Ok(val);
11524            }
11525        }
11526        Err(ErrorContext::new_missing(
11527            "LinkinfoGeneveAttrs",
11528            "TtlInherit",
11529            self.orig_loc,
11530            self.buf.as_ptr() as usize,
11531        ))
11532    }
11533    pub fn get_df(&self) -> Result<u8, ErrorContext> {
11534        let mut iter = self.clone();
11535        iter.pos = 0;
11536        for attr in iter {
11537            if let LinkinfoGeneveAttrs::Df(val) = attr? {
11538                return Ok(val);
11539            }
11540        }
11541        Err(ErrorContext::new_missing(
11542            "LinkinfoGeneveAttrs",
11543            "Df",
11544            self.orig_loc,
11545            self.buf.as_ptr() as usize,
11546        ))
11547    }
11548    pub fn get_inner_proto_inherit(&self) -> Result<(), ErrorContext> {
11549        let mut iter = self.clone();
11550        iter.pos = 0;
11551        for attr in iter {
11552            if let LinkinfoGeneveAttrs::InnerProtoInherit(val) = attr? {
11553                return Ok(val);
11554            }
11555        }
11556        Err(ErrorContext::new_missing(
11557            "LinkinfoGeneveAttrs",
11558            "InnerProtoInherit",
11559            self.orig_loc,
11560            self.buf.as_ptr() as usize,
11561        ))
11562    }
11563    pub fn get_port_range(&self) -> Result<PushIflaGenevePortRange, ErrorContext> {
11564        let mut iter = self.clone();
11565        iter.pos = 0;
11566        for attr in iter {
11567            if let LinkinfoGeneveAttrs::PortRange(val) = attr? {
11568                return Ok(val);
11569            }
11570        }
11571        Err(ErrorContext::new_missing(
11572            "LinkinfoGeneveAttrs",
11573            "PortRange",
11574            self.orig_loc,
11575            self.buf.as_ptr() as usize,
11576        ))
11577    }
11578}
11579impl LinkinfoGeneveAttrs<'_> {
11580    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoGeneveAttrs<'a> {
11581        IterableLinkinfoGeneveAttrs::with_loc(buf, buf.as_ptr() as usize)
11582    }
11583    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11584        let res = match r#type {
11585            1u16 => "Id",
11586            2u16 => "Remote",
11587            3u16 => "Ttl",
11588            4u16 => "Tos",
11589            5u16 => "Port",
11590            6u16 => "CollectMetadata",
11591            7u16 => "Remote6",
11592            8u16 => "UdpCsum",
11593            9u16 => "UdpZeroCsum6Tx",
11594            10u16 => "UdpZeroCsum6Rx",
11595            11u16 => "Label",
11596            12u16 => "TtlInherit",
11597            13u16 => "Df",
11598            14u16 => "InnerProtoInherit",
11599            15u16 => "PortRange",
11600            _ => return None,
11601        };
11602        Some(res)
11603    }
11604}
11605#[derive(Clone, Copy, Default)]
11606pub struct IterableLinkinfoGeneveAttrs<'a> {
11607    buf: &'a [u8],
11608    pos: usize,
11609    orig_loc: usize,
11610}
11611impl<'a> IterableLinkinfoGeneveAttrs<'a> {
11612    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11613        Self {
11614            buf,
11615            pos: 0,
11616            orig_loc,
11617        }
11618    }
11619    pub fn get_buf(&self) -> &'a [u8] {
11620        self.buf
11621    }
11622}
11623impl<'a> Iterator for IterableLinkinfoGeneveAttrs<'a> {
11624    type Item = Result<LinkinfoGeneveAttrs<'a>, ErrorContext>;
11625    fn next(&mut self) -> Option<Self::Item> {
11626        let pos = self.pos;
11627        let mut r#type;
11628        loop {
11629            r#type = None;
11630            if self.buf.len() == self.pos {
11631                return None;
11632            }
11633            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
11634                break;
11635            };
11636            r#type = Some(header.r#type);
11637            let res = match header.r#type {
11638                1u16 => LinkinfoGeneveAttrs::Id({
11639                    let res = parse_u32(next);
11640                    let Some(val) = res else { break };
11641                    val
11642                }),
11643                2u16 => LinkinfoGeneveAttrs::Remote({
11644                    let res = Some(next);
11645                    let Some(val) = res else { break };
11646                    val
11647                }),
11648                3u16 => LinkinfoGeneveAttrs::Ttl({
11649                    let res = parse_u8(next);
11650                    let Some(val) = res else { break };
11651                    val
11652                }),
11653                4u16 => LinkinfoGeneveAttrs::Tos({
11654                    let res = parse_u8(next);
11655                    let Some(val) = res else { break };
11656                    val
11657                }),
11658                5u16 => LinkinfoGeneveAttrs::Port({
11659                    let res = parse_be_u16(next);
11660                    let Some(val) = res else { break };
11661                    val
11662                }),
11663                6u16 => LinkinfoGeneveAttrs::CollectMetadata(()),
11664                7u16 => LinkinfoGeneveAttrs::Remote6({
11665                    let res = Some(next);
11666                    let Some(val) = res else { break };
11667                    val
11668                }),
11669                8u16 => LinkinfoGeneveAttrs::UdpCsum({
11670                    let res = parse_u8(next);
11671                    let Some(val) = res else { break };
11672                    val
11673                }),
11674                9u16 => LinkinfoGeneveAttrs::UdpZeroCsum6Tx({
11675                    let res = parse_u8(next);
11676                    let Some(val) = res else { break };
11677                    val
11678                }),
11679                10u16 => LinkinfoGeneveAttrs::UdpZeroCsum6Rx({
11680                    let res = parse_u8(next);
11681                    let Some(val) = res else { break };
11682                    val
11683                }),
11684                11u16 => LinkinfoGeneveAttrs::Label({
11685                    let res = parse_be_u32(next);
11686                    let Some(val) = res else { break };
11687                    val
11688                }),
11689                12u16 => LinkinfoGeneveAttrs::TtlInherit({
11690                    let res = parse_u8(next);
11691                    let Some(val) = res else { break };
11692                    val
11693                }),
11694                13u16 => LinkinfoGeneveAttrs::Df({
11695                    let res = parse_u8(next);
11696                    let Some(val) = res else { break };
11697                    val
11698                }),
11699                14u16 => LinkinfoGeneveAttrs::InnerProtoInherit(()),
11700                15u16 => LinkinfoGeneveAttrs::PortRange({
11701                    let res = PushIflaGenevePortRange::new_from_slice(next);
11702                    let Some(val) = res else { break };
11703                    val
11704                }),
11705                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
11706                n => continue,
11707            };
11708            return Some(Ok(res));
11709        }
11710        Some(Err(ErrorContext::new(
11711            "LinkinfoGeneveAttrs",
11712            r#type.and_then(|t| LinkinfoGeneveAttrs::attr_from_type(t)),
11713            self.orig_loc,
11714            self.buf.as_ptr().wrapping_add(pos) as usize,
11715        )))
11716    }
11717}
11718impl<'a> std::fmt::Debug for IterableLinkinfoGeneveAttrs<'_> {
11719    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11720        let mut fmt = f.debug_struct("LinkinfoGeneveAttrs");
11721        for attr in self.clone() {
11722            let attr = match attr {
11723                Ok(a) => a,
11724                Err(err) => {
11725                    fmt.finish()?;
11726                    f.write_str("Err(")?;
11727                    err.fmt(f)?;
11728                    return f.write_str(")");
11729                }
11730            };
11731            match attr {
11732                LinkinfoGeneveAttrs::Id(val) => fmt.field("Id", &val),
11733                LinkinfoGeneveAttrs::Remote(val) => fmt.field("Remote", &val),
11734                LinkinfoGeneveAttrs::Ttl(val) => fmt.field("Ttl", &val),
11735                LinkinfoGeneveAttrs::Tos(val) => fmt.field("Tos", &val),
11736                LinkinfoGeneveAttrs::Port(val) => fmt.field("Port", &val),
11737                LinkinfoGeneveAttrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
11738                LinkinfoGeneveAttrs::Remote6(val) => fmt.field("Remote6", &val),
11739                LinkinfoGeneveAttrs::UdpCsum(val) => fmt.field("UdpCsum", &val),
11740                LinkinfoGeneveAttrs::UdpZeroCsum6Tx(val) => fmt.field("UdpZeroCsum6Tx", &val),
11741                LinkinfoGeneveAttrs::UdpZeroCsum6Rx(val) => fmt.field("UdpZeroCsum6Rx", &val),
11742                LinkinfoGeneveAttrs::Label(val) => fmt.field("Label", &val),
11743                LinkinfoGeneveAttrs::TtlInherit(val) => fmt.field("TtlInherit", &val),
11744                LinkinfoGeneveAttrs::Df(val) => fmt.field("Df", &val),
11745                LinkinfoGeneveAttrs::InnerProtoInherit(val) => fmt.field("InnerProtoInherit", &val),
11746                LinkinfoGeneveAttrs::PortRange(val) => fmt.field("PortRange", &val),
11747            };
11748        }
11749        fmt.finish()
11750    }
11751}
11752impl IterableLinkinfoGeneveAttrs<'_> {
11753    pub fn lookup_attr(
11754        &self,
11755        offset: usize,
11756        missing_type: Option<u16>,
11757    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11758        let mut stack = Vec::new();
11759        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11760        if cur == offset {
11761            stack.push(("LinkinfoGeneveAttrs", offset));
11762            return (
11763                stack,
11764                missing_type.and_then(|t| LinkinfoGeneveAttrs::attr_from_type(t)),
11765            );
11766        }
11767        if cur > offset || cur + self.buf.len() < offset {
11768            return (stack, None);
11769        }
11770        let mut attrs = self.clone();
11771        let mut last_off = cur + attrs.pos;
11772        while let Some(attr) = attrs.next() {
11773            let Ok(attr) = attr else { break };
11774            match attr {
11775                LinkinfoGeneveAttrs::Id(val) => {
11776                    if last_off == offset {
11777                        stack.push(("Id", last_off));
11778                        break;
11779                    }
11780                }
11781                LinkinfoGeneveAttrs::Remote(val) => {
11782                    if last_off == offset {
11783                        stack.push(("Remote", last_off));
11784                        break;
11785                    }
11786                }
11787                LinkinfoGeneveAttrs::Ttl(val) => {
11788                    if last_off == offset {
11789                        stack.push(("Ttl", last_off));
11790                        break;
11791                    }
11792                }
11793                LinkinfoGeneveAttrs::Tos(val) => {
11794                    if last_off == offset {
11795                        stack.push(("Tos", last_off));
11796                        break;
11797                    }
11798                }
11799                LinkinfoGeneveAttrs::Port(val) => {
11800                    if last_off == offset {
11801                        stack.push(("Port", last_off));
11802                        break;
11803                    }
11804                }
11805                LinkinfoGeneveAttrs::CollectMetadata(val) => {
11806                    if last_off == offset {
11807                        stack.push(("CollectMetadata", last_off));
11808                        break;
11809                    }
11810                }
11811                LinkinfoGeneveAttrs::Remote6(val) => {
11812                    if last_off == offset {
11813                        stack.push(("Remote6", last_off));
11814                        break;
11815                    }
11816                }
11817                LinkinfoGeneveAttrs::UdpCsum(val) => {
11818                    if last_off == offset {
11819                        stack.push(("UdpCsum", last_off));
11820                        break;
11821                    }
11822                }
11823                LinkinfoGeneveAttrs::UdpZeroCsum6Tx(val) => {
11824                    if last_off == offset {
11825                        stack.push(("UdpZeroCsum6Tx", last_off));
11826                        break;
11827                    }
11828                }
11829                LinkinfoGeneveAttrs::UdpZeroCsum6Rx(val) => {
11830                    if last_off == offset {
11831                        stack.push(("UdpZeroCsum6Rx", last_off));
11832                        break;
11833                    }
11834                }
11835                LinkinfoGeneveAttrs::Label(val) => {
11836                    if last_off == offset {
11837                        stack.push(("Label", last_off));
11838                        break;
11839                    }
11840                }
11841                LinkinfoGeneveAttrs::TtlInherit(val) => {
11842                    if last_off == offset {
11843                        stack.push(("TtlInherit", last_off));
11844                        break;
11845                    }
11846                }
11847                LinkinfoGeneveAttrs::Df(val) => {
11848                    if last_off == offset {
11849                        stack.push(("Df", last_off));
11850                        break;
11851                    }
11852                }
11853                LinkinfoGeneveAttrs::InnerProtoInherit(val) => {
11854                    if last_off == offset {
11855                        stack.push(("InnerProtoInherit", last_off));
11856                        break;
11857                    }
11858                }
11859                LinkinfoGeneveAttrs::PortRange(val) => {
11860                    if last_off == offset {
11861                        stack.push(("PortRange", last_off));
11862                        break;
11863                    }
11864                }
11865                _ => {}
11866            };
11867            last_off = cur + attrs.pos;
11868        }
11869        if !stack.is_empty() {
11870            stack.push(("LinkinfoGeneveAttrs", cur));
11871        }
11872        (stack, None)
11873    }
11874}
11875#[derive(Clone)]
11876pub enum LinkinfoIptunAttrs<'a> {
11877    Link(u32),
11878    Local(&'a [u8]),
11879    Remote(&'a [u8]),
11880    Ttl(u8),
11881    Tos(u8),
11882    EncapLimit(u8),
11883    Flowinfo(u32),
11884    Flags(u16),
11885    Proto(u8),
11886    Pmtudisc(u8),
11887    _6rdPrefix(&'a [u8]),
11888    _6rdRelayPrefix(&'a [u8]),
11889    _6rdPrefixlen(u16),
11890    _6rdRelayPrefixlen(u16),
11891    EncapType(u16),
11892    EncapFlags(u16),
11893    EncapSport(u16),
11894    EncapDport(u16),
11895    CollectMetadata(()),
11896    Fwmark(u32),
11897}
11898impl<'a> IterableLinkinfoIptunAttrs<'a> {
11899    pub fn get_link(&self) -> Result<u32, ErrorContext> {
11900        let mut iter = self.clone();
11901        iter.pos = 0;
11902        for attr in iter {
11903            if let LinkinfoIptunAttrs::Link(val) = attr? {
11904                return Ok(val);
11905            }
11906        }
11907        Err(ErrorContext::new_missing(
11908            "LinkinfoIptunAttrs",
11909            "Link",
11910            self.orig_loc,
11911            self.buf.as_ptr() as usize,
11912        ))
11913    }
11914    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
11915        let mut iter = self.clone();
11916        iter.pos = 0;
11917        for attr in iter {
11918            if let LinkinfoIptunAttrs::Local(val) = attr? {
11919                return Ok(val);
11920            }
11921        }
11922        Err(ErrorContext::new_missing(
11923            "LinkinfoIptunAttrs",
11924            "Local",
11925            self.orig_loc,
11926            self.buf.as_ptr() as usize,
11927        ))
11928    }
11929    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
11930        let mut iter = self.clone();
11931        iter.pos = 0;
11932        for attr in iter {
11933            if let LinkinfoIptunAttrs::Remote(val) = attr? {
11934                return Ok(val);
11935            }
11936        }
11937        Err(ErrorContext::new_missing(
11938            "LinkinfoIptunAttrs",
11939            "Remote",
11940            self.orig_loc,
11941            self.buf.as_ptr() as usize,
11942        ))
11943    }
11944    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
11945        let mut iter = self.clone();
11946        iter.pos = 0;
11947        for attr in iter {
11948            if let LinkinfoIptunAttrs::Ttl(val) = attr? {
11949                return Ok(val);
11950            }
11951        }
11952        Err(ErrorContext::new_missing(
11953            "LinkinfoIptunAttrs",
11954            "Ttl",
11955            self.orig_loc,
11956            self.buf.as_ptr() as usize,
11957        ))
11958    }
11959    pub fn get_tos(&self) -> Result<u8, ErrorContext> {
11960        let mut iter = self.clone();
11961        iter.pos = 0;
11962        for attr in iter {
11963            if let LinkinfoIptunAttrs::Tos(val) = attr? {
11964                return Ok(val);
11965            }
11966        }
11967        Err(ErrorContext::new_missing(
11968            "LinkinfoIptunAttrs",
11969            "Tos",
11970            self.orig_loc,
11971            self.buf.as_ptr() as usize,
11972        ))
11973    }
11974    pub fn get_encap_limit(&self) -> Result<u8, ErrorContext> {
11975        let mut iter = self.clone();
11976        iter.pos = 0;
11977        for attr in iter {
11978            if let LinkinfoIptunAttrs::EncapLimit(val) = attr? {
11979                return Ok(val);
11980            }
11981        }
11982        Err(ErrorContext::new_missing(
11983            "LinkinfoIptunAttrs",
11984            "EncapLimit",
11985            self.orig_loc,
11986            self.buf.as_ptr() as usize,
11987        ))
11988    }
11989    pub fn get_flowinfo(&self) -> Result<u32, ErrorContext> {
11990        let mut iter = self.clone();
11991        iter.pos = 0;
11992        for attr in iter {
11993            if let LinkinfoIptunAttrs::Flowinfo(val) = attr? {
11994                return Ok(val);
11995            }
11996        }
11997        Err(ErrorContext::new_missing(
11998            "LinkinfoIptunAttrs",
11999            "Flowinfo",
12000            self.orig_loc,
12001            self.buf.as_ptr() as usize,
12002        ))
12003    }
12004    pub fn get_flags(&self) -> Result<u16, ErrorContext> {
12005        let mut iter = self.clone();
12006        iter.pos = 0;
12007        for attr in iter {
12008            if let LinkinfoIptunAttrs::Flags(val) = attr? {
12009                return Ok(val);
12010            }
12011        }
12012        Err(ErrorContext::new_missing(
12013            "LinkinfoIptunAttrs",
12014            "Flags",
12015            self.orig_loc,
12016            self.buf.as_ptr() as usize,
12017        ))
12018    }
12019    pub fn get_proto(&self) -> Result<u8, ErrorContext> {
12020        let mut iter = self.clone();
12021        iter.pos = 0;
12022        for attr in iter {
12023            if let LinkinfoIptunAttrs::Proto(val) = attr? {
12024                return Ok(val);
12025            }
12026        }
12027        Err(ErrorContext::new_missing(
12028            "LinkinfoIptunAttrs",
12029            "Proto",
12030            self.orig_loc,
12031            self.buf.as_ptr() as usize,
12032        ))
12033    }
12034    pub fn get_pmtudisc(&self) -> Result<u8, ErrorContext> {
12035        let mut iter = self.clone();
12036        iter.pos = 0;
12037        for attr in iter {
12038            if let LinkinfoIptunAttrs::Pmtudisc(val) = attr? {
12039                return Ok(val);
12040            }
12041        }
12042        Err(ErrorContext::new_missing(
12043            "LinkinfoIptunAttrs",
12044            "Pmtudisc",
12045            self.orig_loc,
12046            self.buf.as_ptr() as usize,
12047        ))
12048    }
12049    pub fn get_6rd_prefix(&self) -> Result<&'a [u8], ErrorContext> {
12050        let mut iter = self.clone();
12051        iter.pos = 0;
12052        for attr in iter {
12053            if let LinkinfoIptunAttrs::_6rdPrefix(val) = attr? {
12054                return Ok(val);
12055            }
12056        }
12057        Err(ErrorContext::new_missing(
12058            "LinkinfoIptunAttrs",
12059            "6rdPrefix",
12060            self.orig_loc,
12061            self.buf.as_ptr() as usize,
12062        ))
12063    }
12064    pub fn get_6rd_relay_prefix(&self) -> Result<&'a [u8], ErrorContext> {
12065        let mut iter = self.clone();
12066        iter.pos = 0;
12067        for attr in iter {
12068            if let LinkinfoIptunAttrs::_6rdRelayPrefix(val) = attr? {
12069                return Ok(val);
12070            }
12071        }
12072        Err(ErrorContext::new_missing(
12073            "LinkinfoIptunAttrs",
12074            "6rdRelayPrefix",
12075            self.orig_loc,
12076            self.buf.as_ptr() as usize,
12077        ))
12078    }
12079    pub fn get_6rd_prefixlen(&self) -> Result<u16, ErrorContext> {
12080        let mut iter = self.clone();
12081        iter.pos = 0;
12082        for attr in iter {
12083            if let LinkinfoIptunAttrs::_6rdPrefixlen(val) = attr? {
12084                return Ok(val);
12085            }
12086        }
12087        Err(ErrorContext::new_missing(
12088            "LinkinfoIptunAttrs",
12089            "6rdPrefixlen",
12090            self.orig_loc,
12091            self.buf.as_ptr() as usize,
12092        ))
12093    }
12094    pub fn get_6rd_relay_prefixlen(&self) -> Result<u16, ErrorContext> {
12095        let mut iter = self.clone();
12096        iter.pos = 0;
12097        for attr in iter {
12098            if let LinkinfoIptunAttrs::_6rdRelayPrefixlen(val) = attr? {
12099                return Ok(val);
12100            }
12101        }
12102        Err(ErrorContext::new_missing(
12103            "LinkinfoIptunAttrs",
12104            "6rdRelayPrefixlen",
12105            self.orig_loc,
12106            self.buf.as_ptr() as usize,
12107        ))
12108    }
12109    pub fn get_encap_type(&self) -> Result<u16, ErrorContext> {
12110        let mut iter = self.clone();
12111        iter.pos = 0;
12112        for attr in iter {
12113            if let LinkinfoIptunAttrs::EncapType(val) = attr? {
12114                return Ok(val);
12115            }
12116        }
12117        Err(ErrorContext::new_missing(
12118            "LinkinfoIptunAttrs",
12119            "EncapType",
12120            self.orig_loc,
12121            self.buf.as_ptr() as usize,
12122        ))
12123    }
12124    pub fn get_encap_flags(&self) -> Result<u16, ErrorContext> {
12125        let mut iter = self.clone();
12126        iter.pos = 0;
12127        for attr in iter {
12128            if let LinkinfoIptunAttrs::EncapFlags(val) = attr? {
12129                return Ok(val);
12130            }
12131        }
12132        Err(ErrorContext::new_missing(
12133            "LinkinfoIptunAttrs",
12134            "EncapFlags",
12135            self.orig_loc,
12136            self.buf.as_ptr() as usize,
12137        ))
12138    }
12139    pub fn get_encap_sport(&self) -> Result<u16, ErrorContext> {
12140        let mut iter = self.clone();
12141        iter.pos = 0;
12142        for attr in iter {
12143            if let LinkinfoIptunAttrs::EncapSport(val) = attr? {
12144                return Ok(val);
12145            }
12146        }
12147        Err(ErrorContext::new_missing(
12148            "LinkinfoIptunAttrs",
12149            "EncapSport",
12150            self.orig_loc,
12151            self.buf.as_ptr() as usize,
12152        ))
12153    }
12154    pub fn get_encap_dport(&self) -> Result<u16, ErrorContext> {
12155        let mut iter = self.clone();
12156        iter.pos = 0;
12157        for attr in iter {
12158            if let LinkinfoIptunAttrs::EncapDport(val) = attr? {
12159                return Ok(val);
12160            }
12161        }
12162        Err(ErrorContext::new_missing(
12163            "LinkinfoIptunAttrs",
12164            "EncapDport",
12165            self.orig_loc,
12166            self.buf.as_ptr() as usize,
12167        ))
12168    }
12169    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
12170        let mut iter = self.clone();
12171        iter.pos = 0;
12172        for attr in iter {
12173            if let LinkinfoIptunAttrs::CollectMetadata(val) = attr? {
12174                return Ok(val);
12175            }
12176        }
12177        Err(ErrorContext::new_missing(
12178            "LinkinfoIptunAttrs",
12179            "CollectMetadata",
12180            self.orig_loc,
12181            self.buf.as_ptr() as usize,
12182        ))
12183    }
12184    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
12185        let mut iter = self.clone();
12186        iter.pos = 0;
12187        for attr in iter {
12188            if let LinkinfoIptunAttrs::Fwmark(val) = attr? {
12189                return Ok(val);
12190            }
12191        }
12192        Err(ErrorContext::new_missing(
12193            "LinkinfoIptunAttrs",
12194            "Fwmark",
12195            self.orig_loc,
12196            self.buf.as_ptr() as usize,
12197        ))
12198    }
12199}
12200impl LinkinfoIptunAttrs<'_> {
12201    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoIptunAttrs<'a> {
12202        IterableLinkinfoIptunAttrs::with_loc(buf, buf.as_ptr() as usize)
12203    }
12204    fn attr_from_type(r#type: u16) -> Option<&'static str> {
12205        let res = match r#type {
12206            1u16 => "Link",
12207            2u16 => "Local",
12208            3u16 => "Remote",
12209            4u16 => "Ttl",
12210            5u16 => "Tos",
12211            6u16 => "EncapLimit",
12212            7u16 => "Flowinfo",
12213            8u16 => "Flags",
12214            9u16 => "Proto",
12215            10u16 => "Pmtudisc",
12216            11u16 => "6rdPrefix",
12217            12u16 => "6rdRelayPrefix",
12218            13u16 => "6rdPrefixlen",
12219            14u16 => "6rdRelayPrefixlen",
12220            15u16 => "EncapType",
12221            16u16 => "EncapFlags",
12222            17u16 => "EncapSport",
12223            18u16 => "EncapDport",
12224            19u16 => "CollectMetadata",
12225            20u16 => "Fwmark",
12226            _ => return None,
12227        };
12228        Some(res)
12229    }
12230}
12231#[derive(Clone, Copy, Default)]
12232pub struct IterableLinkinfoIptunAttrs<'a> {
12233    buf: &'a [u8],
12234    pos: usize,
12235    orig_loc: usize,
12236}
12237impl<'a> IterableLinkinfoIptunAttrs<'a> {
12238    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
12239        Self {
12240            buf,
12241            pos: 0,
12242            orig_loc,
12243        }
12244    }
12245    pub fn get_buf(&self) -> &'a [u8] {
12246        self.buf
12247    }
12248}
12249impl<'a> Iterator for IterableLinkinfoIptunAttrs<'a> {
12250    type Item = Result<LinkinfoIptunAttrs<'a>, ErrorContext>;
12251    fn next(&mut self) -> Option<Self::Item> {
12252        let pos = self.pos;
12253        let mut r#type;
12254        loop {
12255            r#type = None;
12256            if self.buf.len() == self.pos {
12257                return None;
12258            }
12259            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
12260                break;
12261            };
12262            r#type = Some(header.r#type);
12263            let res = match header.r#type {
12264                1u16 => LinkinfoIptunAttrs::Link({
12265                    let res = parse_u32(next);
12266                    let Some(val) = res else { break };
12267                    val
12268                }),
12269                2u16 => LinkinfoIptunAttrs::Local({
12270                    let res = Some(next);
12271                    let Some(val) = res else { break };
12272                    val
12273                }),
12274                3u16 => LinkinfoIptunAttrs::Remote({
12275                    let res = Some(next);
12276                    let Some(val) = res else { break };
12277                    val
12278                }),
12279                4u16 => LinkinfoIptunAttrs::Ttl({
12280                    let res = parse_u8(next);
12281                    let Some(val) = res else { break };
12282                    val
12283                }),
12284                5u16 => LinkinfoIptunAttrs::Tos({
12285                    let res = parse_u8(next);
12286                    let Some(val) = res else { break };
12287                    val
12288                }),
12289                6u16 => LinkinfoIptunAttrs::EncapLimit({
12290                    let res = parse_u8(next);
12291                    let Some(val) = res else { break };
12292                    val
12293                }),
12294                7u16 => LinkinfoIptunAttrs::Flowinfo({
12295                    let res = parse_be_u32(next);
12296                    let Some(val) = res else { break };
12297                    val
12298                }),
12299                8u16 => LinkinfoIptunAttrs::Flags({
12300                    let res = parse_be_u16(next);
12301                    let Some(val) = res else { break };
12302                    val
12303                }),
12304                9u16 => LinkinfoIptunAttrs::Proto({
12305                    let res = parse_u8(next);
12306                    let Some(val) = res else { break };
12307                    val
12308                }),
12309                10u16 => LinkinfoIptunAttrs::Pmtudisc({
12310                    let res = parse_u8(next);
12311                    let Some(val) = res else { break };
12312                    val
12313                }),
12314                11u16 => LinkinfoIptunAttrs::_6rdPrefix({
12315                    let res = Some(next);
12316                    let Some(val) = res else { break };
12317                    val
12318                }),
12319                12u16 => LinkinfoIptunAttrs::_6rdRelayPrefix({
12320                    let res = Some(next);
12321                    let Some(val) = res else { break };
12322                    val
12323                }),
12324                13u16 => LinkinfoIptunAttrs::_6rdPrefixlen({
12325                    let res = parse_u16(next);
12326                    let Some(val) = res else { break };
12327                    val
12328                }),
12329                14u16 => LinkinfoIptunAttrs::_6rdRelayPrefixlen({
12330                    let res = parse_u16(next);
12331                    let Some(val) = res else { break };
12332                    val
12333                }),
12334                15u16 => LinkinfoIptunAttrs::EncapType({
12335                    let res = parse_u16(next);
12336                    let Some(val) = res else { break };
12337                    val
12338                }),
12339                16u16 => LinkinfoIptunAttrs::EncapFlags({
12340                    let res = parse_u16(next);
12341                    let Some(val) = res else { break };
12342                    val
12343                }),
12344                17u16 => LinkinfoIptunAttrs::EncapSport({
12345                    let res = parse_be_u16(next);
12346                    let Some(val) = res else { break };
12347                    val
12348                }),
12349                18u16 => LinkinfoIptunAttrs::EncapDport({
12350                    let res = parse_be_u16(next);
12351                    let Some(val) = res else { break };
12352                    val
12353                }),
12354                19u16 => LinkinfoIptunAttrs::CollectMetadata(()),
12355                20u16 => LinkinfoIptunAttrs::Fwmark({
12356                    let res = parse_u32(next);
12357                    let Some(val) = res else { break };
12358                    val
12359                }),
12360                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
12361                n => continue,
12362            };
12363            return Some(Ok(res));
12364        }
12365        Some(Err(ErrorContext::new(
12366            "LinkinfoIptunAttrs",
12367            r#type.and_then(|t| LinkinfoIptunAttrs::attr_from_type(t)),
12368            self.orig_loc,
12369            self.buf.as_ptr().wrapping_add(pos) as usize,
12370        )))
12371    }
12372}
12373impl<'a> std::fmt::Debug for IterableLinkinfoIptunAttrs<'_> {
12374    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12375        let mut fmt = f.debug_struct("LinkinfoIptunAttrs");
12376        for attr in self.clone() {
12377            let attr = match attr {
12378                Ok(a) => a,
12379                Err(err) => {
12380                    fmt.finish()?;
12381                    f.write_str("Err(")?;
12382                    err.fmt(f)?;
12383                    return f.write_str(")");
12384                }
12385            };
12386            match attr {
12387                LinkinfoIptunAttrs::Link(val) => fmt.field("Link", &val),
12388                LinkinfoIptunAttrs::Local(val) => fmt.field("Local", &val),
12389                LinkinfoIptunAttrs::Remote(val) => fmt.field("Remote", &val),
12390                LinkinfoIptunAttrs::Ttl(val) => fmt.field("Ttl", &val),
12391                LinkinfoIptunAttrs::Tos(val) => fmt.field("Tos", &val),
12392                LinkinfoIptunAttrs::EncapLimit(val) => fmt.field("EncapLimit", &val),
12393                LinkinfoIptunAttrs::Flowinfo(val) => fmt.field("Flowinfo", &val),
12394                LinkinfoIptunAttrs::Flags(val) => fmt.field("Flags", &val),
12395                LinkinfoIptunAttrs::Proto(val) => fmt.field("Proto", &val),
12396                LinkinfoIptunAttrs::Pmtudisc(val) => fmt.field("Pmtudisc", &val),
12397                LinkinfoIptunAttrs::_6rdPrefix(val) => fmt.field("_6rdPrefix", &val),
12398                LinkinfoIptunAttrs::_6rdRelayPrefix(val) => fmt.field("_6rdRelayPrefix", &val),
12399                LinkinfoIptunAttrs::_6rdPrefixlen(val) => fmt.field("_6rdPrefixlen", &val),
12400                LinkinfoIptunAttrs::_6rdRelayPrefixlen(val) => {
12401                    fmt.field("_6rdRelayPrefixlen", &val)
12402                }
12403                LinkinfoIptunAttrs::EncapType(val) => fmt.field("EncapType", &val),
12404                LinkinfoIptunAttrs::EncapFlags(val) => fmt.field("EncapFlags", &val),
12405                LinkinfoIptunAttrs::EncapSport(val) => fmt.field("EncapSport", &val),
12406                LinkinfoIptunAttrs::EncapDport(val) => fmt.field("EncapDport", &val),
12407                LinkinfoIptunAttrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
12408                LinkinfoIptunAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
12409            };
12410        }
12411        fmt.finish()
12412    }
12413}
12414impl IterableLinkinfoIptunAttrs<'_> {
12415    pub fn lookup_attr(
12416        &self,
12417        offset: usize,
12418        missing_type: Option<u16>,
12419    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
12420        let mut stack = Vec::new();
12421        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
12422        if cur == offset {
12423            stack.push(("LinkinfoIptunAttrs", offset));
12424            return (
12425                stack,
12426                missing_type.and_then(|t| LinkinfoIptunAttrs::attr_from_type(t)),
12427            );
12428        }
12429        if cur > offset || cur + self.buf.len() < offset {
12430            return (stack, None);
12431        }
12432        let mut attrs = self.clone();
12433        let mut last_off = cur + attrs.pos;
12434        while let Some(attr) = attrs.next() {
12435            let Ok(attr) = attr else { break };
12436            match attr {
12437                LinkinfoIptunAttrs::Link(val) => {
12438                    if last_off == offset {
12439                        stack.push(("Link", last_off));
12440                        break;
12441                    }
12442                }
12443                LinkinfoIptunAttrs::Local(val) => {
12444                    if last_off == offset {
12445                        stack.push(("Local", last_off));
12446                        break;
12447                    }
12448                }
12449                LinkinfoIptunAttrs::Remote(val) => {
12450                    if last_off == offset {
12451                        stack.push(("Remote", last_off));
12452                        break;
12453                    }
12454                }
12455                LinkinfoIptunAttrs::Ttl(val) => {
12456                    if last_off == offset {
12457                        stack.push(("Ttl", last_off));
12458                        break;
12459                    }
12460                }
12461                LinkinfoIptunAttrs::Tos(val) => {
12462                    if last_off == offset {
12463                        stack.push(("Tos", last_off));
12464                        break;
12465                    }
12466                }
12467                LinkinfoIptunAttrs::EncapLimit(val) => {
12468                    if last_off == offset {
12469                        stack.push(("EncapLimit", last_off));
12470                        break;
12471                    }
12472                }
12473                LinkinfoIptunAttrs::Flowinfo(val) => {
12474                    if last_off == offset {
12475                        stack.push(("Flowinfo", last_off));
12476                        break;
12477                    }
12478                }
12479                LinkinfoIptunAttrs::Flags(val) => {
12480                    if last_off == offset {
12481                        stack.push(("Flags", last_off));
12482                        break;
12483                    }
12484                }
12485                LinkinfoIptunAttrs::Proto(val) => {
12486                    if last_off == offset {
12487                        stack.push(("Proto", last_off));
12488                        break;
12489                    }
12490                }
12491                LinkinfoIptunAttrs::Pmtudisc(val) => {
12492                    if last_off == offset {
12493                        stack.push(("Pmtudisc", last_off));
12494                        break;
12495                    }
12496                }
12497                LinkinfoIptunAttrs::_6rdPrefix(val) => {
12498                    if last_off == offset {
12499                        stack.push(("6rdPrefix", last_off));
12500                        break;
12501                    }
12502                }
12503                LinkinfoIptunAttrs::_6rdRelayPrefix(val) => {
12504                    if last_off == offset {
12505                        stack.push(("6rdRelayPrefix", last_off));
12506                        break;
12507                    }
12508                }
12509                LinkinfoIptunAttrs::_6rdPrefixlen(val) => {
12510                    if last_off == offset {
12511                        stack.push(("6rdPrefixlen", last_off));
12512                        break;
12513                    }
12514                }
12515                LinkinfoIptunAttrs::_6rdRelayPrefixlen(val) => {
12516                    if last_off == offset {
12517                        stack.push(("6rdRelayPrefixlen", last_off));
12518                        break;
12519                    }
12520                }
12521                LinkinfoIptunAttrs::EncapType(val) => {
12522                    if last_off == offset {
12523                        stack.push(("EncapType", last_off));
12524                        break;
12525                    }
12526                }
12527                LinkinfoIptunAttrs::EncapFlags(val) => {
12528                    if last_off == offset {
12529                        stack.push(("EncapFlags", last_off));
12530                        break;
12531                    }
12532                }
12533                LinkinfoIptunAttrs::EncapSport(val) => {
12534                    if last_off == offset {
12535                        stack.push(("EncapSport", last_off));
12536                        break;
12537                    }
12538                }
12539                LinkinfoIptunAttrs::EncapDport(val) => {
12540                    if last_off == offset {
12541                        stack.push(("EncapDport", last_off));
12542                        break;
12543                    }
12544                }
12545                LinkinfoIptunAttrs::CollectMetadata(val) => {
12546                    if last_off == offset {
12547                        stack.push(("CollectMetadata", last_off));
12548                        break;
12549                    }
12550                }
12551                LinkinfoIptunAttrs::Fwmark(val) => {
12552                    if last_off == offset {
12553                        stack.push(("Fwmark", last_off));
12554                        break;
12555                    }
12556                }
12557                _ => {}
12558            };
12559            last_off = cur + attrs.pos;
12560        }
12561        if !stack.is_empty() {
12562            stack.push(("LinkinfoIptunAttrs", cur));
12563        }
12564        (stack, None)
12565    }
12566}
12567#[derive(Clone)]
12568pub enum LinkinfoIp6tnlAttrs<'a> {
12569    Link(u32),
12570    Local(&'a [u8]),
12571    Remote(&'a [u8]),
12572    Ttl(u8),
12573    EncapLimit(u8),
12574    Flowinfo(u32),
12575    Flags(u32),
12576    Proto(u8),
12577    EncapType(u16),
12578    EncapFlags(u16),
12579    EncapSport(u16),
12580    EncapDport(u16),
12581    CollectMetadata(()),
12582    Fwmark(u32),
12583}
12584impl<'a> IterableLinkinfoIp6tnlAttrs<'a> {
12585    pub fn get_link(&self) -> Result<u32, ErrorContext> {
12586        let mut iter = self.clone();
12587        iter.pos = 0;
12588        for attr in iter {
12589            if let LinkinfoIp6tnlAttrs::Link(val) = attr? {
12590                return Ok(val);
12591            }
12592        }
12593        Err(ErrorContext::new_missing(
12594            "LinkinfoIp6tnlAttrs",
12595            "Link",
12596            self.orig_loc,
12597            self.buf.as_ptr() as usize,
12598        ))
12599    }
12600    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
12601        let mut iter = self.clone();
12602        iter.pos = 0;
12603        for attr in iter {
12604            if let LinkinfoIp6tnlAttrs::Local(val) = attr? {
12605                return Ok(val);
12606            }
12607        }
12608        Err(ErrorContext::new_missing(
12609            "LinkinfoIp6tnlAttrs",
12610            "Local",
12611            self.orig_loc,
12612            self.buf.as_ptr() as usize,
12613        ))
12614    }
12615    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
12616        let mut iter = self.clone();
12617        iter.pos = 0;
12618        for attr in iter {
12619            if let LinkinfoIp6tnlAttrs::Remote(val) = attr? {
12620                return Ok(val);
12621            }
12622        }
12623        Err(ErrorContext::new_missing(
12624            "LinkinfoIp6tnlAttrs",
12625            "Remote",
12626            self.orig_loc,
12627            self.buf.as_ptr() as usize,
12628        ))
12629    }
12630    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
12631        let mut iter = self.clone();
12632        iter.pos = 0;
12633        for attr in iter {
12634            if let LinkinfoIp6tnlAttrs::Ttl(val) = attr? {
12635                return Ok(val);
12636            }
12637        }
12638        Err(ErrorContext::new_missing(
12639            "LinkinfoIp6tnlAttrs",
12640            "Ttl",
12641            self.orig_loc,
12642            self.buf.as_ptr() as usize,
12643        ))
12644    }
12645    pub fn get_encap_limit(&self) -> Result<u8, ErrorContext> {
12646        let mut iter = self.clone();
12647        iter.pos = 0;
12648        for attr in iter {
12649            if let LinkinfoIp6tnlAttrs::EncapLimit(val) = attr? {
12650                return Ok(val);
12651            }
12652        }
12653        Err(ErrorContext::new_missing(
12654            "LinkinfoIp6tnlAttrs",
12655            "EncapLimit",
12656            self.orig_loc,
12657            self.buf.as_ptr() as usize,
12658        ))
12659    }
12660    pub fn get_flowinfo(&self) -> Result<u32, ErrorContext> {
12661        let mut iter = self.clone();
12662        iter.pos = 0;
12663        for attr in iter {
12664            if let LinkinfoIp6tnlAttrs::Flowinfo(val) = attr? {
12665                return Ok(val);
12666            }
12667        }
12668        Err(ErrorContext::new_missing(
12669            "LinkinfoIp6tnlAttrs",
12670            "Flowinfo",
12671            self.orig_loc,
12672            self.buf.as_ptr() as usize,
12673        ))
12674    }
12675    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
12676        let mut iter = self.clone();
12677        iter.pos = 0;
12678        for attr in iter {
12679            if let LinkinfoIp6tnlAttrs::Flags(val) = attr? {
12680                return Ok(val);
12681            }
12682        }
12683        Err(ErrorContext::new_missing(
12684            "LinkinfoIp6tnlAttrs",
12685            "Flags",
12686            self.orig_loc,
12687            self.buf.as_ptr() as usize,
12688        ))
12689    }
12690    pub fn get_proto(&self) -> Result<u8, ErrorContext> {
12691        let mut iter = self.clone();
12692        iter.pos = 0;
12693        for attr in iter {
12694            if let LinkinfoIp6tnlAttrs::Proto(val) = attr? {
12695                return Ok(val);
12696            }
12697        }
12698        Err(ErrorContext::new_missing(
12699            "LinkinfoIp6tnlAttrs",
12700            "Proto",
12701            self.orig_loc,
12702            self.buf.as_ptr() as usize,
12703        ))
12704    }
12705    pub fn get_encap_type(&self) -> Result<u16, ErrorContext> {
12706        let mut iter = self.clone();
12707        iter.pos = 0;
12708        for attr in iter {
12709            if let LinkinfoIp6tnlAttrs::EncapType(val) = attr? {
12710                return Ok(val);
12711            }
12712        }
12713        Err(ErrorContext::new_missing(
12714            "LinkinfoIp6tnlAttrs",
12715            "EncapType",
12716            self.orig_loc,
12717            self.buf.as_ptr() as usize,
12718        ))
12719    }
12720    pub fn get_encap_flags(&self) -> Result<u16, ErrorContext> {
12721        let mut iter = self.clone();
12722        iter.pos = 0;
12723        for attr in iter {
12724            if let LinkinfoIp6tnlAttrs::EncapFlags(val) = attr? {
12725                return Ok(val);
12726            }
12727        }
12728        Err(ErrorContext::new_missing(
12729            "LinkinfoIp6tnlAttrs",
12730            "EncapFlags",
12731            self.orig_loc,
12732            self.buf.as_ptr() as usize,
12733        ))
12734    }
12735    pub fn get_encap_sport(&self) -> Result<u16, ErrorContext> {
12736        let mut iter = self.clone();
12737        iter.pos = 0;
12738        for attr in iter {
12739            if let LinkinfoIp6tnlAttrs::EncapSport(val) = attr? {
12740                return Ok(val);
12741            }
12742        }
12743        Err(ErrorContext::new_missing(
12744            "LinkinfoIp6tnlAttrs",
12745            "EncapSport",
12746            self.orig_loc,
12747            self.buf.as_ptr() as usize,
12748        ))
12749    }
12750    pub fn get_encap_dport(&self) -> Result<u16, ErrorContext> {
12751        let mut iter = self.clone();
12752        iter.pos = 0;
12753        for attr in iter {
12754            if let LinkinfoIp6tnlAttrs::EncapDport(val) = attr? {
12755                return Ok(val);
12756            }
12757        }
12758        Err(ErrorContext::new_missing(
12759            "LinkinfoIp6tnlAttrs",
12760            "EncapDport",
12761            self.orig_loc,
12762            self.buf.as_ptr() as usize,
12763        ))
12764    }
12765    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
12766        let mut iter = self.clone();
12767        iter.pos = 0;
12768        for attr in iter {
12769            if let LinkinfoIp6tnlAttrs::CollectMetadata(val) = attr? {
12770                return Ok(val);
12771            }
12772        }
12773        Err(ErrorContext::new_missing(
12774            "LinkinfoIp6tnlAttrs",
12775            "CollectMetadata",
12776            self.orig_loc,
12777            self.buf.as_ptr() as usize,
12778        ))
12779    }
12780    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
12781        let mut iter = self.clone();
12782        iter.pos = 0;
12783        for attr in iter {
12784            if let LinkinfoIp6tnlAttrs::Fwmark(val) = attr? {
12785                return Ok(val);
12786            }
12787        }
12788        Err(ErrorContext::new_missing(
12789            "LinkinfoIp6tnlAttrs",
12790            "Fwmark",
12791            self.orig_loc,
12792            self.buf.as_ptr() as usize,
12793        ))
12794    }
12795}
12796impl LinkinfoIp6tnlAttrs<'_> {
12797    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoIp6tnlAttrs<'a> {
12798        IterableLinkinfoIp6tnlAttrs::with_loc(buf, buf.as_ptr() as usize)
12799    }
12800    fn attr_from_type(r#type: u16) -> Option<&'static str> {
12801        LinkinfoIptunAttrs::attr_from_type(r#type)
12802    }
12803}
12804#[derive(Clone, Copy, Default)]
12805pub struct IterableLinkinfoIp6tnlAttrs<'a> {
12806    buf: &'a [u8],
12807    pos: usize,
12808    orig_loc: usize,
12809}
12810impl<'a> IterableLinkinfoIp6tnlAttrs<'a> {
12811    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
12812        Self {
12813            buf,
12814            pos: 0,
12815            orig_loc,
12816        }
12817    }
12818    pub fn get_buf(&self) -> &'a [u8] {
12819        self.buf
12820    }
12821}
12822impl<'a> Iterator for IterableLinkinfoIp6tnlAttrs<'a> {
12823    type Item = Result<LinkinfoIp6tnlAttrs<'a>, ErrorContext>;
12824    fn next(&mut self) -> Option<Self::Item> {
12825        let pos = self.pos;
12826        let mut r#type;
12827        loop {
12828            r#type = None;
12829            if self.buf.len() == self.pos {
12830                return None;
12831            }
12832            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
12833                break;
12834            };
12835            r#type = Some(header.r#type);
12836            let res = match header.r#type {
12837                1u16 => LinkinfoIp6tnlAttrs::Link({
12838                    let res = parse_u32(next);
12839                    let Some(val) = res else { break };
12840                    val
12841                }),
12842                2u16 => LinkinfoIp6tnlAttrs::Local({
12843                    let res = Some(next);
12844                    let Some(val) = res else { break };
12845                    val
12846                }),
12847                3u16 => LinkinfoIp6tnlAttrs::Remote({
12848                    let res = Some(next);
12849                    let Some(val) = res else { break };
12850                    val
12851                }),
12852                4u16 => LinkinfoIp6tnlAttrs::Ttl({
12853                    let res = parse_u8(next);
12854                    let Some(val) = res else { break };
12855                    val
12856                }),
12857                6u16 => LinkinfoIp6tnlAttrs::EncapLimit({
12858                    let res = parse_u8(next);
12859                    let Some(val) = res else { break };
12860                    val
12861                }),
12862                7u16 => LinkinfoIp6tnlAttrs::Flowinfo({
12863                    let res = parse_be_u32(next);
12864                    let Some(val) = res else { break };
12865                    val
12866                }),
12867                8u16 => LinkinfoIp6tnlAttrs::Flags({
12868                    let res = parse_be_u32(next);
12869                    let Some(val) = res else { break };
12870                    val
12871                }),
12872                9u16 => LinkinfoIp6tnlAttrs::Proto({
12873                    let res = parse_u8(next);
12874                    let Some(val) = res else { break };
12875                    val
12876                }),
12877                15u16 => LinkinfoIp6tnlAttrs::EncapType({
12878                    let res = parse_u16(next);
12879                    let Some(val) = res else { break };
12880                    val
12881                }),
12882                16u16 => LinkinfoIp6tnlAttrs::EncapFlags({
12883                    let res = parse_u16(next);
12884                    let Some(val) = res else { break };
12885                    val
12886                }),
12887                17u16 => LinkinfoIp6tnlAttrs::EncapSport({
12888                    let res = parse_be_u16(next);
12889                    let Some(val) = res else { break };
12890                    val
12891                }),
12892                18u16 => LinkinfoIp6tnlAttrs::EncapDport({
12893                    let res = parse_be_u16(next);
12894                    let Some(val) = res else { break };
12895                    val
12896                }),
12897                19u16 => LinkinfoIp6tnlAttrs::CollectMetadata(()),
12898                20u16 => LinkinfoIp6tnlAttrs::Fwmark({
12899                    let res = parse_u32(next);
12900                    let Some(val) = res else { break };
12901                    val
12902                }),
12903                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
12904                n => continue,
12905            };
12906            return Some(Ok(res));
12907        }
12908        Some(Err(ErrorContext::new(
12909            "LinkinfoIp6tnlAttrs",
12910            r#type.and_then(|t| LinkinfoIp6tnlAttrs::attr_from_type(t)),
12911            self.orig_loc,
12912            self.buf.as_ptr().wrapping_add(pos) as usize,
12913        )))
12914    }
12915}
12916impl<'a> std::fmt::Debug for IterableLinkinfoIp6tnlAttrs<'_> {
12917    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12918        let mut fmt = f.debug_struct("LinkinfoIp6tnlAttrs");
12919        for attr in self.clone() {
12920            let attr = match attr {
12921                Ok(a) => a,
12922                Err(err) => {
12923                    fmt.finish()?;
12924                    f.write_str("Err(")?;
12925                    err.fmt(f)?;
12926                    return f.write_str(")");
12927                }
12928            };
12929            match attr {
12930                LinkinfoIp6tnlAttrs::Link(val) => fmt.field("Link", &val),
12931                LinkinfoIp6tnlAttrs::Local(val) => fmt.field("Local", &val),
12932                LinkinfoIp6tnlAttrs::Remote(val) => fmt.field("Remote", &val),
12933                LinkinfoIp6tnlAttrs::Ttl(val) => fmt.field("Ttl", &val),
12934                LinkinfoIp6tnlAttrs::EncapLimit(val) => fmt.field("EncapLimit", &val),
12935                LinkinfoIp6tnlAttrs::Flowinfo(val) => fmt.field("Flowinfo", &val),
12936                LinkinfoIp6tnlAttrs::Flags(val) => fmt.field("Flags", &val),
12937                LinkinfoIp6tnlAttrs::Proto(val) => fmt.field("Proto", &val),
12938                LinkinfoIp6tnlAttrs::EncapType(val) => fmt.field("EncapType", &val),
12939                LinkinfoIp6tnlAttrs::EncapFlags(val) => fmt.field("EncapFlags", &val),
12940                LinkinfoIp6tnlAttrs::EncapSport(val) => fmt.field("EncapSport", &val),
12941                LinkinfoIp6tnlAttrs::EncapDport(val) => fmt.field("EncapDport", &val),
12942                LinkinfoIp6tnlAttrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
12943                LinkinfoIp6tnlAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
12944            };
12945        }
12946        fmt.finish()
12947    }
12948}
12949impl IterableLinkinfoIp6tnlAttrs<'_> {
12950    pub fn lookup_attr(
12951        &self,
12952        offset: usize,
12953        missing_type: Option<u16>,
12954    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
12955        let mut stack = Vec::new();
12956        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
12957        if cur == offset {
12958            stack.push(("LinkinfoIp6tnlAttrs", offset));
12959            return (
12960                stack,
12961                missing_type.and_then(|t| LinkinfoIp6tnlAttrs::attr_from_type(t)),
12962            );
12963        }
12964        if cur > offset || cur + self.buf.len() < offset {
12965            return (stack, None);
12966        }
12967        let mut attrs = self.clone();
12968        let mut last_off = cur + attrs.pos;
12969        while let Some(attr) = attrs.next() {
12970            let Ok(attr) = attr else { break };
12971            match attr {
12972                LinkinfoIp6tnlAttrs::Link(val) => {
12973                    if last_off == offset {
12974                        stack.push(("Link", last_off));
12975                        break;
12976                    }
12977                }
12978                LinkinfoIp6tnlAttrs::Local(val) => {
12979                    if last_off == offset {
12980                        stack.push(("Local", last_off));
12981                        break;
12982                    }
12983                }
12984                LinkinfoIp6tnlAttrs::Remote(val) => {
12985                    if last_off == offset {
12986                        stack.push(("Remote", last_off));
12987                        break;
12988                    }
12989                }
12990                LinkinfoIp6tnlAttrs::Ttl(val) => {
12991                    if last_off == offset {
12992                        stack.push(("Ttl", last_off));
12993                        break;
12994                    }
12995                }
12996                LinkinfoIp6tnlAttrs::EncapLimit(val) => {
12997                    if last_off == offset {
12998                        stack.push(("EncapLimit", last_off));
12999                        break;
13000                    }
13001                }
13002                LinkinfoIp6tnlAttrs::Flowinfo(val) => {
13003                    if last_off == offset {
13004                        stack.push(("Flowinfo", last_off));
13005                        break;
13006                    }
13007                }
13008                LinkinfoIp6tnlAttrs::Flags(val) => {
13009                    if last_off == offset {
13010                        stack.push(("Flags", last_off));
13011                        break;
13012                    }
13013                }
13014                LinkinfoIp6tnlAttrs::Proto(val) => {
13015                    if last_off == offset {
13016                        stack.push(("Proto", last_off));
13017                        break;
13018                    }
13019                }
13020                LinkinfoIp6tnlAttrs::EncapType(val) => {
13021                    if last_off == offset {
13022                        stack.push(("EncapType", last_off));
13023                        break;
13024                    }
13025                }
13026                LinkinfoIp6tnlAttrs::EncapFlags(val) => {
13027                    if last_off == offset {
13028                        stack.push(("EncapFlags", last_off));
13029                        break;
13030                    }
13031                }
13032                LinkinfoIp6tnlAttrs::EncapSport(val) => {
13033                    if last_off == offset {
13034                        stack.push(("EncapSport", last_off));
13035                        break;
13036                    }
13037                }
13038                LinkinfoIp6tnlAttrs::EncapDport(val) => {
13039                    if last_off == offset {
13040                        stack.push(("EncapDport", last_off));
13041                        break;
13042                    }
13043                }
13044                LinkinfoIp6tnlAttrs::CollectMetadata(val) => {
13045                    if last_off == offset {
13046                        stack.push(("CollectMetadata", last_off));
13047                        break;
13048                    }
13049                }
13050                LinkinfoIp6tnlAttrs::Fwmark(val) => {
13051                    if last_off == offset {
13052                        stack.push(("Fwmark", last_off));
13053                        break;
13054                    }
13055                }
13056                _ => {}
13057            };
13058            last_off = cur + attrs.pos;
13059        }
13060        if !stack.is_empty() {
13061            stack.push(("LinkinfoIp6tnlAttrs", cur));
13062        }
13063        (stack, None)
13064    }
13065}
13066#[derive(Clone)]
13067pub enum LinkinfoTunAttrs {
13068    Owner(u32),
13069    Group(u32),
13070    Type(u8),
13071    Pi(u8),
13072    VnetHdr(u8),
13073    Persist(u8),
13074    MultiQueue(u8),
13075    NumQueues(u32),
13076    NumDisabledQueues(u32),
13077}
13078impl<'a> IterableLinkinfoTunAttrs<'a> {
13079    pub fn get_owner(&self) -> Result<u32, ErrorContext> {
13080        let mut iter = self.clone();
13081        iter.pos = 0;
13082        for attr in iter {
13083            if let LinkinfoTunAttrs::Owner(val) = attr? {
13084                return Ok(val);
13085            }
13086        }
13087        Err(ErrorContext::new_missing(
13088            "LinkinfoTunAttrs",
13089            "Owner",
13090            self.orig_loc,
13091            self.buf.as_ptr() as usize,
13092        ))
13093    }
13094    pub fn get_group(&self) -> Result<u32, ErrorContext> {
13095        let mut iter = self.clone();
13096        iter.pos = 0;
13097        for attr in iter {
13098            if let LinkinfoTunAttrs::Group(val) = attr? {
13099                return Ok(val);
13100            }
13101        }
13102        Err(ErrorContext::new_missing(
13103            "LinkinfoTunAttrs",
13104            "Group",
13105            self.orig_loc,
13106            self.buf.as_ptr() as usize,
13107        ))
13108    }
13109    pub fn get_type(&self) -> Result<u8, ErrorContext> {
13110        let mut iter = self.clone();
13111        iter.pos = 0;
13112        for attr in iter {
13113            if let LinkinfoTunAttrs::Type(val) = attr? {
13114                return Ok(val);
13115            }
13116        }
13117        Err(ErrorContext::new_missing(
13118            "LinkinfoTunAttrs",
13119            "Type",
13120            self.orig_loc,
13121            self.buf.as_ptr() as usize,
13122        ))
13123    }
13124    pub fn get_pi(&self) -> Result<u8, ErrorContext> {
13125        let mut iter = self.clone();
13126        iter.pos = 0;
13127        for attr in iter {
13128            if let LinkinfoTunAttrs::Pi(val) = attr? {
13129                return Ok(val);
13130            }
13131        }
13132        Err(ErrorContext::new_missing(
13133            "LinkinfoTunAttrs",
13134            "Pi",
13135            self.orig_loc,
13136            self.buf.as_ptr() as usize,
13137        ))
13138    }
13139    pub fn get_vnet_hdr(&self) -> Result<u8, ErrorContext> {
13140        let mut iter = self.clone();
13141        iter.pos = 0;
13142        for attr in iter {
13143            if let LinkinfoTunAttrs::VnetHdr(val) = attr? {
13144                return Ok(val);
13145            }
13146        }
13147        Err(ErrorContext::new_missing(
13148            "LinkinfoTunAttrs",
13149            "VnetHdr",
13150            self.orig_loc,
13151            self.buf.as_ptr() as usize,
13152        ))
13153    }
13154    pub fn get_persist(&self) -> Result<u8, ErrorContext> {
13155        let mut iter = self.clone();
13156        iter.pos = 0;
13157        for attr in iter {
13158            if let LinkinfoTunAttrs::Persist(val) = attr? {
13159                return Ok(val);
13160            }
13161        }
13162        Err(ErrorContext::new_missing(
13163            "LinkinfoTunAttrs",
13164            "Persist",
13165            self.orig_loc,
13166            self.buf.as_ptr() as usize,
13167        ))
13168    }
13169    pub fn get_multi_queue(&self) -> Result<u8, ErrorContext> {
13170        let mut iter = self.clone();
13171        iter.pos = 0;
13172        for attr in iter {
13173            if let LinkinfoTunAttrs::MultiQueue(val) = attr? {
13174                return Ok(val);
13175            }
13176        }
13177        Err(ErrorContext::new_missing(
13178            "LinkinfoTunAttrs",
13179            "MultiQueue",
13180            self.orig_loc,
13181            self.buf.as_ptr() as usize,
13182        ))
13183    }
13184    pub fn get_num_queues(&self) -> Result<u32, ErrorContext> {
13185        let mut iter = self.clone();
13186        iter.pos = 0;
13187        for attr in iter {
13188            if let LinkinfoTunAttrs::NumQueues(val) = attr? {
13189                return Ok(val);
13190            }
13191        }
13192        Err(ErrorContext::new_missing(
13193            "LinkinfoTunAttrs",
13194            "NumQueues",
13195            self.orig_loc,
13196            self.buf.as_ptr() as usize,
13197        ))
13198    }
13199    pub fn get_num_disabled_queues(&self) -> Result<u32, ErrorContext> {
13200        let mut iter = self.clone();
13201        iter.pos = 0;
13202        for attr in iter {
13203            if let LinkinfoTunAttrs::NumDisabledQueues(val) = attr? {
13204                return Ok(val);
13205            }
13206        }
13207        Err(ErrorContext::new_missing(
13208            "LinkinfoTunAttrs",
13209            "NumDisabledQueues",
13210            self.orig_loc,
13211            self.buf.as_ptr() as usize,
13212        ))
13213    }
13214}
13215impl LinkinfoTunAttrs {
13216    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoTunAttrs<'a> {
13217        IterableLinkinfoTunAttrs::with_loc(buf, buf.as_ptr() as usize)
13218    }
13219    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13220        let res = match r#type {
13221            1u16 => "Owner",
13222            2u16 => "Group",
13223            3u16 => "Type",
13224            4u16 => "Pi",
13225            5u16 => "VnetHdr",
13226            6u16 => "Persist",
13227            7u16 => "MultiQueue",
13228            8u16 => "NumQueues",
13229            9u16 => "NumDisabledQueues",
13230            _ => return None,
13231        };
13232        Some(res)
13233    }
13234}
13235#[derive(Clone, Copy, Default)]
13236pub struct IterableLinkinfoTunAttrs<'a> {
13237    buf: &'a [u8],
13238    pos: usize,
13239    orig_loc: usize,
13240}
13241impl<'a> IterableLinkinfoTunAttrs<'a> {
13242    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13243        Self {
13244            buf,
13245            pos: 0,
13246            orig_loc,
13247        }
13248    }
13249    pub fn get_buf(&self) -> &'a [u8] {
13250        self.buf
13251    }
13252}
13253impl<'a> Iterator for IterableLinkinfoTunAttrs<'a> {
13254    type Item = Result<LinkinfoTunAttrs, ErrorContext>;
13255    fn next(&mut self) -> Option<Self::Item> {
13256        let pos = self.pos;
13257        let mut r#type;
13258        loop {
13259            r#type = None;
13260            if self.buf.len() == self.pos {
13261                return None;
13262            }
13263            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
13264                break;
13265            };
13266            r#type = Some(header.r#type);
13267            let res = match header.r#type {
13268                1u16 => LinkinfoTunAttrs::Owner({
13269                    let res = parse_u32(next);
13270                    let Some(val) = res else { break };
13271                    val
13272                }),
13273                2u16 => LinkinfoTunAttrs::Group({
13274                    let res = parse_u32(next);
13275                    let Some(val) = res else { break };
13276                    val
13277                }),
13278                3u16 => LinkinfoTunAttrs::Type({
13279                    let res = parse_u8(next);
13280                    let Some(val) = res else { break };
13281                    val
13282                }),
13283                4u16 => LinkinfoTunAttrs::Pi({
13284                    let res = parse_u8(next);
13285                    let Some(val) = res else { break };
13286                    val
13287                }),
13288                5u16 => LinkinfoTunAttrs::VnetHdr({
13289                    let res = parse_u8(next);
13290                    let Some(val) = res else { break };
13291                    val
13292                }),
13293                6u16 => LinkinfoTunAttrs::Persist({
13294                    let res = parse_u8(next);
13295                    let Some(val) = res else { break };
13296                    val
13297                }),
13298                7u16 => LinkinfoTunAttrs::MultiQueue({
13299                    let res = parse_u8(next);
13300                    let Some(val) = res else { break };
13301                    val
13302                }),
13303                8u16 => LinkinfoTunAttrs::NumQueues({
13304                    let res = parse_u32(next);
13305                    let Some(val) = res else { break };
13306                    val
13307                }),
13308                9u16 => LinkinfoTunAttrs::NumDisabledQueues({
13309                    let res = parse_u32(next);
13310                    let Some(val) = res else { break };
13311                    val
13312                }),
13313                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
13314                n => continue,
13315            };
13316            return Some(Ok(res));
13317        }
13318        Some(Err(ErrorContext::new(
13319            "LinkinfoTunAttrs",
13320            r#type.and_then(|t| LinkinfoTunAttrs::attr_from_type(t)),
13321            self.orig_loc,
13322            self.buf.as_ptr().wrapping_add(pos) as usize,
13323        )))
13324    }
13325}
13326impl std::fmt::Debug for IterableLinkinfoTunAttrs<'_> {
13327    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13328        let mut fmt = f.debug_struct("LinkinfoTunAttrs");
13329        for attr in self.clone() {
13330            let attr = match attr {
13331                Ok(a) => a,
13332                Err(err) => {
13333                    fmt.finish()?;
13334                    f.write_str("Err(")?;
13335                    err.fmt(f)?;
13336                    return f.write_str(")");
13337                }
13338            };
13339            match attr {
13340                LinkinfoTunAttrs::Owner(val) => fmt.field("Owner", &val),
13341                LinkinfoTunAttrs::Group(val) => fmt.field("Group", &val),
13342                LinkinfoTunAttrs::Type(val) => fmt.field("Type", &val),
13343                LinkinfoTunAttrs::Pi(val) => fmt.field("Pi", &val),
13344                LinkinfoTunAttrs::VnetHdr(val) => fmt.field("VnetHdr", &val),
13345                LinkinfoTunAttrs::Persist(val) => fmt.field("Persist", &val),
13346                LinkinfoTunAttrs::MultiQueue(val) => fmt.field("MultiQueue", &val),
13347                LinkinfoTunAttrs::NumQueues(val) => fmt.field("NumQueues", &val),
13348                LinkinfoTunAttrs::NumDisabledQueues(val) => fmt.field("NumDisabledQueues", &val),
13349            };
13350        }
13351        fmt.finish()
13352    }
13353}
13354impl IterableLinkinfoTunAttrs<'_> {
13355    pub fn lookup_attr(
13356        &self,
13357        offset: usize,
13358        missing_type: Option<u16>,
13359    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13360        let mut stack = Vec::new();
13361        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13362        if cur == offset {
13363            stack.push(("LinkinfoTunAttrs", offset));
13364            return (
13365                stack,
13366                missing_type.and_then(|t| LinkinfoTunAttrs::attr_from_type(t)),
13367            );
13368        }
13369        if cur > offset || cur + self.buf.len() < offset {
13370            return (stack, None);
13371        }
13372        let mut attrs = self.clone();
13373        let mut last_off = cur + attrs.pos;
13374        while let Some(attr) = attrs.next() {
13375            let Ok(attr) = attr else { break };
13376            match attr {
13377                LinkinfoTunAttrs::Owner(val) => {
13378                    if last_off == offset {
13379                        stack.push(("Owner", last_off));
13380                        break;
13381                    }
13382                }
13383                LinkinfoTunAttrs::Group(val) => {
13384                    if last_off == offset {
13385                        stack.push(("Group", last_off));
13386                        break;
13387                    }
13388                }
13389                LinkinfoTunAttrs::Type(val) => {
13390                    if last_off == offset {
13391                        stack.push(("Type", last_off));
13392                        break;
13393                    }
13394                }
13395                LinkinfoTunAttrs::Pi(val) => {
13396                    if last_off == offset {
13397                        stack.push(("Pi", last_off));
13398                        break;
13399                    }
13400                }
13401                LinkinfoTunAttrs::VnetHdr(val) => {
13402                    if last_off == offset {
13403                        stack.push(("VnetHdr", last_off));
13404                        break;
13405                    }
13406                }
13407                LinkinfoTunAttrs::Persist(val) => {
13408                    if last_off == offset {
13409                        stack.push(("Persist", last_off));
13410                        break;
13411                    }
13412                }
13413                LinkinfoTunAttrs::MultiQueue(val) => {
13414                    if last_off == offset {
13415                        stack.push(("MultiQueue", last_off));
13416                        break;
13417                    }
13418                }
13419                LinkinfoTunAttrs::NumQueues(val) => {
13420                    if last_off == offset {
13421                        stack.push(("NumQueues", last_off));
13422                        break;
13423                    }
13424                }
13425                LinkinfoTunAttrs::NumDisabledQueues(val) => {
13426                    if last_off == offset {
13427                        stack.push(("NumDisabledQueues", last_off));
13428                        break;
13429                    }
13430                }
13431                _ => {}
13432            };
13433            last_off = cur + attrs.pos;
13434        }
13435        if !stack.is_empty() {
13436            stack.push(("LinkinfoTunAttrs", cur));
13437        }
13438        (stack, None)
13439    }
13440}
13441#[derive(Clone)]
13442pub enum LinkinfoVlanAttrs<'a> {
13443    Id(u16),
13444    Flags(PushIflaVlanFlags),
13445    EgressQos(IterableIflaVlanQos<'a>),
13446    IngressQos(IterableIflaVlanQos<'a>),
13447    #[doc = "Associated type: \"VlanProtocols\" (enum)"]
13448    Protocol(u16),
13449}
13450impl<'a> IterableLinkinfoVlanAttrs<'a> {
13451    pub fn get_id(&self) -> Result<u16, ErrorContext> {
13452        let mut iter = self.clone();
13453        iter.pos = 0;
13454        for attr in iter {
13455            if let LinkinfoVlanAttrs::Id(val) = attr? {
13456                return Ok(val);
13457            }
13458        }
13459        Err(ErrorContext::new_missing(
13460            "LinkinfoVlanAttrs",
13461            "Id",
13462            self.orig_loc,
13463            self.buf.as_ptr() as usize,
13464        ))
13465    }
13466    pub fn get_flags(&self) -> Result<PushIflaVlanFlags, ErrorContext> {
13467        let mut iter = self.clone();
13468        iter.pos = 0;
13469        for attr in iter {
13470            if let LinkinfoVlanAttrs::Flags(val) = attr? {
13471                return Ok(val);
13472            }
13473        }
13474        Err(ErrorContext::new_missing(
13475            "LinkinfoVlanAttrs",
13476            "Flags",
13477            self.orig_loc,
13478            self.buf.as_ptr() as usize,
13479        ))
13480    }
13481    pub fn get_egress_qos(&self) -> Result<IterableIflaVlanQos<'a>, ErrorContext> {
13482        let mut iter = self.clone();
13483        iter.pos = 0;
13484        for attr in iter {
13485            if let LinkinfoVlanAttrs::EgressQos(val) = attr? {
13486                return Ok(val);
13487            }
13488        }
13489        Err(ErrorContext::new_missing(
13490            "LinkinfoVlanAttrs",
13491            "EgressQos",
13492            self.orig_loc,
13493            self.buf.as_ptr() as usize,
13494        ))
13495    }
13496    pub fn get_ingress_qos(&self) -> Result<IterableIflaVlanQos<'a>, ErrorContext> {
13497        let mut iter = self.clone();
13498        iter.pos = 0;
13499        for attr in iter {
13500            if let LinkinfoVlanAttrs::IngressQos(val) = attr? {
13501                return Ok(val);
13502            }
13503        }
13504        Err(ErrorContext::new_missing(
13505            "LinkinfoVlanAttrs",
13506            "IngressQos",
13507            self.orig_loc,
13508            self.buf.as_ptr() as usize,
13509        ))
13510    }
13511    #[doc = "Associated type: \"VlanProtocols\" (enum)"]
13512    pub fn get_protocol(&self) -> Result<u16, ErrorContext> {
13513        let mut iter = self.clone();
13514        iter.pos = 0;
13515        for attr in iter {
13516            if let LinkinfoVlanAttrs::Protocol(val) = attr? {
13517                return Ok(val);
13518            }
13519        }
13520        Err(ErrorContext::new_missing(
13521            "LinkinfoVlanAttrs",
13522            "Protocol",
13523            self.orig_loc,
13524            self.buf.as_ptr() as usize,
13525        ))
13526    }
13527}
13528impl LinkinfoVlanAttrs<'_> {
13529    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoVlanAttrs<'a> {
13530        IterableLinkinfoVlanAttrs::with_loc(buf, buf.as_ptr() as usize)
13531    }
13532    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13533        let res = match r#type {
13534            1u16 => "Id",
13535            2u16 => "Flags",
13536            3u16 => "EgressQos",
13537            4u16 => "IngressQos",
13538            5u16 => "Protocol",
13539            _ => return None,
13540        };
13541        Some(res)
13542    }
13543}
13544#[derive(Clone, Copy, Default)]
13545pub struct IterableLinkinfoVlanAttrs<'a> {
13546    buf: &'a [u8],
13547    pos: usize,
13548    orig_loc: usize,
13549}
13550impl<'a> IterableLinkinfoVlanAttrs<'a> {
13551    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13552        Self {
13553            buf,
13554            pos: 0,
13555            orig_loc,
13556        }
13557    }
13558    pub fn get_buf(&self) -> &'a [u8] {
13559        self.buf
13560    }
13561}
13562impl<'a> Iterator for IterableLinkinfoVlanAttrs<'a> {
13563    type Item = Result<LinkinfoVlanAttrs<'a>, ErrorContext>;
13564    fn next(&mut self) -> Option<Self::Item> {
13565        let pos = self.pos;
13566        let mut r#type;
13567        loop {
13568            r#type = None;
13569            if self.buf.len() == self.pos {
13570                return None;
13571            }
13572            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
13573                break;
13574            };
13575            r#type = Some(header.r#type);
13576            let res = match header.r#type {
13577                1u16 => LinkinfoVlanAttrs::Id({
13578                    let res = parse_u16(next);
13579                    let Some(val) = res else { break };
13580                    val
13581                }),
13582                2u16 => LinkinfoVlanAttrs::Flags({
13583                    let res = PushIflaVlanFlags::new_from_slice(next);
13584                    let Some(val) = res else { break };
13585                    val
13586                }),
13587                3u16 => LinkinfoVlanAttrs::EgressQos({
13588                    let res = Some(IterableIflaVlanQos::with_loc(next, self.orig_loc));
13589                    let Some(val) = res else { break };
13590                    val
13591                }),
13592                4u16 => LinkinfoVlanAttrs::IngressQos({
13593                    let res = Some(IterableIflaVlanQos::with_loc(next, self.orig_loc));
13594                    let Some(val) = res else { break };
13595                    val
13596                }),
13597                5u16 => LinkinfoVlanAttrs::Protocol({
13598                    let res = parse_be_u16(next);
13599                    let Some(val) = res else { break };
13600                    val
13601                }),
13602                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
13603                n => continue,
13604            };
13605            return Some(Ok(res));
13606        }
13607        Some(Err(ErrorContext::new(
13608            "LinkinfoVlanAttrs",
13609            r#type.and_then(|t| LinkinfoVlanAttrs::attr_from_type(t)),
13610            self.orig_loc,
13611            self.buf.as_ptr().wrapping_add(pos) as usize,
13612        )))
13613    }
13614}
13615impl<'a> std::fmt::Debug for IterableLinkinfoVlanAttrs<'_> {
13616    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13617        let mut fmt = f.debug_struct("LinkinfoVlanAttrs");
13618        for attr in self.clone() {
13619            let attr = match attr {
13620                Ok(a) => a,
13621                Err(err) => {
13622                    fmt.finish()?;
13623                    f.write_str("Err(")?;
13624                    err.fmt(f)?;
13625                    return f.write_str(")");
13626                }
13627            };
13628            match attr {
13629                LinkinfoVlanAttrs::Id(val) => fmt.field("Id", &val),
13630                LinkinfoVlanAttrs::Flags(val) => fmt.field("Flags", &val),
13631                LinkinfoVlanAttrs::EgressQos(val) => fmt.field("EgressQos", &val),
13632                LinkinfoVlanAttrs::IngressQos(val) => fmt.field("IngressQos", &val),
13633                LinkinfoVlanAttrs::Protocol(val) => fmt.field(
13634                    "Protocol",
13635                    &FormatEnum(val.into(), VlanProtocols::from_value),
13636                ),
13637            };
13638        }
13639        fmt.finish()
13640    }
13641}
13642impl IterableLinkinfoVlanAttrs<'_> {
13643    pub fn lookup_attr(
13644        &self,
13645        offset: usize,
13646        missing_type: Option<u16>,
13647    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13648        let mut stack = Vec::new();
13649        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13650        if cur == offset {
13651            stack.push(("LinkinfoVlanAttrs", offset));
13652            return (
13653                stack,
13654                missing_type.and_then(|t| LinkinfoVlanAttrs::attr_from_type(t)),
13655            );
13656        }
13657        if cur > offset || cur + self.buf.len() < offset {
13658            return (stack, None);
13659        }
13660        let mut attrs = self.clone();
13661        let mut last_off = cur + attrs.pos;
13662        let mut missing = None;
13663        while let Some(attr) = attrs.next() {
13664            let Ok(attr) = attr else { break };
13665            match attr {
13666                LinkinfoVlanAttrs::Id(val) => {
13667                    if last_off == offset {
13668                        stack.push(("Id", last_off));
13669                        break;
13670                    }
13671                }
13672                LinkinfoVlanAttrs::Flags(val) => {
13673                    if last_off == offset {
13674                        stack.push(("Flags", last_off));
13675                        break;
13676                    }
13677                }
13678                LinkinfoVlanAttrs::EgressQos(val) => {
13679                    (stack, missing) = val.lookup_attr(offset, missing_type);
13680                    if !stack.is_empty() {
13681                        break;
13682                    }
13683                }
13684                LinkinfoVlanAttrs::IngressQos(val) => {
13685                    (stack, missing) = val.lookup_attr(offset, missing_type);
13686                    if !stack.is_empty() {
13687                        break;
13688                    }
13689                }
13690                LinkinfoVlanAttrs::Protocol(val) => {
13691                    if last_off == offset {
13692                        stack.push(("Protocol", last_off));
13693                        break;
13694                    }
13695                }
13696                _ => {}
13697            };
13698            last_off = cur + attrs.pos;
13699        }
13700        if !stack.is_empty() {
13701            stack.push(("LinkinfoVlanAttrs", cur));
13702        }
13703        (stack, missing)
13704    }
13705}
13706#[derive(Clone)]
13707pub enum IflaVlanQos {
13708    #[doc = "Attribute may repeat multiple times (treat it as array)"]
13709    Mapping(PushIflaVlanQosMapping),
13710}
13711impl<'a> IterableIflaVlanQos<'a> {
13712    #[doc = "Attribute may repeat multiple times (treat it as array)"]
13713    pub fn get_mapping(&self) -> MultiAttrIterable<Self, IflaVlanQos, PushIflaVlanQosMapping> {
13714        MultiAttrIterable::new(self.clone(), |variant| {
13715            if let IflaVlanQos::Mapping(val) = variant {
13716                Some(val)
13717            } else {
13718                None
13719            }
13720        })
13721    }
13722}
13723impl IflaVlanQos {
13724    pub fn new<'a>(buf: &'a [u8]) -> IterableIflaVlanQos<'a> {
13725        IterableIflaVlanQos::with_loc(buf, buf.as_ptr() as usize)
13726    }
13727    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13728        let res = match r#type {
13729            1u16 => "Mapping",
13730            _ => return None,
13731        };
13732        Some(res)
13733    }
13734}
13735#[derive(Clone, Copy, Default)]
13736pub struct IterableIflaVlanQos<'a> {
13737    buf: &'a [u8],
13738    pos: usize,
13739    orig_loc: usize,
13740}
13741impl<'a> IterableIflaVlanQos<'a> {
13742    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13743        Self {
13744            buf,
13745            pos: 0,
13746            orig_loc,
13747        }
13748    }
13749    pub fn get_buf(&self) -> &'a [u8] {
13750        self.buf
13751    }
13752}
13753impl<'a> Iterator for IterableIflaVlanQos<'a> {
13754    type Item = Result<IflaVlanQos, ErrorContext>;
13755    fn next(&mut self) -> Option<Self::Item> {
13756        let pos = self.pos;
13757        let mut r#type;
13758        loop {
13759            r#type = None;
13760            if self.buf.len() == self.pos {
13761                return None;
13762            }
13763            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
13764                break;
13765            };
13766            r#type = Some(header.r#type);
13767            let res = match header.r#type {
13768                1u16 => IflaVlanQos::Mapping({
13769                    let res = PushIflaVlanQosMapping::new_from_slice(next);
13770                    let Some(val) = res else { break };
13771                    val
13772                }),
13773                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
13774                n => continue,
13775            };
13776            return Some(Ok(res));
13777        }
13778        Some(Err(ErrorContext::new(
13779            "IflaVlanQos",
13780            r#type.and_then(|t| IflaVlanQos::attr_from_type(t)),
13781            self.orig_loc,
13782            self.buf.as_ptr().wrapping_add(pos) as usize,
13783        )))
13784    }
13785}
13786impl std::fmt::Debug for IterableIflaVlanQos<'_> {
13787    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13788        let mut fmt = f.debug_struct("IflaVlanQos");
13789        for attr in self.clone() {
13790            let attr = match attr {
13791                Ok(a) => a,
13792                Err(err) => {
13793                    fmt.finish()?;
13794                    f.write_str("Err(")?;
13795                    err.fmt(f)?;
13796                    return f.write_str(")");
13797                }
13798            };
13799            match attr {
13800                IflaVlanQos::Mapping(val) => fmt.field("Mapping", &val),
13801            };
13802        }
13803        fmt.finish()
13804    }
13805}
13806impl IterableIflaVlanQos<'_> {
13807    pub fn lookup_attr(
13808        &self,
13809        offset: usize,
13810        missing_type: Option<u16>,
13811    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13812        let mut stack = Vec::new();
13813        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13814        if cur == offset {
13815            stack.push(("IflaVlanQos", offset));
13816            return (
13817                stack,
13818                missing_type.and_then(|t| IflaVlanQos::attr_from_type(t)),
13819            );
13820        }
13821        if cur > offset || cur + self.buf.len() < offset {
13822            return (stack, None);
13823        }
13824        let mut attrs = self.clone();
13825        let mut last_off = cur + attrs.pos;
13826        while let Some(attr) = attrs.next() {
13827            let Ok(attr) = attr else { break };
13828            match attr {
13829                IflaVlanQos::Mapping(val) => {
13830                    if last_off == offset {
13831                        stack.push(("Mapping", last_off));
13832                        break;
13833                    }
13834                }
13835                _ => {}
13836            };
13837            last_off = cur + attrs.pos;
13838        }
13839        if !stack.is_empty() {
13840            stack.push(("IflaVlanQos", cur));
13841        }
13842        (stack, None)
13843    }
13844}
13845#[derive(Clone)]
13846pub enum LinkinfoVrfAttrs {
13847    Table(u32),
13848}
13849impl<'a> IterableLinkinfoVrfAttrs<'a> {
13850    pub fn get_table(&self) -> Result<u32, ErrorContext> {
13851        let mut iter = self.clone();
13852        iter.pos = 0;
13853        for attr in iter {
13854            if let LinkinfoVrfAttrs::Table(val) = attr? {
13855                return Ok(val);
13856            }
13857        }
13858        Err(ErrorContext::new_missing(
13859            "LinkinfoVrfAttrs",
13860            "Table",
13861            self.orig_loc,
13862            self.buf.as_ptr() as usize,
13863        ))
13864    }
13865}
13866impl LinkinfoVrfAttrs {
13867    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoVrfAttrs<'a> {
13868        IterableLinkinfoVrfAttrs::with_loc(buf, buf.as_ptr() as usize)
13869    }
13870    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13871        let res = match r#type {
13872            1u16 => "Table",
13873            _ => return None,
13874        };
13875        Some(res)
13876    }
13877}
13878#[derive(Clone, Copy, Default)]
13879pub struct IterableLinkinfoVrfAttrs<'a> {
13880    buf: &'a [u8],
13881    pos: usize,
13882    orig_loc: usize,
13883}
13884impl<'a> IterableLinkinfoVrfAttrs<'a> {
13885    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13886        Self {
13887            buf,
13888            pos: 0,
13889            orig_loc,
13890        }
13891    }
13892    pub fn get_buf(&self) -> &'a [u8] {
13893        self.buf
13894    }
13895}
13896impl<'a> Iterator for IterableLinkinfoVrfAttrs<'a> {
13897    type Item = Result<LinkinfoVrfAttrs, ErrorContext>;
13898    fn next(&mut self) -> Option<Self::Item> {
13899        let pos = self.pos;
13900        let mut r#type;
13901        loop {
13902            r#type = None;
13903            if self.buf.len() == self.pos {
13904                return None;
13905            }
13906            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
13907                break;
13908            };
13909            r#type = Some(header.r#type);
13910            let res = match header.r#type {
13911                1u16 => LinkinfoVrfAttrs::Table({
13912                    let res = parse_u32(next);
13913                    let Some(val) = res else { break };
13914                    val
13915                }),
13916                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
13917                n => continue,
13918            };
13919            return Some(Ok(res));
13920        }
13921        Some(Err(ErrorContext::new(
13922            "LinkinfoVrfAttrs",
13923            r#type.and_then(|t| LinkinfoVrfAttrs::attr_from_type(t)),
13924            self.orig_loc,
13925            self.buf.as_ptr().wrapping_add(pos) as usize,
13926        )))
13927    }
13928}
13929impl std::fmt::Debug for IterableLinkinfoVrfAttrs<'_> {
13930    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13931        let mut fmt = f.debug_struct("LinkinfoVrfAttrs");
13932        for attr in self.clone() {
13933            let attr = match attr {
13934                Ok(a) => a,
13935                Err(err) => {
13936                    fmt.finish()?;
13937                    f.write_str("Err(")?;
13938                    err.fmt(f)?;
13939                    return f.write_str(")");
13940                }
13941            };
13942            match attr {
13943                LinkinfoVrfAttrs::Table(val) => fmt.field("Table", &val),
13944            };
13945        }
13946        fmt.finish()
13947    }
13948}
13949impl IterableLinkinfoVrfAttrs<'_> {
13950    pub fn lookup_attr(
13951        &self,
13952        offset: usize,
13953        missing_type: Option<u16>,
13954    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13955        let mut stack = Vec::new();
13956        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13957        if cur == offset {
13958            stack.push(("LinkinfoVrfAttrs", offset));
13959            return (
13960                stack,
13961                missing_type.and_then(|t| LinkinfoVrfAttrs::attr_from_type(t)),
13962            );
13963        }
13964        if cur > offset || cur + self.buf.len() < offset {
13965            return (stack, None);
13966        }
13967        let mut attrs = self.clone();
13968        let mut last_off = cur + attrs.pos;
13969        while let Some(attr) = attrs.next() {
13970            let Ok(attr) = attr else { break };
13971            match attr {
13972                LinkinfoVrfAttrs::Table(val) => {
13973                    if last_off == offset {
13974                        stack.push(("Table", last_off));
13975                        break;
13976                    }
13977                }
13978                _ => {}
13979            };
13980            last_off = cur + attrs.pos;
13981        }
13982        if !stack.is_empty() {
13983            stack.push(("LinkinfoVrfAttrs", cur));
13984        }
13985        (stack, None)
13986    }
13987}
13988#[derive(Clone)]
13989pub enum XdpAttrs {
13990    Fd(i32),
13991    Attached(u8),
13992    Flags(u32),
13993    ProgId(u32),
13994    DrvProgId(u32),
13995    SkbProgId(u32),
13996    HwProgId(u32),
13997    ExpectedFd(i32),
13998}
13999impl<'a> IterableXdpAttrs<'a> {
14000    pub fn get_fd(&self) -> Result<i32, ErrorContext> {
14001        let mut iter = self.clone();
14002        iter.pos = 0;
14003        for attr in iter {
14004            if let XdpAttrs::Fd(val) = attr? {
14005                return Ok(val);
14006            }
14007        }
14008        Err(ErrorContext::new_missing(
14009            "XdpAttrs",
14010            "Fd",
14011            self.orig_loc,
14012            self.buf.as_ptr() as usize,
14013        ))
14014    }
14015    pub fn get_attached(&self) -> Result<u8, ErrorContext> {
14016        let mut iter = self.clone();
14017        iter.pos = 0;
14018        for attr in iter {
14019            if let XdpAttrs::Attached(val) = attr? {
14020                return Ok(val);
14021            }
14022        }
14023        Err(ErrorContext::new_missing(
14024            "XdpAttrs",
14025            "Attached",
14026            self.orig_loc,
14027            self.buf.as_ptr() as usize,
14028        ))
14029    }
14030    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
14031        let mut iter = self.clone();
14032        iter.pos = 0;
14033        for attr in iter {
14034            if let XdpAttrs::Flags(val) = attr? {
14035                return Ok(val);
14036            }
14037        }
14038        Err(ErrorContext::new_missing(
14039            "XdpAttrs",
14040            "Flags",
14041            self.orig_loc,
14042            self.buf.as_ptr() as usize,
14043        ))
14044    }
14045    pub fn get_prog_id(&self) -> Result<u32, ErrorContext> {
14046        let mut iter = self.clone();
14047        iter.pos = 0;
14048        for attr in iter {
14049            if let XdpAttrs::ProgId(val) = attr? {
14050                return Ok(val);
14051            }
14052        }
14053        Err(ErrorContext::new_missing(
14054            "XdpAttrs",
14055            "ProgId",
14056            self.orig_loc,
14057            self.buf.as_ptr() as usize,
14058        ))
14059    }
14060    pub fn get_drv_prog_id(&self) -> Result<u32, ErrorContext> {
14061        let mut iter = self.clone();
14062        iter.pos = 0;
14063        for attr in iter {
14064            if let XdpAttrs::DrvProgId(val) = attr? {
14065                return Ok(val);
14066            }
14067        }
14068        Err(ErrorContext::new_missing(
14069            "XdpAttrs",
14070            "DrvProgId",
14071            self.orig_loc,
14072            self.buf.as_ptr() as usize,
14073        ))
14074    }
14075    pub fn get_skb_prog_id(&self) -> Result<u32, ErrorContext> {
14076        let mut iter = self.clone();
14077        iter.pos = 0;
14078        for attr in iter {
14079            if let XdpAttrs::SkbProgId(val) = attr? {
14080                return Ok(val);
14081            }
14082        }
14083        Err(ErrorContext::new_missing(
14084            "XdpAttrs",
14085            "SkbProgId",
14086            self.orig_loc,
14087            self.buf.as_ptr() as usize,
14088        ))
14089    }
14090    pub fn get_hw_prog_id(&self) -> Result<u32, ErrorContext> {
14091        let mut iter = self.clone();
14092        iter.pos = 0;
14093        for attr in iter {
14094            if let XdpAttrs::HwProgId(val) = attr? {
14095                return Ok(val);
14096            }
14097        }
14098        Err(ErrorContext::new_missing(
14099            "XdpAttrs",
14100            "HwProgId",
14101            self.orig_loc,
14102            self.buf.as_ptr() as usize,
14103        ))
14104    }
14105    pub fn get_expected_fd(&self) -> Result<i32, ErrorContext> {
14106        let mut iter = self.clone();
14107        iter.pos = 0;
14108        for attr in iter {
14109            if let XdpAttrs::ExpectedFd(val) = attr? {
14110                return Ok(val);
14111            }
14112        }
14113        Err(ErrorContext::new_missing(
14114            "XdpAttrs",
14115            "ExpectedFd",
14116            self.orig_loc,
14117            self.buf.as_ptr() as usize,
14118        ))
14119    }
14120}
14121impl XdpAttrs {
14122    pub fn new<'a>(buf: &'a [u8]) -> IterableXdpAttrs<'a> {
14123        IterableXdpAttrs::with_loc(buf, buf.as_ptr() as usize)
14124    }
14125    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14126        let res = match r#type {
14127            1u16 => "Fd",
14128            2u16 => "Attached",
14129            3u16 => "Flags",
14130            4u16 => "ProgId",
14131            5u16 => "DrvProgId",
14132            6u16 => "SkbProgId",
14133            7u16 => "HwProgId",
14134            8u16 => "ExpectedFd",
14135            _ => return None,
14136        };
14137        Some(res)
14138    }
14139}
14140#[derive(Clone, Copy, Default)]
14141pub struct IterableXdpAttrs<'a> {
14142    buf: &'a [u8],
14143    pos: usize,
14144    orig_loc: usize,
14145}
14146impl<'a> IterableXdpAttrs<'a> {
14147    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14148        Self {
14149            buf,
14150            pos: 0,
14151            orig_loc,
14152        }
14153    }
14154    pub fn get_buf(&self) -> &'a [u8] {
14155        self.buf
14156    }
14157}
14158impl<'a> Iterator for IterableXdpAttrs<'a> {
14159    type Item = Result<XdpAttrs, ErrorContext>;
14160    fn next(&mut self) -> Option<Self::Item> {
14161        let pos = self.pos;
14162        let mut r#type;
14163        loop {
14164            r#type = None;
14165            if self.buf.len() == self.pos {
14166                return None;
14167            }
14168            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
14169                break;
14170            };
14171            r#type = Some(header.r#type);
14172            let res = match header.r#type {
14173                1u16 => XdpAttrs::Fd({
14174                    let res = parse_i32(next);
14175                    let Some(val) = res else { break };
14176                    val
14177                }),
14178                2u16 => XdpAttrs::Attached({
14179                    let res = parse_u8(next);
14180                    let Some(val) = res else { break };
14181                    val
14182                }),
14183                3u16 => XdpAttrs::Flags({
14184                    let res = parse_u32(next);
14185                    let Some(val) = res else { break };
14186                    val
14187                }),
14188                4u16 => XdpAttrs::ProgId({
14189                    let res = parse_u32(next);
14190                    let Some(val) = res else { break };
14191                    val
14192                }),
14193                5u16 => XdpAttrs::DrvProgId({
14194                    let res = parse_u32(next);
14195                    let Some(val) = res else { break };
14196                    val
14197                }),
14198                6u16 => XdpAttrs::SkbProgId({
14199                    let res = parse_u32(next);
14200                    let Some(val) = res else { break };
14201                    val
14202                }),
14203                7u16 => XdpAttrs::HwProgId({
14204                    let res = parse_u32(next);
14205                    let Some(val) = res else { break };
14206                    val
14207                }),
14208                8u16 => XdpAttrs::ExpectedFd({
14209                    let res = parse_i32(next);
14210                    let Some(val) = res else { break };
14211                    val
14212                }),
14213                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
14214                n => continue,
14215            };
14216            return Some(Ok(res));
14217        }
14218        Some(Err(ErrorContext::new(
14219            "XdpAttrs",
14220            r#type.and_then(|t| XdpAttrs::attr_from_type(t)),
14221            self.orig_loc,
14222            self.buf.as_ptr().wrapping_add(pos) as usize,
14223        )))
14224    }
14225}
14226impl std::fmt::Debug for IterableXdpAttrs<'_> {
14227    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14228        let mut fmt = f.debug_struct("XdpAttrs");
14229        for attr in self.clone() {
14230            let attr = match attr {
14231                Ok(a) => a,
14232                Err(err) => {
14233                    fmt.finish()?;
14234                    f.write_str("Err(")?;
14235                    err.fmt(f)?;
14236                    return f.write_str(")");
14237                }
14238            };
14239            match attr {
14240                XdpAttrs::Fd(val) => fmt.field("Fd", &val),
14241                XdpAttrs::Attached(val) => fmt.field("Attached", &val),
14242                XdpAttrs::Flags(val) => fmt.field("Flags", &val),
14243                XdpAttrs::ProgId(val) => fmt.field("ProgId", &val),
14244                XdpAttrs::DrvProgId(val) => fmt.field("DrvProgId", &val),
14245                XdpAttrs::SkbProgId(val) => fmt.field("SkbProgId", &val),
14246                XdpAttrs::HwProgId(val) => fmt.field("HwProgId", &val),
14247                XdpAttrs::ExpectedFd(val) => fmt.field("ExpectedFd", &val),
14248            };
14249        }
14250        fmt.finish()
14251    }
14252}
14253impl IterableXdpAttrs<'_> {
14254    pub fn lookup_attr(
14255        &self,
14256        offset: usize,
14257        missing_type: Option<u16>,
14258    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14259        let mut stack = Vec::new();
14260        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14261        if cur == offset {
14262            stack.push(("XdpAttrs", offset));
14263            return (
14264                stack,
14265                missing_type.and_then(|t| XdpAttrs::attr_from_type(t)),
14266            );
14267        }
14268        if cur > offset || cur + self.buf.len() < offset {
14269            return (stack, None);
14270        }
14271        let mut attrs = self.clone();
14272        let mut last_off = cur + attrs.pos;
14273        while let Some(attr) = attrs.next() {
14274            let Ok(attr) = attr else { break };
14275            match attr {
14276                XdpAttrs::Fd(val) => {
14277                    if last_off == offset {
14278                        stack.push(("Fd", last_off));
14279                        break;
14280                    }
14281                }
14282                XdpAttrs::Attached(val) => {
14283                    if last_off == offset {
14284                        stack.push(("Attached", last_off));
14285                        break;
14286                    }
14287                }
14288                XdpAttrs::Flags(val) => {
14289                    if last_off == offset {
14290                        stack.push(("Flags", last_off));
14291                        break;
14292                    }
14293                }
14294                XdpAttrs::ProgId(val) => {
14295                    if last_off == offset {
14296                        stack.push(("ProgId", last_off));
14297                        break;
14298                    }
14299                }
14300                XdpAttrs::DrvProgId(val) => {
14301                    if last_off == offset {
14302                        stack.push(("DrvProgId", last_off));
14303                        break;
14304                    }
14305                }
14306                XdpAttrs::SkbProgId(val) => {
14307                    if last_off == offset {
14308                        stack.push(("SkbProgId", last_off));
14309                        break;
14310                    }
14311                }
14312                XdpAttrs::HwProgId(val) => {
14313                    if last_off == offset {
14314                        stack.push(("HwProgId", last_off));
14315                        break;
14316                    }
14317                }
14318                XdpAttrs::ExpectedFd(val) => {
14319                    if last_off == offset {
14320                        stack.push(("ExpectedFd", last_off));
14321                        break;
14322                    }
14323                }
14324                _ => {}
14325            };
14326            last_off = cur + attrs.pos;
14327        }
14328        if !stack.is_empty() {
14329            stack.push(("XdpAttrs", cur));
14330        }
14331        (stack, None)
14332    }
14333}
14334#[derive(Clone)]
14335pub enum IflaAttrs<'a> {
14336    #[doc = "u32 indexed by ipv4-devconf - 1 on output, on input it's a nest"]
14337    Conf(&'a [u8]),
14338}
14339impl<'a> IterableIflaAttrs<'a> {
14340    #[doc = "u32 indexed by ipv4-devconf - 1 on output, on input it's a nest"]
14341    pub fn get_conf(&self) -> Result<&'a [u8], ErrorContext> {
14342        let mut iter = self.clone();
14343        iter.pos = 0;
14344        for attr in iter {
14345            if let IflaAttrs::Conf(val) = attr? {
14346                return Ok(val);
14347            }
14348        }
14349        Err(ErrorContext::new_missing(
14350            "IflaAttrs",
14351            "Conf",
14352            self.orig_loc,
14353            self.buf.as_ptr() as usize,
14354        ))
14355    }
14356}
14357impl IflaAttrs<'_> {
14358    pub fn new<'a>(buf: &'a [u8]) -> IterableIflaAttrs<'a> {
14359        IterableIflaAttrs::with_loc(buf, buf.as_ptr() as usize)
14360    }
14361    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14362        let res = match r#type {
14363            1u16 => "Conf",
14364            _ => return None,
14365        };
14366        Some(res)
14367    }
14368}
14369#[derive(Clone, Copy, Default)]
14370pub struct IterableIflaAttrs<'a> {
14371    buf: &'a [u8],
14372    pos: usize,
14373    orig_loc: usize,
14374}
14375impl<'a> IterableIflaAttrs<'a> {
14376    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14377        Self {
14378            buf,
14379            pos: 0,
14380            orig_loc,
14381        }
14382    }
14383    pub fn get_buf(&self) -> &'a [u8] {
14384        self.buf
14385    }
14386}
14387impl<'a> Iterator for IterableIflaAttrs<'a> {
14388    type Item = Result<IflaAttrs<'a>, ErrorContext>;
14389    fn next(&mut self) -> Option<Self::Item> {
14390        let pos = self.pos;
14391        let mut r#type;
14392        loop {
14393            r#type = None;
14394            if self.buf.len() == self.pos {
14395                return None;
14396            }
14397            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
14398                break;
14399            };
14400            r#type = Some(header.r#type);
14401            let res = match header.r#type {
14402                1u16 => IflaAttrs::Conf({
14403                    let res = Some(next);
14404                    let Some(val) = res else { break };
14405                    val
14406                }),
14407                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
14408                n => continue,
14409            };
14410            return Some(Ok(res));
14411        }
14412        Some(Err(ErrorContext::new(
14413            "IflaAttrs",
14414            r#type.and_then(|t| IflaAttrs::attr_from_type(t)),
14415            self.orig_loc,
14416            self.buf.as_ptr().wrapping_add(pos) as usize,
14417        )))
14418    }
14419}
14420impl<'a> std::fmt::Debug for IterableIflaAttrs<'_> {
14421    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14422        let mut fmt = f.debug_struct("IflaAttrs");
14423        for attr in self.clone() {
14424            let attr = match attr {
14425                Ok(a) => a,
14426                Err(err) => {
14427                    fmt.finish()?;
14428                    f.write_str("Err(")?;
14429                    err.fmt(f)?;
14430                    return f.write_str(")");
14431                }
14432            };
14433            match attr {
14434                IflaAttrs::Conf(val) => fmt.field("Conf", &val),
14435            };
14436        }
14437        fmt.finish()
14438    }
14439}
14440impl IterableIflaAttrs<'_> {
14441    pub fn lookup_attr(
14442        &self,
14443        offset: usize,
14444        missing_type: Option<u16>,
14445    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14446        let mut stack = Vec::new();
14447        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14448        if cur == offset {
14449            stack.push(("IflaAttrs", offset));
14450            return (
14451                stack,
14452                missing_type.and_then(|t| IflaAttrs::attr_from_type(t)),
14453            );
14454        }
14455        if cur > offset || cur + self.buf.len() < offset {
14456            return (stack, None);
14457        }
14458        let mut attrs = self.clone();
14459        let mut last_off = cur + attrs.pos;
14460        while let Some(attr) = attrs.next() {
14461            let Ok(attr) = attr else { break };
14462            match attr {
14463                IflaAttrs::Conf(val) => {
14464                    if last_off == offset {
14465                        stack.push(("Conf", last_off));
14466                        break;
14467                    }
14468                }
14469                _ => {}
14470            };
14471            last_off = cur + attrs.pos;
14472        }
14473        if !stack.is_empty() {
14474            stack.push(("IflaAttrs", cur));
14475        }
14476        (stack, None)
14477    }
14478}
14479#[derive(Clone)]
14480pub enum Ifla6Attrs<'a> {
14481    Flags(u32),
14482    #[doc = "u32 indexed by ipv6-devconf - 1 on output, on input it's a nest"]
14483    Conf(&'a [u8]),
14484    Stats(&'a [u8]),
14485    Mcast(&'a [u8]),
14486    Cacheinfo(PushIflaCacheinfo),
14487    Icmp6stats(&'a [u8]),
14488    Token(&'a [u8]),
14489    AddrGenMode(u8),
14490    RaMtu(u32),
14491}
14492impl<'a> IterableIfla6Attrs<'a> {
14493    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
14494        let mut iter = self.clone();
14495        iter.pos = 0;
14496        for attr in iter {
14497            if let Ifla6Attrs::Flags(val) = attr? {
14498                return Ok(val);
14499            }
14500        }
14501        Err(ErrorContext::new_missing(
14502            "Ifla6Attrs",
14503            "Flags",
14504            self.orig_loc,
14505            self.buf.as_ptr() as usize,
14506        ))
14507    }
14508    #[doc = "u32 indexed by ipv6-devconf - 1 on output, on input it's a nest"]
14509    pub fn get_conf(&self) -> Result<&'a [u8], ErrorContext> {
14510        let mut iter = self.clone();
14511        iter.pos = 0;
14512        for attr in iter {
14513            if let Ifla6Attrs::Conf(val) = attr? {
14514                return Ok(val);
14515            }
14516        }
14517        Err(ErrorContext::new_missing(
14518            "Ifla6Attrs",
14519            "Conf",
14520            self.orig_loc,
14521            self.buf.as_ptr() as usize,
14522        ))
14523    }
14524    pub fn get_stats(&self) -> Result<&'a [u8], ErrorContext> {
14525        let mut iter = self.clone();
14526        iter.pos = 0;
14527        for attr in iter {
14528            if let Ifla6Attrs::Stats(val) = attr? {
14529                return Ok(val);
14530            }
14531        }
14532        Err(ErrorContext::new_missing(
14533            "Ifla6Attrs",
14534            "Stats",
14535            self.orig_loc,
14536            self.buf.as_ptr() as usize,
14537        ))
14538    }
14539    pub fn get_mcast(&self) -> Result<&'a [u8], ErrorContext> {
14540        let mut iter = self.clone();
14541        iter.pos = 0;
14542        for attr in iter {
14543            if let Ifla6Attrs::Mcast(val) = attr? {
14544                return Ok(val);
14545            }
14546        }
14547        Err(ErrorContext::new_missing(
14548            "Ifla6Attrs",
14549            "Mcast",
14550            self.orig_loc,
14551            self.buf.as_ptr() as usize,
14552        ))
14553    }
14554    pub fn get_cacheinfo(&self) -> Result<PushIflaCacheinfo, ErrorContext> {
14555        let mut iter = self.clone();
14556        iter.pos = 0;
14557        for attr in iter {
14558            if let Ifla6Attrs::Cacheinfo(val) = attr? {
14559                return Ok(val);
14560            }
14561        }
14562        Err(ErrorContext::new_missing(
14563            "Ifla6Attrs",
14564            "Cacheinfo",
14565            self.orig_loc,
14566            self.buf.as_ptr() as usize,
14567        ))
14568    }
14569    pub fn get_icmp6stats(&self) -> Result<&'a [u8], ErrorContext> {
14570        let mut iter = self.clone();
14571        iter.pos = 0;
14572        for attr in iter {
14573            if let Ifla6Attrs::Icmp6stats(val) = attr? {
14574                return Ok(val);
14575            }
14576        }
14577        Err(ErrorContext::new_missing(
14578            "Ifla6Attrs",
14579            "Icmp6stats",
14580            self.orig_loc,
14581            self.buf.as_ptr() as usize,
14582        ))
14583    }
14584    pub fn get_token(&self) -> Result<&'a [u8], ErrorContext> {
14585        let mut iter = self.clone();
14586        iter.pos = 0;
14587        for attr in iter {
14588            if let Ifla6Attrs::Token(val) = attr? {
14589                return Ok(val);
14590            }
14591        }
14592        Err(ErrorContext::new_missing(
14593            "Ifla6Attrs",
14594            "Token",
14595            self.orig_loc,
14596            self.buf.as_ptr() as usize,
14597        ))
14598    }
14599    pub fn get_addr_gen_mode(&self) -> Result<u8, ErrorContext> {
14600        let mut iter = self.clone();
14601        iter.pos = 0;
14602        for attr in iter {
14603            if let Ifla6Attrs::AddrGenMode(val) = attr? {
14604                return Ok(val);
14605            }
14606        }
14607        Err(ErrorContext::new_missing(
14608            "Ifla6Attrs",
14609            "AddrGenMode",
14610            self.orig_loc,
14611            self.buf.as_ptr() as usize,
14612        ))
14613    }
14614    pub fn get_ra_mtu(&self) -> Result<u32, ErrorContext> {
14615        let mut iter = self.clone();
14616        iter.pos = 0;
14617        for attr in iter {
14618            if let Ifla6Attrs::RaMtu(val) = attr? {
14619                return Ok(val);
14620            }
14621        }
14622        Err(ErrorContext::new_missing(
14623            "Ifla6Attrs",
14624            "RaMtu",
14625            self.orig_loc,
14626            self.buf.as_ptr() as usize,
14627        ))
14628    }
14629}
14630impl Ifla6Attrs<'_> {
14631    pub fn new<'a>(buf: &'a [u8]) -> IterableIfla6Attrs<'a> {
14632        IterableIfla6Attrs::with_loc(buf, buf.as_ptr() as usize)
14633    }
14634    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14635        let res = match r#type {
14636            1u16 => "Flags",
14637            2u16 => "Conf",
14638            3u16 => "Stats",
14639            4u16 => "Mcast",
14640            5u16 => "Cacheinfo",
14641            6u16 => "Icmp6stats",
14642            7u16 => "Token",
14643            8u16 => "AddrGenMode",
14644            9u16 => "RaMtu",
14645            _ => return None,
14646        };
14647        Some(res)
14648    }
14649}
14650#[derive(Clone, Copy, Default)]
14651pub struct IterableIfla6Attrs<'a> {
14652    buf: &'a [u8],
14653    pos: usize,
14654    orig_loc: usize,
14655}
14656impl<'a> IterableIfla6Attrs<'a> {
14657    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14658        Self {
14659            buf,
14660            pos: 0,
14661            orig_loc,
14662        }
14663    }
14664    pub fn get_buf(&self) -> &'a [u8] {
14665        self.buf
14666    }
14667}
14668impl<'a> Iterator for IterableIfla6Attrs<'a> {
14669    type Item = Result<Ifla6Attrs<'a>, ErrorContext>;
14670    fn next(&mut self) -> Option<Self::Item> {
14671        let pos = self.pos;
14672        let mut r#type;
14673        loop {
14674            r#type = None;
14675            if self.buf.len() == self.pos {
14676                return None;
14677            }
14678            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
14679                break;
14680            };
14681            r#type = Some(header.r#type);
14682            let res = match header.r#type {
14683                1u16 => Ifla6Attrs::Flags({
14684                    let res = parse_u32(next);
14685                    let Some(val) = res else { break };
14686                    val
14687                }),
14688                2u16 => Ifla6Attrs::Conf({
14689                    let res = Some(next);
14690                    let Some(val) = res else { break };
14691                    val
14692                }),
14693                3u16 => Ifla6Attrs::Stats({
14694                    let res = Some(next);
14695                    let Some(val) = res else { break };
14696                    val
14697                }),
14698                4u16 => Ifla6Attrs::Mcast({
14699                    let res = Some(next);
14700                    let Some(val) = res else { break };
14701                    val
14702                }),
14703                5u16 => Ifla6Attrs::Cacheinfo({
14704                    let res = PushIflaCacheinfo::new_from_slice(next);
14705                    let Some(val) = res else { break };
14706                    val
14707                }),
14708                6u16 => Ifla6Attrs::Icmp6stats({
14709                    let res = Some(next);
14710                    let Some(val) = res else { break };
14711                    val
14712                }),
14713                7u16 => Ifla6Attrs::Token({
14714                    let res = Some(next);
14715                    let Some(val) = res else { break };
14716                    val
14717                }),
14718                8u16 => Ifla6Attrs::AddrGenMode({
14719                    let res = parse_u8(next);
14720                    let Some(val) = res else { break };
14721                    val
14722                }),
14723                9u16 => Ifla6Attrs::RaMtu({
14724                    let res = parse_u32(next);
14725                    let Some(val) = res else { break };
14726                    val
14727                }),
14728                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
14729                n => continue,
14730            };
14731            return Some(Ok(res));
14732        }
14733        Some(Err(ErrorContext::new(
14734            "Ifla6Attrs",
14735            r#type.and_then(|t| Ifla6Attrs::attr_from_type(t)),
14736            self.orig_loc,
14737            self.buf.as_ptr().wrapping_add(pos) as usize,
14738        )))
14739    }
14740}
14741impl<'a> std::fmt::Debug for IterableIfla6Attrs<'_> {
14742    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14743        let mut fmt = f.debug_struct("Ifla6Attrs");
14744        for attr in self.clone() {
14745            let attr = match attr {
14746                Ok(a) => a,
14747                Err(err) => {
14748                    fmt.finish()?;
14749                    f.write_str("Err(")?;
14750                    err.fmt(f)?;
14751                    return f.write_str(")");
14752                }
14753            };
14754            match attr {
14755                Ifla6Attrs::Flags(val) => fmt.field("Flags", &val),
14756                Ifla6Attrs::Conf(val) => fmt.field("Conf", &val),
14757                Ifla6Attrs::Stats(val) => fmt.field("Stats", &val),
14758                Ifla6Attrs::Mcast(val) => fmt.field("Mcast", &val),
14759                Ifla6Attrs::Cacheinfo(val) => fmt.field("Cacheinfo", &val),
14760                Ifla6Attrs::Icmp6stats(val) => fmt.field("Icmp6stats", &val),
14761                Ifla6Attrs::Token(val) => fmt.field("Token", &val),
14762                Ifla6Attrs::AddrGenMode(val) => fmt.field("AddrGenMode", &val),
14763                Ifla6Attrs::RaMtu(val) => fmt.field("RaMtu", &val),
14764            };
14765        }
14766        fmt.finish()
14767    }
14768}
14769impl IterableIfla6Attrs<'_> {
14770    pub fn lookup_attr(
14771        &self,
14772        offset: usize,
14773        missing_type: Option<u16>,
14774    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14775        let mut stack = Vec::new();
14776        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14777        if cur == offset {
14778            stack.push(("Ifla6Attrs", offset));
14779            return (
14780                stack,
14781                missing_type.and_then(|t| Ifla6Attrs::attr_from_type(t)),
14782            );
14783        }
14784        if cur > offset || cur + self.buf.len() < offset {
14785            return (stack, None);
14786        }
14787        let mut attrs = self.clone();
14788        let mut last_off = cur + attrs.pos;
14789        while let Some(attr) = attrs.next() {
14790            let Ok(attr) = attr else { break };
14791            match attr {
14792                Ifla6Attrs::Flags(val) => {
14793                    if last_off == offset {
14794                        stack.push(("Flags", last_off));
14795                        break;
14796                    }
14797                }
14798                Ifla6Attrs::Conf(val) => {
14799                    if last_off == offset {
14800                        stack.push(("Conf", last_off));
14801                        break;
14802                    }
14803                }
14804                Ifla6Attrs::Stats(val) => {
14805                    if last_off == offset {
14806                        stack.push(("Stats", last_off));
14807                        break;
14808                    }
14809                }
14810                Ifla6Attrs::Mcast(val) => {
14811                    if last_off == offset {
14812                        stack.push(("Mcast", last_off));
14813                        break;
14814                    }
14815                }
14816                Ifla6Attrs::Cacheinfo(val) => {
14817                    if last_off == offset {
14818                        stack.push(("Cacheinfo", last_off));
14819                        break;
14820                    }
14821                }
14822                Ifla6Attrs::Icmp6stats(val) => {
14823                    if last_off == offset {
14824                        stack.push(("Icmp6stats", last_off));
14825                        break;
14826                    }
14827                }
14828                Ifla6Attrs::Token(val) => {
14829                    if last_off == offset {
14830                        stack.push(("Token", last_off));
14831                        break;
14832                    }
14833                }
14834                Ifla6Attrs::AddrGenMode(val) => {
14835                    if last_off == offset {
14836                        stack.push(("AddrGenMode", last_off));
14837                        break;
14838                    }
14839                }
14840                Ifla6Attrs::RaMtu(val) => {
14841                    if last_off == offset {
14842                        stack.push(("RaMtu", last_off));
14843                        break;
14844                    }
14845                }
14846                _ => {}
14847            };
14848            last_off = cur + attrs.pos;
14849        }
14850        if !stack.is_empty() {
14851            stack.push(("Ifla6Attrs", cur));
14852        }
14853        (stack, None)
14854    }
14855}
14856#[derive(Clone)]
14857pub enum MctpAttrs {
14858    Net(u32),
14859    PhysBinding(u8),
14860}
14861impl<'a> IterableMctpAttrs<'a> {
14862    pub fn get_net(&self) -> Result<u32, ErrorContext> {
14863        let mut iter = self.clone();
14864        iter.pos = 0;
14865        for attr in iter {
14866            if let MctpAttrs::Net(val) = attr? {
14867                return Ok(val);
14868            }
14869        }
14870        Err(ErrorContext::new_missing(
14871            "MctpAttrs",
14872            "Net",
14873            self.orig_loc,
14874            self.buf.as_ptr() as usize,
14875        ))
14876    }
14877    pub fn get_phys_binding(&self) -> Result<u8, ErrorContext> {
14878        let mut iter = self.clone();
14879        iter.pos = 0;
14880        for attr in iter {
14881            if let MctpAttrs::PhysBinding(val) = attr? {
14882                return Ok(val);
14883            }
14884        }
14885        Err(ErrorContext::new_missing(
14886            "MctpAttrs",
14887            "PhysBinding",
14888            self.orig_loc,
14889            self.buf.as_ptr() as usize,
14890        ))
14891    }
14892}
14893impl MctpAttrs {
14894    pub fn new<'a>(buf: &'a [u8]) -> IterableMctpAttrs<'a> {
14895        IterableMctpAttrs::with_loc(buf, buf.as_ptr() as usize)
14896    }
14897    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14898        let res = match r#type {
14899            1u16 => "Net",
14900            2u16 => "PhysBinding",
14901            _ => return None,
14902        };
14903        Some(res)
14904    }
14905}
14906#[derive(Clone, Copy, Default)]
14907pub struct IterableMctpAttrs<'a> {
14908    buf: &'a [u8],
14909    pos: usize,
14910    orig_loc: usize,
14911}
14912impl<'a> IterableMctpAttrs<'a> {
14913    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14914        Self {
14915            buf,
14916            pos: 0,
14917            orig_loc,
14918        }
14919    }
14920    pub fn get_buf(&self) -> &'a [u8] {
14921        self.buf
14922    }
14923}
14924impl<'a> Iterator for IterableMctpAttrs<'a> {
14925    type Item = Result<MctpAttrs, ErrorContext>;
14926    fn next(&mut self) -> Option<Self::Item> {
14927        let pos = self.pos;
14928        let mut r#type;
14929        loop {
14930            r#type = None;
14931            if self.buf.len() == self.pos {
14932                return None;
14933            }
14934            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
14935                break;
14936            };
14937            r#type = Some(header.r#type);
14938            let res = match header.r#type {
14939                1u16 => MctpAttrs::Net({
14940                    let res = parse_u32(next);
14941                    let Some(val) = res else { break };
14942                    val
14943                }),
14944                2u16 => MctpAttrs::PhysBinding({
14945                    let res = parse_u8(next);
14946                    let Some(val) = res else { break };
14947                    val
14948                }),
14949                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
14950                n => continue,
14951            };
14952            return Some(Ok(res));
14953        }
14954        Some(Err(ErrorContext::new(
14955            "MctpAttrs",
14956            r#type.and_then(|t| MctpAttrs::attr_from_type(t)),
14957            self.orig_loc,
14958            self.buf.as_ptr().wrapping_add(pos) as usize,
14959        )))
14960    }
14961}
14962impl std::fmt::Debug for IterableMctpAttrs<'_> {
14963    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14964        let mut fmt = f.debug_struct("MctpAttrs");
14965        for attr in self.clone() {
14966            let attr = match attr {
14967                Ok(a) => a,
14968                Err(err) => {
14969                    fmt.finish()?;
14970                    f.write_str("Err(")?;
14971                    err.fmt(f)?;
14972                    return f.write_str(")");
14973                }
14974            };
14975            match attr {
14976                MctpAttrs::Net(val) => fmt.field("Net", &val),
14977                MctpAttrs::PhysBinding(val) => fmt.field("PhysBinding", &val),
14978            };
14979        }
14980        fmt.finish()
14981    }
14982}
14983impl IterableMctpAttrs<'_> {
14984    pub fn lookup_attr(
14985        &self,
14986        offset: usize,
14987        missing_type: Option<u16>,
14988    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14989        let mut stack = Vec::new();
14990        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14991        if cur == offset {
14992            stack.push(("MctpAttrs", offset));
14993            return (
14994                stack,
14995                missing_type.and_then(|t| MctpAttrs::attr_from_type(t)),
14996            );
14997        }
14998        if cur > offset || cur + self.buf.len() < offset {
14999            return (stack, None);
15000        }
15001        let mut attrs = self.clone();
15002        let mut last_off = cur + attrs.pos;
15003        while let Some(attr) = attrs.next() {
15004            let Ok(attr) = attr else { break };
15005            match attr {
15006                MctpAttrs::Net(val) => {
15007                    if last_off == offset {
15008                        stack.push(("Net", last_off));
15009                        break;
15010                    }
15011                }
15012                MctpAttrs::PhysBinding(val) => {
15013                    if last_off == offset {
15014                        stack.push(("PhysBinding", last_off));
15015                        break;
15016                    }
15017                }
15018                _ => {}
15019            };
15020            last_off = cur + attrs.pos;
15021        }
15022        if !stack.is_empty() {
15023            stack.push(("MctpAttrs", cur));
15024        }
15025        (stack, None)
15026    }
15027}
15028#[derive(Clone)]
15029pub enum StatsAttrs<'a> {
15030    Link64(PushRtnlLinkStats64),
15031    LinkXstats(&'a [u8]),
15032    LinkXstatsSlave(&'a [u8]),
15033    LinkOffloadXstats(IterableLinkOffloadXstats<'a>),
15034    AfSpec(&'a [u8]),
15035}
15036impl<'a> IterableStatsAttrs<'a> {
15037    pub fn get_link_64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
15038        let mut iter = self.clone();
15039        iter.pos = 0;
15040        for attr in iter {
15041            if let StatsAttrs::Link64(val) = attr? {
15042                return Ok(val);
15043            }
15044        }
15045        Err(ErrorContext::new_missing(
15046            "StatsAttrs",
15047            "Link64",
15048            self.orig_loc,
15049            self.buf.as_ptr() as usize,
15050        ))
15051    }
15052    pub fn get_link_xstats(&self) -> Result<&'a [u8], ErrorContext> {
15053        let mut iter = self.clone();
15054        iter.pos = 0;
15055        for attr in iter {
15056            if let StatsAttrs::LinkXstats(val) = attr? {
15057                return Ok(val);
15058            }
15059        }
15060        Err(ErrorContext::new_missing(
15061            "StatsAttrs",
15062            "LinkXstats",
15063            self.orig_loc,
15064            self.buf.as_ptr() as usize,
15065        ))
15066    }
15067    pub fn get_link_xstats_slave(&self) -> Result<&'a [u8], ErrorContext> {
15068        let mut iter = self.clone();
15069        iter.pos = 0;
15070        for attr in iter {
15071            if let StatsAttrs::LinkXstatsSlave(val) = attr? {
15072                return Ok(val);
15073            }
15074        }
15075        Err(ErrorContext::new_missing(
15076            "StatsAttrs",
15077            "LinkXstatsSlave",
15078            self.orig_loc,
15079            self.buf.as_ptr() as usize,
15080        ))
15081    }
15082    pub fn get_link_offload_xstats(&self) -> Result<IterableLinkOffloadXstats<'a>, ErrorContext> {
15083        let mut iter = self.clone();
15084        iter.pos = 0;
15085        for attr in iter {
15086            if let StatsAttrs::LinkOffloadXstats(val) = attr? {
15087                return Ok(val);
15088            }
15089        }
15090        Err(ErrorContext::new_missing(
15091            "StatsAttrs",
15092            "LinkOffloadXstats",
15093            self.orig_loc,
15094            self.buf.as_ptr() as usize,
15095        ))
15096    }
15097    pub fn get_af_spec(&self) -> Result<&'a [u8], ErrorContext> {
15098        let mut iter = self.clone();
15099        iter.pos = 0;
15100        for attr in iter {
15101            if let StatsAttrs::AfSpec(val) = attr? {
15102                return Ok(val);
15103            }
15104        }
15105        Err(ErrorContext::new_missing(
15106            "StatsAttrs",
15107            "AfSpec",
15108            self.orig_loc,
15109            self.buf.as_ptr() as usize,
15110        ))
15111    }
15112}
15113impl StatsAttrs<'_> {
15114    pub fn new<'a>(buf: &'a [u8]) -> IterableStatsAttrs<'a> {
15115        IterableStatsAttrs::with_loc(buf, buf.as_ptr() as usize)
15116    }
15117    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15118        let res = match r#type {
15119            1u16 => "Link64",
15120            2u16 => "LinkXstats",
15121            3u16 => "LinkXstatsSlave",
15122            4u16 => "LinkOffloadXstats",
15123            5u16 => "AfSpec",
15124            _ => return None,
15125        };
15126        Some(res)
15127    }
15128}
15129#[derive(Clone, Copy, Default)]
15130pub struct IterableStatsAttrs<'a> {
15131    buf: &'a [u8],
15132    pos: usize,
15133    orig_loc: usize,
15134}
15135impl<'a> IterableStatsAttrs<'a> {
15136    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15137        Self {
15138            buf,
15139            pos: 0,
15140            orig_loc,
15141        }
15142    }
15143    pub fn get_buf(&self) -> &'a [u8] {
15144        self.buf
15145    }
15146}
15147impl<'a> Iterator for IterableStatsAttrs<'a> {
15148    type Item = Result<StatsAttrs<'a>, ErrorContext>;
15149    fn next(&mut self) -> Option<Self::Item> {
15150        let pos = self.pos;
15151        let mut r#type;
15152        loop {
15153            r#type = None;
15154            if self.buf.len() == self.pos {
15155                return None;
15156            }
15157            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
15158                break;
15159            };
15160            r#type = Some(header.r#type);
15161            let res = match header.r#type {
15162                1u16 => StatsAttrs::Link64({
15163                    let res = Some(PushRtnlLinkStats64::new_from_zeroed(next));
15164                    let Some(val) = res else { break };
15165                    val
15166                }),
15167                2u16 => StatsAttrs::LinkXstats({
15168                    let res = Some(next);
15169                    let Some(val) = res else { break };
15170                    val
15171                }),
15172                3u16 => StatsAttrs::LinkXstatsSlave({
15173                    let res = Some(next);
15174                    let Some(val) = res else { break };
15175                    val
15176                }),
15177                4u16 => StatsAttrs::LinkOffloadXstats({
15178                    let res = Some(IterableLinkOffloadXstats::with_loc(next, self.orig_loc));
15179                    let Some(val) = res else { break };
15180                    val
15181                }),
15182                5u16 => StatsAttrs::AfSpec({
15183                    let res = Some(next);
15184                    let Some(val) = res else { break };
15185                    val
15186                }),
15187                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
15188                n => continue,
15189            };
15190            return Some(Ok(res));
15191        }
15192        Some(Err(ErrorContext::new(
15193            "StatsAttrs",
15194            r#type.and_then(|t| StatsAttrs::attr_from_type(t)),
15195            self.orig_loc,
15196            self.buf.as_ptr().wrapping_add(pos) as usize,
15197        )))
15198    }
15199}
15200impl<'a> std::fmt::Debug for IterableStatsAttrs<'_> {
15201    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15202        let mut fmt = f.debug_struct("StatsAttrs");
15203        for attr in self.clone() {
15204            let attr = match attr {
15205                Ok(a) => a,
15206                Err(err) => {
15207                    fmt.finish()?;
15208                    f.write_str("Err(")?;
15209                    err.fmt(f)?;
15210                    return f.write_str(")");
15211                }
15212            };
15213            match attr {
15214                StatsAttrs::Link64(val) => fmt.field("Link64", &val),
15215                StatsAttrs::LinkXstats(val) => fmt.field("LinkXstats", &val),
15216                StatsAttrs::LinkXstatsSlave(val) => fmt.field("LinkXstatsSlave", &val),
15217                StatsAttrs::LinkOffloadXstats(val) => fmt.field("LinkOffloadXstats", &val),
15218                StatsAttrs::AfSpec(val) => fmt.field("AfSpec", &val),
15219            };
15220        }
15221        fmt.finish()
15222    }
15223}
15224impl IterableStatsAttrs<'_> {
15225    pub fn lookup_attr(
15226        &self,
15227        offset: usize,
15228        missing_type: Option<u16>,
15229    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15230        let mut stack = Vec::new();
15231        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15232        if cur == offset {
15233            stack.push(("StatsAttrs", offset));
15234            return (
15235                stack,
15236                missing_type.and_then(|t| StatsAttrs::attr_from_type(t)),
15237            );
15238        }
15239        if cur > offset || cur + self.buf.len() < offset {
15240            return (stack, None);
15241        }
15242        let mut attrs = self.clone();
15243        let mut last_off = cur + attrs.pos;
15244        let mut missing = None;
15245        while let Some(attr) = attrs.next() {
15246            let Ok(attr) = attr else { break };
15247            match attr {
15248                StatsAttrs::Link64(val) => {
15249                    if last_off == offset {
15250                        stack.push(("Link64", last_off));
15251                        break;
15252                    }
15253                }
15254                StatsAttrs::LinkXstats(val) => {
15255                    if last_off == offset {
15256                        stack.push(("LinkXstats", last_off));
15257                        break;
15258                    }
15259                }
15260                StatsAttrs::LinkXstatsSlave(val) => {
15261                    if last_off == offset {
15262                        stack.push(("LinkXstatsSlave", last_off));
15263                        break;
15264                    }
15265                }
15266                StatsAttrs::LinkOffloadXstats(val) => {
15267                    (stack, missing) = val.lookup_attr(offset, missing_type);
15268                    if !stack.is_empty() {
15269                        break;
15270                    }
15271                }
15272                StatsAttrs::AfSpec(val) => {
15273                    if last_off == offset {
15274                        stack.push(("AfSpec", last_off));
15275                        break;
15276                    }
15277                }
15278                _ => {}
15279            };
15280            last_off = cur + attrs.pos;
15281        }
15282        if !stack.is_empty() {
15283            stack.push(("StatsAttrs", cur));
15284        }
15285        (stack, missing)
15286    }
15287}
15288#[derive(Clone)]
15289pub enum LinkOffloadXstats<'a> {
15290    CpuHit(&'a [u8]),
15291    HwSInfo(IterableArrayHwSInfoOne<'a>),
15292    L3Stats(&'a [u8]),
15293}
15294impl<'a> IterableLinkOffloadXstats<'a> {
15295    pub fn get_cpu_hit(&self) -> Result<&'a [u8], ErrorContext> {
15296        let mut iter = self.clone();
15297        iter.pos = 0;
15298        for attr in iter {
15299            if let LinkOffloadXstats::CpuHit(val) = attr? {
15300                return Ok(val);
15301            }
15302        }
15303        Err(ErrorContext::new_missing(
15304            "LinkOffloadXstats",
15305            "CpuHit",
15306            self.orig_loc,
15307            self.buf.as_ptr() as usize,
15308        ))
15309    }
15310    pub fn get_hw_s_info(
15311        &self,
15312    ) -> Result<ArrayIterable<IterableArrayHwSInfoOne<'a>, IterableHwSInfoOne<'a>>, ErrorContext>
15313    {
15314        for attr in self.clone() {
15315            if let LinkOffloadXstats::HwSInfo(val) = attr? {
15316                return Ok(ArrayIterable::new(val));
15317            }
15318        }
15319        Err(ErrorContext::new_missing(
15320            "LinkOffloadXstats",
15321            "HwSInfo",
15322            self.orig_loc,
15323            self.buf.as_ptr() as usize,
15324        ))
15325    }
15326    pub fn get_l3_stats(&self) -> Result<&'a [u8], ErrorContext> {
15327        let mut iter = self.clone();
15328        iter.pos = 0;
15329        for attr in iter {
15330            if let LinkOffloadXstats::L3Stats(val) = attr? {
15331                return Ok(val);
15332            }
15333        }
15334        Err(ErrorContext::new_missing(
15335            "LinkOffloadXstats",
15336            "L3Stats",
15337            self.orig_loc,
15338            self.buf.as_ptr() as usize,
15339        ))
15340    }
15341}
15342impl HwSInfoOne {
15343    pub fn new_array(buf: &[u8]) -> IterableArrayHwSInfoOne<'_> {
15344        IterableArrayHwSInfoOne::with_loc(buf, buf.as_ptr() as usize)
15345    }
15346}
15347#[derive(Clone, Copy, Default)]
15348pub struct IterableArrayHwSInfoOne<'a> {
15349    buf: &'a [u8],
15350    pos: usize,
15351    orig_loc: usize,
15352}
15353impl<'a> IterableArrayHwSInfoOne<'a> {
15354    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15355        Self {
15356            buf,
15357            pos: 0,
15358            orig_loc,
15359        }
15360    }
15361    pub fn get_buf(&self) -> &'a [u8] {
15362        self.buf
15363    }
15364}
15365impl<'a> Iterator for IterableArrayHwSInfoOne<'a> {
15366    type Item = Result<IterableHwSInfoOne<'a>, ErrorContext>;
15367    fn next(&mut self) -> Option<Self::Item> {
15368        if self.buf.len() == self.pos {
15369            return None;
15370        }
15371        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
15372            {
15373                return Some(Ok(IterableHwSInfoOne::with_loc(next, self.orig_loc)));
15374            }
15375        }
15376        Some(Err(ErrorContext::new(
15377            "HwSInfoOne",
15378            None,
15379            self.orig_loc,
15380            self.buf.as_ptr().wrapping_add(self.pos) as usize,
15381        )))
15382    }
15383}
15384impl LinkOffloadXstats<'_> {
15385    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkOffloadXstats<'a> {
15386        IterableLinkOffloadXstats::with_loc(buf, buf.as_ptr() as usize)
15387    }
15388    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15389        let res = match r#type {
15390            1u16 => "CpuHit",
15391            2u16 => "HwSInfo",
15392            3u16 => "L3Stats",
15393            _ => return None,
15394        };
15395        Some(res)
15396    }
15397}
15398#[derive(Clone, Copy, Default)]
15399pub struct IterableLinkOffloadXstats<'a> {
15400    buf: &'a [u8],
15401    pos: usize,
15402    orig_loc: usize,
15403}
15404impl<'a> IterableLinkOffloadXstats<'a> {
15405    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15406        Self {
15407            buf,
15408            pos: 0,
15409            orig_loc,
15410        }
15411    }
15412    pub fn get_buf(&self) -> &'a [u8] {
15413        self.buf
15414    }
15415}
15416impl<'a> Iterator for IterableLinkOffloadXstats<'a> {
15417    type Item = Result<LinkOffloadXstats<'a>, ErrorContext>;
15418    fn next(&mut self) -> Option<Self::Item> {
15419        let pos = self.pos;
15420        let mut r#type;
15421        loop {
15422            r#type = None;
15423            if self.buf.len() == self.pos {
15424                return None;
15425            }
15426            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
15427                break;
15428            };
15429            r#type = Some(header.r#type);
15430            let res = match header.r#type {
15431                1u16 => LinkOffloadXstats::CpuHit({
15432                    let res = Some(next);
15433                    let Some(val) = res else { break };
15434                    val
15435                }),
15436                2u16 => LinkOffloadXstats::HwSInfo({
15437                    let res = Some(IterableArrayHwSInfoOne::with_loc(next, self.orig_loc));
15438                    let Some(val) = res else { break };
15439                    val
15440                }),
15441                3u16 => LinkOffloadXstats::L3Stats({
15442                    let res = Some(next);
15443                    let Some(val) = res else { break };
15444                    val
15445                }),
15446                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
15447                n => continue,
15448            };
15449            return Some(Ok(res));
15450        }
15451        Some(Err(ErrorContext::new(
15452            "LinkOffloadXstats",
15453            r#type.and_then(|t| LinkOffloadXstats::attr_from_type(t)),
15454            self.orig_loc,
15455            self.buf.as_ptr().wrapping_add(pos) as usize,
15456        )))
15457    }
15458}
15459impl std::fmt::Debug for IterableArrayHwSInfoOne<'_> {
15460    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15461        fmt.debug_list()
15462            .entries(self.clone().map(FlattenErrorContext))
15463            .finish()
15464    }
15465}
15466impl<'a> std::fmt::Debug for IterableLinkOffloadXstats<'_> {
15467    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15468        let mut fmt = f.debug_struct("LinkOffloadXstats");
15469        for attr in self.clone() {
15470            let attr = match attr {
15471                Ok(a) => a,
15472                Err(err) => {
15473                    fmt.finish()?;
15474                    f.write_str("Err(")?;
15475                    err.fmt(f)?;
15476                    return f.write_str(")");
15477                }
15478            };
15479            match attr {
15480                LinkOffloadXstats::CpuHit(val) => fmt.field("CpuHit", &val),
15481                LinkOffloadXstats::HwSInfo(val) => fmt.field("HwSInfo", &val),
15482                LinkOffloadXstats::L3Stats(val) => fmt.field("L3Stats", &val),
15483            };
15484        }
15485        fmt.finish()
15486    }
15487}
15488impl IterableLinkOffloadXstats<'_> {
15489    pub fn lookup_attr(
15490        &self,
15491        offset: usize,
15492        missing_type: Option<u16>,
15493    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15494        let mut stack = Vec::new();
15495        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15496        if cur == offset {
15497            stack.push(("LinkOffloadXstats", offset));
15498            return (
15499                stack,
15500                missing_type.and_then(|t| LinkOffloadXstats::attr_from_type(t)),
15501            );
15502        }
15503        if cur > offset || cur + self.buf.len() < offset {
15504            return (stack, None);
15505        }
15506        let mut attrs = self.clone();
15507        let mut last_off = cur + attrs.pos;
15508        let mut missing = None;
15509        while let Some(attr) = attrs.next() {
15510            let Ok(attr) = attr else { break };
15511            match attr {
15512                LinkOffloadXstats::CpuHit(val) => {
15513                    if last_off == offset {
15514                        stack.push(("CpuHit", last_off));
15515                        break;
15516                    }
15517                }
15518                LinkOffloadXstats::HwSInfo(val) => {
15519                    for entry in val {
15520                        let Ok(attr) = entry else { break };
15521                        (stack, missing) = attr.lookup_attr(offset, missing_type);
15522                        if !stack.is_empty() {
15523                            break;
15524                        }
15525                    }
15526                    if !stack.is_empty() {
15527                        stack.push(("HwSInfo", last_off));
15528                        break;
15529                    }
15530                }
15531                LinkOffloadXstats::L3Stats(val) => {
15532                    if last_off == offset {
15533                        stack.push(("L3Stats", last_off));
15534                        break;
15535                    }
15536                }
15537                _ => {}
15538            };
15539            last_off = cur + attrs.pos;
15540        }
15541        if !stack.is_empty() {
15542            stack.push(("LinkOffloadXstats", cur));
15543        }
15544        (stack, missing)
15545    }
15546}
15547#[derive(Clone)]
15548pub enum HwSInfoOne {
15549    Request(u8),
15550    Used(u8),
15551}
15552impl<'a> IterableHwSInfoOne<'a> {
15553    pub fn get_request(&self) -> Result<u8, ErrorContext> {
15554        let mut iter = self.clone();
15555        iter.pos = 0;
15556        for attr in iter {
15557            if let HwSInfoOne::Request(val) = attr? {
15558                return Ok(val);
15559            }
15560        }
15561        Err(ErrorContext::new_missing(
15562            "HwSInfoOne",
15563            "Request",
15564            self.orig_loc,
15565            self.buf.as_ptr() as usize,
15566        ))
15567    }
15568    pub fn get_used(&self) -> Result<u8, ErrorContext> {
15569        let mut iter = self.clone();
15570        iter.pos = 0;
15571        for attr in iter {
15572            if let HwSInfoOne::Used(val) = attr? {
15573                return Ok(val);
15574            }
15575        }
15576        Err(ErrorContext::new_missing(
15577            "HwSInfoOne",
15578            "Used",
15579            self.orig_loc,
15580            self.buf.as_ptr() as usize,
15581        ))
15582    }
15583}
15584impl HwSInfoOne {
15585    pub fn new<'a>(buf: &'a [u8]) -> IterableHwSInfoOne<'a> {
15586        IterableHwSInfoOne::with_loc(buf, buf.as_ptr() as usize)
15587    }
15588    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15589        let res = match r#type {
15590            1u16 => "Request",
15591            2u16 => "Used",
15592            _ => return None,
15593        };
15594        Some(res)
15595    }
15596}
15597#[derive(Clone, Copy, Default)]
15598pub struct IterableHwSInfoOne<'a> {
15599    buf: &'a [u8],
15600    pos: usize,
15601    orig_loc: usize,
15602}
15603impl<'a> IterableHwSInfoOne<'a> {
15604    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15605        Self {
15606            buf,
15607            pos: 0,
15608            orig_loc,
15609        }
15610    }
15611    pub fn get_buf(&self) -> &'a [u8] {
15612        self.buf
15613    }
15614}
15615impl<'a> Iterator for IterableHwSInfoOne<'a> {
15616    type Item = Result<HwSInfoOne, ErrorContext>;
15617    fn next(&mut self) -> Option<Self::Item> {
15618        let pos = self.pos;
15619        let mut r#type;
15620        loop {
15621            r#type = None;
15622            if self.buf.len() == self.pos {
15623                return None;
15624            }
15625            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
15626                break;
15627            };
15628            r#type = Some(header.r#type);
15629            let res = match header.r#type {
15630                1u16 => HwSInfoOne::Request({
15631                    let res = parse_u8(next);
15632                    let Some(val) = res else { break };
15633                    val
15634                }),
15635                2u16 => HwSInfoOne::Used({
15636                    let res = parse_u8(next);
15637                    let Some(val) = res else { break };
15638                    val
15639                }),
15640                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
15641                n => continue,
15642            };
15643            return Some(Ok(res));
15644        }
15645        Some(Err(ErrorContext::new(
15646            "HwSInfoOne",
15647            r#type.and_then(|t| HwSInfoOne::attr_from_type(t)),
15648            self.orig_loc,
15649            self.buf.as_ptr().wrapping_add(pos) as usize,
15650        )))
15651    }
15652}
15653impl std::fmt::Debug for IterableHwSInfoOne<'_> {
15654    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15655        let mut fmt = f.debug_struct("HwSInfoOne");
15656        for attr in self.clone() {
15657            let attr = match attr {
15658                Ok(a) => a,
15659                Err(err) => {
15660                    fmt.finish()?;
15661                    f.write_str("Err(")?;
15662                    err.fmt(f)?;
15663                    return f.write_str(")");
15664                }
15665            };
15666            match attr {
15667                HwSInfoOne::Request(val) => fmt.field("Request", &val),
15668                HwSInfoOne::Used(val) => fmt.field("Used", &val),
15669            };
15670        }
15671        fmt.finish()
15672    }
15673}
15674impl IterableHwSInfoOne<'_> {
15675    pub fn lookup_attr(
15676        &self,
15677        offset: usize,
15678        missing_type: Option<u16>,
15679    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15680        let mut stack = Vec::new();
15681        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15682        if cur == offset {
15683            stack.push(("HwSInfoOne", offset));
15684            return (
15685                stack,
15686                missing_type.and_then(|t| HwSInfoOne::attr_from_type(t)),
15687            );
15688        }
15689        if cur > offset || cur + self.buf.len() < offset {
15690            return (stack, None);
15691        }
15692        let mut attrs = self.clone();
15693        let mut last_off = cur + attrs.pos;
15694        while let Some(attr) = attrs.next() {
15695            let Ok(attr) = attr else { break };
15696            match attr {
15697                HwSInfoOne::Request(val) => {
15698                    if last_off == offset {
15699                        stack.push(("Request", last_off));
15700                        break;
15701                    }
15702                }
15703                HwSInfoOne::Used(val) => {
15704                    if last_off == offset {
15705                        stack.push(("Used", last_off));
15706                        break;
15707                    }
15708                }
15709                _ => {}
15710            };
15711            last_off = cur + attrs.pos;
15712        }
15713        if !stack.is_empty() {
15714            stack.push(("HwSInfoOne", cur));
15715        }
15716        (stack, None)
15717    }
15718}
15719#[derive(Clone)]
15720pub enum LinkDpllPinAttrs {
15721    Id(u32),
15722}
15723impl<'a> IterableLinkDpllPinAttrs<'a> {
15724    pub fn get_id(&self) -> Result<u32, ErrorContext> {
15725        let mut iter = self.clone();
15726        iter.pos = 0;
15727        for attr in iter {
15728            if let LinkDpllPinAttrs::Id(val) = attr? {
15729                return Ok(val);
15730            }
15731        }
15732        Err(ErrorContext::new_missing(
15733            "LinkDpllPinAttrs",
15734            "Id",
15735            self.orig_loc,
15736            self.buf.as_ptr() as usize,
15737        ))
15738    }
15739}
15740impl LinkDpllPinAttrs {
15741    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkDpllPinAttrs<'a> {
15742        IterableLinkDpllPinAttrs::with_loc(buf, buf.as_ptr() as usize)
15743    }
15744    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15745        let res = match r#type {
15746            1u16 => "Id",
15747            _ => return None,
15748        };
15749        Some(res)
15750    }
15751}
15752#[derive(Clone, Copy, Default)]
15753pub struct IterableLinkDpllPinAttrs<'a> {
15754    buf: &'a [u8],
15755    pos: usize,
15756    orig_loc: usize,
15757}
15758impl<'a> IterableLinkDpllPinAttrs<'a> {
15759    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15760        Self {
15761            buf,
15762            pos: 0,
15763            orig_loc,
15764        }
15765    }
15766    pub fn get_buf(&self) -> &'a [u8] {
15767        self.buf
15768    }
15769}
15770impl<'a> Iterator for IterableLinkDpllPinAttrs<'a> {
15771    type Item = Result<LinkDpllPinAttrs, ErrorContext>;
15772    fn next(&mut self) -> Option<Self::Item> {
15773        let pos = self.pos;
15774        let mut r#type;
15775        loop {
15776            r#type = None;
15777            if self.buf.len() == self.pos {
15778                return None;
15779            }
15780            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
15781                break;
15782            };
15783            r#type = Some(header.r#type);
15784            let res = match header.r#type {
15785                1u16 => LinkDpllPinAttrs::Id({
15786                    let res = parse_u32(next);
15787                    let Some(val) = res else { break };
15788                    val
15789                }),
15790                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
15791                n => continue,
15792            };
15793            return Some(Ok(res));
15794        }
15795        Some(Err(ErrorContext::new(
15796            "LinkDpllPinAttrs",
15797            r#type.and_then(|t| LinkDpllPinAttrs::attr_from_type(t)),
15798            self.orig_loc,
15799            self.buf.as_ptr().wrapping_add(pos) as usize,
15800        )))
15801    }
15802}
15803impl std::fmt::Debug for IterableLinkDpllPinAttrs<'_> {
15804    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15805        let mut fmt = f.debug_struct("LinkDpllPinAttrs");
15806        for attr in self.clone() {
15807            let attr = match attr {
15808                Ok(a) => a,
15809                Err(err) => {
15810                    fmt.finish()?;
15811                    f.write_str("Err(")?;
15812                    err.fmt(f)?;
15813                    return f.write_str(")");
15814                }
15815            };
15816            match attr {
15817                LinkDpllPinAttrs::Id(val) => fmt.field("Id", &val),
15818            };
15819        }
15820        fmt.finish()
15821    }
15822}
15823impl IterableLinkDpllPinAttrs<'_> {
15824    pub fn lookup_attr(
15825        &self,
15826        offset: usize,
15827        missing_type: Option<u16>,
15828    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15829        let mut stack = Vec::new();
15830        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15831        if cur == offset {
15832            stack.push(("LinkDpllPinAttrs", offset));
15833            return (
15834                stack,
15835                missing_type.and_then(|t| LinkDpllPinAttrs::attr_from_type(t)),
15836            );
15837        }
15838        if cur > offset || cur + self.buf.len() < offset {
15839            return (stack, None);
15840        }
15841        let mut attrs = self.clone();
15842        let mut last_off = cur + attrs.pos;
15843        while let Some(attr) = attrs.next() {
15844            let Ok(attr) = attr else { break };
15845            match attr {
15846                LinkDpllPinAttrs::Id(val) => {
15847                    if last_off == offset {
15848                        stack.push(("Id", last_off));
15849                        break;
15850                    }
15851                }
15852                _ => {}
15853            };
15854            last_off = cur + attrs.pos;
15855        }
15856        if !stack.is_empty() {
15857            stack.push(("LinkDpllPinAttrs", cur));
15858        }
15859        (stack, None)
15860    }
15861}
15862#[derive(Clone)]
15863pub enum LinkinfoNetkitAttrs<'a> {
15864    PeerInfo(&'a [u8]),
15865    Primary(u8),
15866    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
15867    Policy(u32),
15868    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
15869    PeerPolicy(u32),
15870    #[doc = "Associated type: \"NetkitMode\" (enum)"]
15871    Mode(u32),
15872    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
15873    Scrub(u32),
15874    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
15875    PeerScrub(u32),
15876    Headroom(u16),
15877    Tailroom(u16),
15878}
15879impl<'a> IterableLinkinfoNetkitAttrs<'a> {
15880    pub fn get_peer_info(&self) -> Result<&'a [u8], ErrorContext> {
15881        let mut iter = self.clone();
15882        iter.pos = 0;
15883        for attr in iter {
15884            if let LinkinfoNetkitAttrs::PeerInfo(val) = attr? {
15885                return Ok(val);
15886            }
15887        }
15888        Err(ErrorContext::new_missing(
15889            "LinkinfoNetkitAttrs",
15890            "PeerInfo",
15891            self.orig_loc,
15892            self.buf.as_ptr() as usize,
15893        ))
15894    }
15895    pub fn get_primary(&self) -> Result<u8, ErrorContext> {
15896        let mut iter = self.clone();
15897        iter.pos = 0;
15898        for attr in iter {
15899            if let LinkinfoNetkitAttrs::Primary(val) = attr? {
15900                return Ok(val);
15901            }
15902        }
15903        Err(ErrorContext::new_missing(
15904            "LinkinfoNetkitAttrs",
15905            "Primary",
15906            self.orig_loc,
15907            self.buf.as_ptr() as usize,
15908        ))
15909    }
15910    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
15911    pub fn get_policy(&self) -> Result<u32, ErrorContext> {
15912        let mut iter = self.clone();
15913        iter.pos = 0;
15914        for attr in iter {
15915            if let LinkinfoNetkitAttrs::Policy(val) = attr? {
15916                return Ok(val);
15917            }
15918        }
15919        Err(ErrorContext::new_missing(
15920            "LinkinfoNetkitAttrs",
15921            "Policy",
15922            self.orig_loc,
15923            self.buf.as_ptr() as usize,
15924        ))
15925    }
15926    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
15927    pub fn get_peer_policy(&self) -> Result<u32, ErrorContext> {
15928        let mut iter = self.clone();
15929        iter.pos = 0;
15930        for attr in iter {
15931            if let LinkinfoNetkitAttrs::PeerPolicy(val) = attr? {
15932                return Ok(val);
15933            }
15934        }
15935        Err(ErrorContext::new_missing(
15936            "LinkinfoNetkitAttrs",
15937            "PeerPolicy",
15938            self.orig_loc,
15939            self.buf.as_ptr() as usize,
15940        ))
15941    }
15942    #[doc = "Associated type: \"NetkitMode\" (enum)"]
15943    pub fn get_mode(&self) -> Result<u32, ErrorContext> {
15944        let mut iter = self.clone();
15945        iter.pos = 0;
15946        for attr in iter {
15947            if let LinkinfoNetkitAttrs::Mode(val) = attr? {
15948                return Ok(val);
15949            }
15950        }
15951        Err(ErrorContext::new_missing(
15952            "LinkinfoNetkitAttrs",
15953            "Mode",
15954            self.orig_loc,
15955            self.buf.as_ptr() as usize,
15956        ))
15957    }
15958    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
15959    pub fn get_scrub(&self) -> Result<u32, ErrorContext> {
15960        let mut iter = self.clone();
15961        iter.pos = 0;
15962        for attr in iter {
15963            if let LinkinfoNetkitAttrs::Scrub(val) = attr? {
15964                return Ok(val);
15965            }
15966        }
15967        Err(ErrorContext::new_missing(
15968            "LinkinfoNetkitAttrs",
15969            "Scrub",
15970            self.orig_loc,
15971            self.buf.as_ptr() as usize,
15972        ))
15973    }
15974    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
15975    pub fn get_peer_scrub(&self) -> Result<u32, ErrorContext> {
15976        let mut iter = self.clone();
15977        iter.pos = 0;
15978        for attr in iter {
15979            if let LinkinfoNetkitAttrs::PeerScrub(val) = attr? {
15980                return Ok(val);
15981            }
15982        }
15983        Err(ErrorContext::new_missing(
15984            "LinkinfoNetkitAttrs",
15985            "PeerScrub",
15986            self.orig_loc,
15987            self.buf.as_ptr() as usize,
15988        ))
15989    }
15990    pub fn get_headroom(&self) -> Result<u16, ErrorContext> {
15991        let mut iter = self.clone();
15992        iter.pos = 0;
15993        for attr in iter {
15994            if let LinkinfoNetkitAttrs::Headroom(val) = attr? {
15995                return Ok(val);
15996            }
15997        }
15998        Err(ErrorContext::new_missing(
15999            "LinkinfoNetkitAttrs",
16000            "Headroom",
16001            self.orig_loc,
16002            self.buf.as_ptr() as usize,
16003        ))
16004    }
16005    pub fn get_tailroom(&self) -> Result<u16, ErrorContext> {
16006        let mut iter = self.clone();
16007        iter.pos = 0;
16008        for attr in iter {
16009            if let LinkinfoNetkitAttrs::Tailroom(val) = attr? {
16010                return Ok(val);
16011            }
16012        }
16013        Err(ErrorContext::new_missing(
16014            "LinkinfoNetkitAttrs",
16015            "Tailroom",
16016            self.orig_loc,
16017            self.buf.as_ptr() as usize,
16018        ))
16019    }
16020}
16021impl LinkinfoNetkitAttrs<'_> {
16022    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoNetkitAttrs<'a> {
16023        IterableLinkinfoNetkitAttrs::with_loc(buf, buf.as_ptr() as usize)
16024    }
16025    fn attr_from_type(r#type: u16) -> Option<&'static str> {
16026        let res = match r#type {
16027            1u16 => "PeerInfo",
16028            2u16 => "Primary",
16029            3u16 => "Policy",
16030            4u16 => "PeerPolicy",
16031            5u16 => "Mode",
16032            6u16 => "Scrub",
16033            7u16 => "PeerScrub",
16034            8u16 => "Headroom",
16035            9u16 => "Tailroom",
16036            _ => return None,
16037        };
16038        Some(res)
16039    }
16040}
16041#[derive(Clone, Copy, Default)]
16042pub struct IterableLinkinfoNetkitAttrs<'a> {
16043    buf: &'a [u8],
16044    pos: usize,
16045    orig_loc: usize,
16046}
16047impl<'a> IterableLinkinfoNetkitAttrs<'a> {
16048    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
16049        Self {
16050            buf,
16051            pos: 0,
16052            orig_loc,
16053        }
16054    }
16055    pub fn get_buf(&self) -> &'a [u8] {
16056        self.buf
16057    }
16058}
16059impl<'a> Iterator for IterableLinkinfoNetkitAttrs<'a> {
16060    type Item = Result<LinkinfoNetkitAttrs<'a>, ErrorContext>;
16061    fn next(&mut self) -> Option<Self::Item> {
16062        let pos = self.pos;
16063        let mut r#type;
16064        loop {
16065            r#type = None;
16066            if self.buf.len() == self.pos {
16067                return None;
16068            }
16069            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
16070                break;
16071            };
16072            r#type = Some(header.r#type);
16073            let res = match header.r#type {
16074                1u16 => LinkinfoNetkitAttrs::PeerInfo({
16075                    let res = Some(next);
16076                    let Some(val) = res else { break };
16077                    val
16078                }),
16079                2u16 => LinkinfoNetkitAttrs::Primary({
16080                    let res = parse_u8(next);
16081                    let Some(val) = res else { break };
16082                    val
16083                }),
16084                3u16 => LinkinfoNetkitAttrs::Policy({
16085                    let res = parse_u32(next);
16086                    let Some(val) = res else { break };
16087                    val
16088                }),
16089                4u16 => LinkinfoNetkitAttrs::PeerPolicy({
16090                    let res = parse_u32(next);
16091                    let Some(val) = res else { break };
16092                    val
16093                }),
16094                5u16 => LinkinfoNetkitAttrs::Mode({
16095                    let res = parse_u32(next);
16096                    let Some(val) = res else { break };
16097                    val
16098                }),
16099                6u16 => LinkinfoNetkitAttrs::Scrub({
16100                    let res = parse_u32(next);
16101                    let Some(val) = res else { break };
16102                    val
16103                }),
16104                7u16 => LinkinfoNetkitAttrs::PeerScrub({
16105                    let res = parse_u32(next);
16106                    let Some(val) = res else { break };
16107                    val
16108                }),
16109                8u16 => LinkinfoNetkitAttrs::Headroom({
16110                    let res = parse_u16(next);
16111                    let Some(val) = res else { break };
16112                    val
16113                }),
16114                9u16 => LinkinfoNetkitAttrs::Tailroom({
16115                    let res = parse_u16(next);
16116                    let Some(val) = res else { break };
16117                    val
16118                }),
16119                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
16120                n => continue,
16121            };
16122            return Some(Ok(res));
16123        }
16124        Some(Err(ErrorContext::new(
16125            "LinkinfoNetkitAttrs",
16126            r#type.and_then(|t| LinkinfoNetkitAttrs::attr_from_type(t)),
16127            self.orig_loc,
16128            self.buf.as_ptr().wrapping_add(pos) as usize,
16129        )))
16130    }
16131}
16132impl<'a> std::fmt::Debug for IterableLinkinfoNetkitAttrs<'_> {
16133    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16134        let mut fmt = f.debug_struct("LinkinfoNetkitAttrs");
16135        for attr in self.clone() {
16136            let attr = match attr {
16137                Ok(a) => a,
16138                Err(err) => {
16139                    fmt.finish()?;
16140                    f.write_str("Err(")?;
16141                    err.fmt(f)?;
16142                    return f.write_str(")");
16143                }
16144            };
16145            match attr {
16146                LinkinfoNetkitAttrs::PeerInfo(val) => fmt.field("PeerInfo", &val),
16147                LinkinfoNetkitAttrs::Primary(val) => fmt.field("Primary", &val),
16148                LinkinfoNetkitAttrs::Policy(val) => {
16149                    fmt.field("Policy", &FormatEnum(val.into(), NetkitPolicy::from_value))
16150                }
16151                LinkinfoNetkitAttrs::PeerPolicy(val) => fmt.field(
16152                    "PeerPolicy",
16153                    &FormatEnum(val.into(), NetkitPolicy::from_value),
16154                ),
16155                LinkinfoNetkitAttrs::Mode(val) => {
16156                    fmt.field("Mode", &FormatEnum(val.into(), NetkitMode::from_value))
16157                }
16158                LinkinfoNetkitAttrs::Scrub(val) => {
16159                    fmt.field("Scrub", &FormatEnum(val.into(), NetkitScrub::from_value))
16160                }
16161                LinkinfoNetkitAttrs::PeerScrub(val) => fmt.field(
16162                    "PeerScrub",
16163                    &FormatEnum(val.into(), NetkitScrub::from_value),
16164                ),
16165                LinkinfoNetkitAttrs::Headroom(val) => fmt.field("Headroom", &val),
16166                LinkinfoNetkitAttrs::Tailroom(val) => fmt.field("Tailroom", &val),
16167            };
16168        }
16169        fmt.finish()
16170    }
16171}
16172impl IterableLinkinfoNetkitAttrs<'_> {
16173    pub fn lookup_attr(
16174        &self,
16175        offset: usize,
16176        missing_type: Option<u16>,
16177    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16178        let mut stack = Vec::new();
16179        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
16180        if cur == offset {
16181            stack.push(("LinkinfoNetkitAttrs", offset));
16182            return (
16183                stack,
16184                missing_type.and_then(|t| LinkinfoNetkitAttrs::attr_from_type(t)),
16185            );
16186        }
16187        if cur > offset || cur + self.buf.len() < offset {
16188            return (stack, None);
16189        }
16190        let mut attrs = self.clone();
16191        let mut last_off = cur + attrs.pos;
16192        while let Some(attr) = attrs.next() {
16193            let Ok(attr) = attr else { break };
16194            match attr {
16195                LinkinfoNetkitAttrs::PeerInfo(val) => {
16196                    if last_off == offset {
16197                        stack.push(("PeerInfo", last_off));
16198                        break;
16199                    }
16200                }
16201                LinkinfoNetkitAttrs::Primary(val) => {
16202                    if last_off == offset {
16203                        stack.push(("Primary", last_off));
16204                        break;
16205                    }
16206                }
16207                LinkinfoNetkitAttrs::Policy(val) => {
16208                    if last_off == offset {
16209                        stack.push(("Policy", last_off));
16210                        break;
16211                    }
16212                }
16213                LinkinfoNetkitAttrs::PeerPolicy(val) => {
16214                    if last_off == offset {
16215                        stack.push(("PeerPolicy", last_off));
16216                        break;
16217                    }
16218                }
16219                LinkinfoNetkitAttrs::Mode(val) => {
16220                    if last_off == offset {
16221                        stack.push(("Mode", last_off));
16222                        break;
16223                    }
16224                }
16225                LinkinfoNetkitAttrs::Scrub(val) => {
16226                    if last_off == offset {
16227                        stack.push(("Scrub", last_off));
16228                        break;
16229                    }
16230                }
16231                LinkinfoNetkitAttrs::PeerScrub(val) => {
16232                    if last_off == offset {
16233                        stack.push(("PeerScrub", last_off));
16234                        break;
16235                    }
16236                }
16237                LinkinfoNetkitAttrs::Headroom(val) => {
16238                    if last_off == offset {
16239                        stack.push(("Headroom", last_off));
16240                        break;
16241                    }
16242                }
16243                LinkinfoNetkitAttrs::Tailroom(val) => {
16244                    if last_off == offset {
16245                        stack.push(("Tailroom", last_off));
16246                        break;
16247                    }
16248                }
16249                _ => {}
16250            };
16251            last_off = cur + attrs.pos;
16252        }
16253        if !stack.is_empty() {
16254            stack.push(("LinkinfoNetkitAttrs", cur));
16255        }
16256        (stack, None)
16257    }
16258}
16259#[derive(Clone)]
16260pub enum LinkinfoOvpnAttrs {
16261    #[doc = "Associated type: \"OvpnMode\" (enum)"]
16262    Mode(u8),
16263}
16264impl<'a> IterableLinkinfoOvpnAttrs<'a> {
16265    #[doc = "Associated type: \"OvpnMode\" (enum)"]
16266    pub fn get_mode(&self) -> Result<u8, ErrorContext> {
16267        let mut iter = self.clone();
16268        iter.pos = 0;
16269        for attr in iter {
16270            if let LinkinfoOvpnAttrs::Mode(val) = attr? {
16271                return Ok(val);
16272            }
16273        }
16274        Err(ErrorContext::new_missing(
16275            "LinkinfoOvpnAttrs",
16276            "Mode",
16277            self.orig_loc,
16278            self.buf.as_ptr() as usize,
16279        ))
16280    }
16281}
16282impl LinkinfoOvpnAttrs {
16283    pub fn new<'a>(buf: &'a [u8]) -> IterableLinkinfoOvpnAttrs<'a> {
16284        IterableLinkinfoOvpnAttrs::with_loc(buf, buf.as_ptr() as usize)
16285    }
16286    fn attr_from_type(r#type: u16) -> Option<&'static str> {
16287        let res = match r#type {
16288            1u16 => "Mode",
16289            _ => return None,
16290        };
16291        Some(res)
16292    }
16293}
16294#[derive(Clone, Copy, Default)]
16295pub struct IterableLinkinfoOvpnAttrs<'a> {
16296    buf: &'a [u8],
16297    pos: usize,
16298    orig_loc: usize,
16299}
16300impl<'a> IterableLinkinfoOvpnAttrs<'a> {
16301    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
16302        Self {
16303            buf,
16304            pos: 0,
16305            orig_loc,
16306        }
16307    }
16308    pub fn get_buf(&self) -> &'a [u8] {
16309        self.buf
16310    }
16311}
16312impl<'a> Iterator for IterableLinkinfoOvpnAttrs<'a> {
16313    type Item = Result<LinkinfoOvpnAttrs, ErrorContext>;
16314    fn next(&mut self) -> Option<Self::Item> {
16315        let pos = self.pos;
16316        let mut r#type;
16317        loop {
16318            r#type = None;
16319            if self.buf.len() == self.pos {
16320                return None;
16321            }
16322            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
16323                break;
16324            };
16325            r#type = Some(header.r#type);
16326            let res = match header.r#type {
16327                1u16 => LinkinfoOvpnAttrs::Mode({
16328                    let res = parse_u8(next);
16329                    let Some(val) = res else { break };
16330                    val
16331                }),
16332                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
16333                n => continue,
16334            };
16335            return Some(Ok(res));
16336        }
16337        Some(Err(ErrorContext::new(
16338            "LinkinfoOvpnAttrs",
16339            r#type.and_then(|t| LinkinfoOvpnAttrs::attr_from_type(t)),
16340            self.orig_loc,
16341            self.buf.as_ptr().wrapping_add(pos) as usize,
16342        )))
16343    }
16344}
16345impl std::fmt::Debug for IterableLinkinfoOvpnAttrs<'_> {
16346    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16347        let mut fmt = f.debug_struct("LinkinfoOvpnAttrs");
16348        for attr in self.clone() {
16349            let attr = match attr {
16350                Ok(a) => a,
16351                Err(err) => {
16352                    fmt.finish()?;
16353                    f.write_str("Err(")?;
16354                    err.fmt(f)?;
16355                    return f.write_str(")");
16356                }
16357            };
16358            match attr {
16359                LinkinfoOvpnAttrs::Mode(val) => {
16360                    fmt.field("Mode", &FormatEnum(val.into(), OvpnMode::from_value))
16361                }
16362            };
16363        }
16364        fmt.finish()
16365    }
16366}
16367impl IterableLinkinfoOvpnAttrs<'_> {
16368    pub fn lookup_attr(
16369        &self,
16370        offset: usize,
16371        missing_type: Option<u16>,
16372    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16373        let mut stack = Vec::new();
16374        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
16375        if cur == offset {
16376            stack.push(("LinkinfoOvpnAttrs", offset));
16377            return (
16378                stack,
16379                missing_type.and_then(|t| LinkinfoOvpnAttrs::attr_from_type(t)),
16380            );
16381        }
16382        if cur > offset || cur + self.buf.len() < offset {
16383            return (stack, None);
16384        }
16385        let mut attrs = self.clone();
16386        let mut last_off = cur + attrs.pos;
16387        while let Some(attr) = attrs.next() {
16388            let Ok(attr) = attr else { break };
16389            match attr {
16390                LinkinfoOvpnAttrs::Mode(val) => {
16391                    if last_off == offset {
16392                        stack.push(("Mode", last_off));
16393                        break;
16394                    }
16395                }
16396                _ => {}
16397            };
16398            last_off = cur + attrs.pos;
16399        }
16400        if !stack.is_empty() {
16401            stack.push(("LinkinfoOvpnAttrs", cur));
16402        }
16403        (stack, None)
16404    }
16405}
16406pub struct PushLinkAttrs<Prev: Rec> {
16407    pub(crate) prev: Option<Prev>,
16408    pub(crate) header_offset: Option<usize>,
16409}
16410impl<Prev: Rec> Rec for PushLinkAttrs<Prev> {
16411    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
16412        self.prev.as_mut().unwrap().as_rec_mut()
16413    }
16414    fn as_rec(&self) -> &Vec<u8> {
16415        self.prev.as_ref().unwrap().as_rec()
16416    }
16417}
16418impl<Prev: Rec> PushLinkAttrs<Prev> {
16419    pub fn new(prev: Prev) -> Self {
16420        Self {
16421            prev: Some(prev),
16422            header_offset: None,
16423        }
16424    }
16425    pub fn end_nested(mut self) -> Prev {
16426        let mut prev = self.prev.take().unwrap();
16427        if let Some(header_offset) = &self.header_offset {
16428            finalize_nested_header(prev.as_rec_mut(), *header_offset);
16429        }
16430        prev
16431    }
16432    pub fn push_address(mut self, value: &[u8]) -> Self {
16433        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
16434        self.as_rec_mut().extend(value);
16435        self
16436    }
16437    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
16438        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
16439        self.as_rec_mut().extend(value);
16440        self
16441    }
16442    pub fn push_ifname(mut self, value: &CStr) -> Self {
16443        push_header(
16444            self.as_rec_mut(),
16445            3u16,
16446            value.to_bytes_with_nul().len() as u16,
16447        );
16448        self.as_rec_mut().extend(value.to_bytes_with_nul());
16449        self
16450    }
16451    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
16452        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
16453        self.as_rec_mut().extend(value);
16454        self.as_rec_mut().push(0);
16455        self
16456    }
16457    pub fn push_mtu(mut self, value: u32) -> Self {
16458        push_header(self.as_rec_mut(), 4u16, 4 as u16);
16459        self.as_rec_mut().extend(value.to_ne_bytes());
16460        self
16461    }
16462    pub fn push_link(mut self, value: u32) -> Self {
16463        push_header(self.as_rec_mut(), 5u16, 4 as u16);
16464        self.as_rec_mut().extend(value.to_ne_bytes());
16465        self
16466    }
16467    pub fn push_qdisc(mut self, value: &CStr) -> Self {
16468        push_header(
16469            self.as_rec_mut(),
16470            6u16,
16471            value.to_bytes_with_nul().len() as u16,
16472        );
16473        self.as_rec_mut().extend(value.to_bytes_with_nul());
16474        self
16475    }
16476    pub fn push_qdisc_bytes(mut self, value: &[u8]) -> Self {
16477        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
16478        self.as_rec_mut().extend(value);
16479        self.as_rec_mut().push(0);
16480        self
16481    }
16482    pub fn push_stats(mut self, value: PushRtnlLinkStats) -> Self {
16483        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
16484        self.as_rec_mut().extend(value.as_slice());
16485        self
16486    }
16487    pub fn push_cost(mut self, value: &CStr) -> Self {
16488        push_header(
16489            self.as_rec_mut(),
16490            8u16,
16491            value.to_bytes_with_nul().len() as u16,
16492        );
16493        self.as_rec_mut().extend(value.to_bytes_with_nul());
16494        self
16495    }
16496    pub fn push_cost_bytes(mut self, value: &[u8]) -> Self {
16497        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
16498        self.as_rec_mut().extend(value);
16499        self.as_rec_mut().push(0);
16500        self
16501    }
16502    pub fn push_priority(mut self, value: &CStr) -> Self {
16503        push_header(
16504            self.as_rec_mut(),
16505            9u16,
16506            value.to_bytes_with_nul().len() as u16,
16507        );
16508        self.as_rec_mut().extend(value.to_bytes_with_nul());
16509        self
16510    }
16511    pub fn push_priority_bytes(mut self, value: &[u8]) -> Self {
16512        push_header(self.as_rec_mut(), 9u16, (value.len() + 1) as u16);
16513        self.as_rec_mut().extend(value);
16514        self.as_rec_mut().push(0);
16515        self
16516    }
16517    pub fn push_master(mut self, value: u32) -> Self {
16518        push_header(self.as_rec_mut(), 10u16, 4 as u16);
16519        self.as_rec_mut().extend(value.to_ne_bytes());
16520        self
16521    }
16522    pub fn push_wireless(mut self, value: &CStr) -> Self {
16523        push_header(
16524            self.as_rec_mut(),
16525            11u16,
16526            value.to_bytes_with_nul().len() as u16,
16527        );
16528        self.as_rec_mut().extend(value.to_bytes_with_nul());
16529        self
16530    }
16531    pub fn push_wireless_bytes(mut self, value: &[u8]) -> Self {
16532        push_header(self.as_rec_mut(), 11u16, (value.len() + 1) as u16);
16533        self.as_rec_mut().extend(value);
16534        self.as_rec_mut().push(0);
16535        self
16536    }
16537    pub fn push_protinfo(mut self, value: &CStr) -> Self {
16538        push_header(
16539            self.as_rec_mut(),
16540            12u16,
16541            value.to_bytes_with_nul().len() as u16,
16542        );
16543        self.as_rec_mut().extend(value.to_bytes_with_nul());
16544        self
16545    }
16546    pub fn push_protinfo_bytes(mut self, value: &[u8]) -> Self {
16547        push_header(self.as_rec_mut(), 12u16, (value.len() + 1) as u16);
16548        self.as_rec_mut().extend(value);
16549        self.as_rec_mut().push(0);
16550        self
16551    }
16552    pub fn push_txqlen(mut self, value: u32) -> Self {
16553        push_header(self.as_rec_mut(), 13u16, 4 as u16);
16554        self.as_rec_mut().extend(value.to_ne_bytes());
16555        self
16556    }
16557    pub fn push_map(mut self, value: PushRtnlLinkIfmap) -> Self {
16558        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
16559        self.as_rec_mut().extend(value.as_slice());
16560        self
16561    }
16562    pub fn push_weight(mut self, value: u32) -> Self {
16563        push_header(self.as_rec_mut(), 15u16, 4 as u16);
16564        self.as_rec_mut().extend(value.to_ne_bytes());
16565        self
16566    }
16567    pub fn push_operstate(mut self, value: u8) -> Self {
16568        push_header(self.as_rec_mut(), 16u16, 1 as u16);
16569        self.as_rec_mut().extend(value.to_ne_bytes());
16570        self
16571    }
16572    pub fn push_linkmode(mut self, value: u8) -> Self {
16573        push_header(self.as_rec_mut(), 17u16, 1 as u16);
16574        self.as_rec_mut().extend(value.to_ne_bytes());
16575        self
16576    }
16577    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
16578        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
16579        PushLinkinfoAttrs {
16580            prev: Some(self),
16581            header_offset: Some(header_offset),
16582        }
16583    }
16584    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
16585        push_header(self.as_rec_mut(), 19u16, 4 as u16);
16586        self.as_rec_mut().extend(value.to_ne_bytes());
16587        self
16588    }
16589    pub fn push_ifalias(mut self, value: &CStr) -> Self {
16590        push_header(
16591            self.as_rec_mut(),
16592            20u16,
16593            value.to_bytes_with_nul().len() as u16,
16594        );
16595        self.as_rec_mut().extend(value.to_bytes_with_nul());
16596        self
16597    }
16598    pub fn push_ifalias_bytes(mut self, value: &[u8]) -> Self {
16599        push_header(self.as_rec_mut(), 20u16, (value.len() + 1) as u16);
16600        self.as_rec_mut().extend(value);
16601        self.as_rec_mut().push(0);
16602        self
16603    }
16604    pub fn push_num_vf(mut self, value: u32) -> Self {
16605        push_header(self.as_rec_mut(), 21u16, 4 as u16);
16606        self.as_rec_mut().extend(value.to_ne_bytes());
16607        self
16608    }
16609    pub fn nested_vfinfo_list(mut self) -> PushVfinfoListAttrs<Self> {
16610        let header_offset = push_nested_header(self.as_rec_mut(), 22u16);
16611        PushVfinfoListAttrs {
16612            prev: Some(self),
16613            header_offset: Some(header_offset),
16614        }
16615    }
16616    pub fn push_stats64(mut self, value: PushRtnlLinkStats64) -> Self {
16617        push_header(self.as_rec_mut(), 23u16, value.as_slice().len() as u16);
16618        self.as_rec_mut().extend(value.as_slice());
16619        self
16620    }
16621    pub fn nested_vf_ports(mut self) -> PushVfPortsAttrs<Self> {
16622        let header_offset = push_nested_header(self.as_rec_mut(), 24u16);
16623        PushVfPortsAttrs {
16624            prev: Some(self),
16625            header_offset: Some(header_offset),
16626        }
16627    }
16628    pub fn nested_port_self(mut self) -> PushPortSelfAttrs<Self> {
16629        let header_offset = push_nested_header(self.as_rec_mut(), 25u16);
16630        PushPortSelfAttrs {
16631            prev: Some(self),
16632            header_offset: Some(header_offset),
16633        }
16634    }
16635    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
16636        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
16637        PushAfSpecAttrs {
16638            prev: Some(self),
16639            header_offset: Some(header_offset),
16640        }
16641    }
16642    pub fn push_group(mut self, value: u32) -> Self {
16643        push_header(self.as_rec_mut(), 27u16, 4 as u16);
16644        self.as_rec_mut().extend(value.to_ne_bytes());
16645        self
16646    }
16647    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
16648        push_header(self.as_rec_mut(), 28u16, 4 as u16);
16649        self.as_rec_mut().extend(value.to_ne_bytes());
16650        self
16651    }
16652    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
16653    pub fn push_ext_mask(mut self, value: u32) -> Self {
16654        push_header(self.as_rec_mut(), 29u16, 4 as u16);
16655        self.as_rec_mut().extend(value.to_ne_bytes());
16656        self
16657    }
16658    pub fn push_promiscuity(mut self, value: u32) -> Self {
16659        push_header(self.as_rec_mut(), 30u16, 4 as u16);
16660        self.as_rec_mut().extend(value.to_ne_bytes());
16661        self
16662    }
16663    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
16664        push_header(self.as_rec_mut(), 31u16, 4 as u16);
16665        self.as_rec_mut().extend(value.to_ne_bytes());
16666        self
16667    }
16668    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
16669        push_header(self.as_rec_mut(), 32u16, 4 as u16);
16670        self.as_rec_mut().extend(value.to_ne_bytes());
16671        self
16672    }
16673    pub fn push_carrier(mut self, value: u8) -> Self {
16674        push_header(self.as_rec_mut(), 33u16, 1 as u16);
16675        self.as_rec_mut().extend(value.to_ne_bytes());
16676        self
16677    }
16678    pub fn push_phys_port_id(mut self, value: &[u8]) -> Self {
16679        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
16680        self.as_rec_mut().extend(value);
16681        self
16682    }
16683    pub fn push_carrier_changes(mut self, value: u32) -> Self {
16684        push_header(self.as_rec_mut(), 35u16, 4 as u16);
16685        self.as_rec_mut().extend(value.to_ne_bytes());
16686        self
16687    }
16688    pub fn push_phys_switch_id(mut self, value: &[u8]) -> Self {
16689        push_header(self.as_rec_mut(), 36u16, value.len() as u16);
16690        self.as_rec_mut().extend(value);
16691        self
16692    }
16693    pub fn push_link_netnsid(mut self, value: i32) -> Self {
16694        push_header(self.as_rec_mut(), 37u16, 4 as u16);
16695        self.as_rec_mut().extend(value.to_ne_bytes());
16696        self
16697    }
16698    pub fn push_phys_port_name(mut self, value: &CStr) -> Self {
16699        push_header(
16700            self.as_rec_mut(),
16701            38u16,
16702            value.to_bytes_with_nul().len() as u16,
16703        );
16704        self.as_rec_mut().extend(value.to_bytes_with_nul());
16705        self
16706    }
16707    pub fn push_phys_port_name_bytes(mut self, value: &[u8]) -> Self {
16708        push_header(self.as_rec_mut(), 38u16, (value.len() + 1) as u16);
16709        self.as_rec_mut().extend(value);
16710        self.as_rec_mut().push(0);
16711        self
16712    }
16713    pub fn push_proto_down(mut self, value: u8) -> Self {
16714        push_header(self.as_rec_mut(), 39u16, 1 as u16);
16715        self.as_rec_mut().extend(value.to_ne_bytes());
16716        self
16717    }
16718    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
16719        push_header(self.as_rec_mut(), 40u16, 4 as u16);
16720        self.as_rec_mut().extend(value.to_ne_bytes());
16721        self
16722    }
16723    pub fn push_gso_max_size(mut self, value: u32) -> Self {
16724        push_header(self.as_rec_mut(), 41u16, 4 as u16);
16725        self.as_rec_mut().extend(value.to_ne_bytes());
16726        self
16727    }
16728    pub fn push_pad(mut self, value: &[u8]) -> Self {
16729        push_header(self.as_rec_mut(), 42u16, value.len() as u16);
16730        self.as_rec_mut().extend(value);
16731        self
16732    }
16733    pub fn nested_xdp(mut self) -> PushXdpAttrs<Self> {
16734        let header_offset = push_nested_header(self.as_rec_mut(), 43u16);
16735        PushXdpAttrs {
16736            prev: Some(self),
16737            header_offset: Some(header_offset),
16738        }
16739    }
16740    pub fn push_event(mut self, value: u32) -> Self {
16741        push_header(self.as_rec_mut(), 44u16, 4 as u16);
16742        self.as_rec_mut().extend(value.to_ne_bytes());
16743        self
16744    }
16745    pub fn push_new_netnsid(mut self, value: i32) -> Self {
16746        push_header(self.as_rec_mut(), 45u16, 4 as u16);
16747        self.as_rec_mut().extend(value.to_ne_bytes());
16748        self
16749    }
16750    pub fn push_target_netnsid(mut self, value: i32) -> Self {
16751        push_header(self.as_rec_mut(), 46u16, 4 as u16);
16752        self.as_rec_mut().extend(value.to_ne_bytes());
16753        self
16754    }
16755    pub fn push_carrier_up_count(mut self, value: u32) -> Self {
16756        push_header(self.as_rec_mut(), 47u16, 4 as u16);
16757        self.as_rec_mut().extend(value.to_ne_bytes());
16758        self
16759    }
16760    pub fn push_carrier_down_count(mut self, value: u32) -> Self {
16761        push_header(self.as_rec_mut(), 48u16, 4 as u16);
16762        self.as_rec_mut().extend(value.to_ne_bytes());
16763        self
16764    }
16765    pub fn push_new_ifindex(mut self, value: i32) -> Self {
16766        push_header(self.as_rec_mut(), 49u16, 4 as u16);
16767        self.as_rec_mut().extend(value.to_ne_bytes());
16768        self
16769    }
16770    pub fn push_min_mtu(mut self, value: u32) -> Self {
16771        push_header(self.as_rec_mut(), 50u16, 4 as u16);
16772        self.as_rec_mut().extend(value.to_ne_bytes());
16773        self
16774    }
16775    pub fn push_max_mtu(mut self, value: u32) -> Self {
16776        push_header(self.as_rec_mut(), 51u16, 4 as u16);
16777        self.as_rec_mut().extend(value.to_ne_bytes());
16778        self
16779    }
16780    pub fn nested_prop_list(mut self) -> PushPropListLinkAttrs<Self> {
16781        let header_offset = push_nested_header(self.as_rec_mut(), 52u16);
16782        PushPropListLinkAttrs {
16783            prev: Some(self),
16784            header_offset: Some(header_offset),
16785        }
16786    }
16787    pub fn push_alt_ifname(mut self, value: &CStr) -> Self {
16788        push_header(
16789            self.as_rec_mut(),
16790            53u16,
16791            value.to_bytes_with_nul().len() as u16,
16792        );
16793        self.as_rec_mut().extend(value.to_bytes_with_nul());
16794        self
16795    }
16796    pub fn push_alt_ifname_bytes(mut self, value: &[u8]) -> Self {
16797        push_header(self.as_rec_mut(), 53u16, (value.len() + 1) as u16);
16798        self.as_rec_mut().extend(value);
16799        self.as_rec_mut().push(0);
16800        self
16801    }
16802    pub fn push_perm_address(mut self, value: &[u8]) -> Self {
16803        push_header(self.as_rec_mut(), 54u16, value.len() as u16);
16804        self.as_rec_mut().extend(value);
16805        self
16806    }
16807    pub fn push_proto_down_reason(mut self, value: &CStr) -> Self {
16808        push_header(
16809            self.as_rec_mut(),
16810            55u16,
16811            value.to_bytes_with_nul().len() as u16,
16812        );
16813        self.as_rec_mut().extend(value.to_bytes_with_nul());
16814        self
16815    }
16816    pub fn push_proto_down_reason_bytes(mut self, value: &[u8]) -> Self {
16817        push_header(self.as_rec_mut(), 55u16, (value.len() + 1) as u16);
16818        self.as_rec_mut().extend(value);
16819        self.as_rec_mut().push(0);
16820        self
16821    }
16822    pub fn push_parent_dev_name(mut self, value: &CStr) -> Self {
16823        push_header(
16824            self.as_rec_mut(),
16825            56u16,
16826            value.to_bytes_with_nul().len() as u16,
16827        );
16828        self.as_rec_mut().extend(value.to_bytes_with_nul());
16829        self
16830    }
16831    pub fn push_parent_dev_name_bytes(mut self, value: &[u8]) -> Self {
16832        push_header(self.as_rec_mut(), 56u16, (value.len() + 1) as u16);
16833        self.as_rec_mut().extend(value);
16834        self.as_rec_mut().push(0);
16835        self
16836    }
16837    pub fn push_parent_dev_bus_name(mut self, value: &CStr) -> Self {
16838        push_header(
16839            self.as_rec_mut(),
16840            57u16,
16841            value.to_bytes_with_nul().len() as u16,
16842        );
16843        self.as_rec_mut().extend(value.to_bytes_with_nul());
16844        self
16845    }
16846    pub fn push_parent_dev_bus_name_bytes(mut self, value: &[u8]) -> Self {
16847        push_header(self.as_rec_mut(), 57u16, (value.len() + 1) as u16);
16848        self.as_rec_mut().extend(value);
16849        self.as_rec_mut().push(0);
16850        self
16851    }
16852    pub fn push_gro_max_size(mut self, value: u32) -> Self {
16853        push_header(self.as_rec_mut(), 58u16, 4 as u16);
16854        self.as_rec_mut().extend(value.to_ne_bytes());
16855        self
16856    }
16857    pub fn push_tso_max_size(mut self, value: u32) -> Self {
16858        push_header(self.as_rec_mut(), 59u16, 4 as u16);
16859        self.as_rec_mut().extend(value.to_ne_bytes());
16860        self
16861    }
16862    pub fn push_tso_max_segs(mut self, value: u32) -> Self {
16863        push_header(self.as_rec_mut(), 60u16, 4 as u16);
16864        self.as_rec_mut().extend(value.to_ne_bytes());
16865        self
16866    }
16867    pub fn push_allmulti(mut self, value: u32) -> Self {
16868        push_header(self.as_rec_mut(), 61u16, 4 as u16);
16869        self.as_rec_mut().extend(value.to_ne_bytes());
16870        self
16871    }
16872    pub fn push_devlink_port(mut self, value: &[u8]) -> Self {
16873        push_header(self.as_rec_mut(), 62u16, value.len() as u16);
16874        self.as_rec_mut().extend(value);
16875        self
16876    }
16877    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
16878        push_header(self.as_rec_mut(), 63u16, 4 as u16);
16879        self.as_rec_mut().extend(value.to_ne_bytes());
16880        self
16881    }
16882    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
16883        push_header(self.as_rec_mut(), 64u16, 4 as u16);
16884        self.as_rec_mut().extend(value.to_ne_bytes());
16885        self
16886    }
16887    pub fn nested_dpll_pin(mut self) -> PushLinkDpllPinAttrs<Self> {
16888        let header_offset = push_nested_header(self.as_rec_mut(), 65u16);
16889        PushLinkDpllPinAttrs {
16890            prev: Some(self),
16891            header_offset: Some(header_offset),
16892        }
16893    }
16894    #[doc = "EDT offload horizon supported by the device (in nsec)."]
16895    pub fn push_max_pacing_offload_horizon(mut self, value: u32) -> Self {
16896        push_header(self.as_rec_mut(), 66u16, 4 as u16);
16897        self.as_rec_mut().extend(value.to_ne_bytes());
16898        self
16899    }
16900    pub fn push_netns_immutable(mut self, value: u8) -> Self {
16901        push_header(self.as_rec_mut(), 67u16, 1 as u16);
16902        self.as_rec_mut().extend(value.to_ne_bytes());
16903        self
16904    }
16905}
16906impl<Prev: Rec> Drop for PushLinkAttrs<Prev> {
16907    fn drop(&mut self) {
16908        if let Some(prev) = &mut self.prev {
16909            if let Some(header_offset) = &self.header_offset {
16910                finalize_nested_header(prev.as_rec_mut(), *header_offset);
16911            }
16912        }
16913    }
16914}
16915pub struct PushPropListLinkAttrs<Prev: Rec> {
16916    pub(crate) prev: Option<Prev>,
16917    pub(crate) header_offset: Option<usize>,
16918}
16919impl<Prev: Rec> Rec for PushPropListLinkAttrs<Prev> {
16920    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
16921        self.prev.as_mut().unwrap().as_rec_mut()
16922    }
16923    fn as_rec(&self) -> &Vec<u8> {
16924        self.prev.as_ref().unwrap().as_rec()
16925    }
16926}
16927impl<Prev: Rec> PushPropListLinkAttrs<Prev> {
16928    pub fn new(prev: Prev) -> Self {
16929        Self {
16930            prev: Some(prev),
16931            header_offset: None,
16932        }
16933    }
16934    pub fn end_nested(mut self) -> Prev {
16935        let mut prev = self.prev.take().unwrap();
16936        if let Some(header_offset) = &self.header_offset {
16937            finalize_nested_header(prev.as_rec_mut(), *header_offset);
16938        }
16939        prev
16940    }
16941    #[doc = "Attribute may repeat multiple times (treat it as array)"]
16942    pub fn push_alt_ifname(mut self, value: &CStr) -> Self {
16943        push_header(
16944            self.as_rec_mut(),
16945            53u16,
16946            value.to_bytes_with_nul().len() as u16,
16947        );
16948        self.as_rec_mut().extend(value.to_bytes_with_nul());
16949        self
16950    }
16951    #[doc = "Attribute may repeat multiple times (treat it as array)"]
16952    pub fn push_alt_ifname_bytes(mut self, value: &[u8]) -> Self {
16953        push_header(self.as_rec_mut(), 53u16, (value.len() + 1) as u16);
16954        self.as_rec_mut().extend(value);
16955        self.as_rec_mut().push(0);
16956        self
16957    }
16958}
16959impl<Prev: Rec> Drop for PushPropListLinkAttrs<Prev> {
16960    fn drop(&mut self) {
16961        if let Some(prev) = &mut self.prev {
16962            if let Some(header_offset) = &self.header_offset {
16963                finalize_nested_header(prev.as_rec_mut(), *header_offset);
16964            }
16965        }
16966    }
16967}
16968pub struct PushAfSpecAttrs<Prev: Rec> {
16969    pub(crate) prev: Option<Prev>,
16970    pub(crate) header_offset: Option<usize>,
16971}
16972impl<Prev: Rec> Rec for PushAfSpecAttrs<Prev> {
16973    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
16974        self.prev.as_mut().unwrap().as_rec_mut()
16975    }
16976    fn as_rec(&self) -> &Vec<u8> {
16977        self.prev.as_ref().unwrap().as_rec()
16978    }
16979}
16980impl<Prev: Rec> PushAfSpecAttrs<Prev> {
16981    pub fn new(prev: Prev) -> Self {
16982        Self {
16983            prev: Some(prev),
16984            header_offset: None,
16985        }
16986    }
16987    pub fn end_nested(mut self) -> Prev {
16988        let mut prev = self.prev.take().unwrap();
16989        if let Some(header_offset) = &self.header_offset {
16990            finalize_nested_header(prev.as_rec_mut(), *header_offset);
16991        }
16992        prev
16993    }
16994    pub fn nested_inet(mut self) -> PushIflaAttrs<Self> {
16995        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
16996        PushIflaAttrs {
16997            prev: Some(self),
16998            header_offset: Some(header_offset),
16999        }
17000    }
17001    pub fn nested_inet6(mut self) -> PushIfla6Attrs<Self> {
17002        let header_offset = push_nested_header(self.as_rec_mut(), 10u16);
17003        PushIfla6Attrs {
17004            prev: Some(self),
17005            header_offset: Some(header_offset),
17006        }
17007    }
17008    pub fn nested_mctp(mut self) -> PushMctpAttrs<Self> {
17009        let header_offset = push_nested_header(self.as_rec_mut(), 45u16);
17010        PushMctpAttrs {
17011            prev: Some(self),
17012            header_offset: Some(header_offset),
17013        }
17014    }
17015}
17016impl<Prev: Rec> Drop for PushAfSpecAttrs<Prev> {
17017    fn drop(&mut self) {
17018        if let Some(prev) = &mut self.prev {
17019            if let Some(header_offset) = &self.header_offset {
17020                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17021            }
17022        }
17023    }
17024}
17025pub struct PushVfinfoListAttrs<Prev: Rec> {
17026    pub(crate) prev: Option<Prev>,
17027    pub(crate) header_offset: Option<usize>,
17028}
17029impl<Prev: Rec> Rec for PushVfinfoListAttrs<Prev> {
17030    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17031        self.prev.as_mut().unwrap().as_rec_mut()
17032    }
17033    fn as_rec(&self) -> &Vec<u8> {
17034        self.prev.as_ref().unwrap().as_rec()
17035    }
17036}
17037impl<Prev: Rec> PushVfinfoListAttrs<Prev> {
17038    pub fn new(prev: Prev) -> Self {
17039        Self {
17040            prev: Some(prev),
17041            header_offset: None,
17042        }
17043    }
17044    pub fn end_nested(mut self) -> Prev {
17045        let mut prev = self.prev.take().unwrap();
17046        if let Some(header_offset) = &self.header_offset {
17047            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17048        }
17049        prev
17050    }
17051    #[doc = "Attribute may repeat multiple times (treat it as array)"]
17052    pub fn nested_info(mut self) -> PushVfinfoAttrs<Self> {
17053        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
17054        PushVfinfoAttrs {
17055            prev: Some(self),
17056            header_offset: Some(header_offset),
17057        }
17058    }
17059}
17060impl<Prev: Rec> Drop for PushVfinfoListAttrs<Prev> {
17061    fn drop(&mut self) {
17062        if let Some(prev) = &mut self.prev {
17063            if let Some(header_offset) = &self.header_offset {
17064                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17065            }
17066        }
17067    }
17068}
17069pub struct PushVfinfoAttrs<Prev: Rec> {
17070    pub(crate) prev: Option<Prev>,
17071    pub(crate) header_offset: Option<usize>,
17072}
17073impl<Prev: Rec> Rec for PushVfinfoAttrs<Prev> {
17074    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17075        self.prev.as_mut().unwrap().as_rec_mut()
17076    }
17077    fn as_rec(&self) -> &Vec<u8> {
17078        self.prev.as_ref().unwrap().as_rec()
17079    }
17080}
17081impl<Prev: Rec> PushVfinfoAttrs<Prev> {
17082    pub fn new(prev: Prev) -> Self {
17083        Self {
17084            prev: Some(prev),
17085            header_offset: None,
17086        }
17087    }
17088    pub fn end_nested(mut self) -> Prev {
17089        let mut prev = self.prev.take().unwrap();
17090        if let Some(header_offset) = &self.header_offset {
17091            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17092        }
17093        prev
17094    }
17095    pub fn push_mac(mut self, value: PushIflaVfMac) -> Self {
17096        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
17097        self.as_rec_mut().extend(value.as_slice());
17098        self
17099    }
17100    pub fn push_vlan(mut self, value: PushIflaVfVlan) -> Self {
17101        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
17102        self.as_rec_mut().extend(value.as_slice());
17103        self
17104    }
17105    pub fn push_tx_rate(mut self, value: PushIflaVfTxRate) -> Self {
17106        push_header(self.as_rec_mut(), 3u16, value.as_slice().len() as u16);
17107        self.as_rec_mut().extend(value.as_slice());
17108        self
17109    }
17110    pub fn push_spoofchk(mut self, value: PushIflaVfSpoofchk) -> Self {
17111        push_header(self.as_rec_mut(), 4u16, value.as_slice().len() as u16);
17112        self.as_rec_mut().extend(value.as_slice());
17113        self
17114    }
17115    pub fn push_link_state(mut self, value: PushIflaVfLinkState) -> Self {
17116        push_header(self.as_rec_mut(), 5u16, value.as_slice().len() as u16);
17117        self.as_rec_mut().extend(value.as_slice());
17118        self
17119    }
17120    pub fn push_rate(mut self, value: PushIflaVfRate) -> Self {
17121        push_header(self.as_rec_mut(), 6u16, value.as_slice().len() as u16);
17122        self.as_rec_mut().extend(value.as_slice());
17123        self
17124    }
17125    pub fn push_rss_query_en(mut self, value: PushIflaVfRssQueryEn) -> Self {
17126        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
17127        self.as_rec_mut().extend(value.as_slice());
17128        self
17129    }
17130    pub fn nested_stats(mut self) -> PushVfStatsAttrs<Self> {
17131        let header_offset = push_nested_header(self.as_rec_mut(), 8u16);
17132        PushVfStatsAttrs {
17133            prev: Some(self),
17134            header_offset: Some(header_offset),
17135        }
17136    }
17137    pub fn push_trust(mut self, value: PushIflaVfTrust) -> Self {
17138        push_header(self.as_rec_mut(), 9u16, value.as_slice().len() as u16);
17139        self.as_rec_mut().extend(value.as_slice());
17140        self
17141    }
17142    pub fn push_ib_node_guid(mut self, value: PushIflaVfGuid) -> Self {
17143        push_header(self.as_rec_mut(), 10u16, value.as_slice().len() as u16);
17144        self.as_rec_mut().extend(value.as_slice());
17145        self
17146    }
17147    pub fn push_ib_port_guid(mut self, value: PushIflaVfGuid) -> Self {
17148        push_header(self.as_rec_mut(), 11u16, value.as_slice().len() as u16);
17149        self.as_rec_mut().extend(value.as_slice());
17150        self
17151    }
17152    pub fn nested_vlan_list(mut self) -> PushVfVlanAttrs<Self> {
17153        let header_offset = push_nested_header(self.as_rec_mut(), 12u16);
17154        PushVfVlanAttrs {
17155            prev: Some(self),
17156            header_offset: Some(header_offset),
17157        }
17158    }
17159    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
17160        push_header(self.as_rec_mut(), 13u16, value.len() as u16);
17161        self.as_rec_mut().extend(value);
17162        self
17163    }
17164}
17165impl<Prev: Rec> Drop for PushVfinfoAttrs<Prev> {
17166    fn drop(&mut self) {
17167        if let Some(prev) = &mut self.prev {
17168            if let Some(header_offset) = &self.header_offset {
17169                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17170            }
17171        }
17172    }
17173}
17174pub struct PushVfStatsAttrs<Prev: Rec> {
17175    pub(crate) prev: Option<Prev>,
17176    pub(crate) header_offset: Option<usize>,
17177}
17178impl<Prev: Rec> Rec for PushVfStatsAttrs<Prev> {
17179    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17180        self.prev.as_mut().unwrap().as_rec_mut()
17181    }
17182    fn as_rec(&self) -> &Vec<u8> {
17183        self.prev.as_ref().unwrap().as_rec()
17184    }
17185}
17186impl<Prev: Rec> PushVfStatsAttrs<Prev> {
17187    pub fn new(prev: Prev) -> Self {
17188        Self {
17189            prev: Some(prev),
17190            header_offset: None,
17191        }
17192    }
17193    pub fn end_nested(mut self) -> Prev {
17194        let mut prev = self.prev.take().unwrap();
17195        if let Some(header_offset) = &self.header_offset {
17196            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17197        }
17198        prev
17199    }
17200    pub fn push_rx_packets(mut self, value: u64) -> Self {
17201        push_header(self.as_rec_mut(), 0u16, 8 as u16);
17202        self.as_rec_mut().extend(value.to_ne_bytes());
17203        self
17204    }
17205    pub fn push_tx_packets(mut self, value: u64) -> Self {
17206        push_header(self.as_rec_mut(), 1u16, 8 as u16);
17207        self.as_rec_mut().extend(value.to_ne_bytes());
17208        self
17209    }
17210    pub fn push_rx_bytes(mut self, value: u64) -> Self {
17211        push_header(self.as_rec_mut(), 2u16, 8 as u16);
17212        self.as_rec_mut().extend(value.to_ne_bytes());
17213        self
17214    }
17215    pub fn push_tx_bytes(mut self, value: u64) -> Self {
17216        push_header(self.as_rec_mut(), 3u16, 8 as u16);
17217        self.as_rec_mut().extend(value.to_ne_bytes());
17218        self
17219    }
17220    pub fn push_broadcast(mut self, value: u64) -> Self {
17221        push_header(self.as_rec_mut(), 4u16, 8 as u16);
17222        self.as_rec_mut().extend(value.to_ne_bytes());
17223        self
17224    }
17225    pub fn push_multicast(mut self, value: u64) -> Self {
17226        push_header(self.as_rec_mut(), 5u16, 8 as u16);
17227        self.as_rec_mut().extend(value.to_ne_bytes());
17228        self
17229    }
17230    pub fn push_pad(mut self, value: &[u8]) -> Self {
17231        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
17232        self.as_rec_mut().extend(value);
17233        self
17234    }
17235    pub fn push_rx_dropped(mut self, value: u64) -> Self {
17236        push_header(self.as_rec_mut(), 7u16, 8 as u16);
17237        self.as_rec_mut().extend(value.to_ne_bytes());
17238        self
17239    }
17240    pub fn push_tx_dropped(mut self, value: u64) -> Self {
17241        push_header(self.as_rec_mut(), 8u16, 8 as u16);
17242        self.as_rec_mut().extend(value.to_ne_bytes());
17243        self
17244    }
17245}
17246impl<Prev: Rec> Drop for PushVfStatsAttrs<Prev> {
17247    fn drop(&mut self) {
17248        if let Some(prev) = &mut self.prev {
17249            if let Some(header_offset) = &self.header_offset {
17250                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17251            }
17252        }
17253    }
17254}
17255pub struct PushVfVlanAttrs<Prev: Rec> {
17256    pub(crate) prev: Option<Prev>,
17257    pub(crate) header_offset: Option<usize>,
17258}
17259impl<Prev: Rec> Rec for PushVfVlanAttrs<Prev> {
17260    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17261        self.prev.as_mut().unwrap().as_rec_mut()
17262    }
17263    fn as_rec(&self) -> &Vec<u8> {
17264        self.prev.as_ref().unwrap().as_rec()
17265    }
17266}
17267impl<Prev: Rec> PushVfVlanAttrs<Prev> {
17268    pub fn new(prev: Prev) -> Self {
17269        Self {
17270            prev: Some(prev),
17271            header_offset: None,
17272        }
17273    }
17274    pub fn end_nested(mut self) -> Prev {
17275        let mut prev = self.prev.take().unwrap();
17276        if let Some(header_offset) = &self.header_offset {
17277            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17278        }
17279        prev
17280    }
17281    #[doc = "Attribute may repeat multiple times (treat it as array)"]
17282    pub fn push_info(mut self, value: PushIflaVfVlanInfo) -> Self {
17283        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
17284        self.as_rec_mut().extend(value.as_slice());
17285        self
17286    }
17287}
17288impl<Prev: Rec> Drop for PushVfVlanAttrs<Prev> {
17289    fn drop(&mut self) {
17290        if let Some(prev) = &mut self.prev {
17291            if let Some(header_offset) = &self.header_offset {
17292                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17293            }
17294        }
17295    }
17296}
17297pub struct PushVfPortsAttrs<Prev: Rec> {
17298    pub(crate) prev: Option<Prev>,
17299    pub(crate) header_offset: Option<usize>,
17300}
17301impl<Prev: Rec> Rec for PushVfPortsAttrs<Prev> {
17302    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17303        self.prev.as_mut().unwrap().as_rec_mut()
17304    }
17305    fn as_rec(&self) -> &Vec<u8> {
17306        self.prev.as_ref().unwrap().as_rec()
17307    }
17308}
17309impl<Prev: Rec> PushVfPortsAttrs<Prev> {
17310    pub fn new(prev: Prev) -> Self {
17311        Self {
17312            prev: Some(prev),
17313            header_offset: None,
17314        }
17315    }
17316    pub fn end_nested(mut self) -> Prev {
17317        let mut prev = self.prev.take().unwrap();
17318        if let Some(header_offset) = &self.header_offset {
17319            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17320        }
17321        prev
17322    }
17323}
17324impl<Prev: Rec> Drop for PushVfPortsAttrs<Prev> {
17325    fn drop(&mut self) {
17326        if let Some(prev) = &mut self.prev {
17327            if let Some(header_offset) = &self.header_offset {
17328                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17329            }
17330        }
17331    }
17332}
17333pub struct PushPortSelfAttrs<Prev: Rec> {
17334    pub(crate) prev: Option<Prev>,
17335    pub(crate) header_offset: Option<usize>,
17336}
17337impl<Prev: Rec> Rec for PushPortSelfAttrs<Prev> {
17338    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17339        self.prev.as_mut().unwrap().as_rec_mut()
17340    }
17341    fn as_rec(&self) -> &Vec<u8> {
17342        self.prev.as_ref().unwrap().as_rec()
17343    }
17344}
17345impl<Prev: Rec> PushPortSelfAttrs<Prev> {
17346    pub fn new(prev: Prev) -> Self {
17347        Self {
17348            prev: Some(prev),
17349            header_offset: None,
17350        }
17351    }
17352    pub fn end_nested(mut self) -> Prev {
17353        let mut prev = self.prev.take().unwrap();
17354        if let Some(header_offset) = &self.header_offset {
17355            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17356        }
17357        prev
17358    }
17359}
17360impl<Prev: Rec> Drop for PushPortSelfAttrs<Prev> {
17361    fn drop(&mut self) {
17362        if let Some(prev) = &mut self.prev {
17363            if let Some(header_offset) = &self.header_offset {
17364                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17365            }
17366        }
17367    }
17368}
17369pub struct PushLinkinfoAttrs<Prev: Rec> {
17370    pub(crate) prev: Option<Prev>,
17371    pub(crate) header_offset: Option<usize>,
17372}
17373impl<Prev: Rec> Rec for PushLinkinfoAttrs<Prev> {
17374    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17375        self.prev.as_mut().unwrap().as_rec_mut()
17376    }
17377    fn as_rec(&self) -> &Vec<u8> {
17378        self.prev.as_ref().unwrap().as_rec()
17379    }
17380}
17381impl<Prev: Rec> PushLinkinfoAttrs<Prev> {
17382    pub fn new(prev: Prev) -> Self {
17383        Self {
17384            prev: Some(prev),
17385            header_offset: None,
17386        }
17387    }
17388    pub fn end_nested(mut self) -> Prev {
17389        let mut prev = self.prev.take().unwrap();
17390        if let Some(header_offset) = &self.header_offset {
17391            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17392        }
17393        prev
17394    }
17395    pub fn push_kind(mut self, value: &CStr) -> Self {
17396        push_header(
17397            self.as_rec_mut(),
17398            1u16,
17399            value.to_bytes_with_nul().len() as u16,
17400        );
17401        self.as_rec_mut().extend(value.to_bytes_with_nul());
17402        self
17403    }
17404    pub fn push_kind_bytes(mut self, value: &[u8]) -> Self {
17405        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
17406        self.as_rec_mut().extend(value);
17407        self.as_rec_mut().push(0);
17408        self
17409    }
17410    #[doc = "Selector attribute is inserted automatically."]
17411    #[doc = "At most one sub-message attribute is expected per attribute set."]
17412    pub fn nested_data_bond(mut self) -> PushLinkinfoBondAttrs<PushDummy<Prev>> {
17413        self = self.push_kind(c"bond");
17414        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17415        let dummy = PushDummy {
17416            prev: self.prev.take(),
17417            header_offset: self.header_offset.take(),
17418        };
17419        PushLinkinfoBondAttrs {
17420            prev: Some(dummy),
17421            header_offset: Some(new_header_offset),
17422        }
17423    }
17424    #[doc = "Selector attribute is inserted automatically."]
17425    #[doc = "At most one sub-message attribute is expected per attribute set."]
17426    pub fn nested_data_bridge(mut self) -> PushLinkinfoBridgeAttrs<PushDummy<Prev>> {
17427        self = self.push_kind(c"bridge");
17428        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17429        let dummy = PushDummy {
17430            prev: self.prev.take(),
17431            header_offset: self.header_offset.take(),
17432        };
17433        PushLinkinfoBridgeAttrs {
17434            prev: Some(dummy),
17435            header_offset: Some(new_header_offset),
17436        }
17437    }
17438    #[doc = "Selector attribute is inserted automatically."]
17439    #[doc = "At most one sub-message attribute is expected per attribute set."]
17440    pub fn nested_data_erspan(mut self) -> PushLinkinfoGreAttrs<PushDummy<Prev>> {
17441        self = self.push_kind(c"erspan");
17442        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17443        let dummy = PushDummy {
17444            prev: self.prev.take(),
17445            header_offset: self.header_offset.take(),
17446        };
17447        PushLinkinfoGreAttrs {
17448            prev: Some(dummy),
17449            header_offset: Some(new_header_offset),
17450        }
17451    }
17452    #[doc = "Selector attribute is inserted automatically."]
17453    #[doc = "At most one sub-message attribute is expected per attribute set."]
17454    pub fn nested_data_gre(mut self) -> PushLinkinfoGreAttrs<PushDummy<Prev>> {
17455        self = self.push_kind(c"gre");
17456        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17457        let dummy = PushDummy {
17458            prev: self.prev.take(),
17459            header_offset: self.header_offset.take(),
17460        };
17461        PushLinkinfoGreAttrs {
17462            prev: Some(dummy),
17463            header_offset: Some(new_header_offset),
17464        }
17465    }
17466    #[doc = "Selector attribute is inserted automatically."]
17467    #[doc = "At most one sub-message attribute is expected per attribute set."]
17468    pub fn nested_data_gretap(mut self) -> PushLinkinfoGreAttrs<PushDummy<Prev>> {
17469        self = self.push_kind(c"gretap");
17470        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17471        let dummy = PushDummy {
17472            prev: self.prev.take(),
17473            header_offset: self.header_offset.take(),
17474        };
17475        PushLinkinfoGreAttrs {
17476            prev: Some(dummy),
17477            header_offset: Some(new_header_offset),
17478        }
17479    }
17480    #[doc = "Selector attribute is inserted automatically."]
17481    #[doc = "At most one sub-message attribute is expected per attribute set."]
17482    pub fn nested_data_ip6gre(mut self) -> PushLinkinfoGre6Attrs<PushDummy<Prev>> {
17483        self = self.push_kind(c"ip6gre");
17484        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17485        let dummy = PushDummy {
17486            prev: self.prev.take(),
17487            header_offset: self.header_offset.take(),
17488        };
17489        PushLinkinfoGre6Attrs {
17490            prev: Some(dummy),
17491            header_offset: Some(new_header_offset),
17492        }
17493    }
17494    #[doc = "Selector attribute is inserted automatically."]
17495    #[doc = "At most one sub-message attribute is expected per attribute set."]
17496    pub fn nested_data_geneve(mut self) -> PushLinkinfoGeneveAttrs<PushDummy<Prev>> {
17497        self = self.push_kind(c"geneve");
17498        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17499        let dummy = PushDummy {
17500            prev: self.prev.take(),
17501            header_offset: self.header_offset.take(),
17502        };
17503        PushLinkinfoGeneveAttrs {
17504            prev: Some(dummy),
17505            header_offset: Some(new_header_offset),
17506        }
17507    }
17508    #[doc = "Selector attribute is inserted automatically."]
17509    #[doc = "At most one sub-message attribute is expected per attribute set."]
17510    pub fn nested_data_ipip(mut self) -> PushLinkinfoIptunAttrs<PushDummy<Prev>> {
17511        self = self.push_kind(c"ipip");
17512        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17513        let dummy = PushDummy {
17514            prev: self.prev.take(),
17515            header_offset: self.header_offset.take(),
17516        };
17517        PushLinkinfoIptunAttrs {
17518            prev: Some(dummy),
17519            header_offset: Some(new_header_offset),
17520        }
17521    }
17522    #[doc = "Selector attribute is inserted automatically."]
17523    #[doc = "At most one sub-message attribute is expected per attribute set."]
17524    pub fn nested_data_ip6tnl(mut self) -> PushLinkinfoIp6tnlAttrs<PushDummy<Prev>> {
17525        self = self.push_kind(c"ip6tnl");
17526        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17527        let dummy = PushDummy {
17528            prev: self.prev.take(),
17529            header_offset: self.header_offset.take(),
17530        };
17531        PushLinkinfoIp6tnlAttrs {
17532            prev: Some(dummy),
17533            header_offset: Some(new_header_offset),
17534        }
17535    }
17536    #[doc = "Selector attribute is inserted automatically."]
17537    #[doc = "At most one sub-message attribute is expected per attribute set."]
17538    pub fn nested_data_sit(mut self) -> PushLinkinfoIptunAttrs<PushDummy<Prev>> {
17539        self = self.push_kind(c"sit");
17540        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17541        let dummy = PushDummy {
17542            prev: self.prev.take(),
17543            header_offset: self.header_offset.take(),
17544        };
17545        PushLinkinfoIptunAttrs {
17546            prev: Some(dummy),
17547            header_offset: Some(new_header_offset),
17548        }
17549    }
17550    #[doc = "Selector attribute is inserted automatically."]
17551    #[doc = "At most one sub-message attribute is expected per attribute set."]
17552    pub fn nested_data_tun(mut self) -> PushLinkinfoTunAttrs<PushDummy<Prev>> {
17553        self = self.push_kind(c"tun");
17554        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17555        let dummy = PushDummy {
17556            prev: self.prev.take(),
17557            header_offset: self.header_offset.take(),
17558        };
17559        PushLinkinfoTunAttrs {
17560            prev: Some(dummy),
17561            header_offset: Some(new_header_offset),
17562        }
17563    }
17564    #[doc = "Selector attribute is inserted automatically."]
17565    #[doc = "At most one sub-message attribute is expected per attribute set."]
17566    pub fn nested_data_vlan(mut self) -> PushLinkinfoVlanAttrs<PushDummy<Prev>> {
17567        self = self.push_kind(c"vlan");
17568        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17569        let dummy = PushDummy {
17570            prev: self.prev.take(),
17571            header_offset: self.header_offset.take(),
17572        };
17573        PushLinkinfoVlanAttrs {
17574            prev: Some(dummy),
17575            header_offset: Some(new_header_offset),
17576        }
17577    }
17578    #[doc = "Selector attribute is inserted automatically."]
17579    #[doc = "At most one sub-message attribute is expected per attribute set."]
17580    pub fn nested_data_vrf(mut self) -> PushLinkinfoVrfAttrs<PushDummy<Prev>> {
17581        self = self.push_kind(c"vrf");
17582        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17583        let dummy = PushDummy {
17584            prev: self.prev.take(),
17585            header_offset: self.header_offset.take(),
17586        };
17587        PushLinkinfoVrfAttrs {
17588            prev: Some(dummy),
17589            header_offset: Some(new_header_offset),
17590        }
17591    }
17592    #[doc = "Selector attribute is inserted automatically."]
17593    #[doc = "At most one sub-message attribute is expected per attribute set."]
17594    pub fn nested_data_vti(mut self) -> PushLinkinfoVtiAttrs<PushDummy<Prev>> {
17595        self = self.push_kind(c"vti");
17596        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17597        let dummy = PushDummy {
17598            prev: self.prev.take(),
17599            header_offset: self.header_offset.take(),
17600        };
17601        PushLinkinfoVtiAttrs {
17602            prev: Some(dummy),
17603            header_offset: Some(new_header_offset),
17604        }
17605    }
17606    #[doc = "Selector attribute is inserted automatically."]
17607    #[doc = "At most one sub-message attribute is expected per attribute set."]
17608    pub fn nested_data_vti6(mut self) -> PushLinkinfoVti6Attrs<PushDummy<Prev>> {
17609        self = self.push_kind(c"vti6");
17610        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17611        let dummy = PushDummy {
17612            prev: self.prev.take(),
17613            header_offset: self.header_offset.take(),
17614        };
17615        PushLinkinfoVti6Attrs {
17616            prev: Some(dummy),
17617            header_offset: Some(new_header_offset),
17618        }
17619    }
17620    #[doc = "Selector attribute is inserted automatically."]
17621    #[doc = "At most one sub-message attribute is expected per attribute set."]
17622    pub fn nested_data_netkit(mut self) -> PushLinkinfoNetkitAttrs<PushDummy<Prev>> {
17623        self = self.push_kind(c"netkit");
17624        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17625        let dummy = PushDummy {
17626            prev: self.prev.take(),
17627            header_offset: self.header_offset.take(),
17628        };
17629        PushLinkinfoNetkitAttrs {
17630            prev: Some(dummy),
17631            header_offset: Some(new_header_offset),
17632        }
17633    }
17634    #[doc = "Selector attribute is inserted automatically."]
17635    #[doc = "At most one sub-message attribute is expected per attribute set."]
17636    pub fn nested_data_ovpn(mut self) -> PushLinkinfoOvpnAttrs<PushDummy<Prev>> {
17637        self = self.push_kind(c"ovpn");
17638        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17639        let dummy = PushDummy {
17640            prev: self.prev.take(),
17641            header_offset: self.header_offset.take(),
17642        };
17643        PushLinkinfoOvpnAttrs {
17644            prev: Some(dummy),
17645            header_offset: Some(new_header_offset),
17646        }
17647    }
17648    pub fn push_xstats(mut self, value: &[u8]) -> Self {
17649        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
17650        self.as_rec_mut().extend(value);
17651        self
17652    }
17653    pub fn push_slave_kind(mut self, value: &CStr) -> Self {
17654        push_header(
17655            self.as_rec_mut(),
17656            4u16,
17657            value.to_bytes_with_nul().len() as u16,
17658        );
17659        self.as_rec_mut().extend(value.to_bytes_with_nul());
17660        self
17661    }
17662    pub fn push_slave_kind_bytes(mut self, value: &[u8]) -> Self {
17663        push_header(self.as_rec_mut(), 4u16, (value.len() + 1) as u16);
17664        self.as_rec_mut().extend(value);
17665        self.as_rec_mut().push(0);
17666        self
17667    }
17668    #[doc = "Selector attribute is inserted automatically."]
17669    #[doc = "At most one sub-message attribute is expected per attribute set."]
17670    pub fn nested_slave_data_bridge(mut self) -> PushLinkinfoBrportAttrs<PushDummy<Prev>> {
17671        self = self.push_slave_kind(c"bridge");
17672        let new_header_offset = push_nested_header(self.as_rec_mut(), 5u16);
17673        let dummy = PushDummy {
17674            prev: self.prev.take(),
17675            header_offset: self.header_offset.take(),
17676        };
17677        PushLinkinfoBrportAttrs {
17678            prev: Some(dummy),
17679            header_offset: Some(new_header_offset),
17680        }
17681    }
17682    #[doc = "Selector attribute is inserted automatically."]
17683    #[doc = "At most one sub-message attribute is expected per attribute set."]
17684    pub fn nested_slave_data_bond(mut self) -> PushBondSlaveAttrs<PushDummy<Prev>> {
17685        self = self.push_slave_kind(c"bond");
17686        let new_header_offset = push_nested_header(self.as_rec_mut(), 5u16);
17687        let dummy = PushDummy {
17688            prev: self.prev.take(),
17689            header_offset: self.header_offset.take(),
17690        };
17691        PushBondSlaveAttrs {
17692            prev: Some(dummy),
17693            header_offset: Some(new_header_offset),
17694        }
17695    }
17696}
17697impl<Prev: Rec> Drop for PushLinkinfoAttrs<Prev> {
17698    fn drop(&mut self) {
17699        if let Some(prev) = &mut self.prev {
17700            if let Some(header_offset) = &self.header_offset {
17701                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17702            }
17703        }
17704    }
17705}
17706pub struct PushLinkinfoBondAttrs<Prev: Rec> {
17707    pub(crate) prev: Option<Prev>,
17708    pub(crate) header_offset: Option<usize>,
17709}
17710impl<Prev: Rec> Rec for PushLinkinfoBondAttrs<Prev> {
17711    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17712        self.prev.as_mut().unwrap().as_rec_mut()
17713    }
17714    fn as_rec(&self) -> &Vec<u8> {
17715        self.prev.as_ref().unwrap().as_rec()
17716    }
17717}
17718pub struct PushArrayU32<Prev: Rec> {
17719    pub(crate) prev: Option<Prev>,
17720    pub(crate) header_offset: Option<usize>,
17721    pub(crate) counter: u16,
17722}
17723impl<Prev: Rec> Rec for PushArrayU32<Prev> {
17724    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17725        self.prev.as_mut().unwrap().as_rec_mut()
17726    }
17727    fn as_rec(&self) -> &Vec<u8> {
17728        self.prev.as_ref().unwrap().as_rec()
17729    }
17730}
17731impl<Prev: Rec> PushArrayU32<Prev> {
17732    pub fn new(prev: Prev) -> Self {
17733        Self {
17734            prev: Some(prev),
17735            header_offset: None,
17736            counter: 0,
17737        }
17738    }
17739    pub fn end_array(mut self) -> Prev {
17740        let mut prev = self.prev.take().unwrap();
17741        if let Some(header_offset) = &self.header_offset {
17742            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17743        }
17744        prev
17745    }
17746    pub fn entry(mut self, value: std::net::Ipv4Addr) -> Self {
17747        let index = self.counter;
17748        self.counter += 1;
17749        push_header(self.as_rec_mut(), index, 4 as u16);
17750        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
17751        self
17752    }
17753}
17754impl<Prev: Rec> Drop for PushArrayU32<Prev> {
17755    fn drop(&mut self) {
17756        if let Some(prev) = &mut self.prev {
17757            if let Some(header_offset) = &self.header_offset {
17758                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17759            }
17760        }
17761    }
17762}
17763pub struct PushArrayBinary<Prev: Rec> {
17764    pub(crate) prev: Option<Prev>,
17765    pub(crate) header_offset: Option<usize>,
17766    pub(crate) counter: u16,
17767}
17768impl<Prev: Rec> Rec for PushArrayBinary<Prev> {
17769    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17770        self.prev.as_mut().unwrap().as_rec_mut()
17771    }
17772    fn as_rec(&self) -> &Vec<u8> {
17773        self.prev.as_ref().unwrap().as_rec()
17774    }
17775}
17776impl<Prev: Rec> PushArrayBinary<Prev> {
17777    pub fn new(prev: Prev) -> Self {
17778        Self {
17779            prev: Some(prev),
17780            header_offset: None,
17781            counter: 0,
17782        }
17783    }
17784    pub fn end_array(mut self) -> Prev {
17785        let mut prev = self.prev.take().unwrap();
17786        if let Some(header_offset) = &self.header_offset {
17787            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17788        }
17789        prev
17790    }
17791    pub fn entry(mut self, value: &[u8]) -> Self {
17792        let index = self.counter;
17793        self.counter += 1;
17794        push_header(self.as_rec_mut(), index, value.len() as u16);
17795        self.as_rec_mut().extend(value);
17796        self
17797    }
17798}
17799impl<Prev: Rec> Drop for PushArrayBinary<Prev> {
17800    fn drop(&mut self) {
17801        if let Some(prev) = &mut self.prev {
17802            if let Some(header_offset) = &self.header_offset {
17803                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17804            }
17805        }
17806    }
17807}
17808impl<Prev: Rec> PushLinkinfoBondAttrs<Prev> {
17809    pub fn new(prev: Prev) -> Self {
17810        Self {
17811            prev: Some(prev),
17812            header_offset: None,
17813        }
17814    }
17815    pub fn end_nested(mut self) -> Prev {
17816        let mut prev = self.prev.take().unwrap();
17817        if let Some(header_offset) = &self.header_offset {
17818            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17819        }
17820        prev
17821    }
17822    pub fn push_mode(mut self, value: u8) -> Self {
17823        push_header(self.as_rec_mut(), 1u16, 1 as u16);
17824        self.as_rec_mut().extend(value.to_ne_bytes());
17825        self
17826    }
17827    pub fn push_active_slave(mut self, value: u32) -> Self {
17828        push_header(self.as_rec_mut(), 2u16, 4 as u16);
17829        self.as_rec_mut().extend(value.to_ne_bytes());
17830        self
17831    }
17832    pub fn push_miimon(mut self, value: u32) -> Self {
17833        push_header(self.as_rec_mut(), 3u16, 4 as u16);
17834        self.as_rec_mut().extend(value.to_ne_bytes());
17835        self
17836    }
17837    pub fn push_updelay(mut self, value: u32) -> Self {
17838        push_header(self.as_rec_mut(), 4u16, 4 as u16);
17839        self.as_rec_mut().extend(value.to_ne_bytes());
17840        self
17841    }
17842    pub fn push_downdelay(mut self, value: u32) -> Self {
17843        push_header(self.as_rec_mut(), 5u16, 4 as u16);
17844        self.as_rec_mut().extend(value.to_ne_bytes());
17845        self
17846    }
17847    pub fn push_use_carrier(mut self, value: u8) -> Self {
17848        push_header(self.as_rec_mut(), 6u16, 1 as u16);
17849        self.as_rec_mut().extend(value.to_ne_bytes());
17850        self
17851    }
17852    pub fn push_arp_interval(mut self, value: u32) -> Self {
17853        push_header(self.as_rec_mut(), 7u16, 4 as u16);
17854        self.as_rec_mut().extend(value.to_ne_bytes());
17855        self
17856    }
17857    pub fn array_arp_ip_target(mut self) -> PushArrayU32<Self> {
17858        let header_offset = push_nested_header(self.as_rec_mut(), 8u16);
17859        PushArrayU32 {
17860            prev: Some(self),
17861            header_offset: Some(header_offset),
17862            counter: 0,
17863        }
17864    }
17865    pub fn push_arp_validate(mut self, value: u32) -> Self {
17866        push_header(self.as_rec_mut(), 9u16, 4 as u16);
17867        self.as_rec_mut().extend(value.to_ne_bytes());
17868        self
17869    }
17870    pub fn push_arp_all_targets(mut self, value: u32) -> Self {
17871        push_header(self.as_rec_mut(), 10u16, 4 as u16);
17872        self.as_rec_mut().extend(value.to_ne_bytes());
17873        self
17874    }
17875    pub fn push_primary(mut self, value: u32) -> Self {
17876        push_header(self.as_rec_mut(), 11u16, 4 as u16);
17877        self.as_rec_mut().extend(value.to_ne_bytes());
17878        self
17879    }
17880    pub fn push_primary_reselect(mut self, value: u8) -> Self {
17881        push_header(self.as_rec_mut(), 12u16, 1 as u16);
17882        self.as_rec_mut().extend(value.to_ne_bytes());
17883        self
17884    }
17885    pub fn push_fail_over_mac(mut self, value: u8) -> Self {
17886        push_header(self.as_rec_mut(), 13u16, 1 as u16);
17887        self.as_rec_mut().extend(value.to_ne_bytes());
17888        self
17889    }
17890    pub fn push_xmit_hash_policy(mut self, value: u8) -> Self {
17891        push_header(self.as_rec_mut(), 14u16, 1 as u16);
17892        self.as_rec_mut().extend(value.to_ne_bytes());
17893        self
17894    }
17895    pub fn push_resend_igmp(mut self, value: u32) -> Self {
17896        push_header(self.as_rec_mut(), 15u16, 4 as u16);
17897        self.as_rec_mut().extend(value.to_ne_bytes());
17898        self
17899    }
17900    pub fn push_num_peer_notif(mut self, value: u8) -> Self {
17901        push_header(self.as_rec_mut(), 16u16, 1 as u16);
17902        self.as_rec_mut().extend(value.to_ne_bytes());
17903        self
17904    }
17905    pub fn push_all_slaves_active(mut self, value: u8) -> Self {
17906        push_header(self.as_rec_mut(), 17u16, 1 as u16);
17907        self.as_rec_mut().extend(value.to_ne_bytes());
17908        self
17909    }
17910    pub fn push_min_links(mut self, value: u32) -> Self {
17911        push_header(self.as_rec_mut(), 18u16, 4 as u16);
17912        self.as_rec_mut().extend(value.to_ne_bytes());
17913        self
17914    }
17915    pub fn push_lp_interval(mut self, value: u32) -> Self {
17916        push_header(self.as_rec_mut(), 19u16, 4 as u16);
17917        self.as_rec_mut().extend(value.to_ne_bytes());
17918        self
17919    }
17920    pub fn push_packets_per_slave(mut self, value: u32) -> Self {
17921        push_header(self.as_rec_mut(), 20u16, 4 as u16);
17922        self.as_rec_mut().extend(value.to_ne_bytes());
17923        self
17924    }
17925    pub fn push_ad_lacp_rate(mut self, value: u8) -> Self {
17926        push_header(self.as_rec_mut(), 21u16, 1 as u16);
17927        self.as_rec_mut().extend(value.to_ne_bytes());
17928        self
17929    }
17930    pub fn push_ad_select(mut self, value: u8) -> Self {
17931        push_header(self.as_rec_mut(), 22u16, 1 as u16);
17932        self.as_rec_mut().extend(value.to_ne_bytes());
17933        self
17934    }
17935    pub fn nested_ad_info(mut self) -> PushBondAdInfoAttrs<Self> {
17936        let header_offset = push_nested_header(self.as_rec_mut(), 23u16);
17937        PushBondAdInfoAttrs {
17938            prev: Some(self),
17939            header_offset: Some(header_offset),
17940        }
17941    }
17942    pub fn push_ad_actor_sys_prio(mut self, value: u16) -> Self {
17943        push_header(self.as_rec_mut(), 24u16, 2 as u16);
17944        self.as_rec_mut().extend(value.to_ne_bytes());
17945        self
17946    }
17947    pub fn push_ad_user_port_key(mut self, value: u16) -> Self {
17948        push_header(self.as_rec_mut(), 25u16, 2 as u16);
17949        self.as_rec_mut().extend(value.to_ne_bytes());
17950        self
17951    }
17952    pub fn push_ad_actor_system(mut self, value: &[u8]) -> Self {
17953        push_header(self.as_rec_mut(), 26u16, value.len() as u16);
17954        self.as_rec_mut().extend(value);
17955        self
17956    }
17957    pub fn push_tlb_dynamic_lb(mut self, value: u8) -> Self {
17958        push_header(self.as_rec_mut(), 27u16, 1 as u16);
17959        self.as_rec_mut().extend(value.to_ne_bytes());
17960        self
17961    }
17962    pub fn push_peer_notif_delay(mut self, value: u32) -> Self {
17963        push_header(self.as_rec_mut(), 28u16, 4 as u16);
17964        self.as_rec_mut().extend(value.to_ne_bytes());
17965        self
17966    }
17967    pub fn push_ad_lacp_active(mut self, value: u8) -> Self {
17968        push_header(self.as_rec_mut(), 29u16, 1 as u16);
17969        self.as_rec_mut().extend(value.to_ne_bytes());
17970        self
17971    }
17972    pub fn push_missed_max(mut self, value: u8) -> Self {
17973        push_header(self.as_rec_mut(), 30u16, 1 as u16);
17974        self.as_rec_mut().extend(value.to_ne_bytes());
17975        self
17976    }
17977    pub fn array_ns_ip6_target(mut self) -> PushArrayBinary<Self> {
17978        let header_offset = push_nested_header(self.as_rec_mut(), 31u16);
17979        PushArrayBinary {
17980            prev: Some(self),
17981            header_offset: Some(header_offset),
17982            counter: 0,
17983        }
17984    }
17985    pub fn push_coupled_control(mut self, value: u8) -> Self {
17986        push_header(self.as_rec_mut(), 32u16, 1 as u16);
17987        self.as_rec_mut().extend(value.to_ne_bytes());
17988        self
17989    }
17990}
17991impl<Prev: Rec> Drop for PushLinkinfoBondAttrs<Prev> {
17992    fn drop(&mut self) {
17993        if let Some(prev) = &mut self.prev {
17994            if let Some(header_offset) = &self.header_offset {
17995                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17996            }
17997        }
17998    }
17999}
18000pub struct PushBondAdInfoAttrs<Prev: Rec> {
18001    pub(crate) prev: Option<Prev>,
18002    pub(crate) header_offset: Option<usize>,
18003}
18004impl<Prev: Rec> Rec for PushBondAdInfoAttrs<Prev> {
18005    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18006        self.prev.as_mut().unwrap().as_rec_mut()
18007    }
18008    fn as_rec(&self) -> &Vec<u8> {
18009        self.prev.as_ref().unwrap().as_rec()
18010    }
18011}
18012impl<Prev: Rec> PushBondAdInfoAttrs<Prev> {
18013    pub fn new(prev: Prev) -> Self {
18014        Self {
18015            prev: Some(prev),
18016            header_offset: None,
18017        }
18018    }
18019    pub fn end_nested(mut self) -> Prev {
18020        let mut prev = self.prev.take().unwrap();
18021        if let Some(header_offset) = &self.header_offset {
18022            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18023        }
18024        prev
18025    }
18026    pub fn push_aggregator(mut self, value: u16) -> Self {
18027        push_header(self.as_rec_mut(), 1u16, 2 as u16);
18028        self.as_rec_mut().extend(value.to_ne_bytes());
18029        self
18030    }
18031    pub fn push_num_ports(mut self, value: u16) -> Self {
18032        push_header(self.as_rec_mut(), 2u16, 2 as u16);
18033        self.as_rec_mut().extend(value.to_ne_bytes());
18034        self
18035    }
18036    pub fn push_actor_key(mut self, value: u16) -> Self {
18037        push_header(self.as_rec_mut(), 3u16, 2 as u16);
18038        self.as_rec_mut().extend(value.to_ne_bytes());
18039        self
18040    }
18041    pub fn push_partner_key(mut self, value: u16) -> Self {
18042        push_header(self.as_rec_mut(), 4u16, 2 as u16);
18043        self.as_rec_mut().extend(value.to_ne_bytes());
18044        self
18045    }
18046    pub fn push_partner_mac(mut self, value: &[u8]) -> Self {
18047        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
18048        self.as_rec_mut().extend(value);
18049        self
18050    }
18051}
18052impl<Prev: Rec> Drop for PushBondAdInfoAttrs<Prev> {
18053    fn drop(&mut self) {
18054        if let Some(prev) = &mut self.prev {
18055            if let Some(header_offset) = &self.header_offset {
18056                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18057            }
18058        }
18059    }
18060}
18061pub struct PushBondSlaveAttrs<Prev: Rec> {
18062    pub(crate) prev: Option<Prev>,
18063    pub(crate) header_offset: Option<usize>,
18064}
18065impl<Prev: Rec> Rec for PushBondSlaveAttrs<Prev> {
18066    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18067        self.prev.as_mut().unwrap().as_rec_mut()
18068    }
18069    fn as_rec(&self) -> &Vec<u8> {
18070        self.prev.as_ref().unwrap().as_rec()
18071    }
18072}
18073impl<Prev: Rec> PushBondSlaveAttrs<Prev> {
18074    pub fn new(prev: Prev) -> Self {
18075        Self {
18076            prev: Some(prev),
18077            header_offset: None,
18078        }
18079    }
18080    pub fn end_nested(mut self) -> Prev {
18081        let mut prev = self.prev.take().unwrap();
18082        if let Some(header_offset) = &self.header_offset {
18083            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18084        }
18085        prev
18086    }
18087    pub fn push_state(mut self, value: u8) -> Self {
18088        push_header(self.as_rec_mut(), 1u16, 1 as u16);
18089        self.as_rec_mut().extend(value.to_ne_bytes());
18090        self
18091    }
18092    pub fn push_mii_status(mut self, value: u8) -> Self {
18093        push_header(self.as_rec_mut(), 2u16, 1 as u16);
18094        self.as_rec_mut().extend(value.to_ne_bytes());
18095        self
18096    }
18097    pub fn push_link_failure_count(mut self, value: u32) -> Self {
18098        push_header(self.as_rec_mut(), 3u16, 4 as u16);
18099        self.as_rec_mut().extend(value.to_ne_bytes());
18100        self
18101    }
18102    pub fn push_perm_hwaddr(mut self, value: &[u8]) -> Self {
18103        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
18104        self.as_rec_mut().extend(value);
18105        self
18106    }
18107    pub fn push_queue_id(mut self, value: u16) -> Self {
18108        push_header(self.as_rec_mut(), 5u16, 2 as u16);
18109        self.as_rec_mut().extend(value.to_ne_bytes());
18110        self
18111    }
18112    pub fn push_ad_aggregator_id(mut self, value: u16) -> Self {
18113        push_header(self.as_rec_mut(), 6u16, 2 as u16);
18114        self.as_rec_mut().extend(value.to_ne_bytes());
18115        self
18116    }
18117    pub fn push_ad_actor_oper_port_state(mut self, value: u8) -> Self {
18118        push_header(self.as_rec_mut(), 7u16, 1 as u16);
18119        self.as_rec_mut().extend(value.to_ne_bytes());
18120        self
18121    }
18122    pub fn push_ad_partner_oper_port_state(mut self, value: u16) -> Self {
18123        push_header(self.as_rec_mut(), 8u16, 2 as u16);
18124        self.as_rec_mut().extend(value.to_ne_bytes());
18125        self
18126    }
18127    pub fn push_prio(mut self, value: u32) -> Self {
18128        push_header(self.as_rec_mut(), 9u16, 4 as u16);
18129        self.as_rec_mut().extend(value.to_ne_bytes());
18130        self
18131    }
18132}
18133impl<Prev: Rec> Drop for PushBondSlaveAttrs<Prev> {
18134    fn drop(&mut self) {
18135        if let Some(prev) = &mut self.prev {
18136            if let Some(header_offset) = &self.header_offset {
18137                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18138            }
18139        }
18140    }
18141}
18142pub struct PushLinkinfoBridgeAttrs<Prev: Rec> {
18143    pub(crate) prev: Option<Prev>,
18144    pub(crate) header_offset: Option<usize>,
18145}
18146impl<Prev: Rec> Rec for PushLinkinfoBridgeAttrs<Prev> {
18147    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18148        self.prev.as_mut().unwrap().as_rec_mut()
18149    }
18150    fn as_rec(&self) -> &Vec<u8> {
18151        self.prev.as_ref().unwrap().as_rec()
18152    }
18153}
18154impl<Prev: Rec> PushLinkinfoBridgeAttrs<Prev> {
18155    pub fn new(prev: Prev) -> Self {
18156        Self {
18157            prev: Some(prev),
18158            header_offset: None,
18159        }
18160    }
18161    pub fn end_nested(mut self) -> Prev {
18162        let mut prev = self.prev.take().unwrap();
18163        if let Some(header_offset) = &self.header_offset {
18164            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18165        }
18166        prev
18167    }
18168    pub fn push_forward_delay(mut self, value: u32) -> Self {
18169        push_header(self.as_rec_mut(), 1u16, 4 as u16);
18170        self.as_rec_mut().extend(value.to_ne_bytes());
18171        self
18172    }
18173    pub fn push_hello_time(mut self, value: u32) -> Self {
18174        push_header(self.as_rec_mut(), 2u16, 4 as u16);
18175        self.as_rec_mut().extend(value.to_ne_bytes());
18176        self
18177    }
18178    pub fn push_max_age(mut self, value: u32) -> Self {
18179        push_header(self.as_rec_mut(), 3u16, 4 as u16);
18180        self.as_rec_mut().extend(value.to_ne_bytes());
18181        self
18182    }
18183    pub fn push_ageing_time(mut self, value: u32) -> Self {
18184        push_header(self.as_rec_mut(), 4u16, 4 as u16);
18185        self.as_rec_mut().extend(value.to_ne_bytes());
18186        self
18187    }
18188    pub fn push_stp_state(mut self, value: u32) -> Self {
18189        push_header(self.as_rec_mut(), 5u16, 4 as u16);
18190        self.as_rec_mut().extend(value.to_ne_bytes());
18191        self
18192    }
18193    pub fn push_priority(mut self, value: u16) -> Self {
18194        push_header(self.as_rec_mut(), 6u16, 2 as u16);
18195        self.as_rec_mut().extend(value.to_ne_bytes());
18196        self
18197    }
18198    pub fn push_vlan_filtering(mut self, value: u8) -> Self {
18199        push_header(self.as_rec_mut(), 7u16, 1 as u16);
18200        self.as_rec_mut().extend(value.to_ne_bytes());
18201        self
18202    }
18203    pub fn push_vlan_protocol(mut self, value: u16) -> Self {
18204        push_header(self.as_rec_mut(), 8u16, 2 as u16);
18205        self.as_rec_mut().extend(value.to_ne_bytes());
18206        self
18207    }
18208    pub fn push_group_fwd_mask(mut self, value: u16) -> Self {
18209        push_header(self.as_rec_mut(), 9u16, 2 as u16);
18210        self.as_rec_mut().extend(value.to_ne_bytes());
18211        self
18212    }
18213    pub fn push_root_id(mut self, value: PushIflaBridgeId) -> Self {
18214        push_header(self.as_rec_mut(), 10u16, value.as_slice().len() as u16);
18215        self.as_rec_mut().extend(value.as_slice());
18216        self
18217    }
18218    pub fn push_bridge_id(mut self, value: PushIflaBridgeId) -> Self {
18219        push_header(self.as_rec_mut(), 11u16, value.as_slice().len() as u16);
18220        self.as_rec_mut().extend(value.as_slice());
18221        self
18222    }
18223    pub fn push_root_port(mut self, value: u16) -> Self {
18224        push_header(self.as_rec_mut(), 12u16, 2 as u16);
18225        self.as_rec_mut().extend(value.to_ne_bytes());
18226        self
18227    }
18228    pub fn push_root_path_cost(mut self, value: u32) -> Self {
18229        push_header(self.as_rec_mut(), 13u16, 4 as u16);
18230        self.as_rec_mut().extend(value.to_ne_bytes());
18231        self
18232    }
18233    pub fn push_topology_change(mut self, value: u8) -> Self {
18234        push_header(self.as_rec_mut(), 14u16, 1 as u16);
18235        self.as_rec_mut().extend(value.to_ne_bytes());
18236        self
18237    }
18238    pub fn push_topology_change_detected(mut self, value: u8) -> Self {
18239        push_header(self.as_rec_mut(), 15u16, 1 as u16);
18240        self.as_rec_mut().extend(value.to_ne_bytes());
18241        self
18242    }
18243    pub fn push_hello_timer(mut self, value: u64) -> Self {
18244        push_header(self.as_rec_mut(), 16u16, 8 as u16);
18245        self.as_rec_mut().extend(value.to_ne_bytes());
18246        self
18247    }
18248    pub fn push_tcn_timer(mut self, value: u64) -> Self {
18249        push_header(self.as_rec_mut(), 17u16, 8 as u16);
18250        self.as_rec_mut().extend(value.to_ne_bytes());
18251        self
18252    }
18253    pub fn push_topology_change_timer(mut self, value: u64) -> Self {
18254        push_header(self.as_rec_mut(), 18u16, 8 as u16);
18255        self.as_rec_mut().extend(value.to_ne_bytes());
18256        self
18257    }
18258    pub fn push_gc_timer(mut self, value: u64) -> Self {
18259        push_header(self.as_rec_mut(), 19u16, 8 as u16);
18260        self.as_rec_mut().extend(value.to_ne_bytes());
18261        self
18262    }
18263    pub fn push_group_addr(mut self, value: &[u8]) -> Self {
18264        push_header(self.as_rec_mut(), 20u16, value.len() as u16);
18265        self.as_rec_mut().extend(value);
18266        self
18267    }
18268    pub fn push_fdb_flush(mut self, value: &[u8]) -> Self {
18269        push_header(self.as_rec_mut(), 21u16, value.len() as u16);
18270        self.as_rec_mut().extend(value);
18271        self
18272    }
18273    pub fn push_mcast_router(mut self, value: u8) -> Self {
18274        push_header(self.as_rec_mut(), 22u16, 1 as u16);
18275        self.as_rec_mut().extend(value.to_ne_bytes());
18276        self
18277    }
18278    pub fn push_mcast_snooping(mut self, value: u8) -> Self {
18279        push_header(self.as_rec_mut(), 23u16, 1 as u16);
18280        self.as_rec_mut().extend(value.to_ne_bytes());
18281        self
18282    }
18283    pub fn push_mcast_query_use_ifaddr(mut self, value: u8) -> Self {
18284        push_header(self.as_rec_mut(), 24u16, 1 as u16);
18285        self.as_rec_mut().extend(value.to_ne_bytes());
18286        self
18287    }
18288    pub fn push_mcast_querier(mut self, value: u8) -> Self {
18289        push_header(self.as_rec_mut(), 25u16, 1 as u16);
18290        self.as_rec_mut().extend(value.to_ne_bytes());
18291        self
18292    }
18293    pub fn push_mcast_hash_elasticity(mut self, value: u32) -> Self {
18294        push_header(self.as_rec_mut(), 26u16, 4 as u16);
18295        self.as_rec_mut().extend(value.to_ne_bytes());
18296        self
18297    }
18298    pub fn push_mcast_hash_max(mut self, value: u32) -> Self {
18299        push_header(self.as_rec_mut(), 27u16, 4 as u16);
18300        self.as_rec_mut().extend(value.to_ne_bytes());
18301        self
18302    }
18303    pub fn push_mcast_last_member_cnt(mut self, value: u32) -> Self {
18304        push_header(self.as_rec_mut(), 28u16, 4 as u16);
18305        self.as_rec_mut().extend(value.to_ne_bytes());
18306        self
18307    }
18308    pub fn push_mcast_startup_query_cnt(mut self, value: u32) -> Self {
18309        push_header(self.as_rec_mut(), 29u16, 4 as u16);
18310        self.as_rec_mut().extend(value.to_ne_bytes());
18311        self
18312    }
18313    pub fn push_mcast_last_member_intvl(mut self, value: u64) -> Self {
18314        push_header(self.as_rec_mut(), 30u16, 8 as u16);
18315        self.as_rec_mut().extend(value.to_ne_bytes());
18316        self
18317    }
18318    pub fn push_mcast_membership_intvl(mut self, value: u64) -> Self {
18319        push_header(self.as_rec_mut(), 31u16, 8 as u16);
18320        self.as_rec_mut().extend(value.to_ne_bytes());
18321        self
18322    }
18323    pub fn push_mcast_querier_intvl(mut self, value: u64) -> Self {
18324        push_header(self.as_rec_mut(), 32u16, 8 as u16);
18325        self.as_rec_mut().extend(value.to_ne_bytes());
18326        self
18327    }
18328    pub fn push_mcast_query_intvl(mut self, value: u64) -> Self {
18329        push_header(self.as_rec_mut(), 33u16, 8 as u16);
18330        self.as_rec_mut().extend(value.to_ne_bytes());
18331        self
18332    }
18333    pub fn push_mcast_query_response_intvl(mut self, value: u64) -> Self {
18334        push_header(self.as_rec_mut(), 34u16, 8 as u16);
18335        self.as_rec_mut().extend(value.to_ne_bytes());
18336        self
18337    }
18338    pub fn push_mcast_startup_query_intvl(mut self, value: u64) -> Self {
18339        push_header(self.as_rec_mut(), 35u16, 8 as u16);
18340        self.as_rec_mut().extend(value.to_ne_bytes());
18341        self
18342    }
18343    pub fn push_nf_call_iptables(mut self, value: u8) -> Self {
18344        push_header(self.as_rec_mut(), 36u16, 1 as u16);
18345        self.as_rec_mut().extend(value.to_ne_bytes());
18346        self
18347    }
18348    pub fn push_nf_call_ip6tables(mut self, value: u8) -> Self {
18349        push_header(self.as_rec_mut(), 37u16, 1 as u16);
18350        self.as_rec_mut().extend(value.to_ne_bytes());
18351        self
18352    }
18353    pub fn push_nf_call_arptables(mut self, value: u8) -> Self {
18354        push_header(self.as_rec_mut(), 38u16, 1 as u16);
18355        self.as_rec_mut().extend(value.to_ne_bytes());
18356        self
18357    }
18358    pub fn push_vlan_default_pvid(mut self, value: u16) -> Self {
18359        push_header(self.as_rec_mut(), 39u16, 2 as u16);
18360        self.as_rec_mut().extend(value.to_ne_bytes());
18361        self
18362    }
18363    pub fn push_pad(mut self, value: &[u8]) -> Self {
18364        push_header(self.as_rec_mut(), 40u16, value.len() as u16);
18365        self.as_rec_mut().extend(value);
18366        self
18367    }
18368    pub fn push_vlan_stats_enabled(mut self, value: u8) -> Self {
18369        push_header(self.as_rec_mut(), 41u16, 1 as u16);
18370        self.as_rec_mut().extend(value.to_ne_bytes());
18371        self
18372    }
18373    pub fn push_mcast_stats_enabled(mut self, value: u8) -> Self {
18374        push_header(self.as_rec_mut(), 42u16, 1 as u16);
18375        self.as_rec_mut().extend(value.to_ne_bytes());
18376        self
18377    }
18378    pub fn push_mcast_igmp_version(mut self, value: u8) -> Self {
18379        push_header(self.as_rec_mut(), 43u16, 1 as u16);
18380        self.as_rec_mut().extend(value.to_ne_bytes());
18381        self
18382    }
18383    pub fn push_mcast_mld_version(mut self, value: u8) -> Self {
18384        push_header(self.as_rec_mut(), 44u16, 1 as u16);
18385        self.as_rec_mut().extend(value.to_ne_bytes());
18386        self
18387    }
18388    pub fn push_vlan_stats_per_port(mut self, value: u8) -> Self {
18389        push_header(self.as_rec_mut(), 45u16, 1 as u16);
18390        self.as_rec_mut().extend(value.to_ne_bytes());
18391        self
18392    }
18393    pub fn push_multi_boolopt(mut self, value: PushBrBooloptMulti) -> Self {
18394        push_header(self.as_rec_mut(), 46u16, value.as_slice().len() as u16);
18395        self.as_rec_mut().extend(value.as_slice());
18396        self
18397    }
18398    pub fn push_mcast_querier_state(mut self, value: &[u8]) -> Self {
18399        push_header(self.as_rec_mut(), 47u16, value.len() as u16);
18400        self.as_rec_mut().extend(value);
18401        self
18402    }
18403    pub fn push_fdb_n_learned(mut self, value: u32) -> Self {
18404        push_header(self.as_rec_mut(), 48u16, 4 as u16);
18405        self.as_rec_mut().extend(value.to_ne_bytes());
18406        self
18407    }
18408    pub fn push_fdb_max_learned(mut self, value: u32) -> Self {
18409        push_header(self.as_rec_mut(), 49u16, 4 as u16);
18410        self.as_rec_mut().extend(value.to_ne_bytes());
18411        self
18412    }
18413}
18414impl<Prev: Rec> Drop for PushLinkinfoBridgeAttrs<Prev> {
18415    fn drop(&mut self) {
18416        if let Some(prev) = &mut self.prev {
18417            if let Some(header_offset) = &self.header_offset {
18418                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18419            }
18420        }
18421    }
18422}
18423pub struct PushLinkinfoBrportAttrs<Prev: Rec> {
18424    pub(crate) prev: Option<Prev>,
18425    pub(crate) header_offset: Option<usize>,
18426}
18427impl<Prev: Rec> Rec for PushLinkinfoBrportAttrs<Prev> {
18428    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18429        self.prev.as_mut().unwrap().as_rec_mut()
18430    }
18431    fn as_rec(&self) -> &Vec<u8> {
18432        self.prev.as_ref().unwrap().as_rec()
18433    }
18434}
18435impl<Prev: Rec> PushLinkinfoBrportAttrs<Prev> {
18436    pub fn new(prev: Prev) -> Self {
18437        Self {
18438            prev: Some(prev),
18439            header_offset: None,
18440        }
18441    }
18442    pub fn end_nested(mut self) -> Prev {
18443        let mut prev = self.prev.take().unwrap();
18444        if let Some(header_offset) = &self.header_offset {
18445            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18446        }
18447        prev
18448    }
18449    pub fn push_state(mut self, value: u8) -> Self {
18450        push_header(self.as_rec_mut(), 1u16, 1 as u16);
18451        self.as_rec_mut().extend(value.to_ne_bytes());
18452        self
18453    }
18454    pub fn push_priority(mut self, value: u16) -> Self {
18455        push_header(self.as_rec_mut(), 2u16, 2 as u16);
18456        self.as_rec_mut().extend(value.to_ne_bytes());
18457        self
18458    }
18459    pub fn push_cost(mut self, value: u32) -> Self {
18460        push_header(self.as_rec_mut(), 3u16, 4 as u16);
18461        self.as_rec_mut().extend(value.to_ne_bytes());
18462        self
18463    }
18464    pub fn push_mode(mut self, value: ()) -> Self {
18465        push_header(self.as_rec_mut(), 4u16, 0 as u16);
18466        self
18467    }
18468    pub fn push_guard(mut self, value: ()) -> Self {
18469        push_header(self.as_rec_mut(), 5u16, 0 as u16);
18470        self
18471    }
18472    pub fn push_protect(mut self, value: ()) -> Self {
18473        push_header(self.as_rec_mut(), 6u16, 0 as u16);
18474        self
18475    }
18476    pub fn push_fast_leave(mut self, value: ()) -> Self {
18477        push_header(self.as_rec_mut(), 7u16, 0 as u16);
18478        self
18479    }
18480    pub fn push_learning(mut self, value: ()) -> Self {
18481        push_header(self.as_rec_mut(), 8u16, 0 as u16);
18482        self
18483    }
18484    pub fn push_unicast_flood(mut self, value: ()) -> Self {
18485        push_header(self.as_rec_mut(), 9u16, 0 as u16);
18486        self
18487    }
18488    pub fn push_proxyarp(mut self, value: ()) -> Self {
18489        push_header(self.as_rec_mut(), 10u16, 0 as u16);
18490        self
18491    }
18492    pub fn push_learning_sync(mut self, value: ()) -> Self {
18493        push_header(self.as_rec_mut(), 11u16, 0 as u16);
18494        self
18495    }
18496    pub fn push_proxyarp_wifi(mut self, value: ()) -> Self {
18497        push_header(self.as_rec_mut(), 12u16, 0 as u16);
18498        self
18499    }
18500    pub fn push_root_id(mut self, value: PushIflaBridgeId) -> Self {
18501        push_header(self.as_rec_mut(), 13u16, value.as_slice().len() as u16);
18502        self.as_rec_mut().extend(value.as_slice());
18503        self
18504    }
18505    pub fn push_bridge_id(mut self, value: PushIflaBridgeId) -> Self {
18506        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
18507        self.as_rec_mut().extend(value.as_slice());
18508        self
18509    }
18510    pub fn push_designated_port(mut self, value: u16) -> Self {
18511        push_header(self.as_rec_mut(), 15u16, 2 as u16);
18512        self.as_rec_mut().extend(value.to_ne_bytes());
18513        self
18514    }
18515    pub fn push_designated_cost(mut self, value: u16) -> Self {
18516        push_header(self.as_rec_mut(), 16u16, 2 as u16);
18517        self.as_rec_mut().extend(value.to_ne_bytes());
18518        self
18519    }
18520    pub fn push_id(mut self, value: u16) -> Self {
18521        push_header(self.as_rec_mut(), 17u16, 2 as u16);
18522        self.as_rec_mut().extend(value.to_ne_bytes());
18523        self
18524    }
18525    pub fn push_no(mut self, value: u16) -> Self {
18526        push_header(self.as_rec_mut(), 18u16, 2 as u16);
18527        self.as_rec_mut().extend(value.to_ne_bytes());
18528        self
18529    }
18530    pub fn push_topology_change_ack(mut self, value: u8) -> Self {
18531        push_header(self.as_rec_mut(), 19u16, 1 as u16);
18532        self.as_rec_mut().extend(value.to_ne_bytes());
18533        self
18534    }
18535    pub fn push_config_pending(mut self, value: u8) -> Self {
18536        push_header(self.as_rec_mut(), 20u16, 1 as u16);
18537        self.as_rec_mut().extend(value.to_ne_bytes());
18538        self
18539    }
18540    pub fn push_message_age_timer(mut self, value: u64) -> Self {
18541        push_header(self.as_rec_mut(), 21u16, 8 as u16);
18542        self.as_rec_mut().extend(value.to_ne_bytes());
18543        self
18544    }
18545    pub fn push_forward_delay_timer(mut self, value: u64) -> Self {
18546        push_header(self.as_rec_mut(), 22u16, 8 as u16);
18547        self.as_rec_mut().extend(value.to_ne_bytes());
18548        self
18549    }
18550    pub fn push_hold_timer(mut self, value: u64) -> Self {
18551        push_header(self.as_rec_mut(), 23u16, 8 as u16);
18552        self.as_rec_mut().extend(value.to_ne_bytes());
18553        self
18554    }
18555    pub fn push_flush(mut self, value: ()) -> Self {
18556        push_header(self.as_rec_mut(), 24u16, 0 as u16);
18557        self
18558    }
18559    pub fn push_multicast_router(mut self, value: u8) -> Self {
18560        push_header(self.as_rec_mut(), 25u16, 1 as u16);
18561        self.as_rec_mut().extend(value.to_ne_bytes());
18562        self
18563    }
18564    pub fn push_pad(mut self, value: &[u8]) -> Self {
18565        push_header(self.as_rec_mut(), 26u16, value.len() as u16);
18566        self.as_rec_mut().extend(value);
18567        self
18568    }
18569    pub fn push_mcast_flood(mut self, value: ()) -> Self {
18570        push_header(self.as_rec_mut(), 27u16, 0 as u16);
18571        self
18572    }
18573    pub fn push_mcast_to_ucast(mut self, value: ()) -> Self {
18574        push_header(self.as_rec_mut(), 28u16, 0 as u16);
18575        self
18576    }
18577    pub fn push_vlan_tunnel(mut self, value: ()) -> Self {
18578        push_header(self.as_rec_mut(), 29u16, 0 as u16);
18579        self
18580    }
18581    pub fn push_bcast_flood(mut self, value: ()) -> Self {
18582        push_header(self.as_rec_mut(), 30u16, 0 as u16);
18583        self
18584    }
18585    pub fn push_group_fwd_mask(mut self, value: u16) -> Self {
18586        push_header(self.as_rec_mut(), 31u16, 2 as u16);
18587        self.as_rec_mut().extend(value.to_ne_bytes());
18588        self
18589    }
18590    pub fn push_neigh_suppress(mut self, value: ()) -> Self {
18591        push_header(self.as_rec_mut(), 32u16, 0 as u16);
18592        self
18593    }
18594    pub fn push_isolated(mut self, value: ()) -> Self {
18595        push_header(self.as_rec_mut(), 33u16, 0 as u16);
18596        self
18597    }
18598    pub fn push_backup_port(mut self, value: u32) -> Self {
18599        push_header(self.as_rec_mut(), 34u16, 4 as u16);
18600        self.as_rec_mut().extend(value.to_ne_bytes());
18601        self
18602    }
18603    pub fn push_mrp_ring_open(mut self, value: ()) -> Self {
18604        push_header(self.as_rec_mut(), 35u16, 0 as u16);
18605        self
18606    }
18607    pub fn push_mrp_in_open(mut self, value: ()) -> Self {
18608        push_header(self.as_rec_mut(), 36u16, 0 as u16);
18609        self
18610    }
18611    pub fn push_mcast_eht_hosts_limit(mut self, value: u32) -> Self {
18612        push_header(self.as_rec_mut(), 37u16, 4 as u16);
18613        self.as_rec_mut().extend(value.to_ne_bytes());
18614        self
18615    }
18616    pub fn push_mcast_eht_hosts_cnt(mut self, value: u32) -> Self {
18617        push_header(self.as_rec_mut(), 38u16, 4 as u16);
18618        self.as_rec_mut().extend(value.to_ne_bytes());
18619        self
18620    }
18621    pub fn push_locked(mut self, value: ()) -> Self {
18622        push_header(self.as_rec_mut(), 39u16, 0 as u16);
18623        self
18624    }
18625    pub fn push_mab(mut self, value: ()) -> Self {
18626        push_header(self.as_rec_mut(), 40u16, 0 as u16);
18627        self
18628    }
18629    pub fn push_mcast_n_groups(mut self, value: u32) -> Self {
18630        push_header(self.as_rec_mut(), 41u16, 4 as u16);
18631        self.as_rec_mut().extend(value.to_ne_bytes());
18632        self
18633    }
18634    pub fn push_mcast_max_groups(mut self, value: u32) -> Self {
18635        push_header(self.as_rec_mut(), 42u16, 4 as u16);
18636        self.as_rec_mut().extend(value.to_ne_bytes());
18637        self
18638    }
18639    pub fn push_neigh_vlan_suppress(mut self, value: ()) -> Self {
18640        push_header(self.as_rec_mut(), 43u16, 0 as u16);
18641        self
18642    }
18643    pub fn push_backup_nhid(mut self, value: u32) -> Self {
18644        push_header(self.as_rec_mut(), 44u16, 4 as u16);
18645        self.as_rec_mut().extend(value.to_ne_bytes());
18646        self
18647    }
18648}
18649impl<Prev: Rec> Drop for PushLinkinfoBrportAttrs<Prev> {
18650    fn drop(&mut self) {
18651        if let Some(prev) = &mut self.prev {
18652            if let Some(header_offset) = &self.header_offset {
18653                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18654            }
18655        }
18656    }
18657}
18658pub struct PushLinkinfoGreAttrs<Prev: Rec> {
18659    pub(crate) prev: Option<Prev>,
18660    pub(crate) header_offset: Option<usize>,
18661}
18662impl<Prev: Rec> Rec for PushLinkinfoGreAttrs<Prev> {
18663    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18664        self.prev.as_mut().unwrap().as_rec_mut()
18665    }
18666    fn as_rec(&self) -> &Vec<u8> {
18667        self.prev.as_ref().unwrap().as_rec()
18668    }
18669}
18670impl<Prev: Rec> PushLinkinfoGreAttrs<Prev> {
18671    pub fn new(prev: Prev) -> Self {
18672        Self {
18673            prev: Some(prev),
18674            header_offset: None,
18675        }
18676    }
18677    pub fn end_nested(mut self) -> Prev {
18678        let mut prev = self.prev.take().unwrap();
18679        if let Some(header_offset) = &self.header_offset {
18680            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18681        }
18682        prev
18683    }
18684    pub fn push_link(mut self, value: u32) -> Self {
18685        push_header(self.as_rec_mut(), 1u16, 4 as u16);
18686        self.as_rec_mut().extend(value.to_ne_bytes());
18687        self
18688    }
18689    pub fn push_iflags(mut self, value: u16) -> Self {
18690        push_header(self.as_rec_mut(), 2u16, 2 as u16);
18691        self.as_rec_mut().extend(value.to_be_bytes());
18692        self
18693    }
18694    pub fn push_oflags(mut self, value: u16) -> Self {
18695        push_header(self.as_rec_mut(), 3u16, 2 as u16);
18696        self.as_rec_mut().extend(value.to_be_bytes());
18697        self
18698    }
18699    pub fn push_ikey(mut self, value: u32) -> Self {
18700        push_header(self.as_rec_mut(), 4u16, 4 as u16);
18701        self.as_rec_mut().extend(value.to_be_bytes());
18702        self
18703    }
18704    pub fn push_okey(mut self, value: u32) -> Self {
18705        push_header(self.as_rec_mut(), 5u16, 4 as u16);
18706        self.as_rec_mut().extend(value.to_be_bytes());
18707        self
18708    }
18709    pub fn push_local(mut self, value: &[u8]) -> Self {
18710        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
18711        self.as_rec_mut().extend(value);
18712        self
18713    }
18714    pub fn push_remote(mut self, value: &[u8]) -> Self {
18715        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
18716        self.as_rec_mut().extend(value);
18717        self
18718    }
18719    pub fn push_ttl(mut self, value: u8) -> Self {
18720        push_header(self.as_rec_mut(), 8u16, 1 as u16);
18721        self.as_rec_mut().extend(value.to_ne_bytes());
18722        self
18723    }
18724    pub fn push_tos(mut self, value: u8) -> Self {
18725        push_header(self.as_rec_mut(), 9u16, 1 as u16);
18726        self.as_rec_mut().extend(value.to_ne_bytes());
18727        self
18728    }
18729    pub fn push_pmtudisc(mut self, value: u8) -> Self {
18730        push_header(self.as_rec_mut(), 10u16, 1 as u16);
18731        self.as_rec_mut().extend(value.to_ne_bytes());
18732        self
18733    }
18734    pub fn push_encap_limit(mut self, value: u8) -> Self {
18735        push_header(self.as_rec_mut(), 11u16, 1 as u16);
18736        self.as_rec_mut().extend(value.to_ne_bytes());
18737        self
18738    }
18739    pub fn push_flowinfo(mut self, value: u32) -> Self {
18740        push_header(self.as_rec_mut(), 12u16, 4 as u16);
18741        self.as_rec_mut().extend(value.to_be_bytes());
18742        self
18743    }
18744    pub fn push_flags(mut self, value: u32) -> Self {
18745        push_header(self.as_rec_mut(), 13u16, 4 as u16);
18746        self.as_rec_mut().extend(value.to_ne_bytes());
18747        self
18748    }
18749    pub fn push_encap_type(mut self, value: u16) -> Self {
18750        push_header(self.as_rec_mut(), 14u16, 2 as u16);
18751        self.as_rec_mut().extend(value.to_ne_bytes());
18752        self
18753    }
18754    pub fn push_encap_flags(mut self, value: u16) -> Self {
18755        push_header(self.as_rec_mut(), 15u16, 2 as u16);
18756        self.as_rec_mut().extend(value.to_ne_bytes());
18757        self
18758    }
18759    pub fn push_encap_sport(mut self, value: u16) -> Self {
18760        push_header(self.as_rec_mut(), 16u16, 2 as u16);
18761        self.as_rec_mut().extend(value.to_be_bytes());
18762        self
18763    }
18764    pub fn push_encap_dport(mut self, value: u16) -> Self {
18765        push_header(self.as_rec_mut(), 17u16, 2 as u16);
18766        self.as_rec_mut().extend(value.to_be_bytes());
18767        self
18768    }
18769    pub fn push_collect_metadata(mut self, value: ()) -> Self {
18770        push_header(self.as_rec_mut(), 18u16, 0 as u16);
18771        self
18772    }
18773    pub fn push_ignore_df(mut self, value: u8) -> Self {
18774        push_header(self.as_rec_mut(), 19u16, 1 as u16);
18775        self.as_rec_mut().extend(value.to_ne_bytes());
18776        self
18777    }
18778    pub fn push_fwmark(mut self, value: u32) -> Self {
18779        push_header(self.as_rec_mut(), 20u16, 4 as u16);
18780        self.as_rec_mut().extend(value.to_ne_bytes());
18781        self
18782    }
18783    pub fn push_erspan_index(mut self, value: u32) -> Self {
18784        push_header(self.as_rec_mut(), 21u16, 4 as u16);
18785        self.as_rec_mut().extend(value.to_ne_bytes());
18786        self
18787    }
18788    pub fn push_erspan_ver(mut self, value: u8) -> Self {
18789        push_header(self.as_rec_mut(), 22u16, 1 as u16);
18790        self.as_rec_mut().extend(value.to_ne_bytes());
18791        self
18792    }
18793    pub fn push_erspan_dir(mut self, value: u8) -> Self {
18794        push_header(self.as_rec_mut(), 23u16, 1 as u16);
18795        self.as_rec_mut().extend(value.to_ne_bytes());
18796        self
18797    }
18798    pub fn push_erspan_hwid(mut self, value: u16) -> Self {
18799        push_header(self.as_rec_mut(), 24u16, 2 as u16);
18800        self.as_rec_mut().extend(value.to_ne_bytes());
18801        self
18802    }
18803}
18804impl<Prev: Rec> Drop for PushLinkinfoGreAttrs<Prev> {
18805    fn drop(&mut self) {
18806        if let Some(prev) = &mut self.prev {
18807            if let Some(header_offset) = &self.header_offset {
18808                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18809            }
18810        }
18811    }
18812}
18813pub struct PushLinkinfoGre6Attrs<Prev: Rec> {
18814    pub(crate) prev: Option<Prev>,
18815    pub(crate) header_offset: Option<usize>,
18816}
18817impl<Prev: Rec> Rec for PushLinkinfoGre6Attrs<Prev> {
18818    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18819        self.prev.as_mut().unwrap().as_rec_mut()
18820    }
18821    fn as_rec(&self) -> &Vec<u8> {
18822        self.prev.as_ref().unwrap().as_rec()
18823    }
18824}
18825impl<Prev: Rec> PushLinkinfoGre6Attrs<Prev> {
18826    pub fn new(prev: Prev) -> Self {
18827        Self {
18828            prev: Some(prev),
18829            header_offset: None,
18830        }
18831    }
18832    pub fn end_nested(mut self) -> Prev {
18833        let mut prev = self.prev.take().unwrap();
18834        if let Some(header_offset) = &self.header_offset {
18835            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18836        }
18837        prev
18838    }
18839    pub fn push_link(mut self, value: u32) -> Self {
18840        push_header(self.as_rec_mut(), 1u16, 4 as u16);
18841        self.as_rec_mut().extend(value.to_ne_bytes());
18842        self
18843    }
18844    pub fn push_iflags(mut self, value: u16) -> Self {
18845        push_header(self.as_rec_mut(), 2u16, 2 as u16);
18846        self.as_rec_mut().extend(value.to_be_bytes());
18847        self
18848    }
18849    pub fn push_oflags(mut self, value: u16) -> Self {
18850        push_header(self.as_rec_mut(), 3u16, 2 as u16);
18851        self.as_rec_mut().extend(value.to_be_bytes());
18852        self
18853    }
18854    pub fn push_ikey(mut self, value: u32) -> Self {
18855        push_header(self.as_rec_mut(), 4u16, 4 as u16);
18856        self.as_rec_mut().extend(value.to_be_bytes());
18857        self
18858    }
18859    pub fn push_okey(mut self, value: u32) -> Self {
18860        push_header(self.as_rec_mut(), 5u16, 4 as u16);
18861        self.as_rec_mut().extend(value.to_be_bytes());
18862        self
18863    }
18864    pub fn push_local(mut self, value: &[u8]) -> Self {
18865        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
18866        self.as_rec_mut().extend(value);
18867        self
18868    }
18869    pub fn push_remote(mut self, value: &[u8]) -> Self {
18870        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
18871        self.as_rec_mut().extend(value);
18872        self
18873    }
18874    pub fn push_ttl(mut self, value: u8) -> Self {
18875        push_header(self.as_rec_mut(), 8u16, 1 as u16);
18876        self.as_rec_mut().extend(value.to_ne_bytes());
18877        self
18878    }
18879    pub fn push_encap_limit(mut self, value: u8) -> Self {
18880        push_header(self.as_rec_mut(), 11u16, 1 as u16);
18881        self.as_rec_mut().extend(value.to_ne_bytes());
18882        self
18883    }
18884    pub fn push_flowinfo(mut self, value: u32) -> Self {
18885        push_header(self.as_rec_mut(), 12u16, 4 as u16);
18886        self.as_rec_mut().extend(value.to_be_bytes());
18887        self
18888    }
18889    pub fn push_flags(mut self, value: u32) -> Self {
18890        push_header(self.as_rec_mut(), 13u16, 4 as u16);
18891        self.as_rec_mut().extend(value.to_ne_bytes());
18892        self
18893    }
18894    pub fn push_encap_type(mut self, value: u16) -> Self {
18895        push_header(self.as_rec_mut(), 14u16, 2 as u16);
18896        self.as_rec_mut().extend(value.to_ne_bytes());
18897        self
18898    }
18899    pub fn push_encap_flags(mut self, value: u16) -> Self {
18900        push_header(self.as_rec_mut(), 15u16, 2 as u16);
18901        self.as_rec_mut().extend(value.to_ne_bytes());
18902        self
18903    }
18904    pub fn push_encap_sport(mut self, value: u16) -> Self {
18905        push_header(self.as_rec_mut(), 16u16, 2 as u16);
18906        self.as_rec_mut().extend(value.to_be_bytes());
18907        self
18908    }
18909    pub fn push_encap_dport(mut self, value: u16) -> Self {
18910        push_header(self.as_rec_mut(), 17u16, 2 as u16);
18911        self.as_rec_mut().extend(value.to_be_bytes());
18912        self
18913    }
18914    pub fn push_collect_metadata(mut self, value: ()) -> Self {
18915        push_header(self.as_rec_mut(), 18u16, 0 as u16);
18916        self
18917    }
18918    pub fn push_fwmark(mut self, value: u32) -> Self {
18919        push_header(self.as_rec_mut(), 20u16, 4 as u16);
18920        self.as_rec_mut().extend(value.to_ne_bytes());
18921        self
18922    }
18923    pub fn push_erspan_index(mut self, value: u32) -> Self {
18924        push_header(self.as_rec_mut(), 21u16, 4 as u16);
18925        self.as_rec_mut().extend(value.to_ne_bytes());
18926        self
18927    }
18928    pub fn push_erspan_ver(mut self, value: u8) -> Self {
18929        push_header(self.as_rec_mut(), 22u16, 1 as u16);
18930        self.as_rec_mut().extend(value.to_ne_bytes());
18931        self
18932    }
18933    pub fn push_erspan_dir(mut self, value: u8) -> Self {
18934        push_header(self.as_rec_mut(), 23u16, 1 as u16);
18935        self.as_rec_mut().extend(value.to_ne_bytes());
18936        self
18937    }
18938    pub fn push_erspan_hwid(mut self, value: u16) -> Self {
18939        push_header(self.as_rec_mut(), 24u16, 2 as u16);
18940        self.as_rec_mut().extend(value.to_ne_bytes());
18941        self
18942    }
18943}
18944impl<Prev: Rec> Drop for PushLinkinfoGre6Attrs<Prev> {
18945    fn drop(&mut self) {
18946        if let Some(prev) = &mut self.prev {
18947            if let Some(header_offset) = &self.header_offset {
18948                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18949            }
18950        }
18951    }
18952}
18953pub struct PushLinkinfoVtiAttrs<Prev: Rec> {
18954    pub(crate) prev: Option<Prev>,
18955    pub(crate) header_offset: Option<usize>,
18956}
18957impl<Prev: Rec> Rec for PushLinkinfoVtiAttrs<Prev> {
18958    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18959        self.prev.as_mut().unwrap().as_rec_mut()
18960    }
18961    fn as_rec(&self) -> &Vec<u8> {
18962        self.prev.as_ref().unwrap().as_rec()
18963    }
18964}
18965impl<Prev: Rec> PushLinkinfoVtiAttrs<Prev> {
18966    pub fn new(prev: Prev) -> Self {
18967        Self {
18968            prev: Some(prev),
18969            header_offset: None,
18970        }
18971    }
18972    pub fn end_nested(mut self) -> Prev {
18973        let mut prev = self.prev.take().unwrap();
18974        if let Some(header_offset) = &self.header_offset {
18975            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18976        }
18977        prev
18978    }
18979    pub fn push_link(mut self, value: u32) -> Self {
18980        push_header(self.as_rec_mut(), 1u16, 4 as u16);
18981        self.as_rec_mut().extend(value.to_ne_bytes());
18982        self
18983    }
18984    pub fn push_ikey(mut self, value: u32) -> Self {
18985        push_header(self.as_rec_mut(), 2u16, 4 as u16);
18986        self.as_rec_mut().extend(value.to_be_bytes());
18987        self
18988    }
18989    pub fn push_okey(mut self, value: u32) -> Self {
18990        push_header(self.as_rec_mut(), 3u16, 4 as u16);
18991        self.as_rec_mut().extend(value.to_be_bytes());
18992        self
18993    }
18994    pub fn push_local(mut self, value: &[u8]) -> Self {
18995        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
18996        self.as_rec_mut().extend(value);
18997        self
18998    }
18999    pub fn push_remote(mut self, value: &[u8]) -> Self {
19000        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
19001        self.as_rec_mut().extend(value);
19002        self
19003    }
19004    pub fn push_fwmark(mut self, value: u32) -> Self {
19005        push_header(self.as_rec_mut(), 6u16, 4 as u16);
19006        self.as_rec_mut().extend(value.to_ne_bytes());
19007        self
19008    }
19009}
19010impl<Prev: Rec> Drop for PushLinkinfoVtiAttrs<Prev> {
19011    fn drop(&mut self) {
19012        if let Some(prev) = &mut self.prev {
19013            if let Some(header_offset) = &self.header_offset {
19014                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19015            }
19016        }
19017    }
19018}
19019pub struct PushLinkinfoVti6Attrs<Prev: Rec> {
19020    pub(crate) prev: Option<Prev>,
19021    pub(crate) header_offset: Option<usize>,
19022}
19023impl<Prev: Rec> Rec for PushLinkinfoVti6Attrs<Prev> {
19024    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19025        self.prev.as_mut().unwrap().as_rec_mut()
19026    }
19027    fn as_rec(&self) -> &Vec<u8> {
19028        self.prev.as_ref().unwrap().as_rec()
19029    }
19030}
19031impl<Prev: Rec> PushLinkinfoVti6Attrs<Prev> {
19032    pub fn new(prev: Prev) -> Self {
19033        Self {
19034            prev: Some(prev),
19035            header_offset: None,
19036        }
19037    }
19038    pub fn end_nested(mut self) -> Prev {
19039        let mut prev = self.prev.take().unwrap();
19040        if let Some(header_offset) = &self.header_offset {
19041            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19042        }
19043        prev
19044    }
19045    pub fn push_link(mut self, value: u32) -> Self {
19046        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19047        self.as_rec_mut().extend(value.to_ne_bytes());
19048        self
19049    }
19050    pub fn push_ikey(mut self, value: u32) -> Self {
19051        push_header(self.as_rec_mut(), 2u16, 4 as u16);
19052        self.as_rec_mut().extend(value.to_be_bytes());
19053        self
19054    }
19055    pub fn push_okey(mut self, value: u32) -> Self {
19056        push_header(self.as_rec_mut(), 3u16, 4 as u16);
19057        self.as_rec_mut().extend(value.to_be_bytes());
19058        self
19059    }
19060    pub fn push_local(mut self, value: &[u8]) -> Self {
19061        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
19062        self.as_rec_mut().extend(value);
19063        self
19064    }
19065    pub fn push_remote(mut self, value: &[u8]) -> Self {
19066        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
19067        self.as_rec_mut().extend(value);
19068        self
19069    }
19070    pub fn push_fwmark(mut self, value: u32) -> Self {
19071        push_header(self.as_rec_mut(), 6u16, 4 as u16);
19072        self.as_rec_mut().extend(value.to_ne_bytes());
19073        self
19074    }
19075}
19076impl<Prev: Rec> Drop for PushLinkinfoVti6Attrs<Prev> {
19077    fn drop(&mut self) {
19078        if let Some(prev) = &mut self.prev {
19079            if let Some(header_offset) = &self.header_offset {
19080                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19081            }
19082        }
19083    }
19084}
19085pub struct PushLinkinfoGeneveAttrs<Prev: Rec> {
19086    pub(crate) prev: Option<Prev>,
19087    pub(crate) header_offset: Option<usize>,
19088}
19089impl<Prev: Rec> Rec for PushLinkinfoGeneveAttrs<Prev> {
19090    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19091        self.prev.as_mut().unwrap().as_rec_mut()
19092    }
19093    fn as_rec(&self) -> &Vec<u8> {
19094        self.prev.as_ref().unwrap().as_rec()
19095    }
19096}
19097impl<Prev: Rec> PushLinkinfoGeneveAttrs<Prev> {
19098    pub fn new(prev: Prev) -> Self {
19099        Self {
19100            prev: Some(prev),
19101            header_offset: None,
19102        }
19103    }
19104    pub fn end_nested(mut self) -> Prev {
19105        let mut prev = self.prev.take().unwrap();
19106        if let Some(header_offset) = &self.header_offset {
19107            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19108        }
19109        prev
19110    }
19111    pub fn push_id(mut self, value: u32) -> Self {
19112        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19113        self.as_rec_mut().extend(value.to_ne_bytes());
19114        self
19115    }
19116    pub fn push_remote(mut self, value: &[u8]) -> Self {
19117        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19118        self.as_rec_mut().extend(value);
19119        self
19120    }
19121    pub fn push_ttl(mut self, value: u8) -> Self {
19122        push_header(self.as_rec_mut(), 3u16, 1 as u16);
19123        self.as_rec_mut().extend(value.to_ne_bytes());
19124        self
19125    }
19126    pub fn push_tos(mut self, value: u8) -> Self {
19127        push_header(self.as_rec_mut(), 4u16, 1 as u16);
19128        self.as_rec_mut().extend(value.to_ne_bytes());
19129        self
19130    }
19131    pub fn push_port(mut self, value: u16) -> Self {
19132        push_header(self.as_rec_mut(), 5u16, 2 as u16);
19133        self.as_rec_mut().extend(value.to_be_bytes());
19134        self
19135    }
19136    pub fn push_collect_metadata(mut self, value: ()) -> Self {
19137        push_header(self.as_rec_mut(), 6u16, 0 as u16);
19138        self
19139    }
19140    pub fn push_remote6(mut self, value: &[u8]) -> Self {
19141        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
19142        self.as_rec_mut().extend(value);
19143        self
19144    }
19145    pub fn push_udp_csum(mut self, value: u8) -> Self {
19146        push_header(self.as_rec_mut(), 8u16, 1 as u16);
19147        self.as_rec_mut().extend(value.to_ne_bytes());
19148        self
19149    }
19150    pub fn push_udp_zero_csum6_tx(mut self, value: u8) -> Self {
19151        push_header(self.as_rec_mut(), 9u16, 1 as u16);
19152        self.as_rec_mut().extend(value.to_ne_bytes());
19153        self
19154    }
19155    pub fn push_udp_zero_csum6_rx(mut self, value: u8) -> Self {
19156        push_header(self.as_rec_mut(), 10u16, 1 as u16);
19157        self.as_rec_mut().extend(value.to_ne_bytes());
19158        self
19159    }
19160    pub fn push_label(mut self, value: u32) -> Self {
19161        push_header(self.as_rec_mut(), 11u16, 4 as u16);
19162        self.as_rec_mut().extend(value.to_be_bytes());
19163        self
19164    }
19165    pub fn push_ttl_inherit(mut self, value: u8) -> Self {
19166        push_header(self.as_rec_mut(), 12u16, 1 as u16);
19167        self.as_rec_mut().extend(value.to_ne_bytes());
19168        self
19169    }
19170    pub fn push_df(mut self, value: u8) -> Self {
19171        push_header(self.as_rec_mut(), 13u16, 1 as u16);
19172        self.as_rec_mut().extend(value.to_ne_bytes());
19173        self
19174    }
19175    pub fn push_inner_proto_inherit(mut self, value: ()) -> Self {
19176        push_header(self.as_rec_mut(), 14u16, 0 as u16);
19177        self
19178    }
19179    pub fn push_port_range(mut self, value: PushIflaGenevePortRange) -> Self {
19180        push_header(self.as_rec_mut(), 15u16, value.as_slice().len() as u16);
19181        self.as_rec_mut().extend(value.as_slice());
19182        self
19183    }
19184}
19185impl<Prev: Rec> Drop for PushLinkinfoGeneveAttrs<Prev> {
19186    fn drop(&mut self) {
19187        if let Some(prev) = &mut self.prev {
19188            if let Some(header_offset) = &self.header_offset {
19189                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19190            }
19191        }
19192    }
19193}
19194pub struct PushLinkinfoIptunAttrs<Prev: Rec> {
19195    pub(crate) prev: Option<Prev>,
19196    pub(crate) header_offset: Option<usize>,
19197}
19198impl<Prev: Rec> Rec for PushLinkinfoIptunAttrs<Prev> {
19199    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19200        self.prev.as_mut().unwrap().as_rec_mut()
19201    }
19202    fn as_rec(&self) -> &Vec<u8> {
19203        self.prev.as_ref().unwrap().as_rec()
19204    }
19205}
19206impl<Prev: Rec> PushLinkinfoIptunAttrs<Prev> {
19207    pub fn new(prev: Prev) -> Self {
19208        Self {
19209            prev: Some(prev),
19210            header_offset: None,
19211        }
19212    }
19213    pub fn end_nested(mut self) -> Prev {
19214        let mut prev = self.prev.take().unwrap();
19215        if let Some(header_offset) = &self.header_offset {
19216            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19217        }
19218        prev
19219    }
19220    pub fn push_link(mut self, value: u32) -> Self {
19221        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19222        self.as_rec_mut().extend(value.to_ne_bytes());
19223        self
19224    }
19225    pub fn push_local(mut self, value: &[u8]) -> Self {
19226        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19227        self.as_rec_mut().extend(value);
19228        self
19229    }
19230    pub fn push_remote(mut self, value: &[u8]) -> Self {
19231        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
19232        self.as_rec_mut().extend(value);
19233        self
19234    }
19235    pub fn push_ttl(mut self, value: u8) -> Self {
19236        push_header(self.as_rec_mut(), 4u16, 1 as u16);
19237        self.as_rec_mut().extend(value.to_ne_bytes());
19238        self
19239    }
19240    pub fn push_tos(mut self, value: u8) -> Self {
19241        push_header(self.as_rec_mut(), 5u16, 1 as u16);
19242        self.as_rec_mut().extend(value.to_ne_bytes());
19243        self
19244    }
19245    pub fn push_encap_limit(mut self, value: u8) -> Self {
19246        push_header(self.as_rec_mut(), 6u16, 1 as u16);
19247        self.as_rec_mut().extend(value.to_ne_bytes());
19248        self
19249    }
19250    pub fn push_flowinfo(mut self, value: u32) -> Self {
19251        push_header(self.as_rec_mut(), 7u16, 4 as u16);
19252        self.as_rec_mut().extend(value.to_be_bytes());
19253        self
19254    }
19255    pub fn push_flags(mut self, value: u16) -> Self {
19256        push_header(self.as_rec_mut(), 8u16, 2 as u16);
19257        self.as_rec_mut().extend(value.to_be_bytes());
19258        self
19259    }
19260    pub fn push_proto(mut self, value: u8) -> Self {
19261        push_header(self.as_rec_mut(), 9u16, 1 as u16);
19262        self.as_rec_mut().extend(value.to_ne_bytes());
19263        self
19264    }
19265    pub fn push_pmtudisc(mut self, value: u8) -> Self {
19266        push_header(self.as_rec_mut(), 10u16, 1 as u16);
19267        self.as_rec_mut().extend(value.to_ne_bytes());
19268        self
19269    }
19270    pub fn push_6rd_prefix(mut self, value: &[u8]) -> Self {
19271        push_header(self.as_rec_mut(), 11u16, value.len() as u16);
19272        self.as_rec_mut().extend(value);
19273        self
19274    }
19275    pub fn push_6rd_relay_prefix(mut self, value: &[u8]) -> Self {
19276        push_header(self.as_rec_mut(), 12u16, value.len() as u16);
19277        self.as_rec_mut().extend(value);
19278        self
19279    }
19280    pub fn push_6rd_prefixlen(mut self, value: u16) -> Self {
19281        push_header(self.as_rec_mut(), 13u16, 2 as u16);
19282        self.as_rec_mut().extend(value.to_ne_bytes());
19283        self
19284    }
19285    pub fn push_6rd_relay_prefixlen(mut self, value: u16) -> Self {
19286        push_header(self.as_rec_mut(), 14u16, 2 as u16);
19287        self.as_rec_mut().extend(value.to_ne_bytes());
19288        self
19289    }
19290    pub fn push_encap_type(mut self, value: u16) -> Self {
19291        push_header(self.as_rec_mut(), 15u16, 2 as u16);
19292        self.as_rec_mut().extend(value.to_ne_bytes());
19293        self
19294    }
19295    pub fn push_encap_flags(mut self, value: u16) -> Self {
19296        push_header(self.as_rec_mut(), 16u16, 2 as u16);
19297        self.as_rec_mut().extend(value.to_ne_bytes());
19298        self
19299    }
19300    pub fn push_encap_sport(mut self, value: u16) -> Self {
19301        push_header(self.as_rec_mut(), 17u16, 2 as u16);
19302        self.as_rec_mut().extend(value.to_be_bytes());
19303        self
19304    }
19305    pub fn push_encap_dport(mut self, value: u16) -> Self {
19306        push_header(self.as_rec_mut(), 18u16, 2 as u16);
19307        self.as_rec_mut().extend(value.to_be_bytes());
19308        self
19309    }
19310    pub fn push_collect_metadata(mut self, value: ()) -> Self {
19311        push_header(self.as_rec_mut(), 19u16, 0 as u16);
19312        self
19313    }
19314    pub fn push_fwmark(mut self, value: u32) -> Self {
19315        push_header(self.as_rec_mut(), 20u16, 4 as u16);
19316        self.as_rec_mut().extend(value.to_ne_bytes());
19317        self
19318    }
19319}
19320impl<Prev: Rec> Drop for PushLinkinfoIptunAttrs<Prev> {
19321    fn drop(&mut self) {
19322        if let Some(prev) = &mut self.prev {
19323            if let Some(header_offset) = &self.header_offset {
19324                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19325            }
19326        }
19327    }
19328}
19329pub struct PushLinkinfoIp6tnlAttrs<Prev: Rec> {
19330    pub(crate) prev: Option<Prev>,
19331    pub(crate) header_offset: Option<usize>,
19332}
19333impl<Prev: Rec> Rec for PushLinkinfoIp6tnlAttrs<Prev> {
19334    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19335        self.prev.as_mut().unwrap().as_rec_mut()
19336    }
19337    fn as_rec(&self) -> &Vec<u8> {
19338        self.prev.as_ref().unwrap().as_rec()
19339    }
19340}
19341impl<Prev: Rec> PushLinkinfoIp6tnlAttrs<Prev> {
19342    pub fn new(prev: Prev) -> Self {
19343        Self {
19344            prev: Some(prev),
19345            header_offset: None,
19346        }
19347    }
19348    pub fn end_nested(mut self) -> Prev {
19349        let mut prev = self.prev.take().unwrap();
19350        if let Some(header_offset) = &self.header_offset {
19351            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19352        }
19353        prev
19354    }
19355    pub fn push_link(mut self, value: u32) -> Self {
19356        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19357        self.as_rec_mut().extend(value.to_ne_bytes());
19358        self
19359    }
19360    pub fn push_local(mut self, value: &[u8]) -> Self {
19361        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19362        self.as_rec_mut().extend(value);
19363        self
19364    }
19365    pub fn push_remote(mut self, value: &[u8]) -> Self {
19366        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
19367        self.as_rec_mut().extend(value);
19368        self
19369    }
19370    pub fn push_ttl(mut self, value: u8) -> Self {
19371        push_header(self.as_rec_mut(), 4u16, 1 as u16);
19372        self.as_rec_mut().extend(value.to_ne_bytes());
19373        self
19374    }
19375    pub fn push_encap_limit(mut self, value: u8) -> Self {
19376        push_header(self.as_rec_mut(), 6u16, 1 as u16);
19377        self.as_rec_mut().extend(value.to_ne_bytes());
19378        self
19379    }
19380    pub fn push_flowinfo(mut self, value: u32) -> Self {
19381        push_header(self.as_rec_mut(), 7u16, 4 as u16);
19382        self.as_rec_mut().extend(value.to_be_bytes());
19383        self
19384    }
19385    pub fn push_flags(mut self, value: u32) -> Self {
19386        push_header(self.as_rec_mut(), 8u16, 4 as u16);
19387        self.as_rec_mut().extend(value.to_be_bytes());
19388        self
19389    }
19390    pub fn push_proto(mut self, value: u8) -> Self {
19391        push_header(self.as_rec_mut(), 9u16, 1 as u16);
19392        self.as_rec_mut().extend(value.to_ne_bytes());
19393        self
19394    }
19395    pub fn push_encap_type(mut self, value: u16) -> Self {
19396        push_header(self.as_rec_mut(), 15u16, 2 as u16);
19397        self.as_rec_mut().extend(value.to_ne_bytes());
19398        self
19399    }
19400    pub fn push_encap_flags(mut self, value: u16) -> Self {
19401        push_header(self.as_rec_mut(), 16u16, 2 as u16);
19402        self.as_rec_mut().extend(value.to_ne_bytes());
19403        self
19404    }
19405    pub fn push_encap_sport(mut self, value: u16) -> Self {
19406        push_header(self.as_rec_mut(), 17u16, 2 as u16);
19407        self.as_rec_mut().extend(value.to_be_bytes());
19408        self
19409    }
19410    pub fn push_encap_dport(mut self, value: u16) -> Self {
19411        push_header(self.as_rec_mut(), 18u16, 2 as u16);
19412        self.as_rec_mut().extend(value.to_be_bytes());
19413        self
19414    }
19415    pub fn push_collect_metadata(mut self, value: ()) -> Self {
19416        push_header(self.as_rec_mut(), 19u16, 0 as u16);
19417        self
19418    }
19419    pub fn push_fwmark(mut self, value: u32) -> Self {
19420        push_header(self.as_rec_mut(), 20u16, 4 as u16);
19421        self.as_rec_mut().extend(value.to_ne_bytes());
19422        self
19423    }
19424}
19425impl<Prev: Rec> Drop for PushLinkinfoIp6tnlAttrs<Prev> {
19426    fn drop(&mut self) {
19427        if let Some(prev) = &mut self.prev {
19428            if let Some(header_offset) = &self.header_offset {
19429                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19430            }
19431        }
19432    }
19433}
19434pub struct PushLinkinfoTunAttrs<Prev: Rec> {
19435    pub(crate) prev: Option<Prev>,
19436    pub(crate) header_offset: Option<usize>,
19437}
19438impl<Prev: Rec> Rec for PushLinkinfoTunAttrs<Prev> {
19439    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19440        self.prev.as_mut().unwrap().as_rec_mut()
19441    }
19442    fn as_rec(&self) -> &Vec<u8> {
19443        self.prev.as_ref().unwrap().as_rec()
19444    }
19445}
19446impl<Prev: Rec> PushLinkinfoTunAttrs<Prev> {
19447    pub fn new(prev: Prev) -> Self {
19448        Self {
19449            prev: Some(prev),
19450            header_offset: None,
19451        }
19452    }
19453    pub fn end_nested(mut self) -> Prev {
19454        let mut prev = self.prev.take().unwrap();
19455        if let Some(header_offset) = &self.header_offset {
19456            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19457        }
19458        prev
19459    }
19460    pub fn push_owner(mut self, value: u32) -> Self {
19461        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19462        self.as_rec_mut().extend(value.to_ne_bytes());
19463        self
19464    }
19465    pub fn push_group(mut self, value: u32) -> Self {
19466        push_header(self.as_rec_mut(), 2u16, 4 as u16);
19467        self.as_rec_mut().extend(value.to_ne_bytes());
19468        self
19469    }
19470    pub fn push_type(mut self, value: u8) -> Self {
19471        push_header(self.as_rec_mut(), 3u16, 1 as u16);
19472        self.as_rec_mut().extend(value.to_ne_bytes());
19473        self
19474    }
19475    pub fn push_pi(mut self, value: u8) -> Self {
19476        push_header(self.as_rec_mut(), 4u16, 1 as u16);
19477        self.as_rec_mut().extend(value.to_ne_bytes());
19478        self
19479    }
19480    pub fn push_vnet_hdr(mut self, value: u8) -> Self {
19481        push_header(self.as_rec_mut(), 5u16, 1 as u16);
19482        self.as_rec_mut().extend(value.to_ne_bytes());
19483        self
19484    }
19485    pub fn push_persist(mut self, value: u8) -> Self {
19486        push_header(self.as_rec_mut(), 6u16, 1 as u16);
19487        self.as_rec_mut().extend(value.to_ne_bytes());
19488        self
19489    }
19490    pub fn push_multi_queue(mut self, value: u8) -> Self {
19491        push_header(self.as_rec_mut(), 7u16, 1 as u16);
19492        self.as_rec_mut().extend(value.to_ne_bytes());
19493        self
19494    }
19495    pub fn push_num_queues(mut self, value: u32) -> Self {
19496        push_header(self.as_rec_mut(), 8u16, 4 as u16);
19497        self.as_rec_mut().extend(value.to_ne_bytes());
19498        self
19499    }
19500    pub fn push_num_disabled_queues(mut self, value: u32) -> Self {
19501        push_header(self.as_rec_mut(), 9u16, 4 as u16);
19502        self.as_rec_mut().extend(value.to_ne_bytes());
19503        self
19504    }
19505}
19506impl<Prev: Rec> Drop for PushLinkinfoTunAttrs<Prev> {
19507    fn drop(&mut self) {
19508        if let Some(prev) = &mut self.prev {
19509            if let Some(header_offset) = &self.header_offset {
19510                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19511            }
19512        }
19513    }
19514}
19515pub struct PushLinkinfoVlanAttrs<Prev: Rec> {
19516    pub(crate) prev: Option<Prev>,
19517    pub(crate) header_offset: Option<usize>,
19518}
19519impl<Prev: Rec> Rec for PushLinkinfoVlanAttrs<Prev> {
19520    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19521        self.prev.as_mut().unwrap().as_rec_mut()
19522    }
19523    fn as_rec(&self) -> &Vec<u8> {
19524        self.prev.as_ref().unwrap().as_rec()
19525    }
19526}
19527impl<Prev: Rec> PushLinkinfoVlanAttrs<Prev> {
19528    pub fn new(prev: Prev) -> Self {
19529        Self {
19530            prev: Some(prev),
19531            header_offset: None,
19532        }
19533    }
19534    pub fn end_nested(mut self) -> Prev {
19535        let mut prev = self.prev.take().unwrap();
19536        if let Some(header_offset) = &self.header_offset {
19537            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19538        }
19539        prev
19540    }
19541    pub fn push_id(mut self, value: u16) -> Self {
19542        push_header(self.as_rec_mut(), 1u16, 2 as u16);
19543        self.as_rec_mut().extend(value.to_ne_bytes());
19544        self
19545    }
19546    pub fn push_flags(mut self, value: PushIflaVlanFlags) -> Self {
19547        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
19548        self.as_rec_mut().extend(value.as_slice());
19549        self
19550    }
19551    pub fn nested_egress_qos(mut self) -> PushIflaVlanQos<Self> {
19552        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
19553        PushIflaVlanQos {
19554            prev: Some(self),
19555            header_offset: Some(header_offset),
19556        }
19557    }
19558    pub fn nested_ingress_qos(mut self) -> PushIflaVlanQos<Self> {
19559        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
19560        PushIflaVlanQos {
19561            prev: Some(self),
19562            header_offset: Some(header_offset),
19563        }
19564    }
19565    #[doc = "Associated type: \"VlanProtocols\" (enum)"]
19566    pub fn push_protocol(mut self, value: u16) -> Self {
19567        push_header(self.as_rec_mut(), 5u16, 2 as u16);
19568        self.as_rec_mut().extend(value.to_be_bytes());
19569        self
19570    }
19571}
19572impl<Prev: Rec> Drop for PushLinkinfoVlanAttrs<Prev> {
19573    fn drop(&mut self) {
19574        if let Some(prev) = &mut self.prev {
19575            if let Some(header_offset) = &self.header_offset {
19576                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19577            }
19578        }
19579    }
19580}
19581pub struct PushIflaVlanQos<Prev: Rec> {
19582    pub(crate) prev: Option<Prev>,
19583    pub(crate) header_offset: Option<usize>,
19584}
19585impl<Prev: Rec> Rec for PushIflaVlanQos<Prev> {
19586    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19587        self.prev.as_mut().unwrap().as_rec_mut()
19588    }
19589    fn as_rec(&self) -> &Vec<u8> {
19590        self.prev.as_ref().unwrap().as_rec()
19591    }
19592}
19593impl<Prev: Rec> PushIflaVlanQos<Prev> {
19594    pub fn new(prev: Prev) -> Self {
19595        Self {
19596            prev: Some(prev),
19597            header_offset: None,
19598        }
19599    }
19600    pub fn end_nested(mut self) -> Prev {
19601        let mut prev = self.prev.take().unwrap();
19602        if let Some(header_offset) = &self.header_offset {
19603            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19604        }
19605        prev
19606    }
19607    #[doc = "Attribute may repeat multiple times (treat it as array)"]
19608    pub fn push_mapping(mut self, value: PushIflaVlanQosMapping) -> Self {
19609        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
19610        self.as_rec_mut().extend(value.as_slice());
19611        self
19612    }
19613}
19614impl<Prev: Rec> Drop for PushIflaVlanQos<Prev> {
19615    fn drop(&mut self) {
19616        if let Some(prev) = &mut self.prev {
19617            if let Some(header_offset) = &self.header_offset {
19618                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19619            }
19620        }
19621    }
19622}
19623pub struct PushLinkinfoVrfAttrs<Prev: Rec> {
19624    pub(crate) prev: Option<Prev>,
19625    pub(crate) header_offset: Option<usize>,
19626}
19627impl<Prev: Rec> Rec for PushLinkinfoVrfAttrs<Prev> {
19628    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19629        self.prev.as_mut().unwrap().as_rec_mut()
19630    }
19631    fn as_rec(&self) -> &Vec<u8> {
19632        self.prev.as_ref().unwrap().as_rec()
19633    }
19634}
19635impl<Prev: Rec> PushLinkinfoVrfAttrs<Prev> {
19636    pub fn new(prev: Prev) -> Self {
19637        Self {
19638            prev: Some(prev),
19639            header_offset: None,
19640        }
19641    }
19642    pub fn end_nested(mut self) -> Prev {
19643        let mut prev = self.prev.take().unwrap();
19644        if let Some(header_offset) = &self.header_offset {
19645            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19646        }
19647        prev
19648    }
19649    pub fn push_table(mut self, value: u32) -> Self {
19650        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19651        self.as_rec_mut().extend(value.to_ne_bytes());
19652        self
19653    }
19654}
19655impl<Prev: Rec> Drop for PushLinkinfoVrfAttrs<Prev> {
19656    fn drop(&mut self) {
19657        if let Some(prev) = &mut self.prev {
19658            if let Some(header_offset) = &self.header_offset {
19659                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19660            }
19661        }
19662    }
19663}
19664pub struct PushXdpAttrs<Prev: Rec> {
19665    pub(crate) prev: Option<Prev>,
19666    pub(crate) header_offset: Option<usize>,
19667}
19668impl<Prev: Rec> Rec for PushXdpAttrs<Prev> {
19669    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19670        self.prev.as_mut().unwrap().as_rec_mut()
19671    }
19672    fn as_rec(&self) -> &Vec<u8> {
19673        self.prev.as_ref().unwrap().as_rec()
19674    }
19675}
19676impl<Prev: Rec> PushXdpAttrs<Prev> {
19677    pub fn new(prev: Prev) -> Self {
19678        Self {
19679            prev: Some(prev),
19680            header_offset: None,
19681        }
19682    }
19683    pub fn end_nested(mut self) -> Prev {
19684        let mut prev = self.prev.take().unwrap();
19685        if let Some(header_offset) = &self.header_offset {
19686            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19687        }
19688        prev
19689    }
19690    pub fn push_fd(mut self, value: i32) -> Self {
19691        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19692        self.as_rec_mut().extend(value.to_ne_bytes());
19693        self
19694    }
19695    pub fn push_attached(mut self, value: u8) -> Self {
19696        push_header(self.as_rec_mut(), 2u16, 1 as u16);
19697        self.as_rec_mut().extend(value.to_ne_bytes());
19698        self
19699    }
19700    pub fn push_flags(mut self, value: u32) -> Self {
19701        push_header(self.as_rec_mut(), 3u16, 4 as u16);
19702        self.as_rec_mut().extend(value.to_ne_bytes());
19703        self
19704    }
19705    pub fn push_prog_id(mut self, value: u32) -> Self {
19706        push_header(self.as_rec_mut(), 4u16, 4 as u16);
19707        self.as_rec_mut().extend(value.to_ne_bytes());
19708        self
19709    }
19710    pub fn push_drv_prog_id(mut self, value: u32) -> Self {
19711        push_header(self.as_rec_mut(), 5u16, 4 as u16);
19712        self.as_rec_mut().extend(value.to_ne_bytes());
19713        self
19714    }
19715    pub fn push_skb_prog_id(mut self, value: u32) -> Self {
19716        push_header(self.as_rec_mut(), 6u16, 4 as u16);
19717        self.as_rec_mut().extend(value.to_ne_bytes());
19718        self
19719    }
19720    pub fn push_hw_prog_id(mut self, value: u32) -> Self {
19721        push_header(self.as_rec_mut(), 7u16, 4 as u16);
19722        self.as_rec_mut().extend(value.to_ne_bytes());
19723        self
19724    }
19725    pub fn push_expected_fd(mut self, value: i32) -> Self {
19726        push_header(self.as_rec_mut(), 8u16, 4 as u16);
19727        self.as_rec_mut().extend(value.to_ne_bytes());
19728        self
19729    }
19730}
19731impl<Prev: Rec> Drop for PushXdpAttrs<Prev> {
19732    fn drop(&mut self) {
19733        if let Some(prev) = &mut self.prev {
19734            if let Some(header_offset) = &self.header_offset {
19735                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19736            }
19737        }
19738    }
19739}
19740pub struct PushIflaAttrs<Prev: Rec> {
19741    pub(crate) prev: Option<Prev>,
19742    pub(crate) header_offset: Option<usize>,
19743}
19744impl<Prev: Rec> Rec for PushIflaAttrs<Prev> {
19745    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19746        self.prev.as_mut().unwrap().as_rec_mut()
19747    }
19748    fn as_rec(&self) -> &Vec<u8> {
19749        self.prev.as_ref().unwrap().as_rec()
19750    }
19751}
19752impl<Prev: Rec> PushIflaAttrs<Prev> {
19753    pub fn new(prev: Prev) -> Self {
19754        Self {
19755            prev: Some(prev),
19756            header_offset: None,
19757        }
19758    }
19759    pub fn end_nested(mut self) -> Prev {
19760        let mut prev = self.prev.take().unwrap();
19761        if let Some(header_offset) = &self.header_offset {
19762            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19763        }
19764        prev
19765    }
19766    #[doc = "u32 indexed by ipv4-devconf - 1 on output, on input it's a nest"]
19767    pub fn push_conf(mut self, value: &[u8]) -> Self {
19768        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
19769        self.as_rec_mut().extend(value);
19770        self
19771    }
19772}
19773impl<Prev: Rec> Drop for PushIflaAttrs<Prev> {
19774    fn drop(&mut self) {
19775        if let Some(prev) = &mut self.prev {
19776            if let Some(header_offset) = &self.header_offset {
19777                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19778            }
19779        }
19780    }
19781}
19782pub struct PushIfla6Attrs<Prev: Rec> {
19783    pub(crate) prev: Option<Prev>,
19784    pub(crate) header_offset: Option<usize>,
19785}
19786impl<Prev: Rec> Rec for PushIfla6Attrs<Prev> {
19787    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19788        self.prev.as_mut().unwrap().as_rec_mut()
19789    }
19790    fn as_rec(&self) -> &Vec<u8> {
19791        self.prev.as_ref().unwrap().as_rec()
19792    }
19793}
19794impl<Prev: Rec> PushIfla6Attrs<Prev> {
19795    pub fn new(prev: Prev) -> Self {
19796        Self {
19797            prev: Some(prev),
19798            header_offset: None,
19799        }
19800    }
19801    pub fn end_nested(mut self) -> Prev {
19802        let mut prev = self.prev.take().unwrap();
19803        if let Some(header_offset) = &self.header_offset {
19804            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19805        }
19806        prev
19807    }
19808    pub fn push_flags(mut self, value: u32) -> Self {
19809        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19810        self.as_rec_mut().extend(value.to_ne_bytes());
19811        self
19812    }
19813    #[doc = "u32 indexed by ipv6-devconf - 1 on output, on input it's a nest"]
19814    pub fn push_conf(mut self, value: &[u8]) -> Self {
19815        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19816        self.as_rec_mut().extend(value);
19817        self
19818    }
19819    pub fn push_stats(mut self, value: &[u8]) -> Self {
19820        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
19821        self.as_rec_mut().extend(value);
19822        self
19823    }
19824    pub fn push_mcast(mut self, value: &[u8]) -> Self {
19825        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
19826        self.as_rec_mut().extend(value);
19827        self
19828    }
19829    pub fn push_cacheinfo(mut self, value: PushIflaCacheinfo) -> Self {
19830        push_header(self.as_rec_mut(), 5u16, value.as_slice().len() as u16);
19831        self.as_rec_mut().extend(value.as_slice());
19832        self
19833    }
19834    pub fn push_icmp6stats(mut self, value: &[u8]) -> Self {
19835        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
19836        self.as_rec_mut().extend(value);
19837        self
19838    }
19839    pub fn push_token(mut self, value: &[u8]) -> Self {
19840        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
19841        self.as_rec_mut().extend(value);
19842        self
19843    }
19844    pub fn push_addr_gen_mode(mut self, value: u8) -> Self {
19845        push_header(self.as_rec_mut(), 8u16, 1 as u16);
19846        self.as_rec_mut().extend(value.to_ne_bytes());
19847        self
19848    }
19849    pub fn push_ra_mtu(mut self, value: u32) -> Self {
19850        push_header(self.as_rec_mut(), 9u16, 4 as u16);
19851        self.as_rec_mut().extend(value.to_ne_bytes());
19852        self
19853    }
19854}
19855impl<Prev: Rec> Drop for PushIfla6Attrs<Prev> {
19856    fn drop(&mut self) {
19857        if let Some(prev) = &mut self.prev {
19858            if let Some(header_offset) = &self.header_offset {
19859                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19860            }
19861        }
19862    }
19863}
19864pub struct PushMctpAttrs<Prev: Rec> {
19865    pub(crate) prev: Option<Prev>,
19866    pub(crate) header_offset: Option<usize>,
19867}
19868impl<Prev: Rec> Rec for PushMctpAttrs<Prev> {
19869    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19870        self.prev.as_mut().unwrap().as_rec_mut()
19871    }
19872    fn as_rec(&self) -> &Vec<u8> {
19873        self.prev.as_ref().unwrap().as_rec()
19874    }
19875}
19876impl<Prev: Rec> PushMctpAttrs<Prev> {
19877    pub fn new(prev: Prev) -> Self {
19878        Self {
19879            prev: Some(prev),
19880            header_offset: None,
19881        }
19882    }
19883    pub fn end_nested(mut self) -> Prev {
19884        let mut prev = self.prev.take().unwrap();
19885        if let Some(header_offset) = &self.header_offset {
19886            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19887        }
19888        prev
19889    }
19890    pub fn push_net(mut self, value: u32) -> Self {
19891        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19892        self.as_rec_mut().extend(value.to_ne_bytes());
19893        self
19894    }
19895    pub fn push_phys_binding(mut self, value: u8) -> Self {
19896        push_header(self.as_rec_mut(), 2u16, 1 as u16);
19897        self.as_rec_mut().extend(value.to_ne_bytes());
19898        self
19899    }
19900}
19901impl<Prev: Rec> Drop for PushMctpAttrs<Prev> {
19902    fn drop(&mut self) {
19903        if let Some(prev) = &mut self.prev {
19904            if let Some(header_offset) = &self.header_offset {
19905                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19906            }
19907        }
19908    }
19909}
19910pub struct PushStatsAttrs<Prev: Rec> {
19911    pub(crate) prev: Option<Prev>,
19912    pub(crate) header_offset: Option<usize>,
19913}
19914impl<Prev: Rec> Rec for PushStatsAttrs<Prev> {
19915    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19916        self.prev.as_mut().unwrap().as_rec_mut()
19917    }
19918    fn as_rec(&self) -> &Vec<u8> {
19919        self.prev.as_ref().unwrap().as_rec()
19920    }
19921}
19922impl<Prev: Rec> PushStatsAttrs<Prev> {
19923    pub fn new(prev: Prev) -> Self {
19924        Self {
19925            prev: Some(prev),
19926            header_offset: None,
19927        }
19928    }
19929    pub fn end_nested(mut self) -> Prev {
19930        let mut prev = self.prev.take().unwrap();
19931        if let Some(header_offset) = &self.header_offset {
19932            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19933        }
19934        prev
19935    }
19936    pub fn push_link_64(mut self, value: PushRtnlLinkStats64) -> Self {
19937        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
19938        self.as_rec_mut().extend(value.as_slice());
19939        self
19940    }
19941    pub fn push_link_xstats(mut self, value: &[u8]) -> Self {
19942        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19943        self.as_rec_mut().extend(value);
19944        self
19945    }
19946    pub fn push_link_xstats_slave(mut self, value: &[u8]) -> Self {
19947        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
19948        self.as_rec_mut().extend(value);
19949        self
19950    }
19951    pub fn nested_link_offload_xstats(mut self) -> PushLinkOffloadXstats<Self> {
19952        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
19953        PushLinkOffloadXstats {
19954            prev: Some(self),
19955            header_offset: Some(header_offset),
19956        }
19957    }
19958    pub fn push_af_spec(mut self, value: &[u8]) -> Self {
19959        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
19960        self.as_rec_mut().extend(value);
19961        self
19962    }
19963}
19964impl<Prev: Rec> Drop for PushStatsAttrs<Prev> {
19965    fn drop(&mut self) {
19966        if let Some(prev) = &mut self.prev {
19967            if let Some(header_offset) = &self.header_offset {
19968                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19969            }
19970        }
19971    }
19972}
19973pub struct PushLinkOffloadXstats<Prev: Rec> {
19974    pub(crate) prev: Option<Prev>,
19975    pub(crate) header_offset: Option<usize>,
19976}
19977impl<Prev: Rec> Rec for PushLinkOffloadXstats<Prev> {
19978    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19979        self.prev.as_mut().unwrap().as_rec_mut()
19980    }
19981    fn as_rec(&self) -> &Vec<u8> {
19982        self.prev.as_ref().unwrap().as_rec()
19983    }
19984}
19985pub struct PushArrayHwSInfoOne<Prev: Rec> {
19986    pub(crate) prev: Option<Prev>,
19987    pub(crate) header_offset: Option<usize>,
19988    pub(crate) counter: u16,
19989}
19990impl<Prev: Rec> Rec for PushArrayHwSInfoOne<Prev> {
19991    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19992        self.prev.as_mut().unwrap().as_rec_mut()
19993    }
19994    fn as_rec(&self) -> &Vec<u8> {
19995        self.prev.as_ref().unwrap().as_rec()
19996    }
19997}
19998impl<Prev: Rec> PushArrayHwSInfoOne<Prev> {
19999    pub fn new(prev: Prev) -> Self {
20000        Self {
20001            prev: Some(prev),
20002            header_offset: None,
20003            counter: 0,
20004        }
20005    }
20006    pub fn end_array(mut self) -> Prev {
20007        let mut prev = self.prev.take().unwrap();
20008        if let Some(header_offset) = &self.header_offset {
20009            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20010        }
20011        prev
20012    }
20013    pub fn entry_nested(mut self) -> PushHwSInfoOne<Self> {
20014        let index = self.counter;
20015        self.counter += 1;
20016        let header_offset = push_nested_header(self.as_rec_mut(), index);
20017        PushHwSInfoOne {
20018            prev: Some(self),
20019            header_offset: Some(header_offset),
20020        }
20021    }
20022}
20023impl<Prev: Rec> Drop for PushArrayHwSInfoOne<Prev> {
20024    fn drop(&mut self) {
20025        if let Some(prev) = &mut self.prev {
20026            if let Some(header_offset) = &self.header_offset {
20027                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20028            }
20029        }
20030    }
20031}
20032impl<Prev: Rec> PushLinkOffloadXstats<Prev> {
20033    pub fn new(prev: Prev) -> Self {
20034        Self {
20035            prev: Some(prev),
20036            header_offset: None,
20037        }
20038    }
20039    pub fn end_nested(mut self) -> Prev {
20040        let mut prev = self.prev.take().unwrap();
20041        if let Some(header_offset) = &self.header_offset {
20042            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20043        }
20044        prev
20045    }
20046    pub fn push_cpu_hit(mut self, value: &[u8]) -> Self {
20047        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
20048        self.as_rec_mut().extend(value);
20049        self
20050    }
20051    pub fn array_hw_s_info(mut self) -> PushArrayHwSInfoOne<Self> {
20052        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
20053        PushArrayHwSInfoOne {
20054            prev: Some(self),
20055            header_offset: Some(header_offset),
20056            counter: 0,
20057        }
20058    }
20059    pub fn push_l3_stats(mut self, value: &[u8]) -> Self {
20060        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
20061        self.as_rec_mut().extend(value);
20062        self
20063    }
20064}
20065impl<Prev: Rec> Drop for PushLinkOffloadXstats<Prev> {
20066    fn drop(&mut self) {
20067        if let Some(prev) = &mut self.prev {
20068            if let Some(header_offset) = &self.header_offset {
20069                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20070            }
20071        }
20072    }
20073}
20074pub struct PushHwSInfoOne<Prev: Rec> {
20075    pub(crate) prev: Option<Prev>,
20076    pub(crate) header_offset: Option<usize>,
20077}
20078impl<Prev: Rec> Rec for PushHwSInfoOne<Prev> {
20079    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
20080        self.prev.as_mut().unwrap().as_rec_mut()
20081    }
20082    fn as_rec(&self) -> &Vec<u8> {
20083        self.prev.as_ref().unwrap().as_rec()
20084    }
20085}
20086impl<Prev: Rec> PushHwSInfoOne<Prev> {
20087    pub fn new(prev: Prev) -> Self {
20088        Self {
20089            prev: Some(prev),
20090            header_offset: None,
20091        }
20092    }
20093    pub fn end_nested(mut self) -> Prev {
20094        let mut prev = self.prev.take().unwrap();
20095        if let Some(header_offset) = &self.header_offset {
20096            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20097        }
20098        prev
20099    }
20100    pub fn push_request(mut self, value: u8) -> Self {
20101        push_header(self.as_rec_mut(), 1u16, 1 as u16);
20102        self.as_rec_mut().extend(value.to_ne_bytes());
20103        self
20104    }
20105    pub fn push_used(mut self, value: u8) -> Self {
20106        push_header(self.as_rec_mut(), 2u16, 1 as u16);
20107        self.as_rec_mut().extend(value.to_ne_bytes());
20108        self
20109    }
20110}
20111impl<Prev: Rec> Drop for PushHwSInfoOne<Prev> {
20112    fn drop(&mut self) {
20113        if let Some(prev) = &mut self.prev {
20114            if let Some(header_offset) = &self.header_offset {
20115                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20116            }
20117        }
20118    }
20119}
20120pub struct PushLinkDpllPinAttrs<Prev: Rec> {
20121    pub(crate) prev: Option<Prev>,
20122    pub(crate) header_offset: Option<usize>,
20123}
20124impl<Prev: Rec> Rec for PushLinkDpllPinAttrs<Prev> {
20125    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
20126        self.prev.as_mut().unwrap().as_rec_mut()
20127    }
20128    fn as_rec(&self) -> &Vec<u8> {
20129        self.prev.as_ref().unwrap().as_rec()
20130    }
20131}
20132impl<Prev: Rec> PushLinkDpllPinAttrs<Prev> {
20133    pub fn new(prev: Prev) -> Self {
20134        Self {
20135            prev: Some(prev),
20136            header_offset: None,
20137        }
20138    }
20139    pub fn end_nested(mut self) -> Prev {
20140        let mut prev = self.prev.take().unwrap();
20141        if let Some(header_offset) = &self.header_offset {
20142            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20143        }
20144        prev
20145    }
20146    pub fn push_id(mut self, value: u32) -> Self {
20147        push_header(self.as_rec_mut(), 1u16, 4 as u16);
20148        self.as_rec_mut().extend(value.to_ne_bytes());
20149        self
20150    }
20151}
20152impl<Prev: Rec> Drop for PushLinkDpllPinAttrs<Prev> {
20153    fn drop(&mut self) {
20154        if let Some(prev) = &mut self.prev {
20155            if let Some(header_offset) = &self.header_offset {
20156                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20157            }
20158        }
20159    }
20160}
20161pub struct PushLinkinfoNetkitAttrs<Prev: Rec> {
20162    pub(crate) prev: Option<Prev>,
20163    pub(crate) header_offset: Option<usize>,
20164}
20165impl<Prev: Rec> Rec for PushLinkinfoNetkitAttrs<Prev> {
20166    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
20167        self.prev.as_mut().unwrap().as_rec_mut()
20168    }
20169    fn as_rec(&self) -> &Vec<u8> {
20170        self.prev.as_ref().unwrap().as_rec()
20171    }
20172}
20173impl<Prev: Rec> PushLinkinfoNetkitAttrs<Prev> {
20174    pub fn new(prev: Prev) -> Self {
20175        Self {
20176            prev: Some(prev),
20177            header_offset: None,
20178        }
20179    }
20180    pub fn end_nested(mut self) -> Prev {
20181        let mut prev = self.prev.take().unwrap();
20182        if let Some(header_offset) = &self.header_offset {
20183            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20184        }
20185        prev
20186    }
20187    pub fn push_peer_info(mut self, value: &[u8]) -> Self {
20188        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
20189        self.as_rec_mut().extend(value);
20190        self
20191    }
20192    pub fn push_primary(mut self, value: u8) -> Self {
20193        push_header(self.as_rec_mut(), 2u16, 1 as u16);
20194        self.as_rec_mut().extend(value.to_ne_bytes());
20195        self
20196    }
20197    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
20198    pub fn push_policy(mut self, value: u32) -> Self {
20199        push_header(self.as_rec_mut(), 3u16, 4 as u16);
20200        self.as_rec_mut().extend(value.to_ne_bytes());
20201        self
20202    }
20203    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
20204    pub fn push_peer_policy(mut self, value: u32) -> Self {
20205        push_header(self.as_rec_mut(), 4u16, 4 as u16);
20206        self.as_rec_mut().extend(value.to_ne_bytes());
20207        self
20208    }
20209    #[doc = "Associated type: \"NetkitMode\" (enum)"]
20210    pub fn push_mode(mut self, value: u32) -> Self {
20211        push_header(self.as_rec_mut(), 5u16, 4 as u16);
20212        self.as_rec_mut().extend(value.to_ne_bytes());
20213        self
20214    }
20215    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
20216    pub fn push_scrub(mut self, value: u32) -> Self {
20217        push_header(self.as_rec_mut(), 6u16, 4 as u16);
20218        self.as_rec_mut().extend(value.to_ne_bytes());
20219        self
20220    }
20221    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
20222    pub fn push_peer_scrub(mut self, value: u32) -> Self {
20223        push_header(self.as_rec_mut(), 7u16, 4 as u16);
20224        self.as_rec_mut().extend(value.to_ne_bytes());
20225        self
20226    }
20227    pub fn push_headroom(mut self, value: u16) -> Self {
20228        push_header(self.as_rec_mut(), 8u16, 2 as u16);
20229        self.as_rec_mut().extend(value.to_ne_bytes());
20230        self
20231    }
20232    pub fn push_tailroom(mut self, value: u16) -> Self {
20233        push_header(self.as_rec_mut(), 9u16, 2 as u16);
20234        self.as_rec_mut().extend(value.to_ne_bytes());
20235        self
20236    }
20237}
20238impl<Prev: Rec> Drop for PushLinkinfoNetkitAttrs<Prev> {
20239    fn drop(&mut self) {
20240        if let Some(prev) = &mut self.prev {
20241            if let Some(header_offset) = &self.header_offset {
20242                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20243            }
20244        }
20245    }
20246}
20247pub struct PushLinkinfoOvpnAttrs<Prev: Rec> {
20248    pub(crate) prev: Option<Prev>,
20249    pub(crate) header_offset: Option<usize>,
20250}
20251impl<Prev: Rec> Rec for PushLinkinfoOvpnAttrs<Prev> {
20252    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
20253        self.prev.as_mut().unwrap().as_rec_mut()
20254    }
20255    fn as_rec(&self) -> &Vec<u8> {
20256        self.prev.as_ref().unwrap().as_rec()
20257    }
20258}
20259impl<Prev: Rec> PushLinkinfoOvpnAttrs<Prev> {
20260    pub fn new(prev: Prev) -> Self {
20261        Self {
20262            prev: Some(prev),
20263            header_offset: None,
20264        }
20265    }
20266    pub fn end_nested(mut self) -> Prev {
20267        let mut prev = self.prev.take().unwrap();
20268        if let Some(header_offset) = &self.header_offset {
20269            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20270        }
20271        prev
20272    }
20273    #[doc = "Associated type: \"OvpnMode\" (enum)"]
20274    pub fn push_mode(mut self, value: u8) -> Self {
20275        push_header(self.as_rec_mut(), 1u16, 1 as u16);
20276        self.as_rec_mut().extend(value.to_ne_bytes());
20277        self
20278    }
20279}
20280impl<Prev: Rec> Drop for PushLinkinfoOvpnAttrs<Prev> {
20281    fn drop(&mut self) {
20282        if let Some(prev) = &mut self.prev {
20283            if let Some(header_offset) = &self.header_offset {
20284                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20285            }
20286        }
20287    }
20288}
20289#[derive(Clone)]
20290pub struct PushRtgenmsg {
20291    pub(crate) buf: [u8; 1usize],
20292}
20293#[doc = "Create zero-initialized struct"]
20294impl Default for PushRtgenmsg {
20295    fn default() -> Self {
20296        Self { buf: [0u8; 1usize] }
20297    }
20298}
20299impl PushRtgenmsg {
20300    #[doc = "Create zero-initialized struct"]
20301    pub fn new() -> Self {
20302        Default::default()
20303    }
20304    #[doc = "Copy from contents from other slice"]
20305    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20306        if other.len() != Self::len() {
20307            return None;
20308        }
20309        let mut buf = [0u8; Self::len()];
20310        buf.clone_from_slice(other);
20311        Some(Self { buf })
20312    }
20313    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
20314    pub fn new_from_zeroed(other: &[u8]) -> Self {
20315        let mut buf = [0u8; Self::len()];
20316        let len = buf.len().min(other.len());
20317        buf[..len].clone_from_slice(&other[..len]);
20318        Self { buf }
20319    }
20320    pub fn as_slice(&self) -> &[u8] {
20321        &self.buf
20322    }
20323    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20324        &mut self.buf
20325    }
20326    pub const fn len() -> usize {
20327        1usize
20328    }
20329    pub fn family(&self) -> u8 {
20330        parse_u8(&self.buf[0usize..1usize]).unwrap()
20331    }
20332    pub fn set_family(&mut self, value: u8) {
20333        self.buf[0usize..1usize].copy_from_slice(&value.to_ne_bytes())
20334    }
20335}
20336impl std::fmt::Debug for PushRtgenmsg {
20337    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20338        fmt.debug_struct("Rtgenmsg")
20339            .field("family", &self.family())
20340            .finish()
20341    }
20342}
20343#[derive(Clone)]
20344pub struct PushIfinfomsg {
20345    pub(crate) buf: [u8; 16usize],
20346}
20347#[doc = "Create zero-initialized struct"]
20348impl Default for PushIfinfomsg {
20349    fn default() -> Self {
20350        Self {
20351            buf: [0u8; 16usize],
20352        }
20353    }
20354}
20355impl PushIfinfomsg {
20356    #[doc = "Create zero-initialized struct"]
20357    pub fn new() -> Self {
20358        Default::default()
20359    }
20360    #[doc = "Copy from contents from other slice"]
20361    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20362        if other.len() != Self::len() {
20363            return None;
20364        }
20365        let mut buf = [0u8; Self::len()];
20366        buf.clone_from_slice(other);
20367        Some(Self { buf })
20368    }
20369    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
20370    pub fn new_from_zeroed(other: &[u8]) -> Self {
20371        let mut buf = [0u8; Self::len()];
20372        let len = buf.len().min(other.len());
20373        buf[..len].clone_from_slice(&other[..len]);
20374        Self { buf }
20375    }
20376    pub fn as_slice(&self) -> &[u8] {
20377        &self.buf
20378    }
20379    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20380        &mut self.buf
20381    }
20382    pub const fn len() -> usize {
20383        16usize
20384    }
20385    pub fn ifi_family(&self) -> u8 {
20386        parse_u8(&self.buf[0usize..1usize]).unwrap()
20387    }
20388    pub fn set_ifi_family(&mut self, value: u8) {
20389        self.buf[0usize..1usize].copy_from_slice(&value.to_ne_bytes())
20390    }
20391    pub fn ifi_type(&self) -> u16 {
20392        parse_u16(&self.buf[2usize..4usize]).unwrap()
20393    }
20394    pub fn set_ifi_type(&mut self, value: u16) {
20395        self.buf[2usize..4usize].copy_from_slice(&value.to_ne_bytes())
20396    }
20397    pub fn ifi_index(&self) -> i32 {
20398        parse_i32(&self.buf[4usize..8usize]).unwrap()
20399    }
20400    pub fn set_ifi_index(&mut self, value: i32) {
20401        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
20402    }
20403    #[doc = "Associated type: \"IfinfoFlags\" (1 bit per enumeration)"]
20404    pub fn ifi_flags(&self) -> u32 {
20405        parse_u32(&self.buf[8usize..12usize]).unwrap()
20406    }
20407    #[doc = "Associated type: \"IfinfoFlags\" (1 bit per enumeration)"]
20408    pub fn set_ifi_flags(&mut self, value: u32) {
20409        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
20410    }
20411    pub fn ifi_change(&self) -> u32 {
20412        parse_u32(&self.buf[12usize..16usize]).unwrap()
20413    }
20414    pub fn set_ifi_change(&mut self, value: u32) {
20415        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
20416    }
20417}
20418impl std::fmt::Debug for PushIfinfomsg {
20419    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20420        fmt.debug_struct("Ifinfomsg")
20421            .field("ifi_family", &self.ifi_family())
20422            .field("ifi_type", &self.ifi_type())
20423            .field("ifi_index", &self.ifi_index())
20424            .field(
20425                "ifi_flags",
20426                &FormatFlags(self.ifi_flags().into(), IfinfoFlags::from_value),
20427            )
20428            .field("ifi_change", &self.ifi_change())
20429            .finish()
20430    }
20431}
20432#[derive(Clone)]
20433pub struct PushIflaBridgeId {
20434    pub(crate) buf: [u8; 8usize],
20435}
20436#[doc = "Create zero-initialized struct"]
20437impl Default for PushIflaBridgeId {
20438    fn default() -> Self {
20439        Self { buf: [0u8; 8usize] }
20440    }
20441}
20442impl PushIflaBridgeId {
20443    #[doc = "Create zero-initialized struct"]
20444    pub fn new() -> Self {
20445        Default::default()
20446    }
20447    #[doc = "Copy from contents from other slice"]
20448    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20449        if other.len() != Self::len() {
20450            return None;
20451        }
20452        let mut buf = [0u8; Self::len()];
20453        buf.clone_from_slice(other);
20454        Some(Self { buf })
20455    }
20456    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
20457    pub fn new_from_zeroed(other: &[u8]) -> Self {
20458        let mut buf = [0u8; Self::len()];
20459        let len = buf.len().min(other.len());
20460        buf[..len].clone_from_slice(&other[..len]);
20461        Self { buf }
20462    }
20463    pub fn as_slice(&self) -> &[u8] {
20464        &self.buf
20465    }
20466    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20467        &mut self.buf
20468    }
20469    pub const fn len() -> usize {
20470        8usize
20471    }
20472    pub fn prio(&self) -> u16 {
20473        parse_u16(&self.buf[0usize..2usize]).unwrap()
20474    }
20475    pub fn set_prio(&mut self, value: u16) {
20476        self.buf[0usize..2usize].copy_from_slice(&value.to_ne_bytes())
20477    }
20478    pub fn addr(&self) -> [u8; 6usize] {
20479        self.buf[2usize..8usize].try_into().unwrap()
20480    }
20481    pub fn set_addr(&mut self, value: [u8; 6usize]) {
20482        self.buf[2usize..8usize].copy_from_slice(&value)
20483    }
20484}
20485impl std::fmt::Debug for PushIflaBridgeId {
20486    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20487        fmt.debug_struct("IflaBridgeId")
20488            .field("prio", &self.prio())
20489            .field("addr", &self.addr())
20490            .finish()
20491    }
20492}
20493#[derive(Clone)]
20494pub struct PushIflaCacheinfo {
20495    pub(crate) buf: [u8; 16usize],
20496}
20497#[doc = "Create zero-initialized struct"]
20498impl Default for PushIflaCacheinfo {
20499    fn default() -> Self {
20500        Self {
20501            buf: [0u8; 16usize],
20502        }
20503    }
20504}
20505impl PushIflaCacheinfo {
20506    #[doc = "Create zero-initialized struct"]
20507    pub fn new() -> Self {
20508        Default::default()
20509    }
20510    #[doc = "Copy from contents from other slice"]
20511    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20512        if other.len() != Self::len() {
20513            return None;
20514        }
20515        let mut buf = [0u8; Self::len()];
20516        buf.clone_from_slice(other);
20517        Some(Self { buf })
20518    }
20519    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
20520    pub fn new_from_zeroed(other: &[u8]) -> Self {
20521        let mut buf = [0u8; Self::len()];
20522        let len = buf.len().min(other.len());
20523        buf[..len].clone_from_slice(&other[..len]);
20524        Self { buf }
20525    }
20526    pub fn as_slice(&self) -> &[u8] {
20527        &self.buf
20528    }
20529    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20530        &mut self.buf
20531    }
20532    pub const fn len() -> usize {
20533        16usize
20534    }
20535    pub fn max_reasm_len(&self) -> u32 {
20536        parse_u32(&self.buf[0usize..4usize]).unwrap()
20537    }
20538    pub fn set_max_reasm_len(&mut self, value: u32) {
20539        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
20540    }
20541    pub fn tstamp(&self) -> u32 {
20542        parse_u32(&self.buf[4usize..8usize]).unwrap()
20543    }
20544    pub fn set_tstamp(&mut self, value: u32) {
20545        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
20546    }
20547    pub fn reachable_time(&self) -> i32 {
20548        parse_i32(&self.buf[8usize..12usize]).unwrap()
20549    }
20550    pub fn set_reachable_time(&mut self, value: i32) {
20551        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
20552    }
20553    pub fn retrans_time(&self) -> u32 {
20554        parse_u32(&self.buf[12usize..16usize]).unwrap()
20555    }
20556    pub fn set_retrans_time(&mut self, value: u32) {
20557        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
20558    }
20559}
20560impl std::fmt::Debug for PushIflaCacheinfo {
20561    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20562        fmt.debug_struct("IflaCacheinfo")
20563            .field("max_reasm_len", &self.max_reasm_len())
20564            .field("tstamp", &self.tstamp())
20565            .field("reachable_time", &self.reachable_time())
20566            .field("retrans_time", &self.retrans_time())
20567            .finish()
20568    }
20569}
20570#[derive(Clone)]
20571pub struct PushRtnlLinkStats {
20572    pub(crate) buf: [u8; 96usize],
20573}
20574#[doc = "Create zero-initialized struct"]
20575impl Default for PushRtnlLinkStats {
20576    fn default() -> Self {
20577        Self {
20578            buf: [0u8; 96usize],
20579        }
20580    }
20581}
20582impl PushRtnlLinkStats {
20583    #[doc = "Create zero-initialized struct"]
20584    pub fn new() -> Self {
20585        Default::default()
20586    }
20587    #[doc = "Copy from contents from other slice"]
20588    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20589        if other.len() != Self::len() {
20590            return None;
20591        }
20592        let mut buf = [0u8; Self::len()];
20593        buf.clone_from_slice(other);
20594        Some(Self { buf })
20595    }
20596    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
20597    pub fn new_from_zeroed(other: &[u8]) -> Self {
20598        let mut buf = [0u8; Self::len()];
20599        let len = buf.len().min(other.len());
20600        buf[..len].clone_from_slice(&other[..len]);
20601        Self { buf }
20602    }
20603    pub fn as_slice(&self) -> &[u8] {
20604        &self.buf
20605    }
20606    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20607        &mut self.buf
20608    }
20609    pub const fn len() -> usize {
20610        96usize
20611    }
20612    pub fn rx_packets(&self) -> u32 {
20613        parse_u32(&self.buf[0usize..4usize]).unwrap()
20614    }
20615    pub fn set_rx_packets(&mut self, value: u32) {
20616        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
20617    }
20618    pub fn tx_packets(&self) -> u32 {
20619        parse_u32(&self.buf[4usize..8usize]).unwrap()
20620    }
20621    pub fn set_tx_packets(&mut self, value: u32) {
20622        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
20623    }
20624    pub fn rx_bytes(&self) -> u32 {
20625        parse_u32(&self.buf[8usize..12usize]).unwrap()
20626    }
20627    pub fn set_rx_bytes(&mut self, value: u32) {
20628        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
20629    }
20630    pub fn tx_bytes(&self) -> u32 {
20631        parse_u32(&self.buf[12usize..16usize]).unwrap()
20632    }
20633    pub fn set_tx_bytes(&mut self, value: u32) {
20634        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
20635    }
20636    pub fn rx_errors(&self) -> u32 {
20637        parse_u32(&self.buf[16usize..20usize]).unwrap()
20638    }
20639    pub fn set_rx_errors(&mut self, value: u32) {
20640        self.buf[16usize..20usize].copy_from_slice(&value.to_ne_bytes())
20641    }
20642    pub fn tx_errors(&self) -> u32 {
20643        parse_u32(&self.buf[20usize..24usize]).unwrap()
20644    }
20645    pub fn set_tx_errors(&mut self, value: u32) {
20646        self.buf[20usize..24usize].copy_from_slice(&value.to_ne_bytes())
20647    }
20648    pub fn rx_dropped(&self) -> u32 {
20649        parse_u32(&self.buf[24usize..28usize]).unwrap()
20650    }
20651    pub fn set_rx_dropped(&mut self, value: u32) {
20652        self.buf[24usize..28usize].copy_from_slice(&value.to_ne_bytes())
20653    }
20654    pub fn tx_dropped(&self) -> u32 {
20655        parse_u32(&self.buf[28usize..32usize]).unwrap()
20656    }
20657    pub fn set_tx_dropped(&mut self, value: u32) {
20658        self.buf[28usize..32usize].copy_from_slice(&value.to_ne_bytes())
20659    }
20660    pub fn multicast(&self) -> u32 {
20661        parse_u32(&self.buf[32usize..36usize]).unwrap()
20662    }
20663    pub fn set_multicast(&mut self, value: u32) {
20664        self.buf[32usize..36usize].copy_from_slice(&value.to_ne_bytes())
20665    }
20666    pub fn collisions(&self) -> u32 {
20667        parse_u32(&self.buf[36usize..40usize]).unwrap()
20668    }
20669    pub fn set_collisions(&mut self, value: u32) {
20670        self.buf[36usize..40usize].copy_from_slice(&value.to_ne_bytes())
20671    }
20672    pub fn rx_length_errors(&self) -> u32 {
20673        parse_u32(&self.buf[40usize..44usize]).unwrap()
20674    }
20675    pub fn set_rx_length_errors(&mut self, value: u32) {
20676        self.buf[40usize..44usize].copy_from_slice(&value.to_ne_bytes())
20677    }
20678    pub fn rx_over_errors(&self) -> u32 {
20679        parse_u32(&self.buf[44usize..48usize]).unwrap()
20680    }
20681    pub fn set_rx_over_errors(&mut self, value: u32) {
20682        self.buf[44usize..48usize].copy_from_slice(&value.to_ne_bytes())
20683    }
20684    pub fn rx_crc_errors(&self) -> u32 {
20685        parse_u32(&self.buf[48usize..52usize]).unwrap()
20686    }
20687    pub fn set_rx_crc_errors(&mut self, value: u32) {
20688        self.buf[48usize..52usize].copy_from_slice(&value.to_ne_bytes())
20689    }
20690    pub fn rx_frame_errors(&self) -> u32 {
20691        parse_u32(&self.buf[52usize..56usize]).unwrap()
20692    }
20693    pub fn set_rx_frame_errors(&mut self, value: u32) {
20694        self.buf[52usize..56usize].copy_from_slice(&value.to_ne_bytes())
20695    }
20696    pub fn rx_fifo_errors(&self) -> u32 {
20697        parse_u32(&self.buf[56usize..60usize]).unwrap()
20698    }
20699    pub fn set_rx_fifo_errors(&mut self, value: u32) {
20700        self.buf[56usize..60usize].copy_from_slice(&value.to_ne_bytes())
20701    }
20702    pub fn rx_missed_errors(&self) -> u32 {
20703        parse_u32(&self.buf[60usize..64usize]).unwrap()
20704    }
20705    pub fn set_rx_missed_errors(&mut self, value: u32) {
20706        self.buf[60usize..64usize].copy_from_slice(&value.to_ne_bytes())
20707    }
20708    pub fn tx_aborted_errors(&self) -> u32 {
20709        parse_u32(&self.buf[64usize..68usize]).unwrap()
20710    }
20711    pub fn set_tx_aborted_errors(&mut self, value: u32) {
20712        self.buf[64usize..68usize].copy_from_slice(&value.to_ne_bytes())
20713    }
20714    pub fn tx_carrier_errors(&self) -> u32 {
20715        parse_u32(&self.buf[68usize..72usize]).unwrap()
20716    }
20717    pub fn set_tx_carrier_errors(&mut self, value: u32) {
20718        self.buf[68usize..72usize].copy_from_slice(&value.to_ne_bytes())
20719    }
20720    pub fn tx_fifo_errors(&self) -> u32 {
20721        parse_u32(&self.buf[72usize..76usize]).unwrap()
20722    }
20723    pub fn set_tx_fifo_errors(&mut self, value: u32) {
20724        self.buf[72usize..76usize].copy_from_slice(&value.to_ne_bytes())
20725    }
20726    pub fn tx_heartbeat_errors(&self) -> u32 {
20727        parse_u32(&self.buf[76usize..80usize]).unwrap()
20728    }
20729    pub fn set_tx_heartbeat_errors(&mut self, value: u32) {
20730        self.buf[76usize..80usize].copy_from_slice(&value.to_ne_bytes())
20731    }
20732    pub fn tx_window_errors(&self) -> u32 {
20733        parse_u32(&self.buf[80usize..84usize]).unwrap()
20734    }
20735    pub fn set_tx_window_errors(&mut self, value: u32) {
20736        self.buf[80usize..84usize].copy_from_slice(&value.to_ne_bytes())
20737    }
20738    pub fn rx_compressed(&self) -> u32 {
20739        parse_u32(&self.buf[84usize..88usize]).unwrap()
20740    }
20741    pub fn set_rx_compressed(&mut self, value: u32) {
20742        self.buf[84usize..88usize].copy_from_slice(&value.to_ne_bytes())
20743    }
20744    pub fn tx_compressed(&self) -> u32 {
20745        parse_u32(&self.buf[88usize..92usize]).unwrap()
20746    }
20747    pub fn set_tx_compressed(&mut self, value: u32) {
20748        self.buf[88usize..92usize].copy_from_slice(&value.to_ne_bytes())
20749    }
20750    pub fn rx_nohandler(&self) -> u32 {
20751        parse_u32(&self.buf[92usize..96usize]).unwrap()
20752    }
20753    pub fn set_rx_nohandler(&mut self, value: u32) {
20754        self.buf[92usize..96usize].copy_from_slice(&value.to_ne_bytes())
20755    }
20756}
20757impl std::fmt::Debug for PushRtnlLinkStats {
20758    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20759        fmt.debug_struct("RtnlLinkStats")
20760            .field("rx_packets", &self.rx_packets())
20761            .field("tx_packets", &self.tx_packets())
20762            .field("rx_bytes", &self.rx_bytes())
20763            .field("tx_bytes", &self.tx_bytes())
20764            .field("rx_errors", &self.rx_errors())
20765            .field("tx_errors", &self.tx_errors())
20766            .field("rx_dropped", &self.rx_dropped())
20767            .field("tx_dropped", &self.tx_dropped())
20768            .field("multicast", &self.multicast())
20769            .field("collisions", &self.collisions())
20770            .field("rx_length_errors", &self.rx_length_errors())
20771            .field("rx_over_errors", &self.rx_over_errors())
20772            .field("rx_crc_errors", &self.rx_crc_errors())
20773            .field("rx_frame_errors", &self.rx_frame_errors())
20774            .field("rx_fifo_errors", &self.rx_fifo_errors())
20775            .field("rx_missed_errors", &self.rx_missed_errors())
20776            .field("tx_aborted_errors", &self.tx_aborted_errors())
20777            .field("tx_carrier_errors", &self.tx_carrier_errors())
20778            .field("tx_fifo_errors", &self.tx_fifo_errors())
20779            .field("tx_heartbeat_errors", &self.tx_heartbeat_errors())
20780            .field("tx_window_errors", &self.tx_window_errors())
20781            .field("rx_compressed", &self.rx_compressed())
20782            .field("tx_compressed", &self.tx_compressed())
20783            .field("rx_nohandler", &self.rx_nohandler())
20784            .finish()
20785    }
20786}
20787#[derive(Clone)]
20788pub struct PushRtnlLinkStats64 {
20789    pub(crate) buf: [u8; 200usize],
20790}
20791#[doc = "Create zero-initialized struct"]
20792impl Default for PushRtnlLinkStats64 {
20793    fn default() -> Self {
20794        Self {
20795            buf: [0u8; 200usize],
20796        }
20797    }
20798}
20799impl PushRtnlLinkStats64 {
20800    #[doc = "Create zero-initialized struct"]
20801    pub fn new() -> Self {
20802        Default::default()
20803    }
20804    #[doc = "Copy from contents from other slice"]
20805    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20806        if other.len() != Self::len() {
20807            return None;
20808        }
20809        let mut buf = [0u8; Self::len()];
20810        buf.clone_from_slice(other);
20811        Some(Self { buf })
20812    }
20813    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
20814    pub fn new_from_zeroed(other: &[u8]) -> Self {
20815        let mut buf = [0u8; Self::len()];
20816        let len = buf.len().min(other.len());
20817        buf[..len].clone_from_slice(&other[..len]);
20818        Self { buf }
20819    }
20820    pub fn as_slice(&self) -> &[u8] {
20821        &self.buf
20822    }
20823    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20824        &mut self.buf
20825    }
20826    pub const fn len() -> usize {
20827        200usize
20828    }
20829    pub fn rx_packets(&self) -> u64 {
20830        parse_u64(&self.buf[0usize..8usize]).unwrap()
20831    }
20832    pub fn set_rx_packets(&mut self, value: u64) {
20833        self.buf[0usize..8usize].copy_from_slice(&value.to_ne_bytes())
20834    }
20835    pub fn tx_packets(&self) -> u64 {
20836        parse_u64(&self.buf[8usize..16usize]).unwrap()
20837    }
20838    pub fn set_tx_packets(&mut self, value: u64) {
20839        self.buf[8usize..16usize].copy_from_slice(&value.to_ne_bytes())
20840    }
20841    pub fn rx_bytes(&self) -> u64 {
20842        parse_u64(&self.buf[16usize..24usize]).unwrap()
20843    }
20844    pub fn set_rx_bytes(&mut self, value: u64) {
20845        self.buf[16usize..24usize].copy_from_slice(&value.to_ne_bytes())
20846    }
20847    pub fn tx_bytes(&self) -> u64 {
20848        parse_u64(&self.buf[24usize..32usize]).unwrap()
20849    }
20850    pub fn set_tx_bytes(&mut self, value: u64) {
20851        self.buf[24usize..32usize].copy_from_slice(&value.to_ne_bytes())
20852    }
20853    pub fn rx_errors(&self) -> u64 {
20854        parse_u64(&self.buf[32usize..40usize]).unwrap()
20855    }
20856    pub fn set_rx_errors(&mut self, value: u64) {
20857        self.buf[32usize..40usize].copy_from_slice(&value.to_ne_bytes())
20858    }
20859    pub fn tx_errors(&self) -> u64 {
20860        parse_u64(&self.buf[40usize..48usize]).unwrap()
20861    }
20862    pub fn set_tx_errors(&mut self, value: u64) {
20863        self.buf[40usize..48usize].copy_from_slice(&value.to_ne_bytes())
20864    }
20865    pub fn rx_dropped(&self) -> u64 {
20866        parse_u64(&self.buf[48usize..56usize]).unwrap()
20867    }
20868    pub fn set_rx_dropped(&mut self, value: u64) {
20869        self.buf[48usize..56usize].copy_from_slice(&value.to_ne_bytes())
20870    }
20871    pub fn tx_dropped(&self) -> u64 {
20872        parse_u64(&self.buf[56usize..64usize]).unwrap()
20873    }
20874    pub fn set_tx_dropped(&mut self, value: u64) {
20875        self.buf[56usize..64usize].copy_from_slice(&value.to_ne_bytes())
20876    }
20877    pub fn multicast(&self) -> u64 {
20878        parse_u64(&self.buf[64usize..72usize]).unwrap()
20879    }
20880    pub fn set_multicast(&mut self, value: u64) {
20881        self.buf[64usize..72usize].copy_from_slice(&value.to_ne_bytes())
20882    }
20883    pub fn collisions(&self) -> u64 {
20884        parse_u64(&self.buf[72usize..80usize]).unwrap()
20885    }
20886    pub fn set_collisions(&mut self, value: u64) {
20887        self.buf[72usize..80usize].copy_from_slice(&value.to_ne_bytes())
20888    }
20889    pub fn rx_length_errors(&self) -> u64 {
20890        parse_u64(&self.buf[80usize..88usize]).unwrap()
20891    }
20892    pub fn set_rx_length_errors(&mut self, value: u64) {
20893        self.buf[80usize..88usize].copy_from_slice(&value.to_ne_bytes())
20894    }
20895    pub fn rx_over_errors(&self) -> u64 {
20896        parse_u64(&self.buf[88usize..96usize]).unwrap()
20897    }
20898    pub fn set_rx_over_errors(&mut self, value: u64) {
20899        self.buf[88usize..96usize].copy_from_slice(&value.to_ne_bytes())
20900    }
20901    pub fn rx_crc_errors(&self) -> u64 {
20902        parse_u64(&self.buf[96usize..104usize]).unwrap()
20903    }
20904    pub fn set_rx_crc_errors(&mut self, value: u64) {
20905        self.buf[96usize..104usize].copy_from_slice(&value.to_ne_bytes())
20906    }
20907    pub fn rx_frame_errors(&self) -> u64 {
20908        parse_u64(&self.buf[104usize..112usize]).unwrap()
20909    }
20910    pub fn set_rx_frame_errors(&mut self, value: u64) {
20911        self.buf[104usize..112usize].copy_from_slice(&value.to_ne_bytes())
20912    }
20913    pub fn rx_fifo_errors(&self) -> u64 {
20914        parse_u64(&self.buf[112usize..120usize]).unwrap()
20915    }
20916    pub fn set_rx_fifo_errors(&mut self, value: u64) {
20917        self.buf[112usize..120usize].copy_from_slice(&value.to_ne_bytes())
20918    }
20919    pub fn rx_missed_errors(&self) -> u64 {
20920        parse_u64(&self.buf[120usize..128usize]).unwrap()
20921    }
20922    pub fn set_rx_missed_errors(&mut self, value: u64) {
20923        self.buf[120usize..128usize].copy_from_slice(&value.to_ne_bytes())
20924    }
20925    pub fn tx_aborted_errors(&self) -> u64 {
20926        parse_u64(&self.buf[128usize..136usize]).unwrap()
20927    }
20928    pub fn set_tx_aborted_errors(&mut self, value: u64) {
20929        self.buf[128usize..136usize].copy_from_slice(&value.to_ne_bytes())
20930    }
20931    pub fn tx_carrier_errors(&self) -> u64 {
20932        parse_u64(&self.buf[136usize..144usize]).unwrap()
20933    }
20934    pub fn set_tx_carrier_errors(&mut self, value: u64) {
20935        self.buf[136usize..144usize].copy_from_slice(&value.to_ne_bytes())
20936    }
20937    pub fn tx_fifo_errors(&self) -> u64 {
20938        parse_u64(&self.buf[144usize..152usize]).unwrap()
20939    }
20940    pub fn set_tx_fifo_errors(&mut self, value: u64) {
20941        self.buf[144usize..152usize].copy_from_slice(&value.to_ne_bytes())
20942    }
20943    pub fn tx_heartbeat_errors(&self) -> u64 {
20944        parse_u64(&self.buf[152usize..160usize]).unwrap()
20945    }
20946    pub fn set_tx_heartbeat_errors(&mut self, value: u64) {
20947        self.buf[152usize..160usize].copy_from_slice(&value.to_ne_bytes())
20948    }
20949    pub fn tx_window_errors(&self) -> u64 {
20950        parse_u64(&self.buf[160usize..168usize]).unwrap()
20951    }
20952    pub fn set_tx_window_errors(&mut self, value: u64) {
20953        self.buf[160usize..168usize].copy_from_slice(&value.to_ne_bytes())
20954    }
20955    pub fn rx_compressed(&self) -> u64 {
20956        parse_u64(&self.buf[168usize..176usize]).unwrap()
20957    }
20958    pub fn set_rx_compressed(&mut self, value: u64) {
20959        self.buf[168usize..176usize].copy_from_slice(&value.to_ne_bytes())
20960    }
20961    pub fn tx_compressed(&self) -> u64 {
20962        parse_u64(&self.buf[176usize..184usize]).unwrap()
20963    }
20964    pub fn set_tx_compressed(&mut self, value: u64) {
20965        self.buf[176usize..184usize].copy_from_slice(&value.to_ne_bytes())
20966    }
20967    pub fn rx_nohandler(&self) -> u64 {
20968        parse_u64(&self.buf[184usize..192usize]).unwrap()
20969    }
20970    pub fn set_rx_nohandler(&mut self, value: u64) {
20971        self.buf[184usize..192usize].copy_from_slice(&value.to_ne_bytes())
20972    }
20973    pub fn rx_otherhost_dropped(&self) -> u64 {
20974        parse_u64(&self.buf[192usize..200usize]).unwrap()
20975    }
20976    pub fn set_rx_otherhost_dropped(&mut self, value: u64) {
20977        self.buf[192usize..200usize].copy_from_slice(&value.to_ne_bytes())
20978    }
20979}
20980impl std::fmt::Debug for PushRtnlLinkStats64 {
20981    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20982        fmt.debug_struct("RtnlLinkStats64")
20983            .field("rx_packets", &self.rx_packets())
20984            .field("tx_packets", &self.tx_packets())
20985            .field("rx_bytes", &self.rx_bytes())
20986            .field("tx_bytes", &self.tx_bytes())
20987            .field("rx_errors", &self.rx_errors())
20988            .field("tx_errors", &self.tx_errors())
20989            .field("rx_dropped", &self.rx_dropped())
20990            .field("tx_dropped", &self.tx_dropped())
20991            .field("multicast", &self.multicast())
20992            .field("collisions", &self.collisions())
20993            .field("rx_length_errors", &self.rx_length_errors())
20994            .field("rx_over_errors", &self.rx_over_errors())
20995            .field("rx_crc_errors", &self.rx_crc_errors())
20996            .field("rx_frame_errors", &self.rx_frame_errors())
20997            .field("rx_fifo_errors", &self.rx_fifo_errors())
20998            .field("rx_missed_errors", &self.rx_missed_errors())
20999            .field("tx_aborted_errors", &self.tx_aborted_errors())
21000            .field("tx_carrier_errors", &self.tx_carrier_errors())
21001            .field("tx_fifo_errors", &self.tx_fifo_errors())
21002            .field("tx_heartbeat_errors", &self.tx_heartbeat_errors())
21003            .field("tx_window_errors", &self.tx_window_errors())
21004            .field("rx_compressed", &self.rx_compressed())
21005            .field("tx_compressed", &self.tx_compressed())
21006            .field("rx_nohandler", &self.rx_nohandler())
21007            .field("rx_otherhost_dropped", &self.rx_otherhost_dropped())
21008            .finish()
21009    }
21010}
21011#[derive(Clone)]
21012pub struct PushRtnlLinkIfmap {
21013    pub(crate) buf: [u8; 32usize],
21014}
21015#[doc = "Create zero-initialized struct"]
21016impl Default for PushRtnlLinkIfmap {
21017    fn default() -> Self {
21018        Self {
21019            buf: [0u8; 32usize],
21020        }
21021    }
21022}
21023impl PushRtnlLinkIfmap {
21024    #[doc = "Create zero-initialized struct"]
21025    pub fn new() -> Self {
21026        Default::default()
21027    }
21028    #[doc = "Copy from contents from other slice"]
21029    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21030        if other.len() != Self::len() {
21031            return None;
21032        }
21033        let mut buf = [0u8; Self::len()];
21034        buf.clone_from_slice(other);
21035        Some(Self { buf })
21036    }
21037    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21038    pub fn new_from_zeroed(other: &[u8]) -> Self {
21039        let mut buf = [0u8; Self::len()];
21040        let len = buf.len().min(other.len());
21041        buf[..len].clone_from_slice(&other[..len]);
21042        Self { buf }
21043    }
21044    pub fn as_slice(&self) -> &[u8] {
21045        &self.buf
21046    }
21047    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21048        &mut self.buf
21049    }
21050    pub const fn len() -> usize {
21051        32usize
21052    }
21053    pub fn mem_start(&self) -> u64 {
21054        parse_u64(&self.buf[0usize..8usize]).unwrap()
21055    }
21056    pub fn set_mem_start(&mut self, value: u64) {
21057        self.buf[0usize..8usize].copy_from_slice(&value.to_ne_bytes())
21058    }
21059    pub fn mem_end(&self) -> u64 {
21060        parse_u64(&self.buf[8usize..16usize]).unwrap()
21061    }
21062    pub fn set_mem_end(&mut self, value: u64) {
21063        self.buf[8usize..16usize].copy_from_slice(&value.to_ne_bytes())
21064    }
21065    pub fn base_addr(&self) -> u64 {
21066        parse_u64(&self.buf[16usize..24usize]).unwrap()
21067    }
21068    pub fn set_base_addr(&mut self, value: u64) {
21069        self.buf[16usize..24usize].copy_from_slice(&value.to_ne_bytes())
21070    }
21071    pub fn irq(&self) -> u16 {
21072        parse_u16(&self.buf[24usize..26usize]).unwrap()
21073    }
21074    pub fn set_irq(&mut self, value: u16) {
21075        self.buf[24usize..26usize].copy_from_slice(&value.to_ne_bytes())
21076    }
21077    pub fn dma(&self) -> u8 {
21078        parse_u8(&self.buf[26usize..27usize]).unwrap()
21079    }
21080    pub fn set_dma(&mut self, value: u8) {
21081        self.buf[26usize..27usize].copy_from_slice(&value.to_ne_bytes())
21082    }
21083    pub fn port(&self) -> u8 {
21084        parse_u8(&self.buf[27usize..28usize]).unwrap()
21085    }
21086    pub fn set_port(&mut self, value: u8) {
21087        self.buf[27usize..28usize].copy_from_slice(&value.to_ne_bytes())
21088    }
21089}
21090impl std::fmt::Debug for PushRtnlLinkIfmap {
21091    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21092        fmt.debug_struct("RtnlLinkIfmap")
21093            .field("mem_start", &self.mem_start())
21094            .field("mem_end", &self.mem_end())
21095            .field("base_addr", &self.base_addr())
21096            .field("irq", &self.irq())
21097            .field("dma", &self.dma())
21098            .field("port", &self.port())
21099            .finish()
21100    }
21101}
21102#[derive(Clone)]
21103pub struct PushBrBooloptMulti {
21104    pub(crate) buf: [u8; 8usize],
21105}
21106#[doc = "Create zero-initialized struct"]
21107impl Default for PushBrBooloptMulti {
21108    fn default() -> Self {
21109        Self { buf: [0u8; 8usize] }
21110    }
21111}
21112impl PushBrBooloptMulti {
21113    #[doc = "Create zero-initialized struct"]
21114    pub fn new() -> Self {
21115        Default::default()
21116    }
21117    #[doc = "Copy from contents from other slice"]
21118    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21119        if other.len() != Self::len() {
21120            return None;
21121        }
21122        let mut buf = [0u8; Self::len()];
21123        buf.clone_from_slice(other);
21124        Some(Self { buf })
21125    }
21126    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21127    pub fn new_from_zeroed(other: &[u8]) -> Self {
21128        let mut buf = [0u8; Self::len()];
21129        let len = buf.len().min(other.len());
21130        buf[..len].clone_from_slice(&other[..len]);
21131        Self { buf }
21132    }
21133    pub fn as_slice(&self) -> &[u8] {
21134        &self.buf
21135    }
21136    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21137        &mut self.buf
21138    }
21139    pub const fn len() -> usize {
21140        8usize
21141    }
21142    pub fn optval(&self) -> u32 {
21143        parse_u32(&self.buf[0usize..4usize]).unwrap()
21144    }
21145    pub fn set_optval(&mut self, value: u32) {
21146        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21147    }
21148    pub fn optmask(&self) -> u32 {
21149        parse_u32(&self.buf[4usize..8usize]).unwrap()
21150    }
21151    pub fn set_optmask(&mut self, value: u32) {
21152        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21153    }
21154}
21155impl std::fmt::Debug for PushBrBooloptMulti {
21156    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21157        fmt.debug_struct("BrBooloptMulti")
21158            .field("optval", &self.optval())
21159            .field("optmask", &self.optmask())
21160            .finish()
21161    }
21162}
21163#[derive(Clone)]
21164pub struct PushIfStatsMsg {
21165    pub(crate) buf: [u8; 12usize],
21166}
21167#[doc = "Create zero-initialized struct"]
21168impl Default for PushIfStatsMsg {
21169    fn default() -> Self {
21170        Self {
21171            buf: [0u8; 12usize],
21172        }
21173    }
21174}
21175impl PushIfStatsMsg {
21176    #[doc = "Create zero-initialized struct"]
21177    pub fn new() -> Self {
21178        Default::default()
21179    }
21180    #[doc = "Copy from contents from other slice"]
21181    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21182        if other.len() != Self::len() {
21183            return None;
21184        }
21185        let mut buf = [0u8; Self::len()];
21186        buf.clone_from_slice(other);
21187        Some(Self { buf })
21188    }
21189    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21190    pub fn new_from_zeroed(other: &[u8]) -> Self {
21191        let mut buf = [0u8; Self::len()];
21192        let len = buf.len().min(other.len());
21193        buf[..len].clone_from_slice(&other[..len]);
21194        Self { buf }
21195    }
21196    pub fn as_slice(&self) -> &[u8] {
21197        &self.buf
21198    }
21199    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21200        &mut self.buf
21201    }
21202    pub const fn len() -> usize {
21203        12usize
21204    }
21205    pub fn family(&self) -> u8 {
21206        parse_u8(&self.buf[0usize..1usize]).unwrap()
21207    }
21208    pub fn set_family(&mut self, value: u8) {
21209        self.buf[0usize..1usize].copy_from_slice(&value.to_ne_bytes())
21210    }
21211    pub fn ifindex(&self) -> u32 {
21212        parse_u32(&self.buf[4usize..8usize]).unwrap()
21213    }
21214    pub fn set_ifindex(&mut self, value: u32) {
21215        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21216    }
21217    pub fn filter_mask(&self) -> u32 {
21218        parse_u32(&self.buf[8usize..12usize]).unwrap()
21219    }
21220    pub fn set_filter_mask(&mut self, value: u32) {
21221        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
21222    }
21223}
21224impl std::fmt::Debug for PushIfStatsMsg {
21225    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21226        fmt.debug_struct("IfStatsMsg")
21227            .field("family", &self.family())
21228            .field("ifindex", &self.ifindex())
21229            .field("filter_mask", &self.filter_mask())
21230            .finish()
21231    }
21232}
21233#[derive(Clone)]
21234pub struct PushIflaVlanFlags {
21235    pub(crate) buf: [u8; 8usize],
21236}
21237#[doc = "Create zero-initialized struct"]
21238impl Default for PushIflaVlanFlags {
21239    fn default() -> Self {
21240        Self { buf: [0u8; 8usize] }
21241    }
21242}
21243impl PushIflaVlanFlags {
21244    #[doc = "Create zero-initialized struct"]
21245    pub fn new() -> Self {
21246        Default::default()
21247    }
21248    #[doc = "Copy from contents from other slice"]
21249    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21250        if other.len() != Self::len() {
21251            return None;
21252        }
21253        let mut buf = [0u8; Self::len()];
21254        buf.clone_from_slice(other);
21255        Some(Self { buf })
21256    }
21257    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21258    pub fn new_from_zeroed(other: &[u8]) -> Self {
21259        let mut buf = [0u8; Self::len()];
21260        let len = buf.len().min(other.len());
21261        buf[..len].clone_from_slice(&other[..len]);
21262        Self { buf }
21263    }
21264    pub fn as_slice(&self) -> &[u8] {
21265        &self.buf
21266    }
21267    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21268        &mut self.buf
21269    }
21270    pub const fn len() -> usize {
21271        8usize
21272    }
21273    #[doc = "Associated type: \"VlanFlags\" (1 bit per enumeration)"]
21274    pub fn flags(&self) -> u32 {
21275        parse_u32(&self.buf[0usize..4usize]).unwrap()
21276    }
21277    #[doc = "Associated type: \"VlanFlags\" (1 bit per enumeration)"]
21278    pub fn set_flags(&mut self, value: u32) {
21279        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21280    }
21281    pub fn mask(&self) -> u32 {
21282        parse_u32(&self.buf[4usize..8usize]).unwrap()
21283    }
21284    pub fn set_mask(&mut self, value: u32) {
21285        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21286    }
21287}
21288impl std::fmt::Debug for PushIflaVlanFlags {
21289    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21290        fmt.debug_struct("IflaVlanFlags")
21291            .field(
21292                "flags",
21293                &FormatFlags(self.flags().into(), VlanFlags::from_value),
21294            )
21295            .field("mask", &FormatHex(self.mask().to_ne_bytes()))
21296            .finish()
21297    }
21298}
21299#[derive(Clone)]
21300pub struct PushIflaVlanQosMapping {
21301    pub(crate) buf: [u8; 8usize],
21302}
21303#[doc = "Create zero-initialized struct"]
21304impl Default for PushIflaVlanQosMapping {
21305    fn default() -> Self {
21306        Self { buf: [0u8; 8usize] }
21307    }
21308}
21309impl PushIflaVlanQosMapping {
21310    #[doc = "Create zero-initialized struct"]
21311    pub fn new() -> Self {
21312        Default::default()
21313    }
21314    #[doc = "Copy from contents from other slice"]
21315    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21316        if other.len() != Self::len() {
21317            return None;
21318        }
21319        let mut buf = [0u8; Self::len()];
21320        buf.clone_from_slice(other);
21321        Some(Self { buf })
21322    }
21323    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21324    pub fn new_from_zeroed(other: &[u8]) -> Self {
21325        let mut buf = [0u8; Self::len()];
21326        let len = buf.len().min(other.len());
21327        buf[..len].clone_from_slice(&other[..len]);
21328        Self { buf }
21329    }
21330    pub fn as_slice(&self) -> &[u8] {
21331        &self.buf
21332    }
21333    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21334        &mut self.buf
21335    }
21336    pub const fn len() -> usize {
21337        8usize
21338    }
21339    pub fn from(&self) -> u32 {
21340        parse_u32(&self.buf[0usize..4usize]).unwrap()
21341    }
21342    pub fn set_from(&mut self, value: u32) {
21343        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21344    }
21345    pub fn to(&self) -> u32 {
21346        parse_u32(&self.buf[4usize..8usize]).unwrap()
21347    }
21348    pub fn set_to(&mut self, value: u32) {
21349        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21350    }
21351}
21352impl std::fmt::Debug for PushIflaVlanQosMapping {
21353    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21354        fmt.debug_struct("IflaVlanQosMapping")
21355            .field("from", &self.from())
21356            .field("to", &self.to())
21357            .finish()
21358    }
21359}
21360#[derive(Clone)]
21361pub struct PushIflaGenevePortRange {
21362    pub(crate) buf: [u8; 4usize],
21363}
21364#[doc = "Create zero-initialized struct"]
21365impl Default for PushIflaGenevePortRange {
21366    fn default() -> Self {
21367        Self { buf: [0u8; 4usize] }
21368    }
21369}
21370impl PushIflaGenevePortRange {
21371    #[doc = "Create zero-initialized struct"]
21372    pub fn new() -> Self {
21373        Default::default()
21374    }
21375    #[doc = "Copy from contents from other slice"]
21376    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21377        if other.len() != Self::len() {
21378            return None;
21379        }
21380        let mut buf = [0u8; Self::len()];
21381        buf.clone_from_slice(other);
21382        Some(Self { buf })
21383    }
21384    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21385    pub fn new_from_zeroed(other: &[u8]) -> Self {
21386        let mut buf = [0u8; Self::len()];
21387        let len = buf.len().min(other.len());
21388        buf[..len].clone_from_slice(&other[..len]);
21389        Self { buf }
21390    }
21391    pub fn as_slice(&self) -> &[u8] {
21392        &self.buf
21393    }
21394    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21395        &mut self.buf
21396    }
21397    pub const fn len() -> usize {
21398        4usize
21399    }
21400    pub fn low(&self) -> u16 {
21401        parse_be_u16(&self.buf[0usize..2usize]).unwrap()
21402    }
21403    pub fn set_low(&mut self, value: u16) {
21404        self.buf[0usize..2usize].copy_from_slice(&value.to_be_bytes())
21405    }
21406    pub fn high(&self) -> u16 {
21407        parse_be_u16(&self.buf[2usize..4usize]).unwrap()
21408    }
21409    pub fn set_high(&mut self, value: u16) {
21410        self.buf[2usize..4usize].copy_from_slice(&value.to_be_bytes())
21411    }
21412}
21413impl std::fmt::Debug for PushIflaGenevePortRange {
21414    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21415        fmt.debug_struct("IflaGenevePortRange")
21416            .field("low", &self.low())
21417            .field("high", &self.high())
21418            .finish()
21419    }
21420}
21421#[derive(Clone)]
21422pub struct PushIflaVfMac {
21423    pub(crate) buf: [u8; 36usize],
21424}
21425#[doc = "Create zero-initialized struct"]
21426impl Default for PushIflaVfMac {
21427    fn default() -> Self {
21428        Self {
21429            buf: [0u8; 36usize],
21430        }
21431    }
21432}
21433impl PushIflaVfMac {
21434    #[doc = "Create zero-initialized struct"]
21435    pub fn new() -> Self {
21436        Default::default()
21437    }
21438    #[doc = "Copy from contents from other slice"]
21439    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21440        if other.len() != Self::len() {
21441            return None;
21442        }
21443        let mut buf = [0u8; Self::len()];
21444        buf.clone_from_slice(other);
21445        Some(Self { buf })
21446    }
21447    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21448    pub fn new_from_zeroed(other: &[u8]) -> Self {
21449        let mut buf = [0u8; Self::len()];
21450        let len = buf.len().min(other.len());
21451        buf[..len].clone_from_slice(&other[..len]);
21452        Self { buf }
21453    }
21454    pub fn as_slice(&self) -> &[u8] {
21455        &self.buf
21456    }
21457    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21458        &mut self.buf
21459    }
21460    pub const fn len() -> usize {
21461        36usize
21462    }
21463    pub fn vf(&self) -> u32 {
21464        parse_u32(&self.buf[0usize..4usize]).unwrap()
21465    }
21466    pub fn set_vf(&mut self, value: u32) {
21467        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21468    }
21469    pub fn mac(&self) -> [u8; 32usize] {
21470        self.buf[4usize..36usize].try_into().unwrap()
21471    }
21472    pub fn set_mac(&mut self, value: [u8; 32usize]) {
21473        self.buf[4usize..36usize].copy_from_slice(&value)
21474    }
21475}
21476impl std::fmt::Debug for PushIflaVfMac {
21477    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21478        fmt.debug_struct("IflaVfMac")
21479            .field("vf", &self.vf())
21480            .field("mac", &self.mac())
21481            .finish()
21482    }
21483}
21484#[derive(Clone)]
21485pub struct PushIflaVfVlan {
21486    pub(crate) buf: [u8; 12usize],
21487}
21488#[doc = "Create zero-initialized struct"]
21489impl Default for PushIflaVfVlan {
21490    fn default() -> Self {
21491        Self {
21492            buf: [0u8; 12usize],
21493        }
21494    }
21495}
21496impl PushIflaVfVlan {
21497    #[doc = "Create zero-initialized struct"]
21498    pub fn new() -> Self {
21499        Default::default()
21500    }
21501    #[doc = "Copy from contents from other slice"]
21502    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21503        if other.len() != Self::len() {
21504            return None;
21505        }
21506        let mut buf = [0u8; Self::len()];
21507        buf.clone_from_slice(other);
21508        Some(Self { buf })
21509    }
21510    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21511    pub fn new_from_zeroed(other: &[u8]) -> Self {
21512        let mut buf = [0u8; Self::len()];
21513        let len = buf.len().min(other.len());
21514        buf[..len].clone_from_slice(&other[..len]);
21515        Self { buf }
21516    }
21517    pub fn as_slice(&self) -> &[u8] {
21518        &self.buf
21519    }
21520    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21521        &mut self.buf
21522    }
21523    pub const fn len() -> usize {
21524        12usize
21525    }
21526    pub fn vf(&self) -> u32 {
21527        parse_u32(&self.buf[0usize..4usize]).unwrap()
21528    }
21529    pub fn set_vf(&mut self, value: u32) {
21530        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21531    }
21532    pub fn vlan(&self) -> u32 {
21533        parse_u32(&self.buf[4usize..8usize]).unwrap()
21534    }
21535    pub fn set_vlan(&mut self, value: u32) {
21536        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21537    }
21538    pub fn qos(&self) -> u32 {
21539        parse_u32(&self.buf[8usize..12usize]).unwrap()
21540    }
21541    pub fn set_qos(&mut self, value: u32) {
21542        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
21543    }
21544}
21545impl std::fmt::Debug for PushIflaVfVlan {
21546    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21547        fmt.debug_struct("IflaVfVlan")
21548            .field("vf", &self.vf())
21549            .field("vlan", &self.vlan())
21550            .field("qos", &self.qos())
21551            .finish()
21552    }
21553}
21554#[derive(Clone)]
21555pub struct PushIflaVfTxRate {
21556    pub(crate) buf: [u8; 8usize],
21557}
21558#[doc = "Create zero-initialized struct"]
21559impl Default for PushIflaVfTxRate {
21560    fn default() -> Self {
21561        Self { buf: [0u8; 8usize] }
21562    }
21563}
21564impl PushIflaVfTxRate {
21565    #[doc = "Create zero-initialized struct"]
21566    pub fn new() -> Self {
21567        Default::default()
21568    }
21569    #[doc = "Copy from contents from other slice"]
21570    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21571        if other.len() != Self::len() {
21572            return None;
21573        }
21574        let mut buf = [0u8; Self::len()];
21575        buf.clone_from_slice(other);
21576        Some(Self { buf })
21577    }
21578    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21579    pub fn new_from_zeroed(other: &[u8]) -> Self {
21580        let mut buf = [0u8; Self::len()];
21581        let len = buf.len().min(other.len());
21582        buf[..len].clone_from_slice(&other[..len]);
21583        Self { buf }
21584    }
21585    pub fn as_slice(&self) -> &[u8] {
21586        &self.buf
21587    }
21588    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21589        &mut self.buf
21590    }
21591    pub const fn len() -> usize {
21592        8usize
21593    }
21594    pub fn vf(&self) -> u32 {
21595        parse_u32(&self.buf[0usize..4usize]).unwrap()
21596    }
21597    pub fn set_vf(&mut self, value: u32) {
21598        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21599    }
21600    pub fn rate(&self) -> u32 {
21601        parse_u32(&self.buf[4usize..8usize]).unwrap()
21602    }
21603    pub fn set_rate(&mut self, value: u32) {
21604        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21605    }
21606}
21607impl std::fmt::Debug for PushIflaVfTxRate {
21608    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21609        fmt.debug_struct("IflaVfTxRate")
21610            .field("vf", &self.vf())
21611            .field("rate", &self.rate())
21612            .finish()
21613    }
21614}
21615#[derive(Clone)]
21616pub struct PushIflaVfSpoofchk {
21617    pub(crate) buf: [u8; 8usize],
21618}
21619#[doc = "Create zero-initialized struct"]
21620impl Default for PushIflaVfSpoofchk {
21621    fn default() -> Self {
21622        Self { buf: [0u8; 8usize] }
21623    }
21624}
21625impl PushIflaVfSpoofchk {
21626    #[doc = "Create zero-initialized struct"]
21627    pub fn new() -> Self {
21628        Default::default()
21629    }
21630    #[doc = "Copy from contents from other slice"]
21631    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21632        if other.len() != Self::len() {
21633            return None;
21634        }
21635        let mut buf = [0u8; Self::len()];
21636        buf.clone_from_slice(other);
21637        Some(Self { buf })
21638    }
21639    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21640    pub fn new_from_zeroed(other: &[u8]) -> Self {
21641        let mut buf = [0u8; Self::len()];
21642        let len = buf.len().min(other.len());
21643        buf[..len].clone_from_slice(&other[..len]);
21644        Self { buf }
21645    }
21646    pub fn as_slice(&self) -> &[u8] {
21647        &self.buf
21648    }
21649    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21650        &mut self.buf
21651    }
21652    pub const fn len() -> usize {
21653        8usize
21654    }
21655    pub fn vf(&self) -> u32 {
21656        parse_u32(&self.buf[0usize..4usize]).unwrap()
21657    }
21658    pub fn set_vf(&mut self, value: u32) {
21659        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21660    }
21661    pub fn setting(&self) -> u32 {
21662        parse_u32(&self.buf[4usize..8usize]).unwrap()
21663    }
21664    pub fn set_setting(&mut self, value: u32) {
21665        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21666    }
21667}
21668impl std::fmt::Debug for PushIflaVfSpoofchk {
21669    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21670        fmt.debug_struct("IflaVfSpoofchk")
21671            .field("vf", &self.vf())
21672            .field("setting", &self.setting())
21673            .finish()
21674    }
21675}
21676#[derive(Clone)]
21677pub struct PushIflaVfLinkState {
21678    pub(crate) buf: [u8; 8usize],
21679}
21680#[doc = "Create zero-initialized struct"]
21681impl Default for PushIflaVfLinkState {
21682    fn default() -> Self {
21683        Self { buf: [0u8; 8usize] }
21684    }
21685}
21686impl PushIflaVfLinkState {
21687    #[doc = "Create zero-initialized struct"]
21688    pub fn new() -> Self {
21689        Default::default()
21690    }
21691    #[doc = "Copy from contents from other slice"]
21692    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21693        if other.len() != Self::len() {
21694            return None;
21695        }
21696        let mut buf = [0u8; Self::len()];
21697        buf.clone_from_slice(other);
21698        Some(Self { buf })
21699    }
21700    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21701    pub fn new_from_zeroed(other: &[u8]) -> Self {
21702        let mut buf = [0u8; Self::len()];
21703        let len = buf.len().min(other.len());
21704        buf[..len].clone_from_slice(&other[..len]);
21705        Self { buf }
21706    }
21707    pub fn as_slice(&self) -> &[u8] {
21708        &self.buf
21709    }
21710    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21711        &mut self.buf
21712    }
21713    pub const fn len() -> usize {
21714        8usize
21715    }
21716    pub fn vf(&self) -> u32 {
21717        parse_u32(&self.buf[0usize..4usize]).unwrap()
21718    }
21719    pub fn set_vf(&mut self, value: u32) {
21720        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21721    }
21722    #[doc = "Associated type: \"IflaVfLinkStateEnum\" (enum)"]
21723    pub fn link_state(&self) -> u32 {
21724        parse_u32(&self.buf[4usize..8usize]).unwrap()
21725    }
21726    #[doc = "Associated type: \"IflaVfLinkStateEnum\" (enum)"]
21727    pub fn set_link_state(&mut self, value: u32) {
21728        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21729    }
21730}
21731impl std::fmt::Debug for PushIflaVfLinkState {
21732    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21733        fmt.debug_struct("IflaVfLinkState")
21734            .field("vf", &self.vf())
21735            .field(
21736                "link_state",
21737                &FormatEnum(self.link_state().into(), IflaVfLinkStateEnum::from_value),
21738            )
21739            .finish()
21740    }
21741}
21742#[derive(Clone)]
21743pub struct PushIflaVfRate {
21744    pub(crate) buf: [u8; 12usize],
21745}
21746#[doc = "Create zero-initialized struct"]
21747impl Default for PushIflaVfRate {
21748    fn default() -> Self {
21749        Self {
21750            buf: [0u8; 12usize],
21751        }
21752    }
21753}
21754impl PushIflaVfRate {
21755    #[doc = "Create zero-initialized struct"]
21756    pub fn new() -> Self {
21757        Default::default()
21758    }
21759    #[doc = "Copy from contents from other slice"]
21760    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21761        if other.len() != Self::len() {
21762            return None;
21763        }
21764        let mut buf = [0u8; Self::len()];
21765        buf.clone_from_slice(other);
21766        Some(Self { buf })
21767    }
21768    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21769    pub fn new_from_zeroed(other: &[u8]) -> Self {
21770        let mut buf = [0u8; Self::len()];
21771        let len = buf.len().min(other.len());
21772        buf[..len].clone_from_slice(&other[..len]);
21773        Self { buf }
21774    }
21775    pub fn as_slice(&self) -> &[u8] {
21776        &self.buf
21777    }
21778    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21779        &mut self.buf
21780    }
21781    pub const fn len() -> usize {
21782        12usize
21783    }
21784    pub fn vf(&self) -> u32 {
21785        parse_u32(&self.buf[0usize..4usize]).unwrap()
21786    }
21787    pub fn set_vf(&mut self, value: u32) {
21788        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21789    }
21790    pub fn min_tx_rate(&self) -> u32 {
21791        parse_u32(&self.buf[4usize..8usize]).unwrap()
21792    }
21793    pub fn set_min_tx_rate(&mut self, value: u32) {
21794        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21795    }
21796    pub fn max_tx_rate(&self) -> u32 {
21797        parse_u32(&self.buf[8usize..12usize]).unwrap()
21798    }
21799    pub fn set_max_tx_rate(&mut self, value: u32) {
21800        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
21801    }
21802}
21803impl std::fmt::Debug for PushIflaVfRate {
21804    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21805        fmt.debug_struct("IflaVfRate")
21806            .field("vf", &self.vf())
21807            .field("min_tx_rate", &self.min_tx_rate())
21808            .field("max_tx_rate", &self.max_tx_rate())
21809            .finish()
21810    }
21811}
21812#[derive(Clone)]
21813pub struct PushIflaVfRssQueryEn {
21814    pub(crate) buf: [u8; 8usize],
21815}
21816#[doc = "Create zero-initialized struct"]
21817impl Default for PushIflaVfRssQueryEn {
21818    fn default() -> Self {
21819        Self { buf: [0u8; 8usize] }
21820    }
21821}
21822impl PushIflaVfRssQueryEn {
21823    #[doc = "Create zero-initialized struct"]
21824    pub fn new() -> Self {
21825        Default::default()
21826    }
21827    #[doc = "Copy from contents from other slice"]
21828    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21829        if other.len() != Self::len() {
21830            return None;
21831        }
21832        let mut buf = [0u8; Self::len()];
21833        buf.clone_from_slice(other);
21834        Some(Self { buf })
21835    }
21836    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21837    pub fn new_from_zeroed(other: &[u8]) -> Self {
21838        let mut buf = [0u8; Self::len()];
21839        let len = buf.len().min(other.len());
21840        buf[..len].clone_from_slice(&other[..len]);
21841        Self { buf }
21842    }
21843    pub fn as_slice(&self) -> &[u8] {
21844        &self.buf
21845    }
21846    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21847        &mut self.buf
21848    }
21849    pub const fn len() -> usize {
21850        8usize
21851    }
21852    pub fn vf(&self) -> u32 {
21853        parse_u32(&self.buf[0usize..4usize]).unwrap()
21854    }
21855    pub fn set_vf(&mut self, value: u32) {
21856        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21857    }
21858    pub fn setting(&self) -> u32 {
21859        parse_u32(&self.buf[4usize..8usize]).unwrap()
21860    }
21861    pub fn set_setting(&mut self, value: u32) {
21862        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21863    }
21864}
21865impl std::fmt::Debug for PushIflaVfRssQueryEn {
21866    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21867        fmt.debug_struct("IflaVfRssQueryEn")
21868            .field("vf", &self.vf())
21869            .field("setting", &self.setting())
21870            .finish()
21871    }
21872}
21873#[derive(Clone)]
21874pub struct PushIflaVfTrust {
21875    pub(crate) buf: [u8; 8usize],
21876}
21877#[doc = "Create zero-initialized struct"]
21878impl Default for PushIflaVfTrust {
21879    fn default() -> Self {
21880        Self { buf: [0u8; 8usize] }
21881    }
21882}
21883impl PushIflaVfTrust {
21884    #[doc = "Create zero-initialized struct"]
21885    pub fn new() -> Self {
21886        Default::default()
21887    }
21888    #[doc = "Copy from contents from other slice"]
21889    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21890        if other.len() != Self::len() {
21891            return None;
21892        }
21893        let mut buf = [0u8; Self::len()];
21894        buf.clone_from_slice(other);
21895        Some(Self { buf })
21896    }
21897    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21898    pub fn new_from_zeroed(other: &[u8]) -> Self {
21899        let mut buf = [0u8; Self::len()];
21900        let len = buf.len().min(other.len());
21901        buf[..len].clone_from_slice(&other[..len]);
21902        Self { buf }
21903    }
21904    pub fn as_slice(&self) -> &[u8] {
21905        &self.buf
21906    }
21907    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21908        &mut self.buf
21909    }
21910    pub const fn len() -> usize {
21911        8usize
21912    }
21913    pub fn vf(&self) -> u32 {
21914        parse_u32(&self.buf[0usize..4usize]).unwrap()
21915    }
21916    pub fn set_vf(&mut self, value: u32) {
21917        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21918    }
21919    pub fn setting(&self) -> u32 {
21920        parse_u32(&self.buf[4usize..8usize]).unwrap()
21921    }
21922    pub fn set_setting(&mut self, value: u32) {
21923        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21924    }
21925}
21926impl std::fmt::Debug for PushIflaVfTrust {
21927    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21928        fmt.debug_struct("IflaVfTrust")
21929            .field("vf", &self.vf())
21930            .field("setting", &self.setting())
21931            .finish()
21932    }
21933}
21934#[derive(Clone)]
21935pub struct PushIflaVfGuid {
21936    pub(crate) buf: [u8; 16usize],
21937}
21938#[doc = "Create zero-initialized struct"]
21939impl Default for PushIflaVfGuid {
21940    fn default() -> Self {
21941        Self {
21942            buf: [0u8; 16usize],
21943        }
21944    }
21945}
21946impl PushIflaVfGuid {
21947    #[doc = "Create zero-initialized struct"]
21948    pub fn new() -> Self {
21949        Default::default()
21950    }
21951    #[doc = "Copy from contents from other slice"]
21952    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21953        if other.len() != Self::len() {
21954            return None;
21955        }
21956        let mut buf = [0u8; Self::len()];
21957        buf.clone_from_slice(other);
21958        Some(Self { buf })
21959    }
21960    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
21961    pub fn new_from_zeroed(other: &[u8]) -> Self {
21962        let mut buf = [0u8; Self::len()];
21963        let len = buf.len().min(other.len());
21964        buf[..len].clone_from_slice(&other[..len]);
21965        Self { buf }
21966    }
21967    pub fn as_slice(&self) -> &[u8] {
21968        &self.buf
21969    }
21970    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21971        &mut self.buf
21972    }
21973    pub const fn len() -> usize {
21974        16usize
21975    }
21976    pub fn vf(&self) -> u32 {
21977        parse_u32(&self.buf[0usize..4usize]).unwrap()
21978    }
21979    pub fn set_vf(&mut self, value: u32) {
21980        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21981    }
21982    pub fn guid(&self) -> u64 {
21983        parse_u64(&self.buf[8usize..16usize]).unwrap()
21984    }
21985    pub fn set_guid(&mut self, value: u64) {
21986        self.buf[8usize..16usize].copy_from_slice(&value.to_ne_bytes())
21987    }
21988}
21989impl std::fmt::Debug for PushIflaVfGuid {
21990    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21991        fmt.debug_struct("IflaVfGuid")
21992            .field("vf", &self.vf())
21993            .field("guid", &self.guid())
21994            .finish()
21995    }
21996}
21997#[derive(Clone)]
21998pub struct PushIflaVfVlanInfo {
21999    pub(crate) buf: [u8; 16usize],
22000}
22001#[doc = "Create zero-initialized struct"]
22002impl Default for PushIflaVfVlanInfo {
22003    fn default() -> Self {
22004        Self {
22005            buf: [0u8; 16usize],
22006        }
22007    }
22008}
22009impl PushIflaVfVlanInfo {
22010    #[doc = "Create zero-initialized struct"]
22011    pub fn new() -> Self {
22012        Default::default()
22013    }
22014    #[doc = "Copy from contents from other slice"]
22015    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
22016        if other.len() != Self::len() {
22017            return None;
22018        }
22019        let mut buf = [0u8; Self::len()];
22020        buf.clone_from_slice(other);
22021        Some(Self { buf })
22022    }
22023    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
22024    pub fn new_from_zeroed(other: &[u8]) -> Self {
22025        let mut buf = [0u8; Self::len()];
22026        let len = buf.len().min(other.len());
22027        buf[..len].clone_from_slice(&other[..len]);
22028        Self { buf }
22029    }
22030    pub fn as_slice(&self) -> &[u8] {
22031        &self.buf
22032    }
22033    pub fn as_mut_slice(&mut self) -> &mut [u8] {
22034        &mut self.buf
22035    }
22036    pub const fn len() -> usize {
22037        16usize
22038    }
22039    pub fn vf(&self) -> u32 {
22040        parse_u32(&self.buf[0usize..4usize]).unwrap()
22041    }
22042    pub fn set_vf(&mut self, value: u32) {
22043        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
22044    }
22045    pub fn vlan(&self) -> u32 {
22046        parse_u32(&self.buf[4usize..8usize]).unwrap()
22047    }
22048    pub fn set_vlan(&mut self, value: u32) {
22049        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
22050    }
22051    pub fn qos(&self) -> u32 {
22052        parse_u32(&self.buf[8usize..12usize]).unwrap()
22053    }
22054    pub fn set_qos(&mut self, value: u32) {
22055        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
22056    }
22057    pub fn vlan_proto(&self) -> u32 {
22058        parse_u32(&self.buf[12usize..16usize]).unwrap()
22059    }
22060    pub fn set_vlan_proto(&mut self, value: u32) {
22061        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
22062    }
22063}
22064impl std::fmt::Debug for PushIflaVfVlanInfo {
22065    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22066        fmt.debug_struct("IflaVfVlanInfo")
22067            .field("vf", &self.vf())
22068            .field("vlan", &self.vlan())
22069            .field("qos", &self.qos())
22070            .field("vlan_proto", &self.vlan_proto())
22071            .finish()
22072    }
22073}
22074#[doc = "Create a new link."]
22075pub struct PushOpNewlinkDoRequest<Prev: Rec> {
22076    pub(crate) prev: Option<Prev>,
22077    pub(crate) header_offset: Option<usize>,
22078}
22079impl<Prev: Rec> Rec for PushOpNewlinkDoRequest<Prev> {
22080    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
22081        self.prev.as_mut().unwrap().as_rec_mut()
22082    }
22083    fn as_rec(&self) -> &Vec<u8> {
22084        self.prev.as_ref().unwrap().as_rec()
22085    }
22086}
22087impl<Prev: Rec> PushOpNewlinkDoRequest<Prev> {
22088    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
22089        Self::write_header(&mut prev, header);
22090        Self::new_without_header(prev)
22091    }
22092    fn new_without_header(prev: Prev) -> Self {
22093        Self {
22094            prev: Some(prev),
22095            header_offset: None,
22096        }
22097    }
22098    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
22099        prev.as_rec_mut().extend(header.as_slice());
22100    }
22101    pub fn end_nested(mut self) -> Prev {
22102        let mut prev = self.prev.take().unwrap();
22103        if let Some(header_offset) = &self.header_offset {
22104            finalize_nested_header(prev.as_rec_mut(), *header_offset);
22105        }
22106        prev
22107    }
22108    pub fn push_address(mut self, value: &[u8]) -> Self {
22109        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
22110        self.as_rec_mut().extend(value);
22111        self
22112    }
22113    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
22114        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
22115        self.as_rec_mut().extend(value);
22116        self
22117    }
22118    pub fn push_ifname(mut self, value: &CStr) -> Self {
22119        push_header(
22120            self.as_rec_mut(),
22121            3u16,
22122            value.to_bytes_with_nul().len() as u16,
22123        );
22124        self.as_rec_mut().extend(value.to_bytes_with_nul());
22125        self
22126    }
22127    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
22128        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
22129        self.as_rec_mut().extend(value);
22130        self.as_rec_mut().push(0);
22131        self
22132    }
22133    pub fn push_mtu(mut self, value: u32) -> Self {
22134        push_header(self.as_rec_mut(), 4u16, 4 as u16);
22135        self.as_rec_mut().extend(value.to_ne_bytes());
22136        self
22137    }
22138    pub fn push_txqlen(mut self, value: u32) -> Self {
22139        push_header(self.as_rec_mut(), 13u16, 4 as u16);
22140        self.as_rec_mut().extend(value.to_ne_bytes());
22141        self
22142    }
22143    pub fn push_operstate(mut self, value: u8) -> Self {
22144        push_header(self.as_rec_mut(), 16u16, 1 as u16);
22145        self.as_rec_mut().extend(value.to_ne_bytes());
22146        self
22147    }
22148    pub fn push_linkmode(mut self, value: u8) -> Self {
22149        push_header(self.as_rec_mut(), 17u16, 1 as u16);
22150        self.as_rec_mut().extend(value.to_ne_bytes());
22151        self
22152    }
22153    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
22154        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
22155        PushLinkinfoAttrs {
22156            prev: Some(self),
22157            header_offset: Some(header_offset),
22158        }
22159    }
22160    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
22161        push_header(self.as_rec_mut(), 19u16, 4 as u16);
22162        self.as_rec_mut().extend(value.to_ne_bytes());
22163        self
22164    }
22165    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
22166        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
22167        PushAfSpecAttrs {
22168            prev: Some(self),
22169            header_offset: Some(header_offset),
22170        }
22171    }
22172    pub fn push_group(mut self, value: u32) -> Self {
22173        push_header(self.as_rec_mut(), 27u16, 4 as u16);
22174        self.as_rec_mut().extend(value.to_ne_bytes());
22175        self
22176    }
22177    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
22178        push_header(self.as_rec_mut(), 28u16, 4 as u16);
22179        self.as_rec_mut().extend(value.to_ne_bytes());
22180        self
22181    }
22182    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
22183        push_header(self.as_rec_mut(), 31u16, 4 as u16);
22184        self.as_rec_mut().extend(value.to_ne_bytes());
22185        self
22186    }
22187    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
22188        push_header(self.as_rec_mut(), 32u16, 4 as u16);
22189        self.as_rec_mut().extend(value.to_ne_bytes());
22190        self
22191    }
22192    pub fn push_link_netnsid(mut self, value: i32) -> Self {
22193        push_header(self.as_rec_mut(), 37u16, 4 as u16);
22194        self.as_rec_mut().extend(value.to_ne_bytes());
22195        self
22196    }
22197    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
22198        push_header(self.as_rec_mut(), 40u16, 4 as u16);
22199        self.as_rec_mut().extend(value.to_ne_bytes());
22200        self
22201    }
22202    pub fn push_gso_max_size(mut self, value: u32) -> Self {
22203        push_header(self.as_rec_mut(), 41u16, 4 as u16);
22204        self.as_rec_mut().extend(value.to_ne_bytes());
22205        self
22206    }
22207    pub fn push_target_netnsid(mut self, value: i32) -> Self {
22208        push_header(self.as_rec_mut(), 46u16, 4 as u16);
22209        self.as_rec_mut().extend(value.to_ne_bytes());
22210        self
22211    }
22212    pub fn push_gro_max_size(mut self, value: u32) -> Self {
22213        push_header(self.as_rec_mut(), 58u16, 4 as u16);
22214        self.as_rec_mut().extend(value.to_ne_bytes());
22215        self
22216    }
22217    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
22218        push_header(self.as_rec_mut(), 63u16, 4 as u16);
22219        self.as_rec_mut().extend(value.to_ne_bytes());
22220        self
22221    }
22222    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
22223        push_header(self.as_rec_mut(), 64u16, 4 as u16);
22224        self.as_rec_mut().extend(value.to_ne_bytes());
22225        self
22226    }
22227}
22228impl<Prev: Rec> Drop for PushOpNewlinkDoRequest<Prev> {
22229    fn drop(&mut self) {
22230        if let Some(prev) = &mut self.prev {
22231            if let Some(header_offset) = &self.header_offset {
22232                finalize_nested_header(prev.as_rec_mut(), *header_offset);
22233            }
22234        }
22235    }
22236}
22237#[doc = "Create a new link."]
22238#[derive(Clone)]
22239pub enum OpNewlinkDoRequest<'a> {
22240    Address(&'a [u8]),
22241    Broadcast(&'a [u8]),
22242    Ifname(&'a CStr),
22243    Mtu(u32),
22244    Txqlen(u32),
22245    Operstate(u8),
22246    Linkmode(u8),
22247    Linkinfo(IterableLinkinfoAttrs<'a>),
22248    NetNsPid(u32),
22249    AfSpec(IterableAfSpecAttrs<'a>),
22250    Group(u32),
22251    NetNsFd(u32),
22252    NumTxQueues(u32),
22253    NumRxQueues(u32),
22254    LinkNetnsid(i32),
22255    GsoMaxSegs(u32),
22256    GsoMaxSize(u32),
22257    TargetNetnsid(i32),
22258    GroMaxSize(u32),
22259    GsoIpv4MaxSize(u32),
22260    GroIpv4MaxSize(u32),
22261}
22262impl<'a> IterableOpNewlinkDoRequest<'a> {
22263    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
22264        let mut iter = self.clone();
22265        iter.pos = 0;
22266        for attr in iter {
22267            if let OpNewlinkDoRequest::Address(val) = attr? {
22268                return Ok(val);
22269            }
22270        }
22271        Err(ErrorContext::new_missing(
22272            "OpNewlinkDoRequest",
22273            "Address",
22274            self.orig_loc,
22275            self.buf.as_ptr() as usize,
22276        ))
22277    }
22278    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
22279        let mut iter = self.clone();
22280        iter.pos = 0;
22281        for attr in iter {
22282            if let OpNewlinkDoRequest::Broadcast(val) = attr? {
22283                return Ok(val);
22284            }
22285        }
22286        Err(ErrorContext::new_missing(
22287            "OpNewlinkDoRequest",
22288            "Broadcast",
22289            self.orig_loc,
22290            self.buf.as_ptr() as usize,
22291        ))
22292    }
22293    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
22294        let mut iter = self.clone();
22295        iter.pos = 0;
22296        for attr in iter {
22297            if let OpNewlinkDoRequest::Ifname(val) = attr? {
22298                return Ok(val);
22299            }
22300        }
22301        Err(ErrorContext::new_missing(
22302            "OpNewlinkDoRequest",
22303            "Ifname",
22304            self.orig_loc,
22305            self.buf.as_ptr() as usize,
22306        ))
22307    }
22308    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
22309        let mut iter = self.clone();
22310        iter.pos = 0;
22311        for attr in iter {
22312            if let OpNewlinkDoRequest::Mtu(val) = attr? {
22313                return Ok(val);
22314            }
22315        }
22316        Err(ErrorContext::new_missing(
22317            "OpNewlinkDoRequest",
22318            "Mtu",
22319            self.orig_loc,
22320            self.buf.as_ptr() as usize,
22321        ))
22322    }
22323    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
22324        let mut iter = self.clone();
22325        iter.pos = 0;
22326        for attr in iter {
22327            if let OpNewlinkDoRequest::Txqlen(val) = attr? {
22328                return Ok(val);
22329            }
22330        }
22331        Err(ErrorContext::new_missing(
22332            "OpNewlinkDoRequest",
22333            "Txqlen",
22334            self.orig_loc,
22335            self.buf.as_ptr() as usize,
22336        ))
22337    }
22338    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
22339        let mut iter = self.clone();
22340        iter.pos = 0;
22341        for attr in iter {
22342            if let OpNewlinkDoRequest::Operstate(val) = attr? {
22343                return Ok(val);
22344            }
22345        }
22346        Err(ErrorContext::new_missing(
22347            "OpNewlinkDoRequest",
22348            "Operstate",
22349            self.orig_loc,
22350            self.buf.as_ptr() as usize,
22351        ))
22352    }
22353    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
22354        let mut iter = self.clone();
22355        iter.pos = 0;
22356        for attr in iter {
22357            if let OpNewlinkDoRequest::Linkmode(val) = attr? {
22358                return Ok(val);
22359            }
22360        }
22361        Err(ErrorContext::new_missing(
22362            "OpNewlinkDoRequest",
22363            "Linkmode",
22364            self.orig_loc,
22365            self.buf.as_ptr() as usize,
22366        ))
22367    }
22368    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
22369        let mut iter = self.clone();
22370        iter.pos = 0;
22371        for attr in iter {
22372            if let OpNewlinkDoRequest::Linkinfo(val) = attr? {
22373                return Ok(val);
22374            }
22375        }
22376        Err(ErrorContext::new_missing(
22377            "OpNewlinkDoRequest",
22378            "Linkinfo",
22379            self.orig_loc,
22380            self.buf.as_ptr() as usize,
22381        ))
22382    }
22383    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
22384        let mut iter = self.clone();
22385        iter.pos = 0;
22386        for attr in iter {
22387            if let OpNewlinkDoRequest::NetNsPid(val) = attr? {
22388                return Ok(val);
22389            }
22390        }
22391        Err(ErrorContext::new_missing(
22392            "OpNewlinkDoRequest",
22393            "NetNsPid",
22394            self.orig_loc,
22395            self.buf.as_ptr() as usize,
22396        ))
22397    }
22398    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
22399        let mut iter = self.clone();
22400        iter.pos = 0;
22401        for attr in iter {
22402            if let OpNewlinkDoRequest::AfSpec(val) = attr? {
22403                return Ok(val);
22404            }
22405        }
22406        Err(ErrorContext::new_missing(
22407            "OpNewlinkDoRequest",
22408            "AfSpec",
22409            self.orig_loc,
22410            self.buf.as_ptr() as usize,
22411        ))
22412    }
22413    pub fn get_group(&self) -> Result<u32, ErrorContext> {
22414        let mut iter = self.clone();
22415        iter.pos = 0;
22416        for attr in iter {
22417            if let OpNewlinkDoRequest::Group(val) = attr? {
22418                return Ok(val);
22419            }
22420        }
22421        Err(ErrorContext::new_missing(
22422            "OpNewlinkDoRequest",
22423            "Group",
22424            self.orig_loc,
22425            self.buf.as_ptr() as usize,
22426        ))
22427    }
22428    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
22429        let mut iter = self.clone();
22430        iter.pos = 0;
22431        for attr in iter {
22432            if let OpNewlinkDoRequest::NetNsFd(val) = attr? {
22433                return Ok(val);
22434            }
22435        }
22436        Err(ErrorContext::new_missing(
22437            "OpNewlinkDoRequest",
22438            "NetNsFd",
22439            self.orig_loc,
22440            self.buf.as_ptr() as usize,
22441        ))
22442    }
22443    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
22444        let mut iter = self.clone();
22445        iter.pos = 0;
22446        for attr in iter {
22447            if let OpNewlinkDoRequest::NumTxQueues(val) = attr? {
22448                return Ok(val);
22449            }
22450        }
22451        Err(ErrorContext::new_missing(
22452            "OpNewlinkDoRequest",
22453            "NumTxQueues",
22454            self.orig_loc,
22455            self.buf.as_ptr() as usize,
22456        ))
22457    }
22458    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
22459        let mut iter = self.clone();
22460        iter.pos = 0;
22461        for attr in iter {
22462            if let OpNewlinkDoRequest::NumRxQueues(val) = attr? {
22463                return Ok(val);
22464            }
22465        }
22466        Err(ErrorContext::new_missing(
22467            "OpNewlinkDoRequest",
22468            "NumRxQueues",
22469            self.orig_loc,
22470            self.buf.as_ptr() as usize,
22471        ))
22472    }
22473    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
22474        let mut iter = self.clone();
22475        iter.pos = 0;
22476        for attr in iter {
22477            if let OpNewlinkDoRequest::LinkNetnsid(val) = attr? {
22478                return Ok(val);
22479            }
22480        }
22481        Err(ErrorContext::new_missing(
22482            "OpNewlinkDoRequest",
22483            "LinkNetnsid",
22484            self.orig_loc,
22485            self.buf.as_ptr() as usize,
22486        ))
22487    }
22488    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
22489        let mut iter = self.clone();
22490        iter.pos = 0;
22491        for attr in iter {
22492            if let OpNewlinkDoRequest::GsoMaxSegs(val) = attr? {
22493                return Ok(val);
22494            }
22495        }
22496        Err(ErrorContext::new_missing(
22497            "OpNewlinkDoRequest",
22498            "GsoMaxSegs",
22499            self.orig_loc,
22500            self.buf.as_ptr() as usize,
22501        ))
22502    }
22503    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
22504        let mut iter = self.clone();
22505        iter.pos = 0;
22506        for attr in iter {
22507            if let OpNewlinkDoRequest::GsoMaxSize(val) = attr? {
22508                return Ok(val);
22509            }
22510        }
22511        Err(ErrorContext::new_missing(
22512            "OpNewlinkDoRequest",
22513            "GsoMaxSize",
22514            self.orig_loc,
22515            self.buf.as_ptr() as usize,
22516        ))
22517    }
22518    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
22519        let mut iter = self.clone();
22520        iter.pos = 0;
22521        for attr in iter {
22522            if let OpNewlinkDoRequest::TargetNetnsid(val) = attr? {
22523                return Ok(val);
22524            }
22525        }
22526        Err(ErrorContext::new_missing(
22527            "OpNewlinkDoRequest",
22528            "TargetNetnsid",
22529            self.orig_loc,
22530            self.buf.as_ptr() as usize,
22531        ))
22532    }
22533    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
22534        let mut iter = self.clone();
22535        iter.pos = 0;
22536        for attr in iter {
22537            if let OpNewlinkDoRequest::GroMaxSize(val) = attr? {
22538                return Ok(val);
22539            }
22540        }
22541        Err(ErrorContext::new_missing(
22542            "OpNewlinkDoRequest",
22543            "GroMaxSize",
22544            self.orig_loc,
22545            self.buf.as_ptr() as usize,
22546        ))
22547    }
22548    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
22549        let mut iter = self.clone();
22550        iter.pos = 0;
22551        for attr in iter {
22552            if let OpNewlinkDoRequest::GsoIpv4MaxSize(val) = attr? {
22553                return Ok(val);
22554            }
22555        }
22556        Err(ErrorContext::new_missing(
22557            "OpNewlinkDoRequest",
22558            "GsoIpv4MaxSize",
22559            self.orig_loc,
22560            self.buf.as_ptr() as usize,
22561        ))
22562    }
22563    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
22564        let mut iter = self.clone();
22565        iter.pos = 0;
22566        for attr in iter {
22567            if let OpNewlinkDoRequest::GroIpv4MaxSize(val) = attr? {
22568                return Ok(val);
22569            }
22570        }
22571        Err(ErrorContext::new_missing(
22572            "OpNewlinkDoRequest",
22573            "GroIpv4MaxSize",
22574            self.orig_loc,
22575            self.buf.as_ptr() as usize,
22576        ))
22577    }
22578}
22579impl OpNewlinkDoRequest<'_> {
22580    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpNewlinkDoRequest<'a>) {
22581        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
22582        (
22583            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
22584            IterableOpNewlinkDoRequest::with_loc(attrs, buf.as_ptr() as usize),
22585        )
22586    }
22587    fn attr_from_type(r#type: u16) -> Option<&'static str> {
22588        LinkAttrs::attr_from_type(r#type)
22589    }
22590}
22591#[derive(Clone, Copy, Default)]
22592pub struct IterableOpNewlinkDoRequest<'a> {
22593    buf: &'a [u8],
22594    pos: usize,
22595    orig_loc: usize,
22596}
22597impl<'a> IterableOpNewlinkDoRequest<'a> {
22598    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
22599        Self {
22600            buf,
22601            pos: 0,
22602            orig_loc,
22603        }
22604    }
22605    pub fn get_buf(&self) -> &'a [u8] {
22606        self.buf
22607    }
22608}
22609impl<'a> Iterator for IterableOpNewlinkDoRequest<'a> {
22610    type Item = Result<OpNewlinkDoRequest<'a>, ErrorContext>;
22611    fn next(&mut self) -> Option<Self::Item> {
22612        let pos = self.pos;
22613        let mut r#type;
22614        loop {
22615            r#type = None;
22616            if self.buf.len() == self.pos {
22617                return None;
22618            }
22619            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
22620                break;
22621            };
22622            r#type = Some(header.r#type);
22623            let res = match header.r#type {
22624                1u16 => OpNewlinkDoRequest::Address({
22625                    let res = Some(next);
22626                    let Some(val) = res else { break };
22627                    val
22628                }),
22629                2u16 => OpNewlinkDoRequest::Broadcast({
22630                    let res = Some(next);
22631                    let Some(val) = res else { break };
22632                    val
22633                }),
22634                3u16 => OpNewlinkDoRequest::Ifname({
22635                    let res = CStr::from_bytes_with_nul(next).ok();
22636                    let Some(val) = res else { break };
22637                    val
22638                }),
22639                4u16 => OpNewlinkDoRequest::Mtu({
22640                    let res = parse_u32(next);
22641                    let Some(val) = res else { break };
22642                    val
22643                }),
22644                13u16 => OpNewlinkDoRequest::Txqlen({
22645                    let res = parse_u32(next);
22646                    let Some(val) = res else { break };
22647                    val
22648                }),
22649                16u16 => OpNewlinkDoRequest::Operstate({
22650                    let res = parse_u8(next);
22651                    let Some(val) = res else { break };
22652                    val
22653                }),
22654                17u16 => OpNewlinkDoRequest::Linkmode({
22655                    let res = parse_u8(next);
22656                    let Some(val) = res else { break };
22657                    val
22658                }),
22659                18u16 => OpNewlinkDoRequest::Linkinfo({
22660                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
22661                    let Some(val) = res else { break };
22662                    val
22663                }),
22664                19u16 => OpNewlinkDoRequest::NetNsPid({
22665                    let res = parse_u32(next);
22666                    let Some(val) = res else { break };
22667                    val
22668                }),
22669                26u16 => OpNewlinkDoRequest::AfSpec({
22670                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
22671                    let Some(val) = res else { break };
22672                    val
22673                }),
22674                27u16 => OpNewlinkDoRequest::Group({
22675                    let res = parse_u32(next);
22676                    let Some(val) = res else { break };
22677                    val
22678                }),
22679                28u16 => OpNewlinkDoRequest::NetNsFd({
22680                    let res = parse_u32(next);
22681                    let Some(val) = res else { break };
22682                    val
22683                }),
22684                31u16 => OpNewlinkDoRequest::NumTxQueues({
22685                    let res = parse_u32(next);
22686                    let Some(val) = res else { break };
22687                    val
22688                }),
22689                32u16 => OpNewlinkDoRequest::NumRxQueues({
22690                    let res = parse_u32(next);
22691                    let Some(val) = res else { break };
22692                    val
22693                }),
22694                37u16 => OpNewlinkDoRequest::LinkNetnsid({
22695                    let res = parse_i32(next);
22696                    let Some(val) = res else { break };
22697                    val
22698                }),
22699                40u16 => OpNewlinkDoRequest::GsoMaxSegs({
22700                    let res = parse_u32(next);
22701                    let Some(val) = res else { break };
22702                    val
22703                }),
22704                41u16 => OpNewlinkDoRequest::GsoMaxSize({
22705                    let res = parse_u32(next);
22706                    let Some(val) = res else { break };
22707                    val
22708                }),
22709                46u16 => OpNewlinkDoRequest::TargetNetnsid({
22710                    let res = parse_i32(next);
22711                    let Some(val) = res else { break };
22712                    val
22713                }),
22714                58u16 => OpNewlinkDoRequest::GroMaxSize({
22715                    let res = parse_u32(next);
22716                    let Some(val) = res else { break };
22717                    val
22718                }),
22719                63u16 => OpNewlinkDoRequest::GsoIpv4MaxSize({
22720                    let res = parse_u32(next);
22721                    let Some(val) = res else { break };
22722                    val
22723                }),
22724                64u16 => OpNewlinkDoRequest::GroIpv4MaxSize({
22725                    let res = parse_u32(next);
22726                    let Some(val) = res else { break };
22727                    val
22728                }),
22729                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
22730                n => continue,
22731            };
22732            return Some(Ok(res));
22733        }
22734        Some(Err(ErrorContext::new(
22735            "OpNewlinkDoRequest",
22736            r#type.and_then(|t| OpNewlinkDoRequest::attr_from_type(t)),
22737            self.orig_loc,
22738            self.buf.as_ptr().wrapping_add(pos) as usize,
22739        )))
22740    }
22741}
22742impl<'a> std::fmt::Debug for IterableOpNewlinkDoRequest<'_> {
22743    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22744        let mut fmt = f.debug_struct("OpNewlinkDoRequest");
22745        for attr in self.clone() {
22746            let attr = match attr {
22747                Ok(a) => a,
22748                Err(err) => {
22749                    fmt.finish()?;
22750                    f.write_str("Err(")?;
22751                    err.fmt(f)?;
22752                    return f.write_str(")");
22753                }
22754            };
22755            match attr {
22756                OpNewlinkDoRequest::Address(val) => fmt.field("Address", &val),
22757                OpNewlinkDoRequest::Broadcast(val) => fmt.field("Broadcast", &val),
22758                OpNewlinkDoRequest::Ifname(val) => fmt.field("Ifname", &val),
22759                OpNewlinkDoRequest::Mtu(val) => fmt.field("Mtu", &val),
22760                OpNewlinkDoRequest::Txqlen(val) => fmt.field("Txqlen", &val),
22761                OpNewlinkDoRequest::Operstate(val) => fmt.field("Operstate", &val),
22762                OpNewlinkDoRequest::Linkmode(val) => fmt.field("Linkmode", &val),
22763                OpNewlinkDoRequest::Linkinfo(val) => fmt.field("Linkinfo", &val),
22764                OpNewlinkDoRequest::NetNsPid(val) => fmt.field("NetNsPid", &val),
22765                OpNewlinkDoRequest::AfSpec(val) => fmt.field("AfSpec", &val),
22766                OpNewlinkDoRequest::Group(val) => fmt.field("Group", &val),
22767                OpNewlinkDoRequest::NetNsFd(val) => fmt.field("NetNsFd", &val),
22768                OpNewlinkDoRequest::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
22769                OpNewlinkDoRequest::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
22770                OpNewlinkDoRequest::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
22771                OpNewlinkDoRequest::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
22772                OpNewlinkDoRequest::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
22773                OpNewlinkDoRequest::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
22774                OpNewlinkDoRequest::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
22775                OpNewlinkDoRequest::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
22776                OpNewlinkDoRequest::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
22777            };
22778        }
22779        fmt.finish()
22780    }
22781}
22782impl IterableOpNewlinkDoRequest<'_> {
22783    pub fn lookup_attr(
22784        &self,
22785        offset: usize,
22786        missing_type: Option<u16>,
22787    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
22788        let mut stack = Vec::new();
22789        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
22790        if cur == offset + PushIfinfomsg::len() {
22791            stack.push(("OpNewlinkDoRequest", offset));
22792            return (
22793                stack,
22794                missing_type.and_then(|t| OpNewlinkDoRequest::attr_from_type(t)),
22795            );
22796        }
22797        if cur > offset || cur + self.buf.len() < offset {
22798            return (stack, None);
22799        }
22800        let mut attrs = self.clone();
22801        let mut last_off = cur + attrs.pos;
22802        let mut missing = None;
22803        while let Some(attr) = attrs.next() {
22804            let Ok(attr) = attr else { break };
22805            match attr {
22806                OpNewlinkDoRequest::Address(val) => {
22807                    if last_off == offset {
22808                        stack.push(("Address", last_off));
22809                        break;
22810                    }
22811                }
22812                OpNewlinkDoRequest::Broadcast(val) => {
22813                    if last_off == offset {
22814                        stack.push(("Broadcast", last_off));
22815                        break;
22816                    }
22817                }
22818                OpNewlinkDoRequest::Ifname(val) => {
22819                    if last_off == offset {
22820                        stack.push(("Ifname", last_off));
22821                        break;
22822                    }
22823                }
22824                OpNewlinkDoRequest::Mtu(val) => {
22825                    if last_off == offset {
22826                        stack.push(("Mtu", last_off));
22827                        break;
22828                    }
22829                }
22830                OpNewlinkDoRequest::Txqlen(val) => {
22831                    if last_off == offset {
22832                        stack.push(("Txqlen", last_off));
22833                        break;
22834                    }
22835                }
22836                OpNewlinkDoRequest::Operstate(val) => {
22837                    if last_off == offset {
22838                        stack.push(("Operstate", last_off));
22839                        break;
22840                    }
22841                }
22842                OpNewlinkDoRequest::Linkmode(val) => {
22843                    if last_off == offset {
22844                        stack.push(("Linkmode", last_off));
22845                        break;
22846                    }
22847                }
22848                OpNewlinkDoRequest::Linkinfo(val) => {
22849                    (stack, missing) = val.lookup_attr(offset, missing_type);
22850                    if !stack.is_empty() {
22851                        break;
22852                    }
22853                }
22854                OpNewlinkDoRequest::NetNsPid(val) => {
22855                    if last_off == offset {
22856                        stack.push(("NetNsPid", last_off));
22857                        break;
22858                    }
22859                }
22860                OpNewlinkDoRequest::AfSpec(val) => {
22861                    (stack, missing) = val.lookup_attr(offset, missing_type);
22862                    if !stack.is_empty() {
22863                        break;
22864                    }
22865                }
22866                OpNewlinkDoRequest::Group(val) => {
22867                    if last_off == offset {
22868                        stack.push(("Group", last_off));
22869                        break;
22870                    }
22871                }
22872                OpNewlinkDoRequest::NetNsFd(val) => {
22873                    if last_off == offset {
22874                        stack.push(("NetNsFd", last_off));
22875                        break;
22876                    }
22877                }
22878                OpNewlinkDoRequest::NumTxQueues(val) => {
22879                    if last_off == offset {
22880                        stack.push(("NumTxQueues", last_off));
22881                        break;
22882                    }
22883                }
22884                OpNewlinkDoRequest::NumRxQueues(val) => {
22885                    if last_off == offset {
22886                        stack.push(("NumRxQueues", last_off));
22887                        break;
22888                    }
22889                }
22890                OpNewlinkDoRequest::LinkNetnsid(val) => {
22891                    if last_off == offset {
22892                        stack.push(("LinkNetnsid", last_off));
22893                        break;
22894                    }
22895                }
22896                OpNewlinkDoRequest::GsoMaxSegs(val) => {
22897                    if last_off == offset {
22898                        stack.push(("GsoMaxSegs", last_off));
22899                        break;
22900                    }
22901                }
22902                OpNewlinkDoRequest::GsoMaxSize(val) => {
22903                    if last_off == offset {
22904                        stack.push(("GsoMaxSize", last_off));
22905                        break;
22906                    }
22907                }
22908                OpNewlinkDoRequest::TargetNetnsid(val) => {
22909                    if last_off == offset {
22910                        stack.push(("TargetNetnsid", last_off));
22911                        break;
22912                    }
22913                }
22914                OpNewlinkDoRequest::GroMaxSize(val) => {
22915                    if last_off == offset {
22916                        stack.push(("GroMaxSize", last_off));
22917                        break;
22918                    }
22919                }
22920                OpNewlinkDoRequest::GsoIpv4MaxSize(val) => {
22921                    if last_off == offset {
22922                        stack.push(("GsoIpv4MaxSize", last_off));
22923                        break;
22924                    }
22925                }
22926                OpNewlinkDoRequest::GroIpv4MaxSize(val) => {
22927                    if last_off == offset {
22928                        stack.push(("GroIpv4MaxSize", last_off));
22929                        break;
22930                    }
22931                }
22932                _ => {}
22933            };
22934            last_off = cur + attrs.pos;
22935        }
22936        if !stack.is_empty() {
22937            stack.push(("OpNewlinkDoRequest", cur));
22938        }
22939        (stack, missing)
22940    }
22941}
22942#[doc = "Create a new link."]
22943pub struct PushOpNewlinkDoReply<Prev: Rec> {
22944    pub(crate) prev: Option<Prev>,
22945    pub(crate) header_offset: Option<usize>,
22946}
22947impl<Prev: Rec> Rec for PushOpNewlinkDoReply<Prev> {
22948    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
22949        self.prev.as_mut().unwrap().as_rec_mut()
22950    }
22951    fn as_rec(&self) -> &Vec<u8> {
22952        self.prev.as_ref().unwrap().as_rec()
22953    }
22954}
22955impl<Prev: Rec> PushOpNewlinkDoReply<Prev> {
22956    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
22957        Self::write_header(&mut prev, header);
22958        Self::new_without_header(prev)
22959    }
22960    fn new_without_header(prev: Prev) -> Self {
22961        Self {
22962            prev: Some(prev),
22963            header_offset: None,
22964        }
22965    }
22966    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
22967        prev.as_rec_mut().extend(header.as_slice());
22968    }
22969    pub fn end_nested(mut self) -> Prev {
22970        let mut prev = self.prev.take().unwrap();
22971        if let Some(header_offset) = &self.header_offset {
22972            finalize_nested_header(prev.as_rec_mut(), *header_offset);
22973        }
22974        prev
22975    }
22976}
22977impl<Prev: Rec> Drop for PushOpNewlinkDoReply<Prev> {
22978    fn drop(&mut self) {
22979        if let Some(prev) = &mut self.prev {
22980            if let Some(header_offset) = &self.header_offset {
22981                finalize_nested_header(prev.as_rec_mut(), *header_offset);
22982            }
22983        }
22984    }
22985}
22986#[doc = "Create a new link."]
22987#[derive(Clone)]
22988pub enum OpNewlinkDoReply {}
22989impl<'a> IterableOpNewlinkDoReply<'a> {}
22990impl OpNewlinkDoReply {
22991    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpNewlinkDoReply<'a>) {
22992        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
22993        (
22994            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
22995            IterableOpNewlinkDoReply::with_loc(attrs, buf.as_ptr() as usize),
22996        )
22997    }
22998    fn attr_from_type(r#type: u16) -> Option<&'static str> {
22999        LinkAttrs::attr_from_type(r#type)
23000    }
23001}
23002#[derive(Clone, Copy, Default)]
23003pub struct IterableOpNewlinkDoReply<'a> {
23004    buf: &'a [u8],
23005    pos: usize,
23006    orig_loc: usize,
23007}
23008impl<'a> IterableOpNewlinkDoReply<'a> {
23009    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23010        Self {
23011            buf,
23012            pos: 0,
23013            orig_loc,
23014        }
23015    }
23016    pub fn get_buf(&self) -> &'a [u8] {
23017        self.buf
23018    }
23019}
23020impl<'a> Iterator for IterableOpNewlinkDoReply<'a> {
23021    type Item = Result<OpNewlinkDoReply, ErrorContext>;
23022    fn next(&mut self) -> Option<Self::Item> {
23023        let pos = self.pos;
23024        let mut r#type;
23025        loop {
23026            r#type = None;
23027            if self.buf.len() == self.pos {
23028                return None;
23029            }
23030            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
23031                break;
23032            };
23033            r#type = Some(header.r#type);
23034            let res = match header.r#type {
23035                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
23036                n => continue,
23037            };
23038            return Some(Ok(res));
23039        }
23040        Some(Err(ErrorContext::new(
23041            "OpNewlinkDoReply",
23042            r#type.and_then(|t| OpNewlinkDoReply::attr_from_type(t)),
23043            self.orig_loc,
23044            self.buf.as_ptr().wrapping_add(pos) as usize,
23045        )))
23046    }
23047}
23048impl std::fmt::Debug for IterableOpNewlinkDoReply<'_> {
23049    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23050        let mut fmt = f.debug_struct("OpNewlinkDoReply");
23051        for attr in self.clone() {
23052            let attr = match attr {
23053                Ok(a) => a,
23054                Err(err) => {
23055                    fmt.finish()?;
23056                    f.write_str("Err(")?;
23057                    err.fmt(f)?;
23058                    return f.write_str(")");
23059                }
23060            };
23061            match attr {};
23062        }
23063        fmt.finish()
23064    }
23065}
23066impl IterableOpNewlinkDoReply<'_> {
23067    pub fn lookup_attr(
23068        &self,
23069        offset: usize,
23070        missing_type: Option<u16>,
23071    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23072        let mut stack = Vec::new();
23073        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23074        if cur == offset + PushIfinfomsg::len() {
23075            stack.push(("OpNewlinkDoReply", offset));
23076            return (
23077                stack,
23078                missing_type.and_then(|t| OpNewlinkDoReply::attr_from_type(t)),
23079            );
23080        }
23081        (stack, None)
23082    }
23083}
23084#[derive(Debug)]
23085pub struct RequestOpNewlinkDoRequest<'r> {
23086    request: Request<'r>,
23087}
23088impl<'r> RequestOpNewlinkDoRequest<'r> {
23089    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
23090        PushOpNewlinkDoRequest::write_header(&mut request.buf_mut(), header);
23091        Self { request: request }
23092    }
23093    pub fn encode(&mut self) -> PushOpNewlinkDoRequest<&mut Vec<u8>> {
23094        PushOpNewlinkDoRequest::new_without_header(self.request.buf_mut())
23095    }
23096    pub fn into_encoder(self) -> PushOpNewlinkDoRequest<RequestBuf<'r>> {
23097        PushOpNewlinkDoRequest::new_without_header(self.request.buf)
23098    }
23099    pub fn decode_request<'buf>(
23100        buf: &'buf [u8],
23101    ) -> (PushIfinfomsg, IterableOpNewlinkDoRequest<'buf>) {
23102        OpNewlinkDoRequest::new(buf)
23103    }
23104}
23105impl NetlinkRequest for RequestOpNewlinkDoRequest<'_> {
23106    fn protocol(&self) -> Protocol {
23107        Protocol::Raw {
23108            protonum: 0u16,
23109            request_type: 16u16,
23110        }
23111    }
23112    fn flags(&self) -> u16 {
23113        self.request.flags
23114    }
23115    fn payload(&self) -> &[u8] {
23116        self.request.buf()
23117    }
23118    type ReplyType<'buf> = (PushIfinfomsg, IterableOpNewlinkDoReply<'buf>);
23119    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
23120        OpNewlinkDoReply::new(buf)
23121    }
23122    fn lookup(
23123        buf: &[u8],
23124        offset: usize,
23125        missing_type: Option<u16>,
23126    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23127        OpNewlinkDoRequest::new(buf)
23128            .1
23129            .lookup_attr(offset, missing_type)
23130    }
23131}
23132#[doc = "Delete an existing link."]
23133pub struct PushOpDellinkDoRequest<Prev: Rec> {
23134    pub(crate) prev: Option<Prev>,
23135    pub(crate) header_offset: Option<usize>,
23136}
23137impl<Prev: Rec> Rec for PushOpDellinkDoRequest<Prev> {
23138    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
23139        self.prev.as_mut().unwrap().as_rec_mut()
23140    }
23141    fn as_rec(&self) -> &Vec<u8> {
23142        self.prev.as_ref().unwrap().as_rec()
23143    }
23144}
23145impl<Prev: Rec> PushOpDellinkDoRequest<Prev> {
23146    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
23147        Self::write_header(&mut prev, header);
23148        Self::new_without_header(prev)
23149    }
23150    fn new_without_header(prev: Prev) -> Self {
23151        Self {
23152            prev: Some(prev),
23153            header_offset: None,
23154        }
23155    }
23156    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
23157        prev.as_rec_mut().extend(header.as_slice());
23158    }
23159    pub fn end_nested(mut self) -> Prev {
23160        let mut prev = self.prev.take().unwrap();
23161        if let Some(header_offset) = &self.header_offset {
23162            finalize_nested_header(prev.as_rec_mut(), *header_offset);
23163        }
23164        prev
23165    }
23166    pub fn push_ifname(mut self, value: &CStr) -> Self {
23167        push_header(
23168            self.as_rec_mut(),
23169            3u16,
23170            value.to_bytes_with_nul().len() as u16,
23171        );
23172        self.as_rec_mut().extend(value.to_bytes_with_nul());
23173        self
23174    }
23175    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
23176        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
23177        self.as_rec_mut().extend(value);
23178        self.as_rec_mut().push(0);
23179        self
23180    }
23181}
23182impl<Prev: Rec> Drop for PushOpDellinkDoRequest<Prev> {
23183    fn drop(&mut self) {
23184        if let Some(prev) = &mut self.prev {
23185            if let Some(header_offset) = &self.header_offset {
23186                finalize_nested_header(prev.as_rec_mut(), *header_offset);
23187            }
23188        }
23189    }
23190}
23191#[doc = "Delete an existing link."]
23192#[derive(Clone)]
23193pub enum OpDellinkDoRequest<'a> {
23194    Ifname(&'a CStr),
23195}
23196impl<'a> IterableOpDellinkDoRequest<'a> {
23197    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
23198        let mut iter = self.clone();
23199        iter.pos = 0;
23200        for attr in iter {
23201            if let OpDellinkDoRequest::Ifname(val) = attr? {
23202                return Ok(val);
23203            }
23204        }
23205        Err(ErrorContext::new_missing(
23206            "OpDellinkDoRequest",
23207            "Ifname",
23208            self.orig_loc,
23209            self.buf.as_ptr() as usize,
23210        ))
23211    }
23212}
23213impl OpDellinkDoRequest<'_> {
23214    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpDellinkDoRequest<'a>) {
23215        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
23216        (
23217            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
23218            IterableOpDellinkDoRequest::with_loc(attrs, buf.as_ptr() as usize),
23219        )
23220    }
23221    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23222        LinkAttrs::attr_from_type(r#type)
23223    }
23224}
23225#[derive(Clone, Copy, Default)]
23226pub struct IterableOpDellinkDoRequest<'a> {
23227    buf: &'a [u8],
23228    pos: usize,
23229    orig_loc: usize,
23230}
23231impl<'a> IterableOpDellinkDoRequest<'a> {
23232    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23233        Self {
23234            buf,
23235            pos: 0,
23236            orig_loc,
23237        }
23238    }
23239    pub fn get_buf(&self) -> &'a [u8] {
23240        self.buf
23241    }
23242}
23243impl<'a> Iterator for IterableOpDellinkDoRequest<'a> {
23244    type Item = Result<OpDellinkDoRequest<'a>, ErrorContext>;
23245    fn next(&mut self) -> Option<Self::Item> {
23246        let pos = self.pos;
23247        let mut r#type;
23248        loop {
23249            r#type = None;
23250            if self.buf.len() == self.pos {
23251                return None;
23252            }
23253            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
23254                break;
23255            };
23256            r#type = Some(header.r#type);
23257            let res = match header.r#type {
23258                3u16 => OpDellinkDoRequest::Ifname({
23259                    let res = CStr::from_bytes_with_nul(next).ok();
23260                    let Some(val) = res else { break };
23261                    val
23262                }),
23263                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
23264                n => continue,
23265            };
23266            return Some(Ok(res));
23267        }
23268        Some(Err(ErrorContext::new(
23269            "OpDellinkDoRequest",
23270            r#type.and_then(|t| OpDellinkDoRequest::attr_from_type(t)),
23271            self.orig_loc,
23272            self.buf.as_ptr().wrapping_add(pos) as usize,
23273        )))
23274    }
23275}
23276impl<'a> std::fmt::Debug for IterableOpDellinkDoRequest<'_> {
23277    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23278        let mut fmt = f.debug_struct("OpDellinkDoRequest");
23279        for attr in self.clone() {
23280            let attr = match attr {
23281                Ok(a) => a,
23282                Err(err) => {
23283                    fmt.finish()?;
23284                    f.write_str("Err(")?;
23285                    err.fmt(f)?;
23286                    return f.write_str(")");
23287                }
23288            };
23289            match attr {
23290                OpDellinkDoRequest::Ifname(val) => fmt.field("Ifname", &val),
23291            };
23292        }
23293        fmt.finish()
23294    }
23295}
23296impl IterableOpDellinkDoRequest<'_> {
23297    pub fn lookup_attr(
23298        &self,
23299        offset: usize,
23300        missing_type: Option<u16>,
23301    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23302        let mut stack = Vec::new();
23303        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23304        if cur == offset + PushIfinfomsg::len() {
23305            stack.push(("OpDellinkDoRequest", offset));
23306            return (
23307                stack,
23308                missing_type.and_then(|t| OpDellinkDoRequest::attr_from_type(t)),
23309            );
23310        }
23311        if cur > offset || cur + self.buf.len() < offset {
23312            return (stack, None);
23313        }
23314        let mut attrs = self.clone();
23315        let mut last_off = cur + attrs.pos;
23316        while let Some(attr) = attrs.next() {
23317            let Ok(attr) = attr else { break };
23318            match attr {
23319                OpDellinkDoRequest::Ifname(val) => {
23320                    if last_off == offset {
23321                        stack.push(("Ifname", last_off));
23322                        break;
23323                    }
23324                }
23325                _ => {}
23326            };
23327            last_off = cur + attrs.pos;
23328        }
23329        if !stack.is_empty() {
23330            stack.push(("OpDellinkDoRequest", cur));
23331        }
23332        (stack, None)
23333    }
23334}
23335#[doc = "Delete an existing link."]
23336pub struct PushOpDellinkDoReply<Prev: Rec> {
23337    pub(crate) prev: Option<Prev>,
23338    pub(crate) header_offset: Option<usize>,
23339}
23340impl<Prev: Rec> Rec for PushOpDellinkDoReply<Prev> {
23341    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
23342        self.prev.as_mut().unwrap().as_rec_mut()
23343    }
23344    fn as_rec(&self) -> &Vec<u8> {
23345        self.prev.as_ref().unwrap().as_rec()
23346    }
23347}
23348impl<Prev: Rec> PushOpDellinkDoReply<Prev> {
23349    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
23350        Self::write_header(&mut prev, header);
23351        Self::new_without_header(prev)
23352    }
23353    fn new_without_header(prev: Prev) -> Self {
23354        Self {
23355            prev: Some(prev),
23356            header_offset: None,
23357        }
23358    }
23359    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
23360        prev.as_rec_mut().extend(header.as_slice());
23361    }
23362    pub fn end_nested(mut self) -> Prev {
23363        let mut prev = self.prev.take().unwrap();
23364        if let Some(header_offset) = &self.header_offset {
23365            finalize_nested_header(prev.as_rec_mut(), *header_offset);
23366        }
23367        prev
23368    }
23369}
23370impl<Prev: Rec> Drop for PushOpDellinkDoReply<Prev> {
23371    fn drop(&mut self) {
23372        if let Some(prev) = &mut self.prev {
23373            if let Some(header_offset) = &self.header_offset {
23374                finalize_nested_header(prev.as_rec_mut(), *header_offset);
23375            }
23376        }
23377    }
23378}
23379#[doc = "Delete an existing link."]
23380#[derive(Clone)]
23381pub enum OpDellinkDoReply {}
23382impl<'a> IterableOpDellinkDoReply<'a> {}
23383impl OpDellinkDoReply {
23384    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpDellinkDoReply<'a>) {
23385        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
23386        (
23387            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
23388            IterableOpDellinkDoReply::with_loc(attrs, buf.as_ptr() as usize),
23389        )
23390    }
23391    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23392        LinkAttrs::attr_from_type(r#type)
23393    }
23394}
23395#[derive(Clone, Copy, Default)]
23396pub struct IterableOpDellinkDoReply<'a> {
23397    buf: &'a [u8],
23398    pos: usize,
23399    orig_loc: usize,
23400}
23401impl<'a> IterableOpDellinkDoReply<'a> {
23402    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23403        Self {
23404            buf,
23405            pos: 0,
23406            orig_loc,
23407        }
23408    }
23409    pub fn get_buf(&self) -> &'a [u8] {
23410        self.buf
23411    }
23412}
23413impl<'a> Iterator for IterableOpDellinkDoReply<'a> {
23414    type Item = Result<OpDellinkDoReply, ErrorContext>;
23415    fn next(&mut self) -> Option<Self::Item> {
23416        let pos = self.pos;
23417        let mut r#type;
23418        loop {
23419            r#type = None;
23420            if self.buf.len() == self.pos {
23421                return None;
23422            }
23423            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
23424                break;
23425            };
23426            r#type = Some(header.r#type);
23427            let res = match header.r#type {
23428                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
23429                n => continue,
23430            };
23431            return Some(Ok(res));
23432        }
23433        Some(Err(ErrorContext::new(
23434            "OpDellinkDoReply",
23435            r#type.and_then(|t| OpDellinkDoReply::attr_from_type(t)),
23436            self.orig_loc,
23437            self.buf.as_ptr().wrapping_add(pos) as usize,
23438        )))
23439    }
23440}
23441impl std::fmt::Debug for IterableOpDellinkDoReply<'_> {
23442    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23443        let mut fmt = f.debug_struct("OpDellinkDoReply");
23444        for attr in self.clone() {
23445            let attr = match attr {
23446                Ok(a) => a,
23447                Err(err) => {
23448                    fmt.finish()?;
23449                    f.write_str("Err(")?;
23450                    err.fmt(f)?;
23451                    return f.write_str(")");
23452                }
23453            };
23454            match attr {};
23455        }
23456        fmt.finish()
23457    }
23458}
23459impl IterableOpDellinkDoReply<'_> {
23460    pub fn lookup_attr(
23461        &self,
23462        offset: usize,
23463        missing_type: Option<u16>,
23464    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23465        let mut stack = Vec::new();
23466        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23467        if cur == offset + PushIfinfomsg::len() {
23468            stack.push(("OpDellinkDoReply", offset));
23469            return (
23470                stack,
23471                missing_type.and_then(|t| OpDellinkDoReply::attr_from_type(t)),
23472            );
23473        }
23474        (stack, None)
23475    }
23476}
23477#[derive(Debug)]
23478pub struct RequestOpDellinkDoRequest<'r> {
23479    request: Request<'r>,
23480}
23481impl<'r> RequestOpDellinkDoRequest<'r> {
23482    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
23483        PushOpDellinkDoRequest::write_header(&mut request.buf_mut(), header);
23484        Self { request: request }
23485    }
23486    pub fn encode(&mut self) -> PushOpDellinkDoRequest<&mut Vec<u8>> {
23487        PushOpDellinkDoRequest::new_without_header(self.request.buf_mut())
23488    }
23489    pub fn into_encoder(self) -> PushOpDellinkDoRequest<RequestBuf<'r>> {
23490        PushOpDellinkDoRequest::new_without_header(self.request.buf)
23491    }
23492    pub fn decode_request<'buf>(
23493        buf: &'buf [u8],
23494    ) -> (PushIfinfomsg, IterableOpDellinkDoRequest<'buf>) {
23495        OpDellinkDoRequest::new(buf)
23496    }
23497}
23498impl NetlinkRequest for RequestOpDellinkDoRequest<'_> {
23499    fn protocol(&self) -> Protocol {
23500        Protocol::Raw {
23501            protonum: 0u16,
23502            request_type: 17u16,
23503        }
23504    }
23505    fn flags(&self) -> u16 {
23506        self.request.flags
23507    }
23508    fn payload(&self) -> &[u8] {
23509        self.request.buf()
23510    }
23511    type ReplyType<'buf> = (PushIfinfomsg, IterableOpDellinkDoReply<'buf>);
23512    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
23513        OpDellinkDoReply::new(buf)
23514    }
23515    fn lookup(
23516        buf: &[u8],
23517        offset: usize,
23518        missing_type: Option<u16>,
23519    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23520        OpDellinkDoRequest::new(buf)
23521            .1
23522            .lookup_attr(offset, missing_type)
23523    }
23524}
23525#[doc = "Get / dump information about a link."]
23526pub struct PushOpGetlinkDumpRequest<Prev: Rec> {
23527    pub(crate) prev: Option<Prev>,
23528    pub(crate) header_offset: Option<usize>,
23529}
23530impl<Prev: Rec> Rec for PushOpGetlinkDumpRequest<Prev> {
23531    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
23532        self.prev.as_mut().unwrap().as_rec_mut()
23533    }
23534    fn as_rec(&self) -> &Vec<u8> {
23535        self.prev.as_ref().unwrap().as_rec()
23536    }
23537}
23538impl<Prev: Rec> PushOpGetlinkDumpRequest<Prev> {
23539    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
23540        Self::write_header(&mut prev, header);
23541        Self::new_without_header(prev)
23542    }
23543    fn new_without_header(prev: Prev) -> Self {
23544        Self {
23545            prev: Some(prev),
23546            header_offset: None,
23547        }
23548    }
23549    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
23550        prev.as_rec_mut().extend(header.as_slice());
23551    }
23552    pub fn end_nested(mut self) -> Prev {
23553        let mut prev = self.prev.take().unwrap();
23554        if let Some(header_offset) = &self.header_offset {
23555            finalize_nested_header(prev.as_rec_mut(), *header_offset);
23556        }
23557        prev
23558    }
23559    pub fn push_master(mut self, value: u32) -> Self {
23560        push_header(self.as_rec_mut(), 10u16, 4 as u16);
23561        self.as_rec_mut().extend(value.to_ne_bytes());
23562        self
23563    }
23564    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
23565        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
23566        PushLinkinfoAttrs {
23567            prev: Some(self),
23568            header_offset: Some(header_offset),
23569        }
23570    }
23571    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
23572    pub fn push_ext_mask(mut self, value: u32) -> Self {
23573        push_header(self.as_rec_mut(), 29u16, 4 as u16);
23574        self.as_rec_mut().extend(value.to_ne_bytes());
23575        self
23576    }
23577    pub fn push_target_netnsid(mut self, value: i32) -> Self {
23578        push_header(self.as_rec_mut(), 46u16, 4 as u16);
23579        self.as_rec_mut().extend(value.to_ne_bytes());
23580        self
23581    }
23582}
23583impl<Prev: Rec> Drop for PushOpGetlinkDumpRequest<Prev> {
23584    fn drop(&mut self) {
23585        if let Some(prev) = &mut self.prev {
23586            if let Some(header_offset) = &self.header_offset {
23587                finalize_nested_header(prev.as_rec_mut(), *header_offset);
23588            }
23589        }
23590    }
23591}
23592#[doc = "Get / dump information about a link."]
23593#[derive(Clone)]
23594pub enum OpGetlinkDumpRequest<'a> {
23595    Master(u32),
23596    Linkinfo(IterableLinkinfoAttrs<'a>),
23597    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
23598    ExtMask(u32),
23599    TargetNetnsid(i32),
23600}
23601impl<'a> IterableOpGetlinkDumpRequest<'a> {
23602    pub fn get_master(&self) -> Result<u32, ErrorContext> {
23603        let mut iter = self.clone();
23604        iter.pos = 0;
23605        for attr in iter {
23606            if let OpGetlinkDumpRequest::Master(val) = attr? {
23607                return Ok(val);
23608            }
23609        }
23610        Err(ErrorContext::new_missing(
23611            "OpGetlinkDumpRequest",
23612            "Master",
23613            self.orig_loc,
23614            self.buf.as_ptr() as usize,
23615        ))
23616    }
23617    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
23618        let mut iter = self.clone();
23619        iter.pos = 0;
23620        for attr in iter {
23621            if let OpGetlinkDumpRequest::Linkinfo(val) = attr? {
23622                return Ok(val);
23623            }
23624        }
23625        Err(ErrorContext::new_missing(
23626            "OpGetlinkDumpRequest",
23627            "Linkinfo",
23628            self.orig_loc,
23629            self.buf.as_ptr() as usize,
23630        ))
23631    }
23632    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
23633    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
23634        let mut iter = self.clone();
23635        iter.pos = 0;
23636        for attr in iter {
23637            if let OpGetlinkDumpRequest::ExtMask(val) = attr? {
23638                return Ok(val);
23639            }
23640        }
23641        Err(ErrorContext::new_missing(
23642            "OpGetlinkDumpRequest",
23643            "ExtMask",
23644            self.orig_loc,
23645            self.buf.as_ptr() as usize,
23646        ))
23647    }
23648    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
23649        let mut iter = self.clone();
23650        iter.pos = 0;
23651        for attr in iter {
23652            if let OpGetlinkDumpRequest::TargetNetnsid(val) = attr? {
23653                return Ok(val);
23654            }
23655        }
23656        Err(ErrorContext::new_missing(
23657            "OpGetlinkDumpRequest",
23658            "TargetNetnsid",
23659            self.orig_loc,
23660            self.buf.as_ptr() as usize,
23661        ))
23662    }
23663}
23664impl OpGetlinkDumpRequest<'_> {
23665    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpGetlinkDumpRequest<'a>) {
23666        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
23667        (
23668            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
23669            IterableOpGetlinkDumpRequest::with_loc(attrs, buf.as_ptr() as usize),
23670        )
23671    }
23672    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23673        LinkAttrs::attr_from_type(r#type)
23674    }
23675}
23676#[derive(Clone, Copy, Default)]
23677pub struct IterableOpGetlinkDumpRequest<'a> {
23678    buf: &'a [u8],
23679    pos: usize,
23680    orig_loc: usize,
23681}
23682impl<'a> IterableOpGetlinkDumpRequest<'a> {
23683    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23684        Self {
23685            buf,
23686            pos: 0,
23687            orig_loc,
23688        }
23689    }
23690    pub fn get_buf(&self) -> &'a [u8] {
23691        self.buf
23692    }
23693}
23694impl<'a> Iterator for IterableOpGetlinkDumpRequest<'a> {
23695    type Item = Result<OpGetlinkDumpRequest<'a>, ErrorContext>;
23696    fn next(&mut self) -> Option<Self::Item> {
23697        let pos = self.pos;
23698        let mut r#type;
23699        loop {
23700            r#type = None;
23701            if self.buf.len() == self.pos {
23702                return None;
23703            }
23704            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
23705                break;
23706            };
23707            r#type = Some(header.r#type);
23708            let res = match header.r#type {
23709                10u16 => OpGetlinkDumpRequest::Master({
23710                    let res = parse_u32(next);
23711                    let Some(val) = res else { break };
23712                    val
23713                }),
23714                18u16 => OpGetlinkDumpRequest::Linkinfo({
23715                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
23716                    let Some(val) = res else { break };
23717                    val
23718                }),
23719                29u16 => OpGetlinkDumpRequest::ExtMask({
23720                    let res = parse_u32(next);
23721                    let Some(val) = res else { break };
23722                    val
23723                }),
23724                46u16 => OpGetlinkDumpRequest::TargetNetnsid({
23725                    let res = parse_i32(next);
23726                    let Some(val) = res else { break };
23727                    val
23728                }),
23729                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
23730                n => continue,
23731            };
23732            return Some(Ok(res));
23733        }
23734        Some(Err(ErrorContext::new(
23735            "OpGetlinkDumpRequest",
23736            r#type.and_then(|t| OpGetlinkDumpRequest::attr_from_type(t)),
23737            self.orig_loc,
23738            self.buf.as_ptr().wrapping_add(pos) as usize,
23739        )))
23740    }
23741}
23742impl<'a> std::fmt::Debug for IterableOpGetlinkDumpRequest<'_> {
23743    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23744        let mut fmt = f.debug_struct("OpGetlinkDumpRequest");
23745        for attr in self.clone() {
23746            let attr = match attr {
23747                Ok(a) => a,
23748                Err(err) => {
23749                    fmt.finish()?;
23750                    f.write_str("Err(")?;
23751                    err.fmt(f)?;
23752                    return f.write_str(")");
23753                }
23754            };
23755            match attr {
23756                OpGetlinkDumpRequest::Master(val) => fmt.field("Master", &val),
23757                OpGetlinkDumpRequest::Linkinfo(val) => fmt.field("Linkinfo", &val),
23758                OpGetlinkDumpRequest::ExtMask(val) => {
23759                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
23760                }
23761                OpGetlinkDumpRequest::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
23762            };
23763        }
23764        fmt.finish()
23765    }
23766}
23767impl IterableOpGetlinkDumpRequest<'_> {
23768    pub fn lookup_attr(
23769        &self,
23770        offset: usize,
23771        missing_type: Option<u16>,
23772    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23773        let mut stack = Vec::new();
23774        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23775        if cur == offset + PushIfinfomsg::len() {
23776            stack.push(("OpGetlinkDumpRequest", offset));
23777            return (
23778                stack,
23779                missing_type.and_then(|t| OpGetlinkDumpRequest::attr_from_type(t)),
23780            );
23781        }
23782        if cur > offset || cur + self.buf.len() < offset {
23783            return (stack, None);
23784        }
23785        let mut attrs = self.clone();
23786        let mut last_off = cur + attrs.pos;
23787        let mut missing = None;
23788        while let Some(attr) = attrs.next() {
23789            let Ok(attr) = attr else { break };
23790            match attr {
23791                OpGetlinkDumpRequest::Master(val) => {
23792                    if last_off == offset {
23793                        stack.push(("Master", last_off));
23794                        break;
23795                    }
23796                }
23797                OpGetlinkDumpRequest::Linkinfo(val) => {
23798                    (stack, missing) = val.lookup_attr(offset, missing_type);
23799                    if !stack.is_empty() {
23800                        break;
23801                    }
23802                }
23803                OpGetlinkDumpRequest::ExtMask(val) => {
23804                    if last_off == offset {
23805                        stack.push(("ExtMask", last_off));
23806                        break;
23807                    }
23808                }
23809                OpGetlinkDumpRequest::TargetNetnsid(val) => {
23810                    if last_off == offset {
23811                        stack.push(("TargetNetnsid", last_off));
23812                        break;
23813                    }
23814                }
23815                _ => {}
23816            };
23817            last_off = cur + attrs.pos;
23818        }
23819        if !stack.is_empty() {
23820            stack.push(("OpGetlinkDumpRequest", cur));
23821        }
23822        (stack, missing)
23823    }
23824}
23825#[doc = "Get / dump information about a link."]
23826pub struct PushOpGetlinkDumpReply<Prev: Rec> {
23827    pub(crate) prev: Option<Prev>,
23828    pub(crate) header_offset: Option<usize>,
23829}
23830impl<Prev: Rec> Rec for PushOpGetlinkDumpReply<Prev> {
23831    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
23832        self.prev.as_mut().unwrap().as_rec_mut()
23833    }
23834    fn as_rec(&self) -> &Vec<u8> {
23835        self.prev.as_ref().unwrap().as_rec()
23836    }
23837}
23838impl<Prev: Rec> PushOpGetlinkDumpReply<Prev> {
23839    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
23840        Self::write_header(&mut prev, header);
23841        Self::new_without_header(prev)
23842    }
23843    fn new_without_header(prev: Prev) -> Self {
23844        Self {
23845            prev: Some(prev),
23846            header_offset: None,
23847        }
23848    }
23849    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
23850        prev.as_rec_mut().extend(header.as_slice());
23851    }
23852    pub fn end_nested(mut self) -> Prev {
23853        let mut prev = self.prev.take().unwrap();
23854        if let Some(header_offset) = &self.header_offset {
23855            finalize_nested_header(prev.as_rec_mut(), *header_offset);
23856        }
23857        prev
23858    }
23859    pub fn push_address(mut self, value: &[u8]) -> Self {
23860        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
23861        self.as_rec_mut().extend(value);
23862        self
23863    }
23864    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
23865        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
23866        self.as_rec_mut().extend(value);
23867        self
23868    }
23869    pub fn push_ifname(mut self, value: &CStr) -> Self {
23870        push_header(
23871            self.as_rec_mut(),
23872            3u16,
23873            value.to_bytes_with_nul().len() as u16,
23874        );
23875        self.as_rec_mut().extend(value.to_bytes_with_nul());
23876        self
23877    }
23878    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
23879        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
23880        self.as_rec_mut().extend(value);
23881        self.as_rec_mut().push(0);
23882        self
23883    }
23884    pub fn push_mtu(mut self, value: u32) -> Self {
23885        push_header(self.as_rec_mut(), 4u16, 4 as u16);
23886        self.as_rec_mut().extend(value.to_ne_bytes());
23887        self
23888    }
23889    pub fn push_link(mut self, value: u32) -> Self {
23890        push_header(self.as_rec_mut(), 5u16, 4 as u16);
23891        self.as_rec_mut().extend(value.to_ne_bytes());
23892        self
23893    }
23894    pub fn push_qdisc(mut self, value: &CStr) -> Self {
23895        push_header(
23896            self.as_rec_mut(),
23897            6u16,
23898            value.to_bytes_with_nul().len() as u16,
23899        );
23900        self.as_rec_mut().extend(value.to_bytes_with_nul());
23901        self
23902    }
23903    pub fn push_qdisc_bytes(mut self, value: &[u8]) -> Self {
23904        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
23905        self.as_rec_mut().extend(value);
23906        self.as_rec_mut().push(0);
23907        self
23908    }
23909    pub fn push_stats(mut self, value: PushRtnlLinkStats) -> Self {
23910        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
23911        self.as_rec_mut().extend(value.as_slice());
23912        self
23913    }
23914    pub fn push_cost(mut self, value: &CStr) -> Self {
23915        push_header(
23916            self.as_rec_mut(),
23917            8u16,
23918            value.to_bytes_with_nul().len() as u16,
23919        );
23920        self.as_rec_mut().extend(value.to_bytes_with_nul());
23921        self
23922    }
23923    pub fn push_cost_bytes(mut self, value: &[u8]) -> Self {
23924        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
23925        self.as_rec_mut().extend(value);
23926        self.as_rec_mut().push(0);
23927        self
23928    }
23929    pub fn push_priority(mut self, value: &CStr) -> Self {
23930        push_header(
23931            self.as_rec_mut(),
23932            9u16,
23933            value.to_bytes_with_nul().len() as u16,
23934        );
23935        self.as_rec_mut().extend(value.to_bytes_with_nul());
23936        self
23937    }
23938    pub fn push_priority_bytes(mut self, value: &[u8]) -> Self {
23939        push_header(self.as_rec_mut(), 9u16, (value.len() + 1) as u16);
23940        self.as_rec_mut().extend(value);
23941        self.as_rec_mut().push(0);
23942        self
23943    }
23944    pub fn push_master(mut self, value: u32) -> Self {
23945        push_header(self.as_rec_mut(), 10u16, 4 as u16);
23946        self.as_rec_mut().extend(value.to_ne_bytes());
23947        self
23948    }
23949    pub fn push_wireless(mut self, value: &CStr) -> Self {
23950        push_header(
23951            self.as_rec_mut(),
23952            11u16,
23953            value.to_bytes_with_nul().len() as u16,
23954        );
23955        self.as_rec_mut().extend(value.to_bytes_with_nul());
23956        self
23957    }
23958    pub fn push_wireless_bytes(mut self, value: &[u8]) -> Self {
23959        push_header(self.as_rec_mut(), 11u16, (value.len() + 1) as u16);
23960        self.as_rec_mut().extend(value);
23961        self.as_rec_mut().push(0);
23962        self
23963    }
23964    pub fn push_protinfo(mut self, value: &CStr) -> Self {
23965        push_header(
23966            self.as_rec_mut(),
23967            12u16,
23968            value.to_bytes_with_nul().len() as u16,
23969        );
23970        self.as_rec_mut().extend(value.to_bytes_with_nul());
23971        self
23972    }
23973    pub fn push_protinfo_bytes(mut self, value: &[u8]) -> Self {
23974        push_header(self.as_rec_mut(), 12u16, (value.len() + 1) as u16);
23975        self.as_rec_mut().extend(value);
23976        self.as_rec_mut().push(0);
23977        self
23978    }
23979    pub fn push_txqlen(mut self, value: u32) -> Self {
23980        push_header(self.as_rec_mut(), 13u16, 4 as u16);
23981        self.as_rec_mut().extend(value.to_ne_bytes());
23982        self
23983    }
23984    pub fn push_map(mut self, value: PushRtnlLinkIfmap) -> Self {
23985        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
23986        self.as_rec_mut().extend(value.as_slice());
23987        self
23988    }
23989    pub fn push_weight(mut self, value: u32) -> Self {
23990        push_header(self.as_rec_mut(), 15u16, 4 as u16);
23991        self.as_rec_mut().extend(value.to_ne_bytes());
23992        self
23993    }
23994    pub fn push_operstate(mut self, value: u8) -> Self {
23995        push_header(self.as_rec_mut(), 16u16, 1 as u16);
23996        self.as_rec_mut().extend(value.to_ne_bytes());
23997        self
23998    }
23999    pub fn push_linkmode(mut self, value: u8) -> Self {
24000        push_header(self.as_rec_mut(), 17u16, 1 as u16);
24001        self.as_rec_mut().extend(value.to_ne_bytes());
24002        self
24003    }
24004    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
24005        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
24006        PushLinkinfoAttrs {
24007            prev: Some(self),
24008            header_offset: Some(header_offset),
24009        }
24010    }
24011    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
24012        push_header(self.as_rec_mut(), 19u16, 4 as u16);
24013        self.as_rec_mut().extend(value.to_ne_bytes());
24014        self
24015    }
24016    pub fn push_ifalias(mut self, value: &CStr) -> Self {
24017        push_header(
24018            self.as_rec_mut(),
24019            20u16,
24020            value.to_bytes_with_nul().len() as u16,
24021        );
24022        self.as_rec_mut().extend(value.to_bytes_with_nul());
24023        self
24024    }
24025    pub fn push_ifalias_bytes(mut self, value: &[u8]) -> Self {
24026        push_header(self.as_rec_mut(), 20u16, (value.len() + 1) as u16);
24027        self.as_rec_mut().extend(value);
24028        self.as_rec_mut().push(0);
24029        self
24030    }
24031    pub fn push_num_vf(mut self, value: u32) -> Self {
24032        push_header(self.as_rec_mut(), 21u16, 4 as u16);
24033        self.as_rec_mut().extend(value.to_ne_bytes());
24034        self
24035    }
24036    pub fn nested_vfinfo_list(mut self) -> PushVfinfoListAttrs<Self> {
24037        let header_offset = push_nested_header(self.as_rec_mut(), 22u16);
24038        PushVfinfoListAttrs {
24039            prev: Some(self),
24040            header_offset: Some(header_offset),
24041        }
24042    }
24043    pub fn push_stats64(mut self, value: PushRtnlLinkStats64) -> Self {
24044        push_header(self.as_rec_mut(), 23u16, value.as_slice().len() as u16);
24045        self.as_rec_mut().extend(value.as_slice());
24046        self
24047    }
24048    pub fn nested_vf_ports(mut self) -> PushVfPortsAttrs<Self> {
24049        let header_offset = push_nested_header(self.as_rec_mut(), 24u16);
24050        PushVfPortsAttrs {
24051            prev: Some(self),
24052            header_offset: Some(header_offset),
24053        }
24054    }
24055    pub fn nested_port_self(mut self) -> PushPortSelfAttrs<Self> {
24056        let header_offset = push_nested_header(self.as_rec_mut(), 25u16);
24057        PushPortSelfAttrs {
24058            prev: Some(self),
24059            header_offset: Some(header_offset),
24060        }
24061    }
24062    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
24063        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
24064        PushAfSpecAttrs {
24065            prev: Some(self),
24066            header_offset: Some(header_offset),
24067        }
24068    }
24069    pub fn push_group(mut self, value: u32) -> Self {
24070        push_header(self.as_rec_mut(), 27u16, 4 as u16);
24071        self.as_rec_mut().extend(value.to_ne_bytes());
24072        self
24073    }
24074    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
24075        push_header(self.as_rec_mut(), 28u16, 4 as u16);
24076        self.as_rec_mut().extend(value.to_ne_bytes());
24077        self
24078    }
24079    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
24080    pub fn push_ext_mask(mut self, value: u32) -> Self {
24081        push_header(self.as_rec_mut(), 29u16, 4 as u16);
24082        self.as_rec_mut().extend(value.to_ne_bytes());
24083        self
24084    }
24085    pub fn push_promiscuity(mut self, value: u32) -> Self {
24086        push_header(self.as_rec_mut(), 30u16, 4 as u16);
24087        self.as_rec_mut().extend(value.to_ne_bytes());
24088        self
24089    }
24090    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
24091        push_header(self.as_rec_mut(), 31u16, 4 as u16);
24092        self.as_rec_mut().extend(value.to_ne_bytes());
24093        self
24094    }
24095    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
24096        push_header(self.as_rec_mut(), 32u16, 4 as u16);
24097        self.as_rec_mut().extend(value.to_ne_bytes());
24098        self
24099    }
24100    pub fn push_carrier(mut self, value: u8) -> Self {
24101        push_header(self.as_rec_mut(), 33u16, 1 as u16);
24102        self.as_rec_mut().extend(value.to_ne_bytes());
24103        self
24104    }
24105    pub fn push_phys_port_id(mut self, value: &[u8]) -> Self {
24106        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
24107        self.as_rec_mut().extend(value);
24108        self
24109    }
24110    pub fn push_carrier_changes(mut self, value: u32) -> Self {
24111        push_header(self.as_rec_mut(), 35u16, 4 as u16);
24112        self.as_rec_mut().extend(value.to_ne_bytes());
24113        self
24114    }
24115    pub fn push_phys_switch_id(mut self, value: &[u8]) -> Self {
24116        push_header(self.as_rec_mut(), 36u16, value.len() as u16);
24117        self.as_rec_mut().extend(value);
24118        self
24119    }
24120    pub fn push_link_netnsid(mut self, value: i32) -> Self {
24121        push_header(self.as_rec_mut(), 37u16, 4 as u16);
24122        self.as_rec_mut().extend(value.to_ne_bytes());
24123        self
24124    }
24125    pub fn push_phys_port_name(mut self, value: &CStr) -> Self {
24126        push_header(
24127            self.as_rec_mut(),
24128            38u16,
24129            value.to_bytes_with_nul().len() as u16,
24130        );
24131        self.as_rec_mut().extend(value.to_bytes_with_nul());
24132        self
24133    }
24134    pub fn push_phys_port_name_bytes(mut self, value: &[u8]) -> Self {
24135        push_header(self.as_rec_mut(), 38u16, (value.len() + 1) as u16);
24136        self.as_rec_mut().extend(value);
24137        self.as_rec_mut().push(0);
24138        self
24139    }
24140    pub fn push_proto_down(mut self, value: u8) -> Self {
24141        push_header(self.as_rec_mut(), 39u16, 1 as u16);
24142        self.as_rec_mut().extend(value.to_ne_bytes());
24143        self
24144    }
24145    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
24146        push_header(self.as_rec_mut(), 40u16, 4 as u16);
24147        self.as_rec_mut().extend(value.to_ne_bytes());
24148        self
24149    }
24150    pub fn push_gso_max_size(mut self, value: u32) -> Self {
24151        push_header(self.as_rec_mut(), 41u16, 4 as u16);
24152        self.as_rec_mut().extend(value.to_ne_bytes());
24153        self
24154    }
24155    pub fn push_pad(mut self, value: &[u8]) -> Self {
24156        push_header(self.as_rec_mut(), 42u16, value.len() as u16);
24157        self.as_rec_mut().extend(value);
24158        self
24159    }
24160    pub fn nested_xdp(mut self) -> PushXdpAttrs<Self> {
24161        let header_offset = push_nested_header(self.as_rec_mut(), 43u16);
24162        PushXdpAttrs {
24163            prev: Some(self),
24164            header_offset: Some(header_offset),
24165        }
24166    }
24167    pub fn push_event(mut self, value: u32) -> Self {
24168        push_header(self.as_rec_mut(), 44u16, 4 as u16);
24169        self.as_rec_mut().extend(value.to_ne_bytes());
24170        self
24171    }
24172    pub fn push_new_netnsid(mut self, value: i32) -> Self {
24173        push_header(self.as_rec_mut(), 45u16, 4 as u16);
24174        self.as_rec_mut().extend(value.to_ne_bytes());
24175        self
24176    }
24177    pub fn push_target_netnsid(mut self, value: i32) -> Self {
24178        push_header(self.as_rec_mut(), 46u16, 4 as u16);
24179        self.as_rec_mut().extend(value.to_ne_bytes());
24180        self
24181    }
24182    pub fn push_carrier_up_count(mut self, value: u32) -> Self {
24183        push_header(self.as_rec_mut(), 47u16, 4 as u16);
24184        self.as_rec_mut().extend(value.to_ne_bytes());
24185        self
24186    }
24187    pub fn push_carrier_down_count(mut self, value: u32) -> Self {
24188        push_header(self.as_rec_mut(), 48u16, 4 as u16);
24189        self.as_rec_mut().extend(value.to_ne_bytes());
24190        self
24191    }
24192    pub fn push_new_ifindex(mut self, value: i32) -> Self {
24193        push_header(self.as_rec_mut(), 49u16, 4 as u16);
24194        self.as_rec_mut().extend(value.to_ne_bytes());
24195        self
24196    }
24197    pub fn push_min_mtu(mut self, value: u32) -> Self {
24198        push_header(self.as_rec_mut(), 50u16, 4 as u16);
24199        self.as_rec_mut().extend(value.to_ne_bytes());
24200        self
24201    }
24202    pub fn push_max_mtu(mut self, value: u32) -> Self {
24203        push_header(self.as_rec_mut(), 51u16, 4 as u16);
24204        self.as_rec_mut().extend(value.to_ne_bytes());
24205        self
24206    }
24207    pub fn nested_prop_list(mut self) -> PushPropListLinkAttrs<Self> {
24208        let header_offset = push_nested_header(self.as_rec_mut(), 52u16);
24209        PushPropListLinkAttrs {
24210            prev: Some(self),
24211            header_offset: Some(header_offset),
24212        }
24213    }
24214    pub fn push_perm_address(mut self, value: &[u8]) -> Self {
24215        push_header(self.as_rec_mut(), 54u16, value.len() as u16);
24216        self.as_rec_mut().extend(value);
24217        self
24218    }
24219    pub fn push_proto_down_reason(mut self, value: &CStr) -> Self {
24220        push_header(
24221            self.as_rec_mut(),
24222            55u16,
24223            value.to_bytes_with_nul().len() as u16,
24224        );
24225        self.as_rec_mut().extend(value.to_bytes_with_nul());
24226        self
24227    }
24228    pub fn push_proto_down_reason_bytes(mut self, value: &[u8]) -> Self {
24229        push_header(self.as_rec_mut(), 55u16, (value.len() + 1) as u16);
24230        self.as_rec_mut().extend(value);
24231        self.as_rec_mut().push(0);
24232        self
24233    }
24234    pub fn push_parent_dev_name(mut self, value: &CStr) -> Self {
24235        push_header(
24236            self.as_rec_mut(),
24237            56u16,
24238            value.to_bytes_with_nul().len() as u16,
24239        );
24240        self.as_rec_mut().extend(value.to_bytes_with_nul());
24241        self
24242    }
24243    pub fn push_parent_dev_name_bytes(mut self, value: &[u8]) -> Self {
24244        push_header(self.as_rec_mut(), 56u16, (value.len() + 1) as u16);
24245        self.as_rec_mut().extend(value);
24246        self.as_rec_mut().push(0);
24247        self
24248    }
24249    pub fn push_parent_dev_bus_name(mut self, value: &CStr) -> Self {
24250        push_header(
24251            self.as_rec_mut(),
24252            57u16,
24253            value.to_bytes_with_nul().len() as u16,
24254        );
24255        self.as_rec_mut().extend(value.to_bytes_with_nul());
24256        self
24257    }
24258    pub fn push_parent_dev_bus_name_bytes(mut self, value: &[u8]) -> Self {
24259        push_header(self.as_rec_mut(), 57u16, (value.len() + 1) as u16);
24260        self.as_rec_mut().extend(value);
24261        self.as_rec_mut().push(0);
24262        self
24263    }
24264    pub fn push_gro_max_size(mut self, value: u32) -> Self {
24265        push_header(self.as_rec_mut(), 58u16, 4 as u16);
24266        self.as_rec_mut().extend(value.to_ne_bytes());
24267        self
24268    }
24269    pub fn push_tso_max_size(mut self, value: u32) -> Self {
24270        push_header(self.as_rec_mut(), 59u16, 4 as u16);
24271        self.as_rec_mut().extend(value.to_ne_bytes());
24272        self
24273    }
24274    pub fn push_tso_max_segs(mut self, value: u32) -> Self {
24275        push_header(self.as_rec_mut(), 60u16, 4 as u16);
24276        self.as_rec_mut().extend(value.to_ne_bytes());
24277        self
24278    }
24279    pub fn push_allmulti(mut self, value: u32) -> Self {
24280        push_header(self.as_rec_mut(), 61u16, 4 as u16);
24281        self.as_rec_mut().extend(value.to_ne_bytes());
24282        self
24283    }
24284    pub fn push_devlink_port(mut self, value: &[u8]) -> Self {
24285        push_header(self.as_rec_mut(), 62u16, value.len() as u16);
24286        self.as_rec_mut().extend(value);
24287        self
24288    }
24289    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
24290        push_header(self.as_rec_mut(), 63u16, 4 as u16);
24291        self.as_rec_mut().extend(value.to_ne_bytes());
24292        self
24293    }
24294    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
24295        push_header(self.as_rec_mut(), 64u16, 4 as u16);
24296        self.as_rec_mut().extend(value.to_ne_bytes());
24297        self
24298    }
24299    pub fn nested_dpll_pin(mut self) -> PushLinkDpllPinAttrs<Self> {
24300        let header_offset = push_nested_header(self.as_rec_mut(), 65u16);
24301        PushLinkDpllPinAttrs {
24302            prev: Some(self),
24303            header_offset: Some(header_offset),
24304        }
24305    }
24306    #[doc = "EDT offload horizon supported by the device (in nsec)."]
24307    pub fn push_max_pacing_offload_horizon(mut self, value: u32) -> Self {
24308        push_header(self.as_rec_mut(), 66u16, 4 as u16);
24309        self.as_rec_mut().extend(value.to_ne_bytes());
24310        self
24311    }
24312    pub fn push_netns_immutable(mut self, value: u8) -> Self {
24313        push_header(self.as_rec_mut(), 67u16, 1 as u16);
24314        self.as_rec_mut().extend(value.to_ne_bytes());
24315        self
24316    }
24317}
24318impl<Prev: Rec> Drop for PushOpGetlinkDumpReply<Prev> {
24319    fn drop(&mut self) {
24320        if let Some(prev) = &mut self.prev {
24321            if let Some(header_offset) = &self.header_offset {
24322                finalize_nested_header(prev.as_rec_mut(), *header_offset);
24323            }
24324        }
24325    }
24326}
24327#[doc = "Get / dump information about a link."]
24328#[derive(Clone)]
24329pub enum OpGetlinkDumpReply<'a> {
24330    Address(&'a [u8]),
24331    Broadcast(&'a [u8]),
24332    Ifname(&'a CStr),
24333    Mtu(u32),
24334    Link(u32),
24335    Qdisc(&'a CStr),
24336    Stats(PushRtnlLinkStats),
24337    Cost(&'a CStr),
24338    Priority(&'a CStr),
24339    Master(u32),
24340    Wireless(&'a CStr),
24341    Protinfo(&'a CStr),
24342    Txqlen(u32),
24343    Map(PushRtnlLinkIfmap),
24344    Weight(u32),
24345    Operstate(u8),
24346    Linkmode(u8),
24347    Linkinfo(IterableLinkinfoAttrs<'a>),
24348    NetNsPid(u32),
24349    Ifalias(&'a CStr),
24350    NumVf(u32),
24351    VfinfoList(IterableVfinfoListAttrs<'a>),
24352    Stats64(PushRtnlLinkStats64),
24353    VfPorts(IterableVfPortsAttrs<'a>),
24354    PortSelf(IterablePortSelfAttrs<'a>),
24355    AfSpec(IterableAfSpecAttrs<'a>),
24356    Group(u32),
24357    NetNsFd(u32),
24358    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
24359    ExtMask(u32),
24360    Promiscuity(u32),
24361    NumTxQueues(u32),
24362    NumRxQueues(u32),
24363    Carrier(u8),
24364    PhysPortId(&'a [u8]),
24365    CarrierChanges(u32),
24366    PhysSwitchId(&'a [u8]),
24367    LinkNetnsid(i32),
24368    PhysPortName(&'a CStr),
24369    ProtoDown(u8),
24370    GsoMaxSegs(u32),
24371    GsoMaxSize(u32),
24372    Pad(&'a [u8]),
24373    Xdp(IterableXdpAttrs<'a>),
24374    Event(u32),
24375    NewNetnsid(i32),
24376    TargetNetnsid(i32),
24377    CarrierUpCount(u32),
24378    CarrierDownCount(u32),
24379    NewIfindex(i32),
24380    MinMtu(u32),
24381    MaxMtu(u32),
24382    PropList(IterablePropListLinkAttrs<'a>),
24383    PermAddress(&'a [u8]),
24384    ProtoDownReason(&'a CStr),
24385    ParentDevName(&'a CStr),
24386    ParentDevBusName(&'a CStr),
24387    GroMaxSize(u32),
24388    TsoMaxSize(u32),
24389    TsoMaxSegs(u32),
24390    Allmulti(u32),
24391    DevlinkPort(&'a [u8]),
24392    GsoIpv4MaxSize(u32),
24393    GroIpv4MaxSize(u32),
24394    DpllPin(IterableLinkDpllPinAttrs<'a>),
24395    #[doc = "EDT offload horizon supported by the device (in nsec)."]
24396    MaxPacingOffloadHorizon(u32),
24397    NetnsImmutable(u8),
24398}
24399impl<'a> IterableOpGetlinkDumpReply<'a> {
24400    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
24401        let mut iter = self.clone();
24402        iter.pos = 0;
24403        for attr in iter {
24404            if let OpGetlinkDumpReply::Address(val) = attr? {
24405                return Ok(val);
24406            }
24407        }
24408        Err(ErrorContext::new_missing(
24409            "OpGetlinkDumpReply",
24410            "Address",
24411            self.orig_loc,
24412            self.buf.as_ptr() as usize,
24413        ))
24414    }
24415    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
24416        let mut iter = self.clone();
24417        iter.pos = 0;
24418        for attr in iter {
24419            if let OpGetlinkDumpReply::Broadcast(val) = attr? {
24420                return Ok(val);
24421            }
24422        }
24423        Err(ErrorContext::new_missing(
24424            "OpGetlinkDumpReply",
24425            "Broadcast",
24426            self.orig_loc,
24427            self.buf.as_ptr() as usize,
24428        ))
24429    }
24430    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
24431        let mut iter = self.clone();
24432        iter.pos = 0;
24433        for attr in iter {
24434            if let OpGetlinkDumpReply::Ifname(val) = attr? {
24435                return Ok(val);
24436            }
24437        }
24438        Err(ErrorContext::new_missing(
24439            "OpGetlinkDumpReply",
24440            "Ifname",
24441            self.orig_loc,
24442            self.buf.as_ptr() as usize,
24443        ))
24444    }
24445    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
24446        let mut iter = self.clone();
24447        iter.pos = 0;
24448        for attr in iter {
24449            if let OpGetlinkDumpReply::Mtu(val) = attr? {
24450                return Ok(val);
24451            }
24452        }
24453        Err(ErrorContext::new_missing(
24454            "OpGetlinkDumpReply",
24455            "Mtu",
24456            self.orig_loc,
24457            self.buf.as_ptr() as usize,
24458        ))
24459    }
24460    pub fn get_link(&self) -> Result<u32, ErrorContext> {
24461        let mut iter = self.clone();
24462        iter.pos = 0;
24463        for attr in iter {
24464            if let OpGetlinkDumpReply::Link(val) = attr? {
24465                return Ok(val);
24466            }
24467        }
24468        Err(ErrorContext::new_missing(
24469            "OpGetlinkDumpReply",
24470            "Link",
24471            self.orig_loc,
24472            self.buf.as_ptr() as usize,
24473        ))
24474    }
24475    pub fn get_qdisc(&self) -> Result<&'a CStr, ErrorContext> {
24476        let mut iter = self.clone();
24477        iter.pos = 0;
24478        for attr in iter {
24479            if let OpGetlinkDumpReply::Qdisc(val) = attr? {
24480                return Ok(val);
24481            }
24482        }
24483        Err(ErrorContext::new_missing(
24484            "OpGetlinkDumpReply",
24485            "Qdisc",
24486            self.orig_loc,
24487            self.buf.as_ptr() as usize,
24488        ))
24489    }
24490    pub fn get_stats(&self) -> Result<PushRtnlLinkStats, ErrorContext> {
24491        let mut iter = self.clone();
24492        iter.pos = 0;
24493        for attr in iter {
24494            if let OpGetlinkDumpReply::Stats(val) = attr? {
24495                return Ok(val);
24496            }
24497        }
24498        Err(ErrorContext::new_missing(
24499            "OpGetlinkDumpReply",
24500            "Stats",
24501            self.orig_loc,
24502            self.buf.as_ptr() as usize,
24503        ))
24504    }
24505    pub fn get_cost(&self) -> Result<&'a CStr, ErrorContext> {
24506        let mut iter = self.clone();
24507        iter.pos = 0;
24508        for attr in iter {
24509            if let OpGetlinkDumpReply::Cost(val) = attr? {
24510                return Ok(val);
24511            }
24512        }
24513        Err(ErrorContext::new_missing(
24514            "OpGetlinkDumpReply",
24515            "Cost",
24516            self.orig_loc,
24517            self.buf.as_ptr() as usize,
24518        ))
24519    }
24520    pub fn get_priority(&self) -> Result<&'a CStr, ErrorContext> {
24521        let mut iter = self.clone();
24522        iter.pos = 0;
24523        for attr in iter {
24524            if let OpGetlinkDumpReply::Priority(val) = attr? {
24525                return Ok(val);
24526            }
24527        }
24528        Err(ErrorContext::new_missing(
24529            "OpGetlinkDumpReply",
24530            "Priority",
24531            self.orig_loc,
24532            self.buf.as_ptr() as usize,
24533        ))
24534    }
24535    pub fn get_master(&self) -> Result<u32, ErrorContext> {
24536        let mut iter = self.clone();
24537        iter.pos = 0;
24538        for attr in iter {
24539            if let OpGetlinkDumpReply::Master(val) = attr? {
24540                return Ok(val);
24541            }
24542        }
24543        Err(ErrorContext::new_missing(
24544            "OpGetlinkDumpReply",
24545            "Master",
24546            self.orig_loc,
24547            self.buf.as_ptr() as usize,
24548        ))
24549    }
24550    pub fn get_wireless(&self) -> Result<&'a CStr, ErrorContext> {
24551        let mut iter = self.clone();
24552        iter.pos = 0;
24553        for attr in iter {
24554            if let OpGetlinkDumpReply::Wireless(val) = attr? {
24555                return Ok(val);
24556            }
24557        }
24558        Err(ErrorContext::new_missing(
24559            "OpGetlinkDumpReply",
24560            "Wireless",
24561            self.orig_loc,
24562            self.buf.as_ptr() as usize,
24563        ))
24564    }
24565    pub fn get_protinfo(&self) -> Result<&'a CStr, ErrorContext> {
24566        let mut iter = self.clone();
24567        iter.pos = 0;
24568        for attr in iter {
24569            if let OpGetlinkDumpReply::Protinfo(val) = attr? {
24570                return Ok(val);
24571            }
24572        }
24573        Err(ErrorContext::new_missing(
24574            "OpGetlinkDumpReply",
24575            "Protinfo",
24576            self.orig_loc,
24577            self.buf.as_ptr() as usize,
24578        ))
24579    }
24580    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
24581        let mut iter = self.clone();
24582        iter.pos = 0;
24583        for attr in iter {
24584            if let OpGetlinkDumpReply::Txqlen(val) = attr? {
24585                return Ok(val);
24586            }
24587        }
24588        Err(ErrorContext::new_missing(
24589            "OpGetlinkDumpReply",
24590            "Txqlen",
24591            self.orig_loc,
24592            self.buf.as_ptr() as usize,
24593        ))
24594    }
24595    pub fn get_map(&self) -> Result<PushRtnlLinkIfmap, ErrorContext> {
24596        let mut iter = self.clone();
24597        iter.pos = 0;
24598        for attr in iter {
24599            if let OpGetlinkDumpReply::Map(val) = attr? {
24600                return Ok(val);
24601            }
24602        }
24603        Err(ErrorContext::new_missing(
24604            "OpGetlinkDumpReply",
24605            "Map",
24606            self.orig_loc,
24607            self.buf.as_ptr() as usize,
24608        ))
24609    }
24610    pub fn get_weight(&self) -> Result<u32, ErrorContext> {
24611        let mut iter = self.clone();
24612        iter.pos = 0;
24613        for attr in iter {
24614            if let OpGetlinkDumpReply::Weight(val) = attr? {
24615                return Ok(val);
24616            }
24617        }
24618        Err(ErrorContext::new_missing(
24619            "OpGetlinkDumpReply",
24620            "Weight",
24621            self.orig_loc,
24622            self.buf.as_ptr() as usize,
24623        ))
24624    }
24625    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
24626        let mut iter = self.clone();
24627        iter.pos = 0;
24628        for attr in iter {
24629            if let OpGetlinkDumpReply::Operstate(val) = attr? {
24630                return Ok(val);
24631            }
24632        }
24633        Err(ErrorContext::new_missing(
24634            "OpGetlinkDumpReply",
24635            "Operstate",
24636            self.orig_loc,
24637            self.buf.as_ptr() as usize,
24638        ))
24639    }
24640    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
24641        let mut iter = self.clone();
24642        iter.pos = 0;
24643        for attr in iter {
24644            if let OpGetlinkDumpReply::Linkmode(val) = attr? {
24645                return Ok(val);
24646            }
24647        }
24648        Err(ErrorContext::new_missing(
24649            "OpGetlinkDumpReply",
24650            "Linkmode",
24651            self.orig_loc,
24652            self.buf.as_ptr() as usize,
24653        ))
24654    }
24655    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
24656        let mut iter = self.clone();
24657        iter.pos = 0;
24658        for attr in iter {
24659            if let OpGetlinkDumpReply::Linkinfo(val) = attr? {
24660                return Ok(val);
24661            }
24662        }
24663        Err(ErrorContext::new_missing(
24664            "OpGetlinkDumpReply",
24665            "Linkinfo",
24666            self.orig_loc,
24667            self.buf.as_ptr() as usize,
24668        ))
24669    }
24670    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
24671        let mut iter = self.clone();
24672        iter.pos = 0;
24673        for attr in iter {
24674            if let OpGetlinkDumpReply::NetNsPid(val) = attr? {
24675                return Ok(val);
24676            }
24677        }
24678        Err(ErrorContext::new_missing(
24679            "OpGetlinkDumpReply",
24680            "NetNsPid",
24681            self.orig_loc,
24682            self.buf.as_ptr() as usize,
24683        ))
24684    }
24685    pub fn get_ifalias(&self) -> Result<&'a CStr, ErrorContext> {
24686        let mut iter = self.clone();
24687        iter.pos = 0;
24688        for attr in iter {
24689            if let OpGetlinkDumpReply::Ifalias(val) = attr? {
24690                return Ok(val);
24691            }
24692        }
24693        Err(ErrorContext::new_missing(
24694            "OpGetlinkDumpReply",
24695            "Ifalias",
24696            self.orig_loc,
24697            self.buf.as_ptr() as usize,
24698        ))
24699    }
24700    pub fn get_num_vf(&self) -> Result<u32, ErrorContext> {
24701        let mut iter = self.clone();
24702        iter.pos = 0;
24703        for attr in iter {
24704            if let OpGetlinkDumpReply::NumVf(val) = attr? {
24705                return Ok(val);
24706            }
24707        }
24708        Err(ErrorContext::new_missing(
24709            "OpGetlinkDumpReply",
24710            "NumVf",
24711            self.orig_loc,
24712            self.buf.as_ptr() as usize,
24713        ))
24714    }
24715    pub fn get_vfinfo_list(&self) -> Result<IterableVfinfoListAttrs<'a>, ErrorContext> {
24716        let mut iter = self.clone();
24717        iter.pos = 0;
24718        for attr in iter {
24719            if let OpGetlinkDumpReply::VfinfoList(val) = attr? {
24720                return Ok(val);
24721            }
24722        }
24723        Err(ErrorContext::new_missing(
24724            "OpGetlinkDumpReply",
24725            "VfinfoList",
24726            self.orig_loc,
24727            self.buf.as_ptr() as usize,
24728        ))
24729    }
24730    pub fn get_stats64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
24731        let mut iter = self.clone();
24732        iter.pos = 0;
24733        for attr in iter {
24734            if let OpGetlinkDumpReply::Stats64(val) = attr? {
24735                return Ok(val);
24736            }
24737        }
24738        Err(ErrorContext::new_missing(
24739            "OpGetlinkDumpReply",
24740            "Stats64",
24741            self.orig_loc,
24742            self.buf.as_ptr() as usize,
24743        ))
24744    }
24745    pub fn get_vf_ports(&self) -> Result<IterableVfPortsAttrs<'a>, ErrorContext> {
24746        let mut iter = self.clone();
24747        iter.pos = 0;
24748        for attr in iter {
24749            if let OpGetlinkDumpReply::VfPorts(val) = attr? {
24750                return Ok(val);
24751            }
24752        }
24753        Err(ErrorContext::new_missing(
24754            "OpGetlinkDumpReply",
24755            "VfPorts",
24756            self.orig_loc,
24757            self.buf.as_ptr() as usize,
24758        ))
24759    }
24760    pub fn get_port_self(&self) -> Result<IterablePortSelfAttrs<'a>, ErrorContext> {
24761        let mut iter = self.clone();
24762        iter.pos = 0;
24763        for attr in iter {
24764            if let OpGetlinkDumpReply::PortSelf(val) = attr? {
24765                return Ok(val);
24766            }
24767        }
24768        Err(ErrorContext::new_missing(
24769            "OpGetlinkDumpReply",
24770            "PortSelf",
24771            self.orig_loc,
24772            self.buf.as_ptr() as usize,
24773        ))
24774    }
24775    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
24776        let mut iter = self.clone();
24777        iter.pos = 0;
24778        for attr in iter {
24779            if let OpGetlinkDumpReply::AfSpec(val) = attr? {
24780                return Ok(val);
24781            }
24782        }
24783        Err(ErrorContext::new_missing(
24784            "OpGetlinkDumpReply",
24785            "AfSpec",
24786            self.orig_loc,
24787            self.buf.as_ptr() as usize,
24788        ))
24789    }
24790    pub fn get_group(&self) -> Result<u32, ErrorContext> {
24791        let mut iter = self.clone();
24792        iter.pos = 0;
24793        for attr in iter {
24794            if let OpGetlinkDumpReply::Group(val) = attr? {
24795                return Ok(val);
24796            }
24797        }
24798        Err(ErrorContext::new_missing(
24799            "OpGetlinkDumpReply",
24800            "Group",
24801            self.orig_loc,
24802            self.buf.as_ptr() as usize,
24803        ))
24804    }
24805    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
24806        let mut iter = self.clone();
24807        iter.pos = 0;
24808        for attr in iter {
24809            if let OpGetlinkDumpReply::NetNsFd(val) = attr? {
24810                return Ok(val);
24811            }
24812        }
24813        Err(ErrorContext::new_missing(
24814            "OpGetlinkDumpReply",
24815            "NetNsFd",
24816            self.orig_loc,
24817            self.buf.as_ptr() as usize,
24818        ))
24819    }
24820    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
24821    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
24822        let mut iter = self.clone();
24823        iter.pos = 0;
24824        for attr in iter {
24825            if let OpGetlinkDumpReply::ExtMask(val) = attr? {
24826                return Ok(val);
24827            }
24828        }
24829        Err(ErrorContext::new_missing(
24830            "OpGetlinkDumpReply",
24831            "ExtMask",
24832            self.orig_loc,
24833            self.buf.as_ptr() as usize,
24834        ))
24835    }
24836    pub fn get_promiscuity(&self) -> Result<u32, ErrorContext> {
24837        let mut iter = self.clone();
24838        iter.pos = 0;
24839        for attr in iter {
24840            if let OpGetlinkDumpReply::Promiscuity(val) = attr? {
24841                return Ok(val);
24842            }
24843        }
24844        Err(ErrorContext::new_missing(
24845            "OpGetlinkDumpReply",
24846            "Promiscuity",
24847            self.orig_loc,
24848            self.buf.as_ptr() as usize,
24849        ))
24850    }
24851    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
24852        let mut iter = self.clone();
24853        iter.pos = 0;
24854        for attr in iter {
24855            if let OpGetlinkDumpReply::NumTxQueues(val) = attr? {
24856                return Ok(val);
24857            }
24858        }
24859        Err(ErrorContext::new_missing(
24860            "OpGetlinkDumpReply",
24861            "NumTxQueues",
24862            self.orig_loc,
24863            self.buf.as_ptr() as usize,
24864        ))
24865    }
24866    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
24867        let mut iter = self.clone();
24868        iter.pos = 0;
24869        for attr in iter {
24870            if let OpGetlinkDumpReply::NumRxQueues(val) = attr? {
24871                return Ok(val);
24872            }
24873        }
24874        Err(ErrorContext::new_missing(
24875            "OpGetlinkDumpReply",
24876            "NumRxQueues",
24877            self.orig_loc,
24878            self.buf.as_ptr() as usize,
24879        ))
24880    }
24881    pub fn get_carrier(&self) -> Result<u8, ErrorContext> {
24882        let mut iter = self.clone();
24883        iter.pos = 0;
24884        for attr in iter {
24885            if let OpGetlinkDumpReply::Carrier(val) = attr? {
24886                return Ok(val);
24887            }
24888        }
24889        Err(ErrorContext::new_missing(
24890            "OpGetlinkDumpReply",
24891            "Carrier",
24892            self.orig_loc,
24893            self.buf.as_ptr() as usize,
24894        ))
24895    }
24896    pub fn get_phys_port_id(&self) -> Result<&'a [u8], ErrorContext> {
24897        let mut iter = self.clone();
24898        iter.pos = 0;
24899        for attr in iter {
24900            if let OpGetlinkDumpReply::PhysPortId(val) = attr? {
24901                return Ok(val);
24902            }
24903        }
24904        Err(ErrorContext::new_missing(
24905            "OpGetlinkDumpReply",
24906            "PhysPortId",
24907            self.orig_loc,
24908            self.buf.as_ptr() as usize,
24909        ))
24910    }
24911    pub fn get_carrier_changes(&self) -> Result<u32, ErrorContext> {
24912        let mut iter = self.clone();
24913        iter.pos = 0;
24914        for attr in iter {
24915            if let OpGetlinkDumpReply::CarrierChanges(val) = attr? {
24916                return Ok(val);
24917            }
24918        }
24919        Err(ErrorContext::new_missing(
24920            "OpGetlinkDumpReply",
24921            "CarrierChanges",
24922            self.orig_loc,
24923            self.buf.as_ptr() as usize,
24924        ))
24925    }
24926    pub fn get_phys_switch_id(&self) -> Result<&'a [u8], ErrorContext> {
24927        let mut iter = self.clone();
24928        iter.pos = 0;
24929        for attr in iter {
24930            if let OpGetlinkDumpReply::PhysSwitchId(val) = attr? {
24931                return Ok(val);
24932            }
24933        }
24934        Err(ErrorContext::new_missing(
24935            "OpGetlinkDumpReply",
24936            "PhysSwitchId",
24937            self.orig_loc,
24938            self.buf.as_ptr() as usize,
24939        ))
24940    }
24941    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
24942        let mut iter = self.clone();
24943        iter.pos = 0;
24944        for attr in iter {
24945            if let OpGetlinkDumpReply::LinkNetnsid(val) = attr? {
24946                return Ok(val);
24947            }
24948        }
24949        Err(ErrorContext::new_missing(
24950            "OpGetlinkDumpReply",
24951            "LinkNetnsid",
24952            self.orig_loc,
24953            self.buf.as_ptr() as usize,
24954        ))
24955    }
24956    pub fn get_phys_port_name(&self) -> Result<&'a CStr, ErrorContext> {
24957        let mut iter = self.clone();
24958        iter.pos = 0;
24959        for attr in iter {
24960            if let OpGetlinkDumpReply::PhysPortName(val) = attr? {
24961                return Ok(val);
24962            }
24963        }
24964        Err(ErrorContext::new_missing(
24965            "OpGetlinkDumpReply",
24966            "PhysPortName",
24967            self.orig_loc,
24968            self.buf.as_ptr() as usize,
24969        ))
24970    }
24971    pub fn get_proto_down(&self) -> Result<u8, ErrorContext> {
24972        let mut iter = self.clone();
24973        iter.pos = 0;
24974        for attr in iter {
24975            if let OpGetlinkDumpReply::ProtoDown(val) = attr? {
24976                return Ok(val);
24977            }
24978        }
24979        Err(ErrorContext::new_missing(
24980            "OpGetlinkDumpReply",
24981            "ProtoDown",
24982            self.orig_loc,
24983            self.buf.as_ptr() as usize,
24984        ))
24985    }
24986    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
24987        let mut iter = self.clone();
24988        iter.pos = 0;
24989        for attr in iter {
24990            if let OpGetlinkDumpReply::GsoMaxSegs(val) = attr? {
24991                return Ok(val);
24992            }
24993        }
24994        Err(ErrorContext::new_missing(
24995            "OpGetlinkDumpReply",
24996            "GsoMaxSegs",
24997            self.orig_loc,
24998            self.buf.as_ptr() as usize,
24999        ))
25000    }
25001    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
25002        let mut iter = self.clone();
25003        iter.pos = 0;
25004        for attr in iter {
25005            if let OpGetlinkDumpReply::GsoMaxSize(val) = attr? {
25006                return Ok(val);
25007            }
25008        }
25009        Err(ErrorContext::new_missing(
25010            "OpGetlinkDumpReply",
25011            "GsoMaxSize",
25012            self.orig_loc,
25013            self.buf.as_ptr() as usize,
25014        ))
25015    }
25016    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
25017        let mut iter = self.clone();
25018        iter.pos = 0;
25019        for attr in iter {
25020            if let OpGetlinkDumpReply::Pad(val) = attr? {
25021                return Ok(val);
25022            }
25023        }
25024        Err(ErrorContext::new_missing(
25025            "OpGetlinkDumpReply",
25026            "Pad",
25027            self.orig_loc,
25028            self.buf.as_ptr() as usize,
25029        ))
25030    }
25031    pub fn get_xdp(&self) -> Result<IterableXdpAttrs<'a>, ErrorContext> {
25032        let mut iter = self.clone();
25033        iter.pos = 0;
25034        for attr in iter {
25035            if let OpGetlinkDumpReply::Xdp(val) = attr? {
25036                return Ok(val);
25037            }
25038        }
25039        Err(ErrorContext::new_missing(
25040            "OpGetlinkDumpReply",
25041            "Xdp",
25042            self.orig_loc,
25043            self.buf.as_ptr() as usize,
25044        ))
25045    }
25046    pub fn get_event(&self) -> Result<u32, ErrorContext> {
25047        let mut iter = self.clone();
25048        iter.pos = 0;
25049        for attr in iter {
25050            if let OpGetlinkDumpReply::Event(val) = attr? {
25051                return Ok(val);
25052            }
25053        }
25054        Err(ErrorContext::new_missing(
25055            "OpGetlinkDumpReply",
25056            "Event",
25057            self.orig_loc,
25058            self.buf.as_ptr() as usize,
25059        ))
25060    }
25061    pub fn get_new_netnsid(&self) -> Result<i32, ErrorContext> {
25062        let mut iter = self.clone();
25063        iter.pos = 0;
25064        for attr in iter {
25065            if let OpGetlinkDumpReply::NewNetnsid(val) = attr? {
25066                return Ok(val);
25067            }
25068        }
25069        Err(ErrorContext::new_missing(
25070            "OpGetlinkDumpReply",
25071            "NewNetnsid",
25072            self.orig_loc,
25073            self.buf.as_ptr() as usize,
25074        ))
25075    }
25076    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
25077        let mut iter = self.clone();
25078        iter.pos = 0;
25079        for attr in iter {
25080            if let OpGetlinkDumpReply::TargetNetnsid(val) = attr? {
25081                return Ok(val);
25082            }
25083        }
25084        Err(ErrorContext::new_missing(
25085            "OpGetlinkDumpReply",
25086            "TargetNetnsid",
25087            self.orig_loc,
25088            self.buf.as_ptr() as usize,
25089        ))
25090    }
25091    pub fn get_carrier_up_count(&self) -> Result<u32, ErrorContext> {
25092        let mut iter = self.clone();
25093        iter.pos = 0;
25094        for attr in iter {
25095            if let OpGetlinkDumpReply::CarrierUpCount(val) = attr? {
25096                return Ok(val);
25097            }
25098        }
25099        Err(ErrorContext::new_missing(
25100            "OpGetlinkDumpReply",
25101            "CarrierUpCount",
25102            self.orig_loc,
25103            self.buf.as_ptr() as usize,
25104        ))
25105    }
25106    pub fn get_carrier_down_count(&self) -> Result<u32, ErrorContext> {
25107        let mut iter = self.clone();
25108        iter.pos = 0;
25109        for attr in iter {
25110            if let OpGetlinkDumpReply::CarrierDownCount(val) = attr? {
25111                return Ok(val);
25112            }
25113        }
25114        Err(ErrorContext::new_missing(
25115            "OpGetlinkDumpReply",
25116            "CarrierDownCount",
25117            self.orig_loc,
25118            self.buf.as_ptr() as usize,
25119        ))
25120    }
25121    pub fn get_new_ifindex(&self) -> Result<i32, ErrorContext> {
25122        let mut iter = self.clone();
25123        iter.pos = 0;
25124        for attr in iter {
25125            if let OpGetlinkDumpReply::NewIfindex(val) = attr? {
25126                return Ok(val);
25127            }
25128        }
25129        Err(ErrorContext::new_missing(
25130            "OpGetlinkDumpReply",
25131            "NewIfindex",
25132            self.orig_loc,
25133            self.buf.as_ptr() as usize,
25134        ))
25135    }
25136    pub fn get_min_mtu(&self) -> Result<u32, ErrorContext> {
25137        let mut iter = self.clone();
25138        iter.pos = 0;
25139        for attr in iter {
25140            if let OpGetlinkDumpReply::MinMtu(val) = attr? {
25141                return Ok(val);
25142            }
25143        }
25144        Err(ErrorContext::new_missing(
25145            "OpGetlinkDumpReply",
25146            "MinMtu",
25147            self.orig_loc,
25148            self.buf.as_ptr() as usize,
25149        ))
25150    }
25151    pub fn get_max_mtu(&self) -> Result<u32, ErrorContext> {
25152        let mut iter = self.clone();
25153        iter.pos = 0;
25154        for attr in iter {
25155            if let OpGetlinkDumpReply::MaxMtu(val) = attr? {
25156                return Ok(val);
25157            }
25158        }
25159        Err(ErrorContext::new_missing(
25160            "OpGetlinkDumpReply",
25161            "MaxMtu",
25162            self.orig_loc,
25163            self.buf.as_ptr() as usize,
25164        ))
25165    }
25166    pub fn get_prop_list(&self) -> Result<IterablePropListLinkAttrs<'a>, ErrorContext> {
25167        let mut iter = self.clone();
25168        iter.pos = 0;
25169        for attr in iter {
25170            if let OpGetlinkDumpReply::PropList(val) = attr? {
25171                return Ok(val);
25172            }
25173        }
25174        Err(ErrorContext::new_missing(
25175            "OpGetlinkDumpReply",
25176            "PropList",
25177            self.orig_loc,
25178            self.buf.as_ptr() as usize,
25179        ))
25180    }
25181    pub fn get_perm_address(&self) -> Result<&'a [u8], ErrorContext> {
25182        let mut iter = self.clone();
25183        iter.pos = 0;
25184        for attr in iter {
25185            if let OpGetlinkDumpReply::PermAddress(val) = attr? {
25186                return Ok(val);
25187            }
25188        }
25189        Err(ErrorContext::new_missing(
25190            "OpGetlinkDumpReply",
25191            "PermAddress",
25192            self.orig_loc,
25193            self.buf.as_ptr() as usize,
25194        ))
25195    }
25196    pub fn get_proto_down_reason(&self) -> Result<&'a CStr, ErrorContext> {
25197        let mut iter = self.clone();
25198        iter.pos = 0;
25199        for attr in iter {
25200            if let OpGetlinkDumpReply::ProtoDownReason(val) = attr? {
25201                return Ok(val);
25202            }
25203        }
25204        Err(ErrorContext::new_missing(
25205            "OpGetlinkDumpReply",
25206            "ProtoDownReason",
25207            self.orig_loc,
25208            self.buf.as_ptr() as usize,
25209        ))
25210    }
25211    pub fn get_parent_dev_name(&self) -> Result<&'a CStr, ErrorContext> {
25212        let mut iter = self.clone();
25213        iter.pos = 0;
25214        for attr in iter {
25215            if let OpGetlinkDumpReply::ParentDevName(val) = attr? {
25216                return Ok(val);
25217            }
25218        }
25219        Err(ErrorContext::new_missing(
25220            "OpGetlinkDumpReply",
25221            "ParentDevName",
25222            self.orig_loc,
25223            self.buf.as_ptr() as usize,
25224        ))
25225    }
25226    pub fn get_parent_dev_bus_name(&self) -> Result<&'a CStr, ErrorContext> {
25227        let mut iter = self.clone();
25228        iter.pos = 0;
25229        for attr in iter {
25230            if let OpGetlinkDumpReply::ParentDevBusName(val) = attr? {
25231                return Ok(val);
25232            }
25233        }
25234        Err(ErrorContext::new_missing(
25235            "OpGetlinkDumpReply",
25236            "ParentDevBusName",
25237            self.orig_loc,
25238            self.buf.as_ptr() as usize,
25239        ))
25240    }
25241    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
25242        let mut iter = self.clone();
25243        iter.pos = 0;
25244        for attr in iter {
25245            if let OpGetlinkDumpReply::GroMaxSize(val) = attr? {
25246                return Ok(val);
25247            }
25248        }
25249        Err(ErrorContext::new_missing(
25250            "OpGetlinkDumpReply",
25251            "GroMaxSize",
25252            self.orig_loc,
25253            self.buf.as_ptr() as usize,
25254        ))
25255    }
25256    pub fn get_tso_max_size(&self) -> Result<u32, ErrorContext> {
25257        let mut iter = self.clone();
25258        iter.pos = 0;
25259        for attr in iter {
25260            if let OpGetlinkDumpReply::TsoMaxSize(val) = attr? {
25261                return Ok(val);
25262            }
25263        }
25264        Err(ErrorContext::new_missing(
25265            "OpGetlinkDumpReply",
25266            "TsoMaxSize",
25267            self.orig_loc,
25268            self.buf.as_ptr() as usize,
25269        ))
25270    }
25271    pub fn get_tso_max_segs(&self) -> Result<u32, ErrorContext> {
25272        let mut iter = self.clone();
25273        iter.pos = 0;
25274        for attr in iter {
25275            if let OpGetlinkDumpReply::TsoMaxSegs(val) = attr? {
25276                return Ok(val);
25277            }
25278        }
25279        Err(ErrorContext::new_missing(
25280            "OpGetlinkDumpReply",
25281            "TsoMaxSegs",
25282            self.orig_loc,
25283            self.buf.as_ptr() as usize,
25284        ))
25285    }
25286    pub fn get_allmulti(&self) -> Result<u32, ErrorContext> {
25287        let mut iter = self.clone();
25288        iter.pos = 0;
25289        for attr in iter {
25290            if let OpGetlinkDumpReply::Allmulti(val) = attr? {
25291                return Ok(val);
25292            }
25293        }
25294        Err(ErrorContext::new_missing(
25295            "OpGetlinkDumpReply",
25296            "Allmulti",
25297            self.orig_loc,
25298            self.buf.as_ptr() as usize,
25299        ))
25300    }
25301    pub fn get_devlink_port(&self) -> Result<&'a [u8], ErrorContext> {
25302        let mut iter = self.clone();
25303        iter.pos = 0;
25304        for attr in iter {
25305            if let OpGetlinkDumpReply::DevlinkPort(val) = attr? {
25306                return Ok(val);
25307            }
25308        }
25309        Err(ErrorContext::new_missing(
25310            "OpGetlinkDumpReply",
25311            "DevlinkPort",
25312            self.orig_loc,
25313            self.buf.as_ptr() as usize,
25314        ))
25315    }
25316    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
25317        let mut iter = self.clone();
25318        iter.pos = 0;
25319        for attr in iter {
25320            if let OpGetlinkDumpReply::GsoIpv4MaxSize(val) = attr? {
25321                return Ok(val);
25322            }
25323        }
25324        Err(ErrorContext::new_missing(
25325            "OpGetlinkDumpReply",
25326            "GsoIpv4MaxSize",
25327            self.orig_loc,
25328            self.buf.as_ptr() as usize,
25329        ))
25330    }
25331    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
25332        let mut iter = self.clone();
25333        iter.pos = 0;
25334        for attr in iter {
25335            if let OpGetlinkDumpReply::GroIpv4MaxSize(val) = attr? {
25336                return Ok(val);
25337            }
25338        }
25339        Err(ErrorContext::new_missing(
25340            "OpGetlinkDumpReply",
25341            "GroIpv4MaxSize",
25342            self.orig_loc,
25343            self.buf.as_ptr() as usize,
25344        ))
25345    }
25346    pub fn get_dpll_pin(&self) -> Result<IterableLinkDpllPinAttrs<'a>, ErrorContext> {
25347        let mut iter = self.clone();
25348        iter.pos = 0;
25349        for attr in iter {
25350            if let OpGetlinkDumpReply::DpllPin(val) = attr? {
25351                return Ok(val);
25352            }
25353        }
25354        Err(ErrorContext::new_missing(
25355            "OpGetlinkDumpReply",
25356            "DpllPin",
25357            self.orig_loc,
25358            self.buf.as_ptr() as usize,
25359        ))
25360    }
25361    #[doc = "EDT offload horizon supported by the device (in nsec)."]
25362    pub fn get_max_pacing_offload_horizon(&self) -> Result<u32, ErrorContext> {
25363        let mut iter = self.clone();
25364        iter.pos = 0;
25365        for attr in iter {
25366            if let OpGetlinkDumpReply::MaxPacingOffloadHorizon(val) = attr? {
25367                return Ok(val);
25368            }
25369        }
25370        Err(ErrorContext::new_missing(
25371            "OpGetlinkDumpReply",
25372            "MaxPacingOffloadHorizon",
25373            self.orig_loc,
25374            self.buf.as_ptr() as usize,
25375        ))
25376    }
25377    pub fn get_netns_immutable(&self) -> Result<u8, ErrorContext> {
25378        let mut iter = self.clone();
25379        iter.pos = 0;
25380        for attr in iter {
25381            if let OpGetlinkDumpReply::NetnsImmutable(val) = attr? {
25382                return Ok(val);
25383            }
25384        }
25385        Err(ErrorContext::new_missing(
25386            "OpGetlinkDumpReply",
25387            "NetnsImmutable",
25388            self.orig_loc,
25389            self.buf.as_ptr() as usize,
25390        ))
25391    }
25392}
25393impl OpGetlinkDumpReply<'_> {
25394    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpGetlinkDumpReply<'a>) {
25395        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
25396        (
25397            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
25398            IterableOpGetlinkDumpReply::with_loc(attrs, buf.as_ptr() as usize),
25399        )
25400    }
25401    fn attr_from_type(r#type: u16) -> Option<&'static str> {
25402        LinkAttrs::attr_from_type(r#type)
25403    }
25404}
25405#[derive(Clone, Copy, Default)]
25406pub struct IterableOpGetlinkDumpReply<'a> {
25407    buf: &'a [u8],
25408    pos: usize,
25409    orig_loc: usize,
25410}
25411impl<'a> IterableOpGetlinkDumpReply<'a> {
25412    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
25413        Self {
25414            buf,
25415            pos: 0,
25416            orig_loc,
25417        }
25418    }
25419    pub fn get_buf(&self) -> &'a [u8] {
25420        self.buf
25421    }
25422}
25423impl<'a> Iterator for IterableOpGetlinkDumpReply<'a> {
25424    type Item = Result<OpGetlinkDumpReply<'a>, ErrorContext>;
25425    fn next(&mut self) -> Option<Self::Item> {
25426        let pos = self.pos;
25427        let mut r#type;
25428        loop {
25429            r#type = None;
25430            if self.buf.len() == self.pos {
25431                return None;
25432            }
25433            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
25434                break;
25435            };
25436            r#type = Some(header.r#type);
25437            let res = match header.r#type {
25438                1u16 => OpGetlinkDumpReply::Address({
25439                    let res = Some(next);
25440                    let Some(val) = res else { break };
25441                    val
25442                }),
25443                2u16 => OpGetlinkDumpReply::Broadcast({
25444                    let res = Some(next);
25445                    let Some(val) = res else { break };
25446                    val
25447                }),
25448                3u16 => OpGetlinkDumpReply::Ifname({
25449                    let res = CStr::from_bytes_with_nul(next).ok();
25450                    let Some(val) = res else { break };
25451                    val
25452                }),
25453                4u16 => OpGetlinkDumpReply::Mtu({
25454                    let res = parse_u32(next);
25455                    let Some(val) = res else { break };
25456                    val
25457                }),
25458                5u16 => OpGetlinkDumpReply::Link({
25459                    let res = parse_u32(next);
25460                    let Some(val) = res else { break };
25461                    val
25462                }),
25463                6u16 => OpGetlinkDumpReply::Qdisc({
25464                    let res = CStr::from_bytes_with_nul(next).ok();
25465                    let Some(val) = res else { break };
25466                    val
25467                }),
25468                7u16 => OpGetlinkDumpReply::Stats({
25469                    let res = Some(PushRtnlLinkStats::new_from_zeroed(next));
25470                    let Some(val) = res else { break };
25471                    val
25472                }),
25473                8u16 => OpGetlinkDumpReply::Cost({
25474                    let res = CStr::from_bytes_with_nul(next).ok();
25475                    let Some(val) = res else { break };
25476                    val
25477                }),
25478                9u16 => OpGetlinkDumpReply::Priority({
25479                    let res = CStr::from_bytes_with_nul(next).ok();
25480                    let Some(val) = res else { break };
25481                    val
25482                }),
25483                10u16 => OpGetlinkDumpReply::Master({
25484                    let res = parse_u32(next);
25485                    let Some(val) = res else { break };
25486                    val
25487                }),
25488                11u16 => OpGetlinkDumpReply::Wireless({
25489                    let res = CStr::from_bytes_with_nul(next).ok();
25490                    let Some(val) = res else { break };
25491                    val
25492                }),
25493                12u16 => OpGetlinkDumpReply::Protinfo({
25494                    let res = CStr::from_bytes_with_nul(next).ok();
25495                    let Some(val) = res else { break };
25496                    val
25497                }),
25498                13u16 => OpGetlinkDumpReply::Txqlen({
25499                    let res = parse_u32(next);
25500                    let Some(val) = res else { break };
25501                    val
25502                }),
25503                14u16 => OpGetlinkDumpReply::Map({
25504                    let res = PushRtnlLinkIfmap::new_from_slice(next);
25505                    let Some(val) = res else { break };
25506                    val
25507                }),
25508                15u16 => OpGetlinkDumpReply::Weight({
25509                    let res = parse_u32(next);
25510                    let Some(val) = res else { break };
25511                    val
25512                }),
25513                16u16 => OpGetlinkDumpReply::Operstate({
25514                    let res = parse_u8(next);
25515                    let Some(val) = res else { break };
25516                    val
25517                }),
25518                17u16 => OpGetlinkDumpReply::Linkmode({
25519                    let res = parse_u8(next);
25520                    let Some(val) = res else { break };
25521                    val
25522                }),
25523                18u16 => OpGetlinkDumpReply::Linkinfo({
25524                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
25525                    let Some(val) = res else { break };
25526                    val
25527                }),
25528                19u16 => OpGetlinkDumpReply::NetNsPid({
25529                    let res = parse_u32(next);
25530                    let Some(val) = res else { break };
25531                    val
25532                }),
25533                20u16 => OpGetlinkDumpReply::Ifalias({
25534                    let res = CStr::from_bytes_with_nul(next).ok();
25535                    let Some(val) = res else { break };
25536                    val
25537                }),
25538                21u16 => OpGetlinkDumpReply::NumVf({
25539                    let res = parse_u32(next);
25540                    let Some(val) = res else { break };
25541                    val
25542                }),
25543                22u16 => OpGetlinkDumpReply::VfinfoList({
25544                    let res = Some(IterableVfinfoListAttrs::with_loc(next, self.orig_loc));
25545                    let Some(val) = res else { break };
25546                    val
25547                }),
25548                23u16 => OpGetlinkDumpReply::Stats64({
25549                    let res = Some(PushRtnlLinkStats64::new_from_zeroed(next));
25550                    let Some(val) = res else { break };
25551                    val
25552                }),
25553                24u16 => OpGetlinkDumpReply::VfPorts({
25554                    let res = Some(IterableVfPortsAttrs::with_loc(next, self.orig_loc));
25555                    let Some(val) = res else { break };
25556                    val
25557                }),
25558                25u16 => OpGetlinkDumpReply::PortSelf({
25559                    let res = Some(IterablePortSelfAttrs::with_loc(next, self.orig_loc));
25560                    let Some(val) = res else { break };
25561                    val
25562                }),
25563                26u16 => OpGetlinkDumpReply::AfSpec({
25564                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
25565                    let Some(val) = res else { break };
25566                    val
25567                }),
25568                27u16 => OpGetlinkDumpReply::Group({
25569                    let res = parse_u32(next);
25570                    let Some(val) = res else { break };
25571                    val
25572                }),
25573                28u16 => OpGetlinkDumpReply::NetNsFd({
25574                    let res = parse_u32(next);
25575                    let Some(val) = res else { break };
25576                    val
25577                }),
25578                29u16 => OpGetlinkDumpReply::ExtMask({
25579                    let res = parse_u32(next);
25580                    let Some(val) = res else { break };
25581                    val
25582                }),
25583                30u16 => OpGetlinkDumpReply::Promiscuity({
25584                    let res = parse_u32(next);
25585                    let Some(val) = res else { break };
25586                    val
25587                }),
25588                31u16 => OpGetlinkDumpReply::NumTxQueues({
25589                    let res = parse_u32(next);
25590                    let Some(val) = res else { break };
25591                    val
25592                }),
25593                32u16 => OpGetlinkDumpReply::NumRxQueues({
25594                    let res = parse_u32(next);
25595                    let Some(val) = res else { break };
25596                    val
25597                }),
25598                33u16 => OpGetlinkDumpReply::Carrier({
25599                    let res = parse_u8(next);
25600                    let Some(val) = res else { break };
25601                    val
25602                }),
25603                34u16 => OpGetlinkDumpReply::PhysPortId({
25604                    let res = Some(next);
25605                    let Some(val) = res else { break };
25606                    val
25607                }),
25608                35u16 => OpGetlinkDumpReply::CarrierChanges({
25609                    let res = parse_u32(next);
25610                    let Some(val) = res else { break };
25611                    val
25612                }),
25613                36u16 => OpGetlinkDumpReply::PhysSwitchId({
25614                    let res = Some(next);
25615                    let Some(val) = res else { break };
25616                    val
25617                }),
25618                37u16 => OpGetlinkDumpReply::LinkNetnsid({
25619                    let res = parse_i32(next);
25620                    let Some(val) = res else { break };
25621                    val
25622                }),
25623                38u16 => OpGetlinkDumpReply::PhysPortName({
25624                    let res = CStr::from_bytes_with_nul(next).ok();
25625                    let Some(val) = res else { break };
25626                    val
25627                }),
25628                39u16 => OpGetlinkDumpReply::ProtoDown({
25629                    let res = parse_u8(next);
25630                    let Some(val) = res else { break };
25631                    val
25632                }),
25633                40u16 => OpGetlinkDumpReply::GsoMaxSegs({
25634                    let res = parse_u32(next);
25635                    let Some(val) = res else { break };
25636                    val
25637                }),
25638                41u16 => OpGetlinkDumpReply::GsoMaxSize({
25639                    let res = parse_u32(next);
25640                    let Some(val) = res else { break };
25641                    val
25642                }),
25643                42u16 => OpGetlinkDumpReply::Pad({
25644                    let res = Some(next);
25645                    let Some(val) = res else { break };
25646                    val
25647                }),
25648                43u16 => OpGetlinkDumpReply::Xdp({
25649                    let res = Some(IterableXdpAttrs::with_loc(next, self.orig_loc));
25650                    let Some(val) = res else { break };
25651                    val
25652                }),
25653                44u16 => OpGetlinkDumpReply::Event({
25654                    let res = parse_u32(next);
25655                    let Some(val) = res else { break };
25656                    val
25657                }),
25658                45u16 => OpGetlinkDumpReply::NewNetnsid({
25659                    let res = parse_i32(next);
25660                    let Some(val) = res else { break };
25661                    val
25662                }),
25663                46u16 => OpGetlinkDumpReply::TargetNetnsid({
25664                    let res = parse_i32(next);
25665                    let Some(val) = res else { break };
25666                    val
25667                }),
25668                47u16 => OpGetlinkDumpReply::CarrierUpCount({
25669                    let res = parse_u32(next);
25670                    let Some(val) = res else { break };
25671                    val
25672                }),
25673                48u16 => OpGetlinkDumpReply::CarrierDownCount({
25674                    let res = parse_u32(next);
25675                    let Some(val) = res else { break };
25676                    val
25677                }),
25678                49u16 => OpGetlinkDumpReply::NewIfindex({
25679                    let res = parse_i32(next);
25680                    let Some(val) = res else { break };
25681                    val
25682                }),
25683                50u16 => OpGetlinkDumpReply::MinMtu({
25684                    let res = parse_u32(next);
25685                    let Some(val) = res else { break };
25686                    val
25687                }),
25688                51u16 => OpGetlinkDumpReply::MaxMtu({
25689                    let res = parse_u32(next);
25690                    let Some(val) = res else { break };
25691                    val
25692                }),
25693                52u16 => OpGetlinkDumpReply::PropList({
25694                    let res = Some(IterablePropListLinkAttrs::with_loc(next, self.orig_loc));
25695                    let Some(val) = res else { break };
25696                    val
25697                }),
25698                54u16 => OpGetlinkDumpReply::PermAddress({
25699                    let res = Some(next);
25700                    let Some(val) = res else { break };
25701                    val
25702                }),
25703                55u16 => OpGetlinkDumpReply::ProtoDownReason({
25704                    let res = CStr::from_bytes_with_nul(next).ok();
25705                    let Some(val) = res else { break };
25706                    val
25707                }),
25708                56u16 => OpGetlinkDumpReply::ParentDevName({
25709                    let res = CStr::from_bytes_with_nul(next).ok();
25710                    let Some(val) = res else { break };
25711                    val
25712                }),
25713                57u16 => OpGetlinkDumpReply::ParentDevBusName({
25714                    let res = CStr::from_bytes_with_nul(next).ok();
25715                    let Some(val) = res else { break };
25716                    val
25717                }),
25718                58u16 => OpGetlinkDumpReply::GroMaxSize({
25719                    let res = parse_u32(next);
25720                    let Some(val) = res else { break };
25721                    val
25722                }),
25723                59u16 => OpGetlinkDumpReply::TsoMaxSize({
25724                    let res = parse_u32(next);
25725                    let Some(val) = res else { break };
25726                    val
25727                }),
25728                60u16 => OpGetlinkDumpReply::TsoMaxSegs({
25729                    let res = parse_u32(next);
25730                    let Some(val) = res else { break };
25731                    val
25732                }),
25733                61u16 => OpGetlinkDumpReply::Allmulti({
25734                    let res = parse_u32(next);
25735                    let Some(val) = res else { break };
25736                    val
25737                }),
25738                62u16 => OpGetlinkDumpReply::DevlinkPort({
25739                    let res = Some(next);
25740                    let Some(val) = res else { break };
25741                    val
25742                }),
25743                63u16 => OpGetlinkDumpReply::GsoIpv4MaxSize({
25744                    let res = parse_u32(next);
25745                    let Some(val) = res else { break };
25746                    val
25747                }),
25748                64u16 => OpGetlinkDumpReply::GroIpv4MaxSize({
25749                    let res = parse_u32(next);
25750                    let Some(val) = res else { break };
25751                    val
25752                }),
25753                65u16 => OpGetlinkDumpReply::DpllPin({
25754                    let res = Some(IterableLinkDpllPinAttrs::with_loc(next, self.orig_loc));
25755                    let Some(val) = res else { break };
25756                    val
25757                }),
25758                66u16 => OpGetlinkDumpReply::MaxPacingOffloadHorizon({
25759                    let res = parse_u32(next);
25760                    let Some(val) = res else { break };
25761                    val
25762                }),
25763                67u16 => OpGetlinkDumpReply::NetnsImmutable({
25764                    let res = parse_u8(next);
25765                    let Some(val) = res else { break };
25766                    val
25767                }),
25768                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
25769                n => continue,
25770            };
25771            return Some(Ok(res));
25772        }
25773        Some(Err(ErrorContext::new(
25774            "OpGetlinkDumpReply",
25775            r#type.and_then(|t| OpGetlinkDumpReply::attr_from_type(t)),
25776            self.orig_loc,
25777            self.buf.as_ptr().wrapping_add(pos) as usize,
25778        )))
25779    }
25780}
25781impl<'a> std::fmt::Debug for IterableOpGetlinkDumpReply<'_> {
25782    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25783        let mut fmt = f.debug_struct("OpGetlinkDumpReply");
25784        for attr in self.clone() {
25785            let attr = match attr {
25786                Ok(a) => a,
25787                Err(err) => {
25788                    fmt.finish()?;
25789                    f.write_str("Err(")?;
25790                    err.fmt(f)?;
25791                    return f.write_str(")");
25792                }
25793            };
25794            match attr {
25795                OpGetlinkDumpReply::Address(val) => fmt.field("Address", &val),
25796                OpGetlinkDumpReply::Broadcast(val) => fmt.field("Broadcast", &val),
25797                OpGetlinkDumpReply::Ifname(val) => fmt.field("Ifname", &val),
25798                OpGetlinkDumpReply::Mtu(val) => fmt.field("Mtu", &val),
25799                OpGetlinkDumpReply::Link(val) => fmt.field("Link", &val),
25800                OpGetlinkDumpReply::Qdisc(val) => fmt.field("Qdisc", &val),
25801                OpGetlinkDumpReply::Stats(val) => fmt.field("Stats", &val),
25802                OpGetlinkDumpReply::Cost(val) => fmt.field("Cost", &val),
25803                OpGetlinkDumpReply::Priority(val) => fmt.field("Priority", &val),
25804                OpGetlinkDumpReply::Master(val) => fmt.field("Master", &val),
25805                OpGetlinkDumpReply::Wireless(val) => fmt.field("Wireless", &val),
25806                OpGetlinkDumpReply::Protinfo(val) => fmt.field("Protinfo", &val),
25807                OpGetlinkDumpReply::Txqlen(val) => fmt.field("Txqlen", &val),
25808                OpGetlinkDumpReply::Map(val) => fmt.field("Map", &val),
25809                OpGetlinkDumpReply::Weight(val) => fmt.field("Weight", &val),
25810                OpGetlinkDumpReply::Operstate(val) => fmt.field("Operstate", &val),
25811                OpGetlinkDumpReply::Linkmode(val) => fmt.field("Linkmode", &val),
25812                OpGetlinkDumpReply::Linkinfo(val) => fmt.field("Linkinfo", &val),
25813                OpGetlinkDumpReply::NetNsPid(val) => fmt.field("NetNsPid", &val),
25814                OpGetlinkDumpReply::Ifalias(val) => fmt.field("Ifalias", &val),
25815                OpGetlinkDumpReply::NumVf(val) => fmt.field("NumVf", &val),
25816                OpGetlinkDumpReply::VfinfoList(val) => fmt.field("VfinfoList", &val),
25817                OpGetlinkDumpReply::Stats64(val) => fmt.field("Stats64", &val),
25818                OpGetlinkDumpReply::VfPorts(val) => fmt.field("VfPorts", &val),
25819                OpGetlinkDumpReply::PortSelf(val) => fmt.field("PortSelf", &val),
25820                OpGetlinkDumpReply::AfSpec(val) => fmt.field("AfSpec", &val),
25821                OpGetlinkDumpReply::Group(val) => fmt.field("Group", &val),
25822                OpGetlinkDumpReply::NetNsFd(val) => fmt.field("NetNsFd", &val),
25823                OpGetlinkDumpReply::ExtMask(val) => {
25824                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
25825                }
25826                OpGetlinkDumpReply::Promiscuity(val) => fmt.field("Promiscuity", &val),
25827                OpGetlinkDumpReply::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
25828                OpGetlinkDumpReply::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
25829                OpGetlinkDumpReply::Carrier(val) => fmt.field("Carrier", &val),
25830                OpGetlinkDumpReply::PhysPortId(val) => fmt.field("PhysPortId", &val),
25831                OpGetlinkDumpReply::CarrierChanges(val) => fmt.field("CarrierChanges", &val),
25832                OpGetlinkDumpReply::PhysSwitchId(val) => fmt.field("PhysSwitchId", &val),
25833                OpGetlinkDumpReply::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
25834                OpGetlinkDumpReply::PhysPortName(val) => fmt.field("PhysPortName", &val),
25835                OpGetlinkDumpReply::ProtoDown(val) => fmt.field("ProtoDown", &val),
25836                OpGetlinkDumpReply::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
25837                OpGetlinkDumpReply::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
25838                OpGetlinkDumpReply::Pad(val) => fmt.field("Pad", &val),
25839                OpGetlinkDumpReply::Xdp(val) => fmt.field("Xdp", &val),
25840                OpGetlinkDumpReply::Event(val) => fmt.field("Event", &val),
25841                OpGetlinkDumpReply::NewNetnsid(val) => fmt.field("NewNetnsid", &val),
25842                OpGetlinkDumpReply::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
25843                OpGetlinkDumpReply::CarrierUpCount(val) => fmt.field("CarrierUpCount", &val),
25844                OpGetlinkDumpReply::CarrierDownCount(val) => fmt.field("CarrierDownCount", &val),
25845                OpGetlinkDumpReply::NewIfindex(val) => fmt.field("NewIfindex", &val),
25846                OpGetlinkDumpReply::MinMtu(val) => fmt.field("MinMtu", &val),
25847                OpGetlinkDumpReply::MaxMtu(val) => fmt.field("MaxMtu", &val),
25848                OpGetlinkDumpReply::PropList(val) => fmt.field("PropList", &val),
25849                OpGetlinkDumpReply::PermAddress(val) => fmt.field("PermAddress", &val),
25850                OpGetlinkDumpReply::ProtoDownReason(val) => fmt.field("ProtoDownReason", &val),
25851                OpGetlinkDumpReply::ParentDevName(val) => fmt.field("ParentDevName", &val),
25852                OpGetlinkDumpReply::ParentDevBusName(val) => fmt.field("ParentDevBusName", &val),
25853                OpGetlinkDumpReply::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
25854                OpGetlinkDumpReply::TsoMaxSize(val) => fmt.field("TsoMaxSize", &val),
25855                OpGetlinkDumpReply::TsoMaxSegs(val) => fmt.field("TsoMaxSegs", &val),
25856                OpGetlinkDumpReply::Allmulti(val) => fmt.field("Allmulti", &val),
25857                OpGetlinkDumpReply::DevlinkPort(val) => fmt.field("DevlinkPort", &val),
25858                OpGetlinkDumpReply::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
25859                OpGetlinkDumpReply::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
25860                OpGetlinkDumpReply::DpllPin(val) => fmt.field("DpllPin", &val),
25861                OpGetlinkDumpReply::MaxPacingOffloadHorizon(val) => {
25862                    fmt.field("MaxPacingOffloadHorizon", &val)
25863                }
25864                OpGetlinkDumpReply::NetnsImmutable(val) => fmt.field("NetnsImmutable", &val),
25865            };
25866        }
25867        fmt.finish()
25868    }
25869}
25870impl IterableOpGetlinkDumpReply<'_> {
25871    pub fn lookup_attr(
25872        &self,
25873        offset: usize,
25874        missing_type: Option<u16>,
25875    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
25876        let mut stack = Vec::new();
25877        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
25878        if cur == offset + PushIfinfomsg::len() {
25879            stack.push(("OpGetlinkDumpReply", offset));
25880            return (
25881                stack,
25882                missing_type.and_then(|t| OpGetlinkDumpReply::attr_from_type(t)),
25883            );
25884        }
25885        if cur > offset || cur + self.buf.len() < offset {
25886            return (stack, None);
25887        }
25888        let mut attrs = self.clone();
25889        let mut last_off = cur + attrs.pos;
25890        let mut missing = None;
25891        while let Some(attr) = attrs.next() {
25892            let Ok(attr) = attr else { break };
25893            match attr {
25894                OpGetlinkDumpReply::Address(val) => {
25895                    if last_off == offset {
25896                        stack.push(("Address", last_off));
25897                        break;
25898                    }
25899                }
25900                OpGetlinkDumpReply::Broadcast(val) => {
25901                    if last_off == offset {
25902                        stack.push(("Broadcast", last_off));
25903                        break;
25904                    }
25905                }
25906                OpGetlinkDumpReply::Ifname(val) => {
25907                    if last_off == offset {
25908                        stack.push(("Ifname", last_off));
25909                        break;
25910                    }
25911                }
25912                OpGetlinkDumpReply::Mtu(val) => {
25913                    if last_off == offset {
25914                        stack.push(("Mtu", last_off));
25915                        break;
25916                    }
25917                }
25918                OpGetlinkDumpReply::Link(val) => {
25919                    if last_off == offset {
25920                        stack.push(("Link", last_off));
25921                        break;
25922                    }
25923                }
25924                OpGetlinkDumpReply::Qdisc(val) => {
25925                    if last_off == offset {
25926                        stack.push(("Qdisc", last_off));
25927                        break;
25928                    }
25929                }
25930                OpGetlinkDumpReply::Stats(val) => {
25931                    if last_off == offset {
25932                        stack.push(("Stats", last_off));
25933                        break;
25934                    }
25935                }
25936                OpGetlinkDumpReply::Cost(val) => {
25937                    if last_off == offset {
25938                        stack.push(("Cost", last_off));
25939                        break;
25940                    }
25941                }
25942                OpGetlinkDumpReply::Priority(val) => {
25943                    if last_off == offset {
25944                        stack.push(("Priority", last_off));
25945                        break;
25946                    }
25947                }
25948                OpGetlinkDumpReply::Master(val) => {
25949                    if last_off == offset {
25950                        stack.push(("Master", last_off));
25951                        break;
25952                    }
25953                }
25954                OpGetlinkDumpReply::Wireless(val) => {
25955                    if last_off == offset {
25956                        stack.push(("Wireless", last_off));
25957                        break;
25958                    }
25959                }
25960                OpGetlinkDumpReply::Protinfo(val) => {
25961                    if last_off == offset {
25962                        stack.push(("Protinfo", last_off));
25963                        break;
25964                    }
25965                }
25966                OpGetlinkDumpReply::Txqlen(val) => {
25967                    if last_off == offset {
25968                        stack.push(("Txqlen", last_off));
25969                        break;
25970                    }
25971                }
25972                OpGetlinkDumpReply::Map(val) => {
25973                    if last_off == offset {
25974                        stack.push(("Map", last_off));
25975                        break;
25976                    }
25977                }
25978                OpGetlinkDumpReply::Weight(val) => {
25979                    if last_off == offset {
25980                        stack.push(("Weight", last_off));
25981                        break;
25982                    }
25983                }
25984                OpGetlinkDumpReply::Operstate(val) => {
25985                    if last_off == offset {
25986                        stack.push(("Operstate", last_off));
25987                        break;
25988                    }
25989                }
25990                OpGetlinkDumpReply::Linkmode(val) => {
25991                    if last_off == offset {
25992                        stack.push(("Linkmode", last_off));
25993                        break;
25994                    }
25995                }
25996                OpGetlinkDumpReply::Linkinfo(val) => {
25997                    (stack, missing) = val.lookup_attr(offset, missing_type);
25998                    if !stack.is_empty() {
25999                        break;
26000                    }
26001                }
26002                OpGetlinkDumpReply::NetNsPid(val) => {
26003                    if last_off == offset {
26004                        stack.push(("NetNsPid", last_off));
26005                        break;
26006                    }
26007                }
26008                OpGetlinkDumpReply::Ifalias(val) => {
26009                    if last_off == offset {
26010                        stack.push(("Ifalias", last_off));
26011                        break;
26012                    }
26013                }
26014                OpGetlinkDumpReply::NumVf(val) => {
26015                    if last_off == offset {
26016                        stack.push(("NumVf", last_off));
26017                        break;
26018                    }
26019                }
26020                OpGetlinkDumpReply::VfinfoList(val) => {
26021                    (stack, missing) = val.lookup_attr(offset, missing_type);
26022                    if !stack.is_empty() {
26023                        break;
26024                    }
26025                }
26026                OpGetlinkDumpReply::Stats64(val) => {
26027                    if last_off == offset {
26028                        stack.push(("Stats64", last_off));
26029                        break;
26030                    }
26031                }
26032                OpGetlinkDumpReply::VfPorts(val) => {
26033                    (stack, missing) = val.lookup_attr(offset, missing_type);
26034                    if !stack.is_empty() {
26035                        break;
26036                    }
26037                }
26038                OpGetlinkDumpReply::PortSelf(val) => {
26039                    (stack, missing) = val.lookup_attr(offset, missing_type);
26040                    if !stack.is_empty() {
26041                        break;
26042                    }
26043                }
26044                OpGetlinkDumpReply::AfSpec(val) => {
26045                    (stack, missing) = val.lookup_attr(offset, missing_type);
26046                    if !stack.is_empty() {
26047                        break;
26048                    }
26049                }
26050                OpGetlinkDumpReply::Group(val) => {
26051                    if last_off == offset {
26052                        stack.push(("Group", last_off));
26053                        break;
26054                    }
26055                }
26056                OpGetlinkDumpReply::NetNsFd(val) => {
26057                    if last_off == offset {
26058                        stack.push(("NetNsFd", last_off));
26059                        break;
26060                    }
26061                }
26062                OpGetlinkDumpReply::ExtMask(val) => {
26063                    if last_off == offset {
26064                        stack.push(("ExtMask", last_off));
26065                        break;
26066                    }
26067                }
26068                OpGetlinkDumpReply::Promiscuity(val) => {
26069                    if last_off == offset {
26070                        stack.push(("Promiscuity", last_off));
26071                        break;
26072                    }
26073                }
26074                OpGetlinkDumpReply::NumTxQueues(val) => {
26075                    if last_off == offset {
26076                        stack.push(("NumTxQueues", last_off));
26077                        break;
26078                    }
26079                }
26080                OpGetlinkDumpReply::NumRxQueues(val) => {
26081                    if last_off == offset {
26082                        stack.push(("NumRxQueues", last_off));
26083                        break;
26084                    }
26085                }
26086                OpGetlinkDumpReply::Carrier(val) => {
26087                    if last_off == offset {
26088                        stack.push(("Carrier", last_off));
26089                        break;
26090                    }
26091                }
26092                OpGetlinkDumpReply::PhysPortId(val) => {
26093                    if last_off == offset {
26094                        stack.push(("PhysPortId", last_off));
26095                        break;
26096                    }
26097                }
26098                OpGetlinkDumpReply::CarrierChanges(val) => {
26099                    if last_off == offset {
26100                        stack.push(("CarrierChanges", last_off));
26101                        break;
26102                    }
26103                }
26104                OpGetlinkDumpReply::PhysSwitchId(val) => {
26105                    if last_off == offset {
26106                        stack.push(("PhysSwitchId", last_off));
26107                        break;
26108                    }
26109                }
26110                OpGetlinkDumpReply::LinkNetnsid(val) => {
26111                    if last_off == offset {
26112                        stack.push(("LinkNetnsid", last_off));
26113                        break;
26114                    }
26115                }
26116                OpGetlinkDumpReply::PhysPortName(val) => {
26117                    if last_off == offset {
26118                        stack.push(("PhysPortName", last_off));
26119                        break;
26120                    }
26121                }
26122                OpGetlinkDumpReply::ProtoDown(val) => {
26123                    if last_off == offset {
26124                        stack.push(("ProtoDown", last_off));
26125                        break;
26126                    }
26127                }
26128                OpGetlinkDumpReply::GsoMaxSegs(val) => {
26129                    if last_off == offset {
26130                        stack.push(("GsoMaxSegs", last_off));
26131                        break;
26132                    }
26133                }
26134                OpGetlinkDumpReply::GsoMaxSize(val) => {
26135                    if last_off == offset {
26136                        stack.push(("GsoMaxSize", last_off));
26137                        break;
26138                    }
26139                }
26140                OpGetlinkDumpReply::Pad(val) => {
26141                    if last_off == offset {
26142                        stack.push(("Pad", last_off));
26143                        break;
26144                    }
26145                }
26146                OpGetlinkDumpReply::Xdp(val) => {
26147                    (stack, missing) = val.lookup_attr(offset, missing_type);
26148                    if !stack.is_empty() {
26149                        break;
26150                    }
26151                }
26152                OpGetlinkDumpReply::Event(val) => {
26153                    if last_off == offset {
26154                        stack.push(("Event", last_off));
26155                        break;
26156                    }
26157                }
26158                OpGetlinkDumpReply::NewNetnsid(val) => {
26159                    if last_off == offset {
26160                        stack.push(("NewNetnsid", last_off));
26161                        break;
26162                    }
26163                }
26164                OpGetlinkDumpReply::TargetNetnsid(val) => {
26165                    if last_off == offset {
26166                        stack.push(("TargetNetnsid", last_off));
26167                        break;
26168                    }
26169                }
26170                OpGetlinkDumpReply::CarrierUpCount(val) => {
26171                    if last_off == offset {
26172                        stack.push(("CarrierUpCount", last_off));
26173                        break;
26174                    }
26175                }
26176                OpGetlinkDumpReply::CarrierDownCount(val) => {
26177                    if last_off == offset {
26178                        stack.push(("CarrierDownCount", last_off));
26179                        break;
26180                    }
26181                }
26182                OpGetlinkDumpReply::NewIfindex(val) => {
26183                    if last_off == offset {
26184                        stack.push(("NewIfindex", last_off));
26185                        break;
26186                    }
26187                }
26188                OpGetlinkDumpReply::MinMtu(val) => {
26189                    if last_off == offset {
26190                        stack.push(("MinMtu", last_off));
26191                        break;
26192                    }
26193                }
26194                OpGetlinkDumpReply::MaxMtu(val) => {
26195                    if last_off == offset {
26196                        stack.push(("MaxMtu", last_off));
26197                        break;
26198                    }
26199                }
26200                OpGetlinkDumpReply::PropList(val) => {
26201                    (stack, missing) = val.lookup_attr(offset, missing_type);
26202                    if !stack.is_empty() {
26203                        break;
26204                    }
26205                }
26206                OpGetlinkDumpReply::PermAddress(val) => {
26207                    if last_off == offset {
26208                        stack.push(("PermAddress", last_off));
26209                        break;
26210                    }
26211                }
26212                OpGetlinkDumpReply::ProtoDownReason(val) => {
26213                    if last_off == offset {
26214                        stack.push(("ProtoDownReason", last_off));
26215                        break;
26216                    }
26217                }
26218                OpGetlinkDumpReply::ParentDevName(val) => {
26219                    if last_off == offset {
26220                        stack.push(("ParentDevName", last_off));
26221                        break;
26222                    }
26223                }
26224                OpGetlinkDumpReply::ParentDevBusName(val) => {
26225                    if last_off == offset {
26226                        stack.push(("ParentDevBusName", last_off));
26227                        break;
26228                    }
26229                }
26230                OpGetlinkDumpReply::GroMaxSize(val) => {
26231                    if last_off == offset {
26232                        stack.push(("GroMaxSize", last_off));
26233                        break;
26234                    }
26235                }
26236                OpGetlinkDumpReply::TsoMaxSize(val) => {
26237                    if last_off == offset {
26238                        stack.push(("TsoMaxSize", last_off));
26239                        break;
26240                    }
26241                }
26242                OpGetlinkDumpReply::TsoMaxSegs(val) => {
26243                    if last_off == offset {
26244                        stack.push(("TsoMaxSegs", last_off));
26245                        break;
26246                    }
26247                }
26248                OpGetlinkDumpReply::Allmulti(val) => {
26249                    if last_off == offset {
26250                        stack.push(("Allmulti", last_off));
26251                        break;
26252                    }
26253                }
26254                OpGetlinkDumpReply::DevlinkPort(val) => {
26255                    if last_off == offset {
26256                        stack.push(("DevlinkPort", last_off));
26257                        break;
26258                    }
26259                }
26260                OpGetlinkDumpReply::GsoIpv4MaxSize(val) => {
26261                    if last_off == offset {
26262                        stack.push(("GsoIpv4MaxSize", last_off));
26263                        break;
26264                    }
26265                }
26266                OpGetlinkDumpReply::GroIpv4MaxSize(val) => {
26267                    if last_off == offset {
26268                        stack.push(("GroIpv4MaxSize", last_off));
26269                        break;
26270                    }
26271                }
26272                OpGetlinkDumpReply::DpllPin(val) => {
26273                    (stack, missing) = val.lookup_attr(offset, missing_type);
26274                    if !stack.is_empty() {
26275                        break;
26276                    }
26277                }
26278                OpGetlinkDumpReply::MaxPacingOffloadHorizon(val) => {
26279                    if last_off == offset {
26280                        stack.push(("MaxPacingOffloadHorizon", last_off));
26281                        break;
26282                    }
26283                }
26284                OpGetlinkDumpReply::NetnsImmutable(val) => {
26285                    if last_off == offset {
26286                        stack.push(("NetnsImmutable", last_off));
26287                        break;
26288                    }
26289                }
26290                _ => {}
26291            };
26292            last_off = cur + attrs.pos;
26293        }
26294        if !stack.is_empty() {
26295            stack.push(("OpGetlinkDumpReply", cur));
26296        }
26297        (stack, missing)
26298    }
26299}
26300#[derive(Debug)]
26301pub struct RequestOpGetlinkDumpRequest<'r> {
26302    request: Request<'r>,
26303}
26304impl<'r> RequestOpGetlinkDumpRequest<'r> {
26305    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
26306        PushOpGetlinkDumpRequest::write_header(&mut request.buf_mut(), header);
26307        Self {
26308            request: request.set_dump(),
26309        }
26310    }
26311    pub fn encode(&mut self) -> PushOpGetlinkDumpRequest<&mut Vec<u8>> {
26312        PushOpGetlinkDumpRequest::new_without_header(self.request.buf_mut())
26313    }
26314    pub fn into_encoder(self) -> PushOpGetlinkDumpRequest<RequestBuf<'r>> {
26315        PushOpGetlinkDumpRequest::new_without_header(self.request.buf)
26316    }
26317    pub fn decode_request<'buf>(
26318        buf: &'buf [u8],
26319    ) -> (PushIfinfomsg, IterableOpGetlinkDumpRequest<'buf>) {
26320        OpGetlinkDumpRequest::new(buf)
26321    }
26322}
26323impl NetlinkRequest for RequestOpGetlinkDumpRequest<'_> {
26324    fn protocol(&self) -> Protocol {
26325        Protocol::Raw {
26326            protonum: 0u16,
26327            request_type: 18u16,
26328        }
26329    }
26330    fn flags(&self) -> u16 {
26331        self.request.flags
26332    }
26333    fn payload(&self) -> &[u8] {
26334        self.request.buf()
26335    }
26336    type ReplyType<'buf> = (PushIfinfomsg, IterableOpGetlinkDumpReply<'buf>);
26337    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
26338        OpGetlinkDumpReply::new(buf)
26339    }
26340    fn lookup(
26341        buf: &[u8],
26342        offset: usize,
26343        missing_type: Option<u16>,
26344    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
26345        OpGetlinkDumpRequest::new(buf)
26346            .1
26347            .lookup_attr(offset, missing_type)
26348    }
26349}
26350#[doc = "Get / dump information about a link."]
26351pub struct PushOpGetlinkDoRequest<Prev: Rec> {
26352    pub(crate) prev: Option<Prev>,
26353    pub(crate) header_offset: Option<usize>,
26354}
26355impl<Prev: Rec> Rec for PushOpGetlinkDoRequest<Prev> {
26356    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
26357        self.prev.as_mut().unwrap().as_rec_mut()
26358    }
26359    fn as_rec(&self) -> &Vec<u8> {
26360        self.prev.as_ref().unwrap().as_rec()
26361    }
26362}
26363impl<Prev: Rec> PushOpGetlinkDoRequest<Prev> {
26364    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
26365        Self::write_header(&mut prev, header);
26366        Self::new_without_header(prev)
26367    }
26368    fn new_without_header(prev: Prev) -> Self {
26369        Self {
26370            prev: Some(prev),
26371            header_offset: None,
26372        }
26373    }
26374    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
26375        prev.as_rec_mut().extend(header.as_slice());
26376    }
26377    pub fn end_nested(mut self) -> Prev {
26378        let mut prev = self.prev.take().unwrap();
26379        if let Some(header_offset) = &self.header_offset {
26380            finalize_nested_header(prev.as_rec_mut(), *header_offset);
26381        }
26382        prev
26383    }
26384    pub fn push_ifname(mut self, value: &CStr) -> Self {
26385        push_header(
26386            self.as_rec_mut(),
26387            3u16,
26388            value.to_bytes_with_nul().len() as u16,
26389        );
26390        self.as_rec_mut().extend(value.to_bytes_with_nul());
26391        self
26392    }
26393    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
26394        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
26395        self.as_rec_mut().extend(value);
26396        self.as_rec_mut().push(0);
26397        self
26398    }
26399    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26400    pub fn push_ext_mask(mut self, value: u32) -> Self {
26401        push_header(self.as_rec_mut(), 29u16, 4 as u16);
26402        self.as_rec_mut().extend(value.to_ne_bytes());
26403        self
26404    }
26405    pub fn push_target_netnsid(mut self, value: i32) -> Self {
26406        push_header(self.as_rec_mut(), 46u16, 4 as u16);
26407        self.as_rec_mut().extend(value.to_ne_bytes());
26408        self
26409    }
26410    pub fn push_alt_ifname(mut self, value: &CStr) -> Self {
26411        push_header(
26412            self.as_rec_mut(),
26413            53u16,
26414            value.to_bytes_with_nul().len() as u16,
26415        );
26416        self.as_rec_mut().extend(value.to_bytes_with_nul());
26417        self
26418    }
26419    pub fn push_alt_ifname_bytes(mut self, value: &[u8]) -> Self {
26420        push_header(self.as_rec_mut(), 53u16, (value.len() + 1) as u16);
26421        self.as_rec_mut().extend(value);
26422        self.as_rec_mut().push(0);
26423        self
26424    }
26425}
26426impl<Prev: Rec> Drop for PushOpGetlinkDoRequest<Prev> {
26427    fn drop(&mut self) {
26428        if let Some(prev) = &mut self.prev {
26429            if let Some(header_offset) = &self.header_offset {
26430                finalize_nested_header(prev.as_rec_mut(), *header_offset);
26431            }
26432        }
26433    }
26434}
26435#[doc = "Get / dump information about a link."]
26436#[derive(Clone)]
26437pub enum OpGetlinkDoRequest<'a> {
26438    Ifname(&'a CStr),
26439    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26440    ExtMask(u32),
26441    TargetNetnsid(i32),
26442    AltIfname(&'a CStr),
26443}
26444impl<'a> IterableOpGetlinkDoRequest<'a> {
26445    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
26446        let mut iter = self.clone();
26447        iter.pos = 0;
26448        for attr in iter {
26449            if let OpGetlinkDoRequest::Ifname(val) = attr? {
26450                return Ok(val);
26451            }
26452        }
26453        Err(ErrorContext::new_missing(
26454            "OpGetlinkDoRequest",
26455            "Ifname",
26456            self.orig_loc,
26457            self.buf.as_ptr() as usize,
26458        ))
26459    }
26460    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26461    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
26462        let mut iter = self.clone();
26463        iter.pos = 0;
26464        for attr in iter {
26465            if let OpGetlinkDoRequest::ExtMask(val) = attr? {
26466                return Ok(val);
26467            }
26468        }
26469        Err(ErrorContext::new_missing(
26470            "OpGetlinkDoRequest",
26471            "ExtMask",
26472            self.orig_loc,
26473            self.buf.as_ptr() as usize,
26474        ))
26475    }
26476    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
26477        let mut iter = self.clone();
26478        iter.pos = 0;
26479        for attr in iter {
26480            if let OpGetlinkDoRequest::TargetNetnsid(val) = attr? {
26481                return Ok(val);
26482            }
26483        }
26484        Err(ErrorContext::new_missing(
26485            "OpGetlinkDoRequest",
26486            "TargetNetnsid",
26487            self.orig_loc,
26488            self.buf.as_ptr() as usize,
26489        ))
26490    }
26491    pub fn get_alt_ifname(&self) -> Result<&'a CStr, ErrorContext> {
26492        let mut iter = self.clone();
26493        iter.pos = 0;
26494        for attr in iter {
26495            if let OpGetlinkDoRequest::AltIfname(val) = attr? {
26496                return Ok(val);
26497            }
26498        }
26499        Err(ErrorContext::new_missing(
26500            "OpGetlinkDoRequest",
26501            "AltIfname",
26502            self.orig_loc,
26503            self.buf.as_ptr() as usize,
26504        ))
26505    }
26506}
26507impl OpGetlinkDoRequest<'_> {
26508    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpGetlinkDoRequest<'a>) {
26509        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
26510        (
26511            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
26512            IterableOpGetlinkDoRequest::with_loc(attrs, buf.as_ptr() as usize),
26513        )
26514    }
26515    fn attr_from_type(r#type: u16) -> Option<&'static str> {
26516        LinkAttrs::attr_from_type(r#type)
26517    }
26518}
26519#[derive(Clone, Copy, Default)]
26520pub struct IterableOpGetlinkDoRequest<'a> {
26521    buf: &'a [u8],
26522    pos: usize,
26523    orig_loc: usize,
26524}
26525impl<'a> IterableOpGetlinkDoRequest<'a> {
26526    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
26527        Self {
26528            buf,
26529            pos: 0,
26530            orig_loc,
26531        }
26532    }
26533    pub fn get_buf(&self) -> &'a [u8] {
26534        self.buf
26535    }
26536}
26537impl<'a> Iterator for IterableOpGetlinkDoRequest<'a> {
26538    type Item = Result<OpGetlinkDoRequest<'a>, ErrorContext>;
26539    fn next(&mut self) -> Option<Self::Item> {
26540        let pos = self.pos;
26541        let mut r#type;
26542        loop {
26543            r#type = None;
26544            if self.buf.len() == self.pos {
26545                return None;
26546            }
26547            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
26548                break;
26549            };
26550            r#type = Some(header.r#type);
26551            let res = match header.r#type {
26552                3u16 => OpGetlinkDoRequest::Ifname({
26553                    let res = CStr::from_bytes_with_nul(next).ok();
26554                    let Some(val) = res else { break };
26555                    val
26556                }),
26557                29u16 => OpGetlinkDoRequest::ExtMask({
26558                    let res = parse_u32(next);
26559                    let Some(val) = res else { break };
26560                    val
26561                }),
26562                46u16 => OpGetlinkDoRequest::TargetNetnsid({
26563                    let res = parse_i32(next);
26564                    let Some(val) = res else { break };
26565                    val
26566                }),
26567                53u16 => OpGetlinkDoRequest::AltIfname({
26568                    let res = CStr::from_bytes_with_nul(next).ok();
26569                    let Some(val) = res else { break };
26570                    val
26571                }),
26572                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
26573                n => continue,
26574            };
26575            return Some(Ok(res));
26576        }
26577        Some(Err(ErrorContext::new(
26578            "OpGetlinkDoRequest",
26579            r#type.and_then(|t| OpGetlinkDoRequest::attr_from_type(t)),
26580            self.orig_loc,
26581            self.buf.as_ptr().wrapping_add(pos) as usize,
26582        )))
26583    }
26584}
26585impl<'a> std::fmt::Debug for IterableOpGetlinkDoRequest<'_> {
26586    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26587        let mut fmt = f.debug_struct("OpGetlinkDoRequest");
26588        for attr in self.clone() {
26589            let attr = match attr {
26590                Ok(a) => a,
26591                Err(err) => {
26592                    fmt.finish()?;
26593                    f.write_str("Err(")?;
26594                    err.fmt(f)?;
26595                    return f.write_str(")");
26596                }
26597            };
26598            match attr {
26599                OpGetlinkDoRequest::Ifname(val) => fmt.field("Ifname", &val),
26600                OpGetlinkDoRequest::ExtMask(val) => {
26601                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
26602                }
26603                OpGetlinkDoRequest::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
26604                OpGetlinkDoRequest::AltIfname(val) => fmt.field("AltIfname", &val),
26605            };
26606        }
26607        fmt.finish()
26608    }
26609}
26610impl IterableOpGetlinkDoRequest<'_> {
26611    pub fn lookup_attr(
26612        &self,
26613        offset: usize,
26614        missing_type: Option<u16>,
26615    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
26616        let mut stack = Vec::new();
26617        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
26618        if cur == offset + PushIfinfomsg::len() {
26619            stack.push(("OpGetlinkDoRequest", offset));
26620            return (
26621                stack,
26622                missing_type.and_then(|t| OpGetlinkDoRequest::attr_from_type(t)),
26623            );
26624        }
26625        if cur > offset || cur + self.buf.len() < offset {
26626            return (stack, None);
26627        }
26628        let mut attrs = self.clone();
26629        let mut last_off = cur + attrs.pos;
26630        while let Some(attr) = attrs.next() {
26631            let Ok(attr) = attr else { break };
26632            match attr {
26633                OpGetlinkDoRequest::Ifname(val) => {
26634                    if last_off == offset {
26635                        stack.push(("Ifname", last_off));
26636                        break;
26637                    }
26638                }
26639                OpGetlinkDoRequest::ExtMask(val) => {
26640                    if last_off == offset {
26641                        stack.push(("ExtMask", last_off));
26642                        break;
26643                    }
26644                }
26645                OpGetlinkDoRequest::TargetNetnsid(val) => {
26646                    if last_off == offset {
26647                        stack.push(("TargetNetnsid", last_off));
26648                        break;
26649                    }
26650                }
26651                OpGetlinkDoRequest::AltIfname(val) => {
26652                    if last_off == offset {
26653                        stack.push(("AltIfname", last_off));
26654                        break;
26655                    }
26656                }
26657                _ => {}
26658            };
26659            last_off = cur + attrs.pos;
26660        }
26661        if !stack.is_empty() {
26662            stack.push(("OpGetlinkDoRequest", cur));
26663        }
26664        (stack, None)
26665    }
26666}
26667#[doc = "Get / dump information about a link."]
26668pub struct PushOpGetlinkDoReply<Prev: Rec> {
26669    pub(crate) prev: Option<Prev>,
26670    pub(crate) header_offset: Option<usize>,
26671}
26672impl<Prev: Rec> Rec for PushOpGetlinkDoReply<Prev> {
26673    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
26674        self.prev.as_mut().unwrap().as_rec_mut()
26675    }
26676    fn as_rec(&self) -> &Vec<u8> {
26677        self.prev.as_ref().unwrap().as_rec()
26678    }
26679}
26680impl<Prev: Rec> PushOpGetlinkDoReply<Prev> {
26681    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
26682        Self::write_header(&mut prev, header);
26683        Self::new_without_header(prev)
26684    }
26685    fn new_without_header(prev: Prev) -> Self {
26686        Self {
26687            prev: Some(prev),
26688            header_offset: None,
26689        }
26690    }
26691    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
26692        prev.as_rec_mut().extend(header.as_slice());
26693    }
26694    pub fn end_nested(mut self) -> Prev {
26695        let mut prev = self.prev.take().unwrap();
26696        if let Some(header_offset) = &self.header_offset {
26697            finalize_nested_header(prev.as_rec_mut(), *header_offset);
26698        }
26699        prev
26700    }
26701    pub fn push_address(mut self, value: &[u8]) -> Self {
26702        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
26703        self.as_rec_mut().extend(value);
26704        self
26705    }
26706    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
26707        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
26708        self.as_rec_mut().extend(value);
26709        self
26710    }
26711    pub fn push_ifname(mut self, value: &CStr) -> Self {
26712        push_header(
26713            self.as_rec_mut(),
26714            3u16,
26715            value.to_bytes_with_nul().len() as u16,
26716        );
26717        self.as_rec_mut().extend(value.to_bytes_with_nul());
26718        self
26719    }
26720    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
26721        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
26722        self.as_rec_mut().extend(value);
26723        self.as_rec_mut().push(0);
26724        self
26725    }
26726    pub fn push_mtu(mut self, value: u32) -> Self {
26727        push_header(self.as_rec_mut(), 4u16, 4 as u16);
26728        self.as_rec_mut().extend(value.to_ne_bytes());
26729        self
26730    }
26731    pub fn push_link(mut self, value: u32) -> Self {
26732        push_header(self.as_rec_mut(), 5u16, 4 as u16);
26733        self.as_rec_mut().extend(value.to_ne_bytes());
26734        self
26735    }
26736    pub fn push_qdisc(mut self, value: &CStr) -> Self {
26737        push_header(
26738            self.as_rec_mut(),
26739            6u16,
26740            value.to_bytes_with_nul().len() as u16,
26741        );
26742        self.as_rec_mut().extend(value.to_bytes_with_nul());
26743        self
26744    }
26745    pub fn push_qdisc_bytes(mut self, value: &[u8]) -> Self {
26746        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
26747        self.as_rec_mut().extend(value);
26748        self.as_rec_mut().push(0);
26749        self
26750    }
26751    pub fn push_stats(mut self, value: PushRtnlLinkStats) -> Self {
26752        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
26753        self.as_rec_mut().extend(value.as_slice());
26754        self
26755    }
26756    pub fn push_cost(mut self, value: &CStr) -> Self {
26757        push_header(
26758            self.as_rec_mut(),
26759            8u16,
26760            value.to_bytes_with_nul().len() as u16,
26761        );
26762        self.as_rec_mut().extend(value.to_bytes_with_nul());
26763        self
26764    }
26765    pub fn push_cost_bytes(mut self, value: &[u8]) -> Self {
26766        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
26767        self.as_rec_mut().extend(value);
26768        self.as_rec_mut().push(0);
26769        self
26770    }
26771    pub fn push_priority(mut self, value: &CStr) -> Self {
26772        push_header(
26773            self.as_rec_mut(),
26774            9u16,
26775            value.to_bytes_with_nul().len() as u16,
26776        );
26777        self.as_rec_mut().extend(value.to_bytes_with_nul());
26778        self
26779    }
26780    pub fn push_priority_bytes(mut self, value: &[u8]) -> Self {
26781        push_header(self.as_rec_mut(), 9u16, (value.len() + 1) as u16);
26782        self.as_rec_mut().extend(value);
26783        self.as_rec_mut().push(0);
26784        self
26785    }
26786    pub fn push_master(mut self, value: u32) -> Self {
26787        push_header(self.as_rec_mut(), 10u16, 4 as u16);
26788        self.as_rec_mut().extend(value.to_ne_bytes());
26789        self
26790    }
26791    pub fn push_wireless(mut self, value: &CStr) -> Self {
26792        push_header(
26793            self.as_rec_mut(),
26794            11u16,
26795            value.to_bytes_with_nul().len() as u16,
26796        );
26797        self.as_rec_mut().extend(value.to_bytes_with_nul());
26798        self
26799    }
26800    pub fn push_wireless_bytes(mut self, value: &[u8]) -> Self {
26801        push_header(self.as_rec_mut(), 11u16, (value.len() + 1) as u16);
26802        self.as_rec_mut().extend(value);
26803        self.as_rec_mut().push(0);
26804        self
26805    }
26806    pub fn push_protinfo(mut self, value: &CStr) -> Self {
26807        push_header(
26808            self.as_rec_mut(),
26809            12u16,
26810            value.to_bytes_with_nul().len() as u16,
26811        );
26812        self.as_rec_mut().extend(value.to_bytes_with_nul());
26813        self
26814    }
26815    pub fn push_protinfo_bytes(mut self, value: &[u8]) -> Self {
26816        push_header(self.as_rec_mut(), 12u16, (value.len() + 1) as u16);
26817        self.as_rec_mut().extend(value);
26818        self.as_rec_mut().push(0);
26819        self
26820    }
26821    pub fn push_txqlen(mut self, value: u32) -> Self {
26822        push_header(self.as_rec_mut(), 13u16, 4 as u16);
26823        self.as_rec_mut().extend(value.to_ne_bytes());
26824        self
26825    }
26826    pub fn push_map(mut self, value: PushRtnlLinkIfmap) -> Self {
26827        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
26828        self.as_rec_mut().extend(value.as_slice());
26829        self
26830    }
26831    pub fn push_weight(mut self, value: u32) -> Self {
26832        push_header(self.as_rec_mut(), 15u16, 4 as u16);
26833        self.as_rec_mut().extend(value.to_ne_bytes());
26834        self
26835    }
26836    pub fn push_operstate(mut self, value: u8) -> Self {
26837        push_header(self.as_rec_mut(), 16u16, 1 as u16);
26838        self.as_rec_mut().extend(value.to_ne_bytes());
26839        self
26840    }
26841    pub fn push_linkmode(mut self, value: u8) -> Self {
26842        push_header(self.as_rec_mut(), 17u16, 1 as u16);
26843        self.as_rec_mut().extend(value.to_ne_bytes());
26844        self
26845    }
26846    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
26847        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
26848        PushLinkinfoAttrs {
26849            prev: Some(self),
26850            header_offset: Some(header_offset),
26851        }
26852    }
26853    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
26854        push_header(self.as_rec_mut(), 19u16, 4 as u16);
26855        self.as_rec_mut().extend(value.to_ne_bytes());
26856        self
26857    }
26858    pub fn push_ifalias(mut self, value: &CStr) -> Self {
26859        push_header(
26860            self.as_rec_mut(),
26861            20u16,
26862            value.to_bytes_with_nul().len() as u16,
26863        );
26864        self.as_rec_mut().extend(value.to_bytes_with_nul());
26865        self
26866    }
26867    pub fn push_ifalias_bytes(mut self, value: &[u8]) -> Self {
26868        push_header(self.as_rec_mut(), 20u16, (value.len() + 1) as u16);
26869        self.as_rec_mut().extend(value);
26870        self.as_rec_mut().push(0);
26871        self
26872    }
26873    pub fn push_num_vf(mut self, value: u32) -> Self {
26874        push_header(self.as_rec_mut(), 21u16, 4 as u16);
26875        self.as_rec_mut().extend(value.to_ne_bytes());
26876        self
26877    }
26878    pub fn nested_vfinfo_list(mut self) -> PushVfinfoListAttrs<Self> {
26879        let header_offset = push_nested_header(self.as_rec_mut(), 22u16);
26880        PushVfinfoListAttrs {
26881            prev: Some(self),
26882            header_offset: Some(header_offset),
26883        }
26884    }
26885    pub fn push_stats64(mut self, value: PushRtnlLinkStats64) -> Self {
26886        push_header(self.as_rec_mut(), 23u16, value.as_slice().len() as u16);
26887        self.as_rec_mut().extend(value.as_slice());
26888        self
26889    }
26890    pub fn nested_vf_ports(mut self) -> PushVfPortsAttrs<Self> {
26891        let header_offset = push_nested_header(self.as_rec_mut(), 24u16);
26892        PushVfPortsAttrs {
26893            prev: Some(self),
26894            header_offset: Some(header_offset),
26895        }
26896    }
26897    pub fn nested_port_self(mut self) -> PushPortSelfAttrs<Self> {
26898        let header_offset = push_nested_header(self.as_rec_mut(), 25u16);
26899        PushPortSelfAttrs {
26900            prev: Some(self),
26901            header_offset: Some(header_offset),
26902        }
26903    }
26904    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
26905        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
26906        PushAfSpecAttrs {
26907            prev: Some(self),
26908            header_offset: Some(header_offset),
26909        }
26910    }
26911    pub fn push_group(mut self, value: u32) -> Self {
26912        push_header(self.as_rec_mut(), 27u16, 4 as u16);
26913        self.as_rec_mut().extend(value.to_ne_bytes());
26914        self
26915    }
26916    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
26917        push_header(self.as_rec_mut(), 28u16, 4 as u16);
26918        self.as_rec_mut().extend(value.to_ne_bytes());
26919        self
26920    }
26921    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26922    pub fn push_ext_mask(mut self, value: u32) -> Self {
26923        push_header(self.as_rec_mut(), 29u16, 4 as u16);
26924        self.as_rec_mut().extend(value.to_ne_bytes());
26925        self
26926    }
26927    pub fn push_promiscuity(mut self, value: u32) -> Self {
26928        push_header(self.as_rec_mut(), 30u16, 4 as u16);
26929        self.as_rec_mut().extend(value.to_ne_bytes());
26930        self
26931    }
26932    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
26933        push_header(self.as_rec_mut(), 31u16, 4 as u16);
26934        self.as_rec_mut().extend(value.to_ne_bytes());
26935        self
26936    }
26937    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
26938        push_header(self.as_rec_mut(), 32u16, 4 as u16);
26939        self.as_rec_mut().extend(value.to_ne_bytes());
26940        self
26941    }
26942    pub fn push_carrier(mut self, value: u8) -> Self {
26943        push_header(self.as_rec_mut(), 33u16, 1 as u16);
26944        self.as_rec_mut().extend(value.to_ne_bytes());
26945        self
26946    }
26947    pub fn push_phys_port_id(mut self, value: &[u8]) -> Self {
26948        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
26949        self.as_rec_mut().extend(value);
26950        self
26951    }
26952    pub fn push_carrier_changes(mut self, value: u32) -> Self {
26953        push_header(self.as_rec_mut(), 35u16, 4 as u16);
26954        self.as_rec_mut().extend(value.to_ne_bytes());
26955        self
26956    }
26957    pub fn push_phys_switch_id(mut self, value: &[u8]) -> Self {
26958        push_header(self.as_rec_mut(), 36u16, value.len() as u16);
26959        self.as_rec_mut().extend(value);
26960        self
26961    }
26962    pub fn push_link_netnsid(mut self, value: i32) -> Self {
26963        push_header(self.as_rec_mut(), 37u16, 4 as u16);
26964        self.as_rec_mut().extend(value.to_ne_bytes());
26965        self
26966    }
26967    pub fn push_phys_port_name(mut self, value: &CStr) -> Self {
26968        push_header(
26969            self.as_rec_mut(),
26970            38u16,
26971            value.to_bytes_with_nul().len() as u16,
26972        );
26973        self.as_rec_mut().extend(value.to_bytes_with_nul());
26974        self
26975    }
26976    pub fn push_phys_port_name_bytes(mut self, value: &[u8]) -> Self {
26977        push_header(self.as_rec_mut(), 38u16, (value.len() + 1) as u16);
26978        self.as_rec_mut().extend(value);
26979        self.as_rec_mut().push(0);
26980        self
26981    }
26982    pub fn push_proto_down(mut self, value: u8) -> Self {
26983        push_header(self.as_rec_mut(), 39u16, 1 as u16);
26984        self.as_rec_mut().extend(value.to_ne_bytes());
26985        self
26986    }
26987    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
26988        push_header(self.as_rec_mut(), 40u16, 4 as u16);
26989        self.as_rec_mut().extend(value.to_ne_bytes());
26990        self
26991    }
26992    pub fn push_gso_max_size(mut self, value: u32) -> Self {
26993        push_header(self.as_rec_mut(), 41u16, 4 as u16);
26994        self.as_rec_mut().extend(value.to_ne_bytes());
26995        self
26996    }
26997    pub fn push_pad(mut self, value: &[u8]) -> Self {
26998        push_header(self.as_rec_mut(), 42u16, value.len() as u16);
26999        self.as_rec_mut().extend(value);
27000        self
27001    }
27002    pub fn nested_xdp(mut self) -> PushXdpAttrs<Self> {
27003        let header_offset = push_nested_header(self.as_rec_mut(), 43u16);
27004        PushXdpAttrs {
27005            prev: Some(self),
27006            header_offset: Some(header_offset),
27007        }
27008    }
27009    pub fn push_event(mut self, value: u32) -> Self {
27010        push_header(self.as_rec_mut(), 44u16, 4 as u16);
27011        self.as_rec_mut().extend(value.to_ne_bytes());
27012        self
27013    }
27014    pub fn push_new_netnsid(mut self, value: i32) -> Self {
27015        push_header(self.as_rec_mut(), 45u16, 4 as u16);
27016        self.as_rec_mut().extend(value.to_ne_bytes());
27017        self
27018    }
27019    pub fn push_target_netnsid(mut self, value: i32) -> Self {
27020        push_header(self.as_rec_mut(), 46u16, 4 as u16);
27021        self.as_rec_mut().extend(value.to_ne_bytes());
27022        self
27023    }
27024    pub fn push_carrier_up_count(mut self, value: u32) -> Self {
27025        push_header(self.as_rec_mut(), 47u16, 4 as u16);
27026        self.as_rec_mut().extend(value.to_ne_bytes());
27027        self
27028    }
27029    pub fn push_carrier_down_count(mut self, value: u32) -> Self {
27030        push_header(self.as_rec_mut(), 48u16, 4 as u16);
27031        self.as_rec_mut().extend(value.to_ne_bytes());
27032        self
27033    }
27034    pub fn push_new_ifindex(mut self, value: i32) -> Self {
27035        push_header(self.as_rec_mut(), 49u16, 4 as u16);
27036        self.as_rec_mut().extend(value.to_ne_bytes());
27037        self
27038    }
27039    pub fn push_min_mtu(mut self, value: u32) -> Self {
27040        push_header(self.as_rec_mut(), 50u16, 4 as u16);
27041        self.as_rec_mut().extend(value.to_ne_bytes());
27042        self
27043    }
27044    pub fn push_max_mtu(mut self, value: u32) -> Self {
27045        push_header(self.as_rec_mut(), 51u16, 4 as u16);
27046        self.as_rec_mut().extend(value.to_ne_bytes());
27047        self
27048    }
27049    pub fn nested_prop_list(mut self) -> PushPropListLinkAttrs<Self> {
27050        let header_offset = push_nested_header(self.as_rec_mut(), 52u16);
27051        PushPropListLinkAttrs {
27052            prev: Some(self),
27053            header_offset: Some(header_offset),
27054        }
27055    }
27056    pub fn push_perm_address(mut self, value: &[u8]) -> Self {
27057        push_header(self.as_rec_mut(), 54u16, value.len() as u16);
27058        self.as_rec_mut().extend(value);
27059        self
27060    }
27061    pub fn push_proto_down_reason(mut self, value: &CStr) -> Self {
27062        push_header(
27063            self.as_rec_mut(),
27064            55u16,
27065            value.to_bytes_with_nul().len() as u16,
27066        );
27067        self.as_rec_mut().extend(value.to_bytes_with_nul());
27068        self
27069    }
27070    pub fn push_proto_down_reason_bytes(mut self, value: &[u8]) -> Self {
27071        push_header(self.as_rec_mut(), 55u16, (value.len() + 1) as u16);
27072        self.as_rec_mut().extend(value);
27073        self.as_rec_mut().push(0);
27074        self
27075    }
27076    pub fn push_parent_dev_name(mut self, value: &CStr) -> Self {
27077        push_header(
27078            self.as_rec_mut(),
27079            56u16,
27080            value.to_bytes_with_nul().len() as u16,
27081        );
27082        self.as_rec_mut().extend(value.to_bytes_with_nul());
27083        self
27084    }
27085    pub fn push_parent_dev_name_bytes(mut self, value: &[u8]) -> Self {
27086        push_header(self.as_rec_mut(), 56u16, (value.len() + 1) as u16);
27087        self.as_rec_mut().extend(value);
27088        self.as_rec_mut().push(0);
27089        self
27090    }
27091    pub fn push_parent_dev_bus_name(mut self, value: &CStr) -> Self {
27092        push_header(
27093            self.as_rec_mut(),
27094            57u16,
27095            value.to_bytes_with_nul().len() as u16,
27096        );
27097        self.as_rec_mut().extend(value.to_bytes_with_nul());
27098        self
27099    }
27100    pub fn push_parent_dev_bus_name_bytes(mut self, value: &[u8]) -> Self {
27101        push_header(self.as_rec_mut(), 57u16, (value.len() + 1) as u16);
27102        self.as_rec_mut().extend(value);
27103        self.as_rec_mut().push(0);
27104        self
27105    }
27106    pub fn push_gro_max_size(mut self, value: u32) -> Self {
27107        push_header(self.as_rec_mut(), 58u16, 4 as u16);
27108        self.as_rec_mut().extend(value.to_ne_bytes());
27109        self
27110    }
27111    pub fn push_tso_max_size(mut self, value: u32) -> Self {
27112        push_header(self.as_rec_mut(), 59u16, 4 as u16);
27113        self.as_rec_mut().extend(value.to_ne_bytes());
27114        self
27115    }
27116    pub fn push_tso_max_segs(mut self, value: u32) -> Self {
27117        push_header(self.as_rec_mut(), 60u16, 4 as u16);
27118        self.as_rec_mut().extend(value.to_ne_bytes());
27119        self
27120    }
27121    pub fn push_allmulti(mut self, value: u32) -> Self {
27122        push_header(self.as_rec_mut(), 61u16, 4 as u16);
27123        self.as_rec_mut().extend(value.to_ne_bytes());
27124        self
27125    }
27126    pub fn push_devlink_port(mut self, value: &[u8]) -> Self {
27127        push_header(self.as_rec_mut(), 62u16, value.len() as u16);
27128        self.as_rec_mut().extend(value);
27129        self
27130    }
27131    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
27132        push_header(self.as_rec_mut(), 63u16, 4 as u16);
27133        self.as_rec_mut().extend(value.to_ne_bytes());
27134        self
27135    }
27136    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
27137        push_header(self.as_rec_mut(), 64u16, 4 as u16);
27138        self.as_rec_mut().extend(value.to_ne_bytes());
27139        self
27140    }
27141    pub fn nested_dpll_pin(mut self) -> PushLinkDpllPinAttrs<Self> {
27142        let header_offset = push_nested_header(self.as_rec_mut(), 65u16);
27143        PushLinkDpllPinAttrs {
27144            prev: Some(self),
27145            header_offset: Some(header_offset),
27146        }
27147    }
27148    #[doc = "EDT offload horizon supported by the device (in nsec)."]
27149    pub fn push_max_pacing_offload_horizon(mut self, value: u32) -> Self {
27150        push_header(self.as_rec_mut(), 66u16, 4 as u16);
27151        self.as_rec_mut().extend(value.to_ne_bytes());
27152        self
27153    }
27154    pub fn push_netns_immutable(mut self, value: u8) -> Self {
27155        push_header(self.as_rec_mut(), 67u16, 1 as u16);
27156        self.as_rec_mut().extend(value.to_ne_bytes());
27157        self
27158    }
27159}
27160impl<Prev: Rec> Drop for PushOpGetlinkDoReply<Prev> {
27161    fn drop(&mut self) {
27162        if let Some(prev) = &mut self.prev {
27163            if let Some(header_offset) = &self.header_offset {
27164                finalize_nested_header(prev.as_rec_mut(), *header_offset);
27165            }
27166        }
27167    }
27168}
27169#[doc = "Get / dump information about a link."]
27170#[derive(Clone)]
27171pub enum OpGetlinkDoReply<'a> {
27172    Address(&'a [u8]),
27173    Broadcast(&'a [u8]),
27174    Ifname(&'a CStr),
27175    Mtu(u32),
27176    Link(u32),
27177    Qdisc(&'a CStr),
27178    Stats(PushRtnlLinkStats),
27179    Cost(&'a CStr),
27180    Priority(&'a CStr),
27181    Master(u32),
27182    Wireless(&'a CStr),
27183    Protinfo(&'a CStr),
27184    Txqlen(u32),
27185    Map(PushRtnlLinkIfmap),
27186    Weight(u32),
27187    Operstate(u8),
27188    Linkmode(u8),
27189    Linkinfo(IterableLinkinfoAttrs<'a>),
27190    NetNsPid(u32),
27191    Ifalias(&'a CStr),
27192    NumVf(u32),
27193    VfinfoList(IterableVfinfoListAttrs<'a>),
27194    Stats64(PushRtnlLinkStats64),
27195    VfPorts(IterableVfPortsAttrs<'a>),
27196    PortSelf(IterablePortSelfAttrs<'a>),
27197    AfSpec(IterableAfSpecAttrs<'a>),
27198    Group(u32),
27199    NetNsFd(u32),
27200    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
27201    ExtMask(u32),
27202    Promiscuity(u32),
27203    NumTxQueues(u32),
27204    NumRxQueues(u32),
27205    Carrier(u8),
27206    PhysPortId(&'a [u8]),
27207    CarrierChanges(u32),
27208    PhysSwitchId(&'a [u8]),
27209    LinkNetnsid(i32),
27210    PhysPortName(&'a CStr),
27211    ProtoDown(u8),
27212    GsoMaxSegs(u32),
27213    GsoMaxSize(u32),
27214    Pad(&'a [u8]),
27215    Xdp(IterableXdpAttrs<'a>),
27216    Event(u32),
27217    NewNetnsid(i32),
27218    TargetNetnsid(i32),
27219    CarrierUpCount(u32),
27220    CarrierDownCount(u32),
27221    NewIfindex(i32),
27222    MinMtu(u32),
27223    MaxMtu(u32),
27224    PropList(IterablePropListLinkAttrs<'a>),
27225    PermAddress(&'a [u8]),
27226    ProtoDownReason(&'a CStr),
27227    ParentDevName(&'a CStr),
27228    ParentDevBusName(&'a CStr),
27229    GroMaxSize(u32),
27230    TsoMaxSize(u32),
27231    TsoMaxSegs(u32),
27232    Allmulti(u32),
27233    DevlinkPort(&'a [u8]),
27234    GsoIpv4MaxSize(u32),
27235    GroIpv4MaxSize(u32),
27236    DpllPin(IterableLinkDpllPinAttrs<'a>),
27237    #[doc = "EDT offload horizon supported by the device (in nsec)."]
27238    MaxPacingOffloadHorizon(u32),
27239    NetnsImmutable(u8),
27240}
27241impl<'a> IterableOpGetlinkDoReply<'a> {
27242    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
27243        let mut iter = self.clone();
27244        iter.pos = 0;
27245        for attr in iter {
27246            if let OpGetlinkDoReply::Address(val) = attr? {
27247                return Ok(val);
27248            }
27249        }
27250        Err(ErrorContext::new_missing(
27251            "OpGetlinkDoReply",
27252            "Address",
27253            self.orig_loc,
27254            self.buf.as_ptr() as usize,
27255        ))
27256    }
27257    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
27258        let mut iter = self.clone();
27259        iter.pos = 0;
27260        for attr in iter {
27261            if let OpGetlinkDoReply::Broadcast(val) = attr? {
27262                return Ok(val);
27263            }
27264        }
27265        Err(ErrorContext::new_missing(
27266            "OpGetlinkDoReply",
27267            "Broadcast",
27268            self.orig_loc,
27269            self.buf.as_ptr() as usize,
27270        ))
27271    }
27272    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
27273        let mut iter = self.clone();
27274        iter.pos = 0;
27275        for attr in iter {
27276            if let OpGetlinkDoReply::Ifname(val) = attr? {
27277                return Ok(val);
27278            }
27279        }
27280        Err(ErrorContext::new_missing(
27281            "OpGetlinkDoReply",
27282            "Ifname",
27283            self.orig_loc,
27284            self.buf.as_ptr() as usize,
27285        ))
27286    }
27287    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
27288        let mut iter = self.clone();
27289        iter.pos = 0;
27290        for attr in iter {
27291            if let OpGetlinkDoReply::Mtu(val) = attr? {
27292                return Ok(val);
27293            }
27294        }
27295        Err(ErrorContext::new_missing(
27296            "OpGetlinkDoReply",
27297            "Mtu",
27298            self.orig_loc,
27299            self.buf.as_ptr() as usize,
27300        ))
27301    }
27302    pub fn get_link(&self) -> Result<u32, ErrorContext> {
27303        let mut iter = self.clone();
27304        iter.pos = 0;
27305        for attr in iter {
27306            if let OpGetlinkDoReply::Link(val) = attr? {
27307                return Ok(val);
27308            }
27309        }
27310        Err(ErrorContext::new_missing(
27311            "OpGetlinkDoReply",
27312            "Link",
27313            self.orig_loc,
27314            self.buf.as_ptr() as usize,
27315        ))
27316    }
27317    pub fn get_qdisc(&self) -> Result<&'a CStr, ErrorContext> {
27318        let mut iter = self.clone();
27319        iter.pos = 0;
27320        for attr in iter {
27321            if let OpGetlinkDoReply::Qdisc(val) = attr? {
27322                return Ok(val);
27323            }
27324        }
27325        Err(ErrorContext::new_missing(
27326            "OpGetlinkDoReply",
27327            "Qdisc",
27328            self.orig_loc,
27329            self.buf.as_ptr() as usize,
27330        ))
27331    }
27332    pub fn get_stats(&self) -> Result<PushRtnlLinkStats, ErrorContext> {
27333        let mut iter = self.clone();
27334        iter.pos = 0;
27335        for attr in iter {
27336            if let OpGetlinkDoReply::Stats(val) = attr? {
27337                return Ok(val);
27338            }
27339        }
27340        Err(ErrorContext::new_missing(
27341            "OpGetlinkDoReply",
27342            "Stats",
27343            self.orig_loc,
27344            self.buf.as_ptr() as usize,
27345        ))
27346    }
27347    pub fn get_cost(&self) -> Result<&'a CStr, ErrorContext> {
27348        let mut iter = self.clone();
27349        iter.pos = 0;
27350        for attr in iter {
27351            if let OpGetlinkDoReply::Cost(val) = attr? {
27352                return Ok(val);
27353            }
27354        }
27355        Err(ErrorContext::new_missing(
27356            "OpGetlinkDoReply",
27357            "Cost",
27358            self.orig_loc,
27359            self.buf.as_ptr() as usize,
27360        ))
27361    }
27362    pub fn get_priority(&self) -> Result<&'a CStr, ErrorContext> {
27363        let mut iter = self.clone();
27364        iter.pos = 0;
27365        for attr in iter {
27366            if let OpGetlinkDoReply::Priority(val) = attr? {
27367                return Ok(val);
27368            }
27369        }
27370        Err(ErrorContext::new_missing(
27371            "OpGetlinkDoReply",
27372            "Priority",
27373            self.orig_loc,
27374            self.buf.as_ptr() as usize,
27375        ))
27376    }
27377    pub fn get_master(&self) -> Result<u32, ErrorContext> {
27378        let mut iter = self.clone();
27379        iter.pos = 0;
27380        for attr in iter {
27381            if let OpGetlinkDoReply::Master(val) = attr? {
27382                return Ok(val);
27383            }
27384        }
27385        Err(ErrorContext::new_missing(
27386            "OpGetlinkDoReply",
27387            "Master",
27388            self.orig_loc,
27389            self.buf.as_ptr() as usize,
27390        ))
27391    }
27392    pub fn get_wireless(&self) -> Result<&'a CStr, ErrorContext> {
27393        let mut iter = self.clone();
27394        iter.pos = 0;
27395        for attr in iter {
27396            if let OpGetlinkDoReply::Wireless(val) = attr? {
27397                return Ok(val);
27398            }
27399        }
27400        Err(ErrorContext::new_missing(
27401            "OpGetlinkDoReply",
27402            "Wireless",
27403            self.orig_loc,
27404            self.buf.as_ptr() as usize,
27405        ))
27406    }
27407    pub fn get_protinfo(&self) -> Result<&'a CStr, ErrorContext> {
27408        let mut iter = self.clone();
27409        iter.pos = 0;
27410        for attr in iter {
27411            if let OpGetlinkDoReply::Protinfo(val) = attr? {
27412                return Ok(val);
27413            }
27414        }
27415        Err(ErrorContext::new_missing(
27416            "OpGetlinkDoReply",
27417            "Protinfo",
27418            self.orig_loc,
27419            self.buf.as_ptr() as usize,
27420        ))
27421    }
27422    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
27423        let mut iter = self.clone();
27424        iter.pos = 0;
27425        for attr in iter {
27426            if let OpGetlinkDoReply::Txqlen(val) = attr? {
27427                return Ok(val);
27428            }
27429        }
27430        Err(ErrorContext::new_missing(
27431            "OpGetlinkDoReply",
27432            "Txqlen",
27433            self.orig_loc,
27434            self.buf.as_ptr() as usize,
27435        ))
27436    }
27437    pub fn get_map(&self) -> Result<PushRtnlLinkIfmap, ErrorContext> {
27438        let mut iter = self.clone();
27439        iter.pos = 0;
27440        for attr in iter {
27441            if let OpGetlinkDoReply::Map(val) = attr? {
27442                return Ok(val);
27443            }
27444        }
27445        Err(ErrorContext::new_missing(
27446            "OpGetlinkDoReply",
27447            "Map",
27448            self.orig_loc,
27449            self.buf.as_ptr() as usize,
27450        ))
27451    }
27452    pub fn get_weight(&self) -> Result<u32, ErrorContext> {
27453        let mut iter = self.clone();
27454        iter.pos = 0;
27455        for attr in iter {
27456            if let OpGetlinkDoReply::Weight(val) = attr? {
27457                return Ok(val);
27458            }
27459        }
27460        Err(ErrorContext::new_missing(
27461            "OpGetlinkDoReply",
27462            "Weight",
27463            self.orig_loc,
27464            self.buf.as_ptr() as usize,
27465        ))
27466    }
27467    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
27468        let mut iter = self.clone();
27469        iter.pos = 0;
27470        for attr in iter {
27471            if let OpGetlinkDoReply::Operstate(val) = attr? {
27472                return Ok(val);
27473            }
27474        }
27475        Err(ErrorContext::new_missing(
27476            "OpGetlinkDoReply",
27477            "Operstate",
27478            self.orig_loc,
27479            self.buf.as_ptr() as usize,
27480        ))
27481    }
27482    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
27483        let mut iter = self.clone();
27484        iter.pos = 0;
27485        for attr in iter {
27486            if let OpGetlinkDoReply::Linkmode(val) = attr? {
27487                return Ok(val);
27488            }
27489        }
27490        Err(ErrorContext::new_missing(
27491            "OpGetlinkDoReply",
27492            "Linkmode",
27493            self.orig_loc,
27494            self.buf.as_ptr() as usize,
27495        ))
27496    }
27497    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
27498        let mut iter = self.clone();
27499        iter.pos = 0;
27500        for attr in iter {
27501            if let OpGetlinkDoReply::Linkinfo(val) = attr? {
27502                return Ok(val);
27503            }
27504        }
27505        Err(ErrorContext::new_missing(
27506            "OpGetlinkDoReply",
27507            "Linkinfo",
27508            self.orig_loc,
27509            self.buf.as_ptr() as usize,
27510        ))
27511    }
27512    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
27513        let mut iter = self.clone();
27514        iter.pos = 0;
27515        for attr in iter {
27516            if let OpGetlinkDoReply::NetNsPid(val) = attr? {
27517                return Ok(val);
27518            }
27519        }
27520        Err(ErrorContext::new_missing(
27521            "OpGetlinkDoReply",
27522            "NetNsPid",
27523            self.orig_loc,
27524            self.buf.as_ptr() as usize,
27525        ))
27526    }
27527    pub fn get_ifalias(&self) -> Result<&'a CStr, ErrorContext> {
27528        let mut iter = self.clone();
27529        iter.pos = 0;
27530        for attr in iter {
27531            if let OpGetlinkDoReply::Ifalias(val) = attr? {
27532                return Ok(val);
27533            }
27534        }
27535        Err(ErrorContext::new_missing(
27536            "OpGetlinkDoReply",
27537            "Ifalias",
27538            self.orig_loc,
27539            self.buf.as_ptr() as usize,
27540        ))
27541    }
27542    pub fn get_num_vf(&self) -> Result<u32, ErrorContext> {
27543        let mut iter = self.clone();
27544        iter.pos = 0;
27545        for attr in iter {
27546            if let OpGetlinkDoReply::NumVf(val) = attr? {
27547                return Ok(val);
27548            }
27549        }
27550        Err(ErrorContext::new_missing(
27551            "OpGetlinkDoReply",
27552            "NumVf",
27553            self.orig_loc,
27554            self.buf.as_ptr() as usize,
27555        ))
27556    }
27557    pub fn get_vfinfo_list(&self) -> Result<IterableVfinfoListAttrs<'a>, ErrorContext> {
27558        let mut iter = self.clone();
27559        iter.pos = 0;
27560        for attr in iter {
27561            if let OpGetlinkDoReply::VfinfoList(val) = attr? {
27562                return Ok(val);
27563            }
27564        }
27565        Err(ErrorContext::new_missing(
27566            "OpGetlinkDoReply",
27567            "VfinfoList",
27568            self.orig_loc,
27569            self.buf.as_ptr() as usize,
27570        ))
27571    }
27572    pub fn get_stats64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
27573        let mut iter = self.clone();
27574        iter.pos = 0;
27575        for attr in iter {
27576            if let OpGetlinkDoReply::Stats64(val) = attr? {
27577                return Ok(val);
27578            }
27579        }
27580        Err(ErrorContext::new_missing(
27581            "OpGetlinkDoReply",
27582            "Stats64",
27583            self.orig_loc,
27584            self.buf.as_ptr() as usize,
27585        ))
27586    }
27587    pub fn get_vf_ports(&self) -> Result<IterableVfPortsAttrs<'a>, ErrorContext> {
27588        let mut iter = self.clone();
27589        iter.pos = 0;
27590        for attr in iter {
27591            if let OpGetlinkDoReply::VfPorts(val) = attr? {
27592                return Ok(val);
27593            }
27594        }
27595        Err(ErrorContext::new_missing(
27596            "OpGetlinkDoReply",
27597            "VfPorts",
27598            self.orig_loc,
27599            self.buf.as_ptr() as usize,
27600        ))
27601    }
27602    pub fn get_port_self(&self) -> Result<IterablePortSelfAttrs<'a>, ErrorContext> {
27603        let mut iter = self.clone();
27604        iter.pos = 0;
27605        for attr in iter {
27606            if let OpGetlinkDoReply::PortSelf(val) = attr? {
27607                return Ok(val);
27608            }
27609        }
27610        Err(ErrorContext::new_missing(
27611            "OpGetlinkDoReply",
27612            "PortSelf",
27613            self.orig_loc,
27614            self.buf.as_ptr() as usize,
27615        ))
27616    }
27617    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
27618        let mut iter = self.clone();
27619        iter.pos = 0;
27620        for attr in iter {
27621            if let OpGetlinkDoReply::AfSpec(val) = attr? {
27622                return Ok(val);
27623            }
27624        }
27625        Err(ErrorContext::new_missing(
27626            "OpGetlinkDoReply",
27627            "AfSpec",
27628            self.orig_loc,
27629            self.buf.as_ptr() as usize,
27630        ))
27631    }
27632    pub fn get_group(&self) -> Result<u32, ErrorContext> {
27633        let mut iter = self.clone();
27634        iter.pos = 0;
27635        for attr in iter {
27636            if let OpGetlinkDoReply::Group(val) = attr? {
27637                return Ok(val);
27638            }
27639        }
27640        Err(ErrorContext::new_missing(
27641            "OpGetlinkDoReply",
27642            "Group",
27643            self.orig_loc,
27644            self.buf.as_ptr() as usize,
27645        ))
27646    }
27647    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
27648        let mut iter = self.clone();
27649        iter.pos = 0;
27650        for attr in iter {
27651            if let OpGetlinkDoReply::NetNsFd(val) = attr? {
27652                return Ok(val);
27653            }
27654        }
27655        Err(ErrorContext::new_missing(
27656            "OpGetlinkDoReply",
27657            "NetNsFd",
27658            self.orig_loc,
27659            self.buf.as_ptr() as usize,
27660        ))
27661    }
27662    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
27663    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
27664        let mut iter = self.clone();
27665        iter.pos = 0;
27666        for attr in iter {
27667            if let OpGetlinkDoReply::ExtMask(val) = attr? {
27668                return Ok(val);
27669            }
27670        }
27671        Err(ErrorContext::new_missing(
27672            "OpGetlinkDoReply",
27673            "ExtMask",
27674            self.orig_loc,
27675            self.buf.as_ptr() as usize,
27676        ))
27677    }
27678    pub fn get_promiscuity(&self) -> Result<u32, ErrorContext> {
27679        let mut iter = self.clone();
27680        iter.pos = 0;
27681        for attr in iter {
27682            if let OpGetlinkDoReply::Promiscuity(val) = attr? {
27683                return Ok(val);
27684            }
27685        }
27686        Err(ErrorContext::new_missing(
27687            "OpGetlinkDoReply",
27688            "Promiscuity",
27689            self.orig_loc,
27690            self.buf.as_ptr() as usize,
27691        ))
27692    }
27693    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
27694        let mut iter = self.clone();
27695        iter.pos = 0;
27696        for attr in iter {
27697            if let OpGetlinkDoReply::NumTxQueues(val) = attr? {
27698                return Ok(val);
27699            }
27700        }
27701        Err(ErrorContext::new_missing(
27702            "OpGetlinkDoReply",
27703            "NumTxQueues",
27704            self.orig_loc,
27705            self.buf.as_ptr() as usize,
27706        ))
27707    }
27708    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
27709        let mut iter = self.clone();
27710        iter.pos = 0;
27711        for attr in iter {
27712            if let OpGetlinkDoReply::NumRxQueues(val) = attr? {
27713                return Ok(val);
27714            }
27715        }
27716        Err(ErrorContext::new_missing(
27717            "OpGetlinkDoReply",
27718            "NumRxQueues",
27719            self.orig_loc,
27720            self.buf.as_ptr() as usize,
27721        ))
27722    }
27723    pub fn get_carrier(&self) -> Result<u8, ErrorContext> {
27724        let mut iter = self.clone();
27725        iter.pos = 0;
27726        for attr in iter {
27727            if let OpGetlinkDoReply::Carrier(val) = attr? {
27728                return Ok(val);
27729            }
27730        }
27731        Err(ErrorContext::new_missing(
27732            "OpGetlinkDoReply",
27733            "Carrier",
27734            self.orig_loc,
27735            self.buf.as_ptr() as usize,
27736        ))
27737    }
27738    pub fn get_phys_port_id(&self) -> Result<&'a [u8], ErrorContext> {
27739        let mut iter = self.clone();
27740        iter.pos = 0;
27741        for attr in iter {
27742            if let OpGetlinkDoReply::PhysPortId(val) = attr? {
27743                return Ok(val);
27744            }
27745        }
27746        Err(ErrorContext::new_missing(
27747            "OpGetlinkDoReply",
27748            "PhysPortId",
27749            self.orig_loc,
27750            self.buf.as_ptr() as usize,
27751        ))
27752    }
27753    pub fn get_carrier_changes(&self) -> Result<u32, ErrorContext> {
27754        let mut iter = self.clone();
27755        iter.pos = 0;
27756        for attr in iter {
27757            if let OpGetlinkDoReply::CarrierChanges(val) = attr? {
27758                return Ok(val);
27759            }
27760        }
27761        Err(ErrorContext::new_missing(
27762            "OpGetlinkDoReply",
27763            "CarrierChanges",
27764            self.orig_loc,
27765            self.buf.as_ptr() as usize,
27766        ))
27767    }
27768    pub fn get_phys_switch_id(&self) -> Result<&'a [u8], ErrorContext> {
27769        let mut iter = self.clone();
27770        iter.pos = 0;
27771        for attr in iter {
27772            if let OpGetlinkDoReply::PhysSwitchId(val) = attr? {
27773                return Ok(val);
27774            }
27775        }
27776        Err(ErrorContext::new_missing(
27777            "OpGetlinkDoReply",
27778            "PhysSwitchId",
27779            self.orig_loc,
27780            self.buf.as_ptr() as usize,
27781        ))
27782    }
27783    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
27784        let mut iter = self.clone();
27785        iter.pos = 0;
27786        for attr in iter {
27787            if let OpGetlinkDoReply::LinkNetnsid(val) = attr? {
27788                return Ok(val);
27789            }
27790        }
27791        Err(ErrorContext::new_missing(
27792            "OpGetlinkDoReply",
27793            "LinkNetnsid",
27794            self.orig_loc,
27795            self.buf.as_ptr() as usize,
27796        ))
27797    }
27798    pub fn get_phys_port_name(&self) -> Result<&'a CStr, ErrorContext> {
27799        let mut iter = self.clone();
27800        iter.pos = 0;
27801        for attr in iter {
27802            if let OpGetlinkDoReply::PhysPortName(val) = attr? {
27803                return Ok(val);
27804            }
27805        }
27806        Err(ErrorContext::new_missing(
27807            "OpGetlinkDoReply",
27808            "PhysPortName",
27809            self.orig_loc,
27810            self.buf.as_ptr() as usize,
27811        ))
27812    }
27813    pub fn get_proto_down(&self) -> Result<u8, ErrorContext> {
27814        let mut iter = self.clone();
27815        iter.pos = 0;
27816        for attr in iter {
27817            if let OpGetlinkDoReply::ProtoDown(val) = attr? {
27818                return Ok(val);
27819            }
27820        }
27821        Err(ErrorContext::new_missing(
27822            "OpGetlinkDoReply",
27823            "ProtoDown",
27824            self.orig_loc,
27825            self.buf.as_ptr() as usize,
27826        ))
27827    }
27828    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
27829        let mut iter = self.clone();
27830        iter.pos = 0;
27831        for attr in iter {
27832            if let OpGetlinkDoReply::GsoMaxSegs(val) = attr? {
27833                return Ok(val);
27834            }
27835        }
27836        Err(ErrorContext::new_missing(
27837            "OpGetlinkDoReply",
27838            "GsoMaxSegs",
27839            self.orig_loc,
27840            self.buf.as_ptr() as usize,
27841        ))
27842    }
27843    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
27844        let mut iter = self.clone();
27845        iter.pos = 0;
27846        for attr in iter {
27847            if let OpGetlinkDoReply::GsoMaxSize(val) = attr? {
27848                return Ok(val);
27849            }
27850        }
27851        Err(ErrorContext::new_missing(
27852            "OpGetlinkDoReply",
27853            "GsoMaxSize",
27854            self.orig_loc,
27855            self.buf.as_ptr() as usize,
27856        ))
27857    }
27858    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
27859        let mut iter = self.clone();
27860        iter.pos = 0;
27861        for attr in iter {
27862            if let OpGetlinkDoReply::Pad(val) = attr? {
27863                return Ok(val);
27864            }
27865        }
27866        Err(ErrorContext::new_missing(
27867            "OpGetlinkDoReply",
27868            "Pad",
27869            self.orig_loc,
27870            self.buf.as_ptr() as usize,
27871        ))
27872    }
27873    pub fn get_xdp(&self) -> Result<IterableXdpAttrs<'a>, ErrorContext> {
27874        let mut iter = self.clone();
27875        iter.pos = 0;
27876        for attr in iter {
27877            if let OpGetlinkDoReply::Xdp(val) = attr? {
27878                return Ok(val);
27879            }
27880        }
27881        Err(ErrorContext::new_missing(
27882            "OpGetlinkDoReply",
27883            "Xdp",
27884            self.orig_loc,
27885            self.buf.as_ptr() as usize,
27886        ))
27887    }
27888    pub fn get_event(&self) -> Result<u32, ErrorContext> {
27889        let mut iter = self.clone();
27890        iter.pos = 0;
27891        for attr in iter {
27892            if let OpGetlinkDoReply::Event(val) = attr? {
27893                return Ok(val);
27894            }
27895        }
27896        Err(ErrorContext::new_missing(
27897            "OpGetlinkDoReply",
27898            "Event",
27899            self.orig_loc,
27900            self.buf.as_ptr() as usize,
27901        ))
27902    }
27903    pub fn get_new_netnsid(&self) -> Result<i32, ErrorContext> {
27904        let mut iter = self.clone();
27905        iter.pos = 0;
27906        for attr in iter {
27907            if let OpGetlinkDoReply::NewNetnsid(val) = attr? {
27908                return Ok(val);
27909            }
27910        }
27911        Err(ErrorContext::new_missing(
27912            "OpGetlinkDoReply",
27913            "NewNetnsid",
27914            self.orig_loc,
27915            self.buf.as_ptr() as usize,
27916        ))
27917    }
27918    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
27919        let mut iter = self.clone();
27920        iter.pos = 0;
27921        for attr in iter {
27922            if let OpGetlinkDoReply::TargetNetnsid(val) = attr? {
27923                return Ok(val);
27924            }
27925        }
27926        Err(ErrorContext::new_missing(
27927            "OpGetlinkDoReply",
27928            "TargetNetnsid",
27929            self.orig_loc,
27930            self.buf.as_ptr() as usize,
27931        ))
27932    }
27933    pub fn get_carrier_up_count(&self) -> Result<u32, ErrorContext> {
27934        let mut iter = self.clone();
27935        iter.pos = 0;
27936        for attr in iter {
27937            if let OpGetlinkDoReply::CarrierUpCount(val) = attr? {
27938                return Ok(val);
27939            }
27940        }
27941        Err(ErrorContext::new_missing(
27942            "OpGetlinkDoReply",
27943            "CarrierUpCount",
27944            self.orig_loc,
27945            self.buf.as_ptr() as usize,
27946        ))
27947    }
27948    pub fn get_carrier_down_count(&self) -> Result<u32, ErrorContext> {
27949        let mut iter = self.clone();
27950        iter.pos = 0;
27951        for attr in iter {
27952            if let OpGetlinkDoReply::CarrierDownCount(val) = attr? {
27953                return Ok(val);
27954            }
27955        }
27956        Err(ErrorContext::new_missing(
27957            "OpGetlinkDoReply",
27958            "CarrierDownCount",
27959            self.orig_loc,
27960            self.buf.as_ptr() as usize,
27961        ))
27962    }
27963    pub fn get_new_ifindex(&self) -> Result<i32, ErrorContext> {
27964        let mut iter = self.clone();
27965        iter.pos = 0;
27966        for attr in iter {
27967            if let OpGetlinkDoReply::NewIfindex(val) = attr? {
27968                return Ok(val);
27969            }
27970        }
27971        Err(ErrorContext::new_missing(
27972            "OpGetlinkDoReply",
27973            "NewIfindex",
27974            self.orig_loc,
27975            self.buf.as_ptr() as usize,
27976        ))
27977    }
27978    pub fn get_min_mtu(&self) -> Result<u32, ErrorContext> {
27979        let mut iter = self.clone();
27980        iter.pos = 0;
27981        for attr in iter {
27982            if let OpGetlinkDoReply::MinMtu(val) = attr? {
27983                return Ok(val);
27984            }
27985        }
27986        Err(ErrorContext::new_missing(
27987            "OpGetlinkDoReply",
27988            "MinMtu",
27989            self.orig_loc,
27990            self.buf.as_ptr() as usize,
27991        ))
27992    }
27993    pub fn get_max_mtu(&self) -> Result<u32, ErrorContext> {
27994        let mut iter = self.clone();
27995        iter.pos = 0;
27996        for attr in iter {
27997            if let OpGetlinkDoReply::MaxMtu(val) = attr? {
27998                return Ok(val);
27999            }
28000        }
28001        Err(ErrorContext::new_missing(
28002            "OpGetlinkDoReply",
28003            "MaxMtu",
28004            self.orig_loc,
28005            self.buf.as_ptr() as usize,
28006        ))
28007    }
28008    pub fn get_prop_list(&self) -> Result<IterablePropListLinkAttrs<'a>, ErrorContext> {
28009        let mut iter = self.clone();
28010        iter.pos = 0;
28011        for attr in iter {
28012            if let OpGetlinkDoReply::PropList(val) = attr? {
28013                return Ok(val);
28014            }
28015        }
28016        Err(ErrorContext::new_missing(
28017            "OpGetlinkDoReply",
28018            "PropList",
28019            self.orig_loc,
28020            self.buf.as_ptr() as usize,
28021        ))
28022    }
28023    pub fn get_perm_address(&self) -> Result<&'a [u8], ErrorContext> {
28024        let mut iter = self.clone();
28025        iter.pos = 0;
28026        for attr in iter {
28027            if let OpGetlinkDoReply::PermAddress(val) = attr? {
28028                return Ok(val);
28029            }
28030        }
28031        Err(ErrorContext::new_missing(
28032            "OpGetlinkDoReply",
28033            "PermAddress",
28034            self.orig_loc,
28035            self.buf.as_ptr() as usize,
28036        ))
28037    }
28038    pub fn get_proto_down_reason(&self) -> Result<&'a CStr, ErrorContext> {
28039        let mut iter = self.clone();
28040        iter.pos = 0;
28041        for attr in iter {
28042            if let OpGetlinkDoReply::ProtoDownReason(val) = attr? {
28043                return Ok(val);
28044            }
28045        }
28046        Err(ErrorContext::new_missing(
28047            "OpGetlinkDoReply",
28048            "ProtoDownReason",
28049            self.orig_loc,
28050            self.buf.as_ptr() as usize,
28051        ))
28052    }
28053    pub fn get_parent_dev_name(&self) -> Result<&'a CStr, ErrorContext> {
28054        let mut iter = self.clone();
28055        iter.pos = 0;
28056        for attr in iter {
28057            if let OpGetlinkDoReply::ParentDevName(val) = attr? {
28058                return Ok(val);
28059            }
28060        }
28061        Err(ErrorContext::new_missing(
28062            "OpGetlinkDoReply",
28063            "ParentDevName",
28064            self.orig_loc,
28065            self.buf.as_ptr() as usize,
28066        ))
28067    }
28068    pub fn get_parent_dev_bus_name(&self) -> Result<&'a CStr, ErrorContext> {
28069        let mut iter = self.clone();
28070        iter.pos = 0;
28071        for attr in iter {
28072            if let OpGetlinkDoReply::ParentDevBusName(val) = attr? {
28073                return Ok(val);
28074            }
28075        }
28076        Err(ErrorContext::new_missing(
28077            "OpGetlinkDoReply",
28078            "ParentDevBusName",
28079            self.orig_loc,
28080            self.buf.as_ptr() as usize,
28081        ))
28082    }
28083    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
28084        let mut iter = self.clone();
28085        iter.pos = 0;
28086        for attr in iter {
28087            if let OpGetlinkDoReply::GroMaxSize(val) = attr? {
28088                return Ok(val);
28089            }
28090        }
28091        Err(ErrorContext::new_missing(
28092            "OpGetlinkDoReply",
28093            "GroMaxSize",
28094            self.orig_loc,
28095            self.buf.as_ptr() as usize,
28096        ))
28097    }
28098    pub fn get_tso_max_size(&self) -> Result<u32, ErrorContext> {
28099        let mut iter = self.clone();
28100        iter.pos = 0;
28101        for attr in iter {
28102            if let OpGetlinkDoReply::TsoMaxSize(val) = attr? {
28103                return Ok(val);
28104            }
28105        }
28106        Err(ErrorContext::new_missing(
28107            "OpGetlinkDoReply",
28108            "TsoMaxSize",
28109            self.orig_loc,
28110            self.buf.as_ptr() as usize,
28111        ))
28112    }
28113    pub fn get_tso_max_segs(&self) -> Result<u32, ErrorContext> {
28114        let mut iter = self.clone();
28115        iter.pos = 0;
28116        for attr in iter {
28117            if let OpGetlinkDoReply::TsoMaxSegs(val) = attr? {
28118                return Ok(val);
28119            }
28120        }
28121        Err(ErrorContext::new_missing(
28122            "OpGetlinkDoReply",
28123            "TsoMaxSegs",
28124            self.orig_loc,
28125            self.buf.as_ptr() as usize,
28126        ))
28127    }
28128    pub fn get_allmulti(&self) -> Result<u32, ErrorContext> {
28129        let mut iter = self.clone();
28130        iter.pos = 0;
28131        for attr in iter {
28132            if let OpGetlinkDoReply::Allmulti(val) = attr? {
28133                return Ok(val);
28134            }
28135        }
28136        Err(ErrorContext::new_missing(
28137            "OpGetlinkDoReply",
28138            "Allmulti",
28139            self.orig_loc,
28140            self.buf.as_ptr() as usize,
28141        ))
28142    }
28143    pub fn get_devlink_port(&self) -> Result<&'a [u8], ErrorContext> {
28144        let mut iter = self.clone();
28145        iter.pos = 0;
28146        for attr in iter {
28147            if let OpGetlinkDoReply::DevlinkPort(val) = attr? {
28148                return Ok(val);
28149            }
28150        }
28151        Err(ErrorContext::new_missing(
28152            "OpGetlinkDoReply",
28153            "DevlinkPort",
28154            self.orig_loc,
28155            self.buf.as_ptr() as usize,
28156        ))
28157    }
28158    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
28159        let mut iter = self.clone();
28160        iter.pos = 0;
28161        for attr in iter {
28162            if let OpGetlinkDoReply::GsoIpv4MaxSize(val) = attr? {
28163                return Ok(val);
28164            }
28165        }
28166        Err(ErrorContext::new_missing(
28167            "OpGetlinkDoReply",
28168            "GsoIpv4MaxSize",
28169            self.orig_loc,
28170            self.buf.as_ptr() as usize,
28171        ))
28172    }
28173    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
28174        let mut iter = self.clone();
28175        iter.pos = 0;
28176        for attr in iter {
28177            if let OpGetlinkDoReply::GroIpv4MaxSize(val) = attr? {
28178                return Ok(val);
28179            }
28180        }
28181        Err(ErrorContext::new_missing(
28182            "OpGetlinkDoReply",
28183            "GroIpv4MaxSize",
28184            self.orig_loc,
28185            self.buf.as_ptr() as usize,
28186        ))
28187    }
28188    pub fn get_dpll_pin(&self) -> Result<IterableLinkDpllPinAttrs<'a>, ErrorContext> {
28189        let mut iter = self.clone();
28190        iter.pos = 0;
28191        for attr in iter {
28192            if let OpGetlinkDoReply::DpllPin(val) = attr? {
28193                return Ok(val);
28194            }
28195        }
28196        Err(ErrorContext::new_missing(
28197            "OpGetlinkDoReply",
28198            "DpllPin",
28199            self.orig_loc,
28200            self.buf.as_ptr() as usize,
28201        ))
28202    }
28203    #[doc = "EDT offload horizon supported by the device (in nsec)."]
28204    pub fn get_max_pacing_offload_horizon(&self) -> Result<u32, ErrorContext> {
28205        let mut iter = self.clone();
28206        iter.pos = 0;
28207        for attr in iter {
28208            if let OpGetlinkDoReply::MaxPacingOffloadHorizon(val) = attr? {
28209                return Ok(val);
28210            }
28211        }
28212        Err(ErrorContext::new_missing(
28213            "OpGetlinkDoReply",
28214            "MaxPacingOffloadHorizon",
28215            self.orig_loc,
28216            self.buf.as_ptr() as usize,
28217        ))
28218    }
28219    pub fn get_netns_immutable(&self) -> Result<u8, ErrorContext> {
28220        let mut iter = self.clone();
28221        iter.pos = 0;
28222        for attr in iter {
28223            if let OpGetlinkDoReply::NetnsImmutable(val) = attr? {
28224                return Ok(val);
28225            }
28226        }
28227        Err(ErrorContext::new_missing(
28228            "OpGetlinkDoReply",
28229            "NetnsImmutable",
28230            self.orig_loc,
28231            self.buf.as_ptr() as usize,
28232        ))
28233    }
28234}
28235impl OpGetlinkDoReply<'_> {
28236    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpGetlinkDoReply<'a>) {
28237        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
28238        (
28239            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
28240            IterableOpGetlinkDoReply::with_loc(attrs, buf.as_ptr() as usize),
28241        )
28242    }
28243    fn attr_from_type(r#type: u16) -> Option<&'static str> {
28244        LinkAttrs::attr_from_type(r#type)
28245    }
28246}
28247#[derive(Clone, Copy, Default)]
28248pub struct IterableOpGetlinkDoReply<'a> {
28249    buf: &'a [u8],
28250    pos: usize,
28251    orig_loc: usize,
28252}
28253impl<'a> IterableOpGetlinkDoReply<'a> {
28254    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
28255        Self {
28256            buf,
28257            pos: 0,
28258            orig_loc,
28259        }
28260    }
28261    pub fn get_buf(&self) -> &'a [u8] {
28262        self.buf
28263    }
28264}
28265impl<'a> Iterator for IterableOpGetlinkDoReply<'a> {
28266    type Item = Result<OpGetlinkDoReply<'a>, ErrorContext>;
28267    fn next(&mut self) -> Option<Self::Item> {
28268        let pos = self.pos;
28269        let mut r#type;
28270        loop {
28271            r#type = None;
28272            if self.buf.len() == self.pos {
28273                return None;
28274            }
28275            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
28276                break;
28277            };
28278            r#type = Some(header.r#type);
28279            let res = match header.r#type {
28280                1u16 => OpGetlinkDoReply::Address({
28281                    let res = Some(next);
28282                    let Some(val) = res else { break };
28283                    val
28284                }),
28285                2u16 => OpGetlinkDoReply::Broadcast({
28286                    let res = Some(next);
28287                    let Some(val) = res else { break };
28288                    val
28289                }),
28290                3u16 => OpGetlinkDoReply::Ifname({
28291                    let res = CStr::from_bytes_with_nul(next).ok();
28292                    let Some(val) = res else { break };
28293                    val
28294                }),
28295                4u16 => OpGetlinkDoReply::Mtu({
28296                    let res = parse_u32(next);
28297                    let Some(val) = res else { break };
28298                    val
28299                }),
28300                5u16 => OpGetlinkDoReply::Link({
28301                    let res = parse_u32(next);
28302                    let Some(val) = res else { break };
28303                    val
28304                }),
28305                6u16 => OpGetlinkDoReply::Qdisc({
28306                    let res = CStr::from_bytes_with_nul(next).ok();
28307                    let Some(val) = res else { break };
28308                    val
28309                }),
28310                7u16 => OpGetlinkDoReply::Stats({
28311                    let res = Some(PushRtnlLinkStats::new_from_zeroed(next));
28312                    let Some(val) = res else { break };
28313                    val
28314                }),
28315                8u16 => OpGetlinkDoReply::Cost({
28316                    let res = CStr::from_bytes_with_nul(next).ok();
28317                    let Some(val) = res else { break };
28318                    val
28319                }),
28320                9u16 => OpGetlinkDoReply::Priority({
28321                    let res = CStr::from_bytes_with_nul(next).ok();
28322                    let Some(val) = res else { break };
28323                    val
28324                }),
28325                10u16 => OpGetlinkDoReply::Master({
28326                    let res = parse_u32(next);
28327                    let Some(val) = res else { break };
28328                    val
28329                }),
28330                11u16 => OpGetlinkDoReply::Wireless({
28331                    let res = CStr::from_bytes_with_nul(next).ok();
28332                    let Some(val) = res else { break };
28333                    val
28334                }),
28335                12u16 => OpGetlinkDoReply::Protinfo({
28336                    let res = CStr::from_bytes_with_nul(next).ok();
28337                    let Some(val) = res else { break };
28338                    val
28339                }),
28340                13u16 => OpGetlinkDoReply::Txqlen({
28341                    let res = parse_u32(next);
28342                    let Some(val) = res else { break };
28343                    val
28344                }),
28345                14u16 => OpGetlinkDoReply::Map({
28346                    let res = PushRtnlLinkIfmap::new_from_slice(next);
28347                    let Some(val) = res else { break };
28348                    val
28349                }),
28350                15u16 => OpGetlinkDoReply::Weight({
28351                    let res = parse_u32(next);
28352                    let Some(val) = res else { break };
28353                    val
28354                }),
28355                16u16 => OpGetlinkDoReply::Operstate({
28356                    let res = parse_u8(next);
28357                    let Some(val) = res else { break };
28358                    val
28359                }),
28360                17u16 => OpGetlinkDoReply::Linkmode({
28361                    let res = parse_u8(next);
28362                    let Some(val) = res else { break };
28363                    val
28364                }),
28365                18u16 => OpGetlinkDoReply::Linkinfo({
28366                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
28367                    let Some(val) = res else { break };
28368                    val
28369                }),
28370                19u16 => OpGetlinkDoReply::NetNsPid({
28371                    let res = parse_u32(next);
28372                    let Some(val) = res else { break };
28373                    val
28374                }),
28375                20u16 => OpGetlinkDoReply::Ifalias({
28376                    let res = CStr::from_bytes_with_nul(next).ok();
28377                    let Some(val) = res else { break };
28378                    val
28379                }),
28380                21u16 => OpGetlinkDoReply::NumVf({
28381                    let res = parse_u32(next);
28382                    let Some(val) = res else { break };
28383                    val
28384                }),
28385                22u16 => OpGetlinkDoReply::VfinfoList({
28386                    let res = Some(IterableVfinfoListAttrs::with_loc(next, self.orig_loc));
28387                    let Some(val) = res else { break };
28388                    val
28389                }),
28390                23u16 => OpGetlinkDoReply::Stats64({
28391                    let res = Some(PushRtnlLinkStats64::new_from_zeroed(next));
28392                    let Some(val) = res else { break };
28393                    val
28394                }),
28395                24u16 => OpGetlinkDoReply::VfPorts({
28396                    let res = Some(IterableVfPortsAttrs::with_loc(next, self.orig_loc));
28397                    let Some(val) = res else { break };
28398                    val
28399                }),
28400                25u16 => OpGetlinkDoReply::PortSelf({
28401                    let res = Some(IterablePortSelfAttrs::with_loc(next, self.orig_loc));
28402                    let Some(val) = res else { break };
28403                    val
28404                }),
28405                26u16 => OpGetlinkDoReply::AfSpec({
28406                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
28407                    let Some(val) = res else { break };
28408                    val
28409                }),
28410                27u16 => OpGetlinkDoReply::Group({
28411                    let res = parse_u32(next);
28412                    let Some(val) = res else { break };
28413                    val
28414                }),
28415                28u16 => OpGetlinkDoReply::NetNsFd({
28416                    let res = parse_u32(next);
28417                    let Some(val) = res else { break };
28418                    val
28419                }),
28420                29u16 => OpGetlinkDoReply::ExtMask({
28421                    let res = parse_u32(next);
28422                    let Some(val) = res else { break };
28423                    val
28424                }),
28425                30u16 => OpGetlinkDoReply::Promiscuity({
28426                    let res = parse_u32(next);
28427                    let Some(val) = res else { break };
28428                    val
28429                }),
28430                31u16 => OpGetlinkDoReply::NumTxQueues({
28431                    let res = parse_u32(next);
28432                    let Some(val) = res else { break };
28433                    val
28434                }),
28435                32u16 => OpGetlinkDoReply::NumRxQueues({
28436                    let res = parse_u32(next);
28437                    let Some(val) = res else { break };
28438                    val
28439                }),
28440                33u16 => OpGetlinkDoReply::Carrier({
28441                    let res = parse_u8(next);
28442                    let Some(val) = res else { break };
28443                    val
28444                }),
28445                34u16 => OpGetlinkDoReply::PhysPortId({
28446                    let res = Some(next);
28447                    let Some(val) = res else { break };
28448                    val
28449                }),
28450                35u16 => OpGetlinkDoReply::CarrierChanges({
28451                    let res = parse_u32(next);
28452                    let Some(val) = res else { break };
28453                    val
28454                }),
28455                36u16 => OpGetlinkDoReply::PhysSwitchId({
28456                    let res = Some(next);
28457                    let Some(val) = res else { break };
28458                    val
28459                }),
28460                37u16 => OpGetlinkDoReply::LinkNetnsid({
28461                    let res = parse_i32(next);
28462                    let Some(val) = res else { break };
28463                    val
28464                }),
28465                38u16 => OpGetlinkDoReply::PhysPortName({
28466                    let res = CStr::from_bytes_with_nul(next).ok();
28467                    let Some(val) = res else { break };
28468                    val
28469                }),
28470                39u16 => OpGetlinkDoReply::ProtoDown({
28471                    let res = parse_u8(next);
28472                    let Some(val) = res else { break };
28473                    val
28474                }),
28475                40u16 => OpGetlinkDoReply::GsoMaxSegs({
28476                    let res = parse_u32(next);
28477                    let Some(val) = res else { break };
28478                    val
28479                }),
28480                41u16 => OpGetlinkDoReply::GsoMaxSize({
28481                    let res = parse_u32(next);
28482                    let Some(val) = res else { break };
28483                    val
28484                }),
28485                42u16 => OpGetlinkDoReply::Pad({
28486                    let res = Some(next);
28487                    let Some(val) = res else { break };
28488                    val
28489                }),
28490                43u16 => OpGetlinkDoReply::Xdp({
28491                    let res = Some(IterableXdpAttrs::with_loc(next, self.orig_loc));
28492                    let Some(val) = res else { break };
28493                    val
28494                }),
28495                44u16 => OpGetlinkDoReply::Event({
28496                    let res = parse_u32(next);
28497                    let Some(val) = res else { break };
28498                    val
28499                }),
28500                45u16 => OpGetlinkDoReply::NewNetnsid({
28501                    let res = parse_i32(next);
28502                    let Some(val) = res else { break };
28503                    val
28504                }),
28505                46u16 => OpGetlinkDoReply::TargetNetnsid({
28506                    let res = parse_i32(next);
28507                    let Some(val) = res else { break };
28508                    val
28509                }),
28510                47u16 => OpGetlinkDoReply::CarrierUpCount({
28511                    let res = parse_u32(next);
28512                    let Some(val) = res else { break };
28513                    val
28514                }),
28515                48u16 => OpGetlinkDoReply::CarrierDownCount({
28516                    let res = parse_u32(next);
28517                    let Some(val) = res else { break };
28518                    val
28519                }),
28520                49u16 => OpGetlinkDoReply::NewIfindex({
28521                    let res = parse_i32(next);
28522                    let Some(val) = res else { break };
28523                    val
28524                }),
28525                50u16 => OpGetlinkDoReply::MinMtu({
28526                    let res = parse_u32(next);
28527                    let Some(val) = res else { break };
28528                    val
28529                }),
28530                51u16 => OpGetlinkDoReply::MaxMtu({
28531                    let res = parse_u32(next);
28532                    let Some(val) = res else { break };
28533                    val
28534                }),
28535                52u16 => OpGetlinkDoReply::PropList({
28536                    let res = Some(IterablePropListLinkAttrs::with_loc(next, self.orig_loc));
28537                    let Some(val) = res else { break };
28538                    val
28539                }),
28540                54u16 => OpGetlinkDoReply::PermAddress({
28541                    let res = Some(next);
28542                    let Some(val) = res else { break };
28543                    val
28544                }),
28545                55u16 => OpGetlinkDoReply::ProtoDownReason({
28546                    let res = CStr::from_bytes_with_nul(next).ok();
28547                    let Some(val) = res else { break };
28548                    val
28549                }),
28550                56u16 => OpGetlinkDoReply::ParentDevName({
28551                    let res = CStr::from_bytes_with_nul(next).ok();
28552                    let Some(val) = res else { break };
28553                    val
28554                }),
28555                57u16 => OpGetlinkDoReply::ParentDevBusName({
28556                    let res = CStr::from_bytes_with_nul(next).ok();
28557                    let Some(val) = res else { break };
28558                    val
28559                }),
28560                58u16 => OpGetlinkDoReply::GroMaxSize({
28561                    let res = parse_u32(next);
28562                    let Some(val) = res else { break };
28563                    val
28564                }),
28565                59u16 => OpGetlinkDoReply::TsoMaxSize({
28566                    let res = parse_u32(next);
28567                    let Some(val) = res else { break };
28568                    val
28569                }),
28570                60u16 => OpGetlinkDoReply::TsoMaxSegs({
28571                    let res = parse_u32(next);
28572                    let Some(val) = res else { break };
28573                    val
28574                }),
28575                61u16 => OpGetlinkDoReply::Allmulti({
28576                    let res = parse_u32(next);
28577                    let Some(val) = res else { break };
28578                    val
28579                }),
28580                62u16 => OpGetlinkDoReply::DevlinkPort({
28581                    let res = Some(next);
28582                    let Some(val) = res else { break };
28583                    val
28584                }),
28585                63u16 => OpGetlinkDoReply::GsoIpv4MaxSize({
28586                    let res = parse_u32(next);
28587                    let Some(val) = res else { break };
28588                    val
28589                }),
28590                64u16 => OpGetlinkDoReply::GroIpv4MaxSize({
28591                    let res = parse_u32(next);
28592                    let Some(val) = res else { break };
28593                    val
28594                }),
28595                65u16 => OpGetlinkDoReply::DpllPin({
28596                    let res = Some(IterableLinkDpllPinAttrs::with_loc(next, self.orig_loc));
28597                    let Some(val) = res else { break };
28598                    val
28599                }),
28600                66u16 => OpGetlinkDoReply::MaxPacingOffloadHorizon({
28601                    let res = parse_u32(next);
28602                    let Some(val) = res else { break };
28603                    val
28604                }),
28605                67u16 => OpGetlinkDoReply::NetnsImmutable({
28606                    let res = parse_u8(next);
28607                    let Some(val) = res else { break };
28608                    val
28609                }),
28610                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
28611                n => continue,
28612            };
28613            return Some(Ok(res));
28614        }
28615        Some(Err(ErrorContext::new(
28616            "OpGetlinkDoReply",
28617            r#type.and_then(|t| OpGetlinkDoReply::attr_from_type(t)),
28618            self.orig_loc,
28619            self.buf.as_ptr().wrapping_add(pos) as usize,
28620        )))
28621    }
28622}
28623impl<'a> std::fmt::Debug for IterableOpGetlinkDoReply<'_> {
28624    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28625        let mut fmt = f.debug_struct("OpGetlinkDoReply");
28626        for attr in self.clone() {
28627            let attr = match attr {
28628                Ok(a) => a,
28629                Err(err) => {
28630                    fmt.finish()?;
28631                    f.write_str("Err(")?;
28632                    err.fmt(f)?;
28633                    return f.write_str(")");
28634                }
28635            };
28636            match attr {
28637                OpGetlinkDoReply::Address(val) => fmt.field("Address", &val),
28638                OpGetlinkDoReply::Broadcast(val) => fmt.field("Broadcast", &val),
28639                OpGetlinkDoReply::Ifname(val) => fmt.field("Ifname", &val),
28640                OpGetlinkDoReply::Mtu(val) => fmt.field("Mtu", &val),
28641                OpGetlinkDoReply::Link(val) => fmt.field("Link", &val),
28642                OpGetlinkDoReply::Qdisc(val) => fmt.field("Qdisc", &val),
28643                OpGetlinkDoReply::Stats(val) => fmt.field("Stats", &val),
28644                OpGetlinkDoReply::Cost(val) => fmt.field("Cost", &val),
28645                OpGetlinkDoReply::Priority(val) => fmt.field("Priority", &val),
28646                OpGetlinkDoReply::Master(val) => fmt.field("Master", &val),
28647                OpGetlinkDoReply::Wireless(val) => fmt.field("Wireless", &val),
28648                OpGetlinkDoReply::Protinfo(val) => fmt.field("Protinfo", &val),
28649                OpGetlinkDoReply::Txqlen(val) => fmt.field("Txqlen", &val),
28650                OpGetlinkDoReply::Map(val) => fmt.field("Map", &val),
28651                OpGetlinkDoReply::Weight(val) => fmt.field("Weight", &val),
28652                OpGetlinkDoReply::Operstate(val) => fmt.field("Operstate", &val),
28653                OpGetlinkDoReply::Linkmode(val) => fmt.field("Linkmode", &val),
28654                OpGetlinkDoReply::Linkinfo(val) => fmt.field("Linkinfo", &val),
28655                OpGetlinkDoReply::NetNsPid(val) => fmt.field("NetNsPid", &val),
28656                OpGetlinkDoReply::Ifalias(val) => fmt.field("Ifalias", &val),
28657                OpGetlinkDoReply::NumVf(val) => fmt.field("NumVf", &val),
28658                OpGetlinkDoReply::VfinfoList(val) => fmt.field("VfinfoList", &val),
28659                OpGetlinkDoReply::Stats64(val) => fmt.field("Stats64", &val),
28660                OpGetlinkDoReply::VfPorts(val) => fmt.field("VfPorts", &val),
28661                OpGetlinkDoReply::PortSelf(val) => fmt.field("PortSelf", &val),
28662                OpGetlinkDoReply::AfSpec(val) => fmt.field("AfSpec", &val),
28663                OpGetlinkDoReply::Group(val) => fmt.field("Group", &val),
28664                OpGetlinkDoReply::NetNsFd(val) => fmt.field("NetNsFd", &val),
28665                OpGetlinkDoReply::ExtMask(val) => {
28666                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
28667                }
28668                OpGetlinkDoReply::Promiscuity(val) => fmt.field("Promiscuity", &val),
28669                OpGetlinkDoReply::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
28670                OpGetlinkDoReply::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
28671                OpGetlinkDoReply::Carrier(val) => fmt.field("Carrier", &val),
28672                OpGetlinkDoReply::PhysPortId(val) => fmt.field("PhysPortId", &val),
28673                OpGetlinkDoReply::CarrierChanges(val) => fmt.field("CarrierChanges", &val),
28674                OpGetlinkDoReply::PhysSwitchId(val) => fmt.field("PhysSwitchId", &val),
28675                OpGetlinkDoReply::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
28676                OpGetlinkDoReply::PhysPortName(val) => fmt.field("PhysPortName", &val),
28677                OpGetlinkDoReply::ProtoDown(val) => fmt.field("ProtoDown", &val),
28678                OpGetlinkDoReply::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
28679                OpGetlinkDoReply::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
28680                OpGetlinkDoReply::Pad(val) => fmt.field("Pad", &val),
28681                OpGetlinkDoReply::Xdp(val) => fmt.field("Xdp", &val),
28682                OpGetlinkDoReply::Event(val) => fmt.field("Event", &val),
28683                OpGetlinkDoReply::NewNetnsid(val) => fmt.field("NewNetnsid", &val),
28684                OpGetlinkDoReply::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
28685                OpGetlinkDoReply::CarrierUpCount(val) => fmt.field("CarrierUpCount", &val),
28686                OpGetlinkDoReply::CarrierDownCount(val) => fmt.field("CarrierDownCount", &val),
28687                OpGetlinkDoReply::NewIfindex(val) => fmt.field("NewIfindex", &val),
28688                OpGetlinkDoReply::MinMtu(val) => fmt.field("MinMtu", &val),
28689                OpGetlinkDoReply::MaxMtu(val) => fmt.field("MaxMtu", &val),
28690                OpGetlinkDoReply::PropList(val) => fmt.field("PropList", &val),
28691                OpGetlinkDoReply::PermAddress(val) => fmt.field("PermAddress", &val),
28692                OpGetlinkDoReply::ProtoDownReason(val) => fmt.field("ProtoDownReason", &val),
28693                OpGetlinkDoReply::ParentDevName(val) => fmt.field("ParentDevName", &val),
28694                OpGetlinkDoReply::ParentDevBusName(val) => fmt.field("ParentDevBusName", &val),
28695                OpGetlinkDoReply::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
28696                OpGetlinkDoReply::TsoMaxSize(val) => fmt.field("TsoMaxSize", &val),
28697                OpGetlinkDoReply::TsoMaxSegs(val) => fmt.field("TsoMaxSegs", &val),
28698                OpGetlinkDoReply::Allmulti(val) => fmt.field("Allmulti", &val),
28699                OpGetlinkDoReply::DevlinkPort(val) => fmt.field("DevlinkPort", &val),
28700                OpGetlinkDoReply::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
28701                OpGetlinkDoReply::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
28702                OpGetlinkDoReply::DpllPin(val) => fmt.field("DpllPin", &val),
28703                OpGetlinkDoReply::MaxPacingOffloadHorizon(val) => {
28704                    fmt.field("MaxPacingOffloadHorizon", &val)
28705                }
28706                OpGetlinkDoReply::NetnsImmutable(val) => fmt.field("NetnsImmutable", &val),
28707            };
28708        }
28709        fmt.finish()
28710    }
28711}
28712impl IterableOpGetlinkDoReply<'_> {
28713    pub fn lookup_attr(
28714        &self,
28715        offset: usize,
28716        missing_type: Option<u16>,
28717    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
28718        let mut stack = Vec::new();
28719        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
28720        if cur == offset + PushIfinfomsg::len() {
28721            stack.push(("OpGetlinkDoReply", offset));
28722            return (
28723                stack,
28724                missing_type.and_then(|t| OpGetlinkDoReply::attr_from_type(t)),
28725            );
28726        }
28727        if cur > offset || cur + self.buf.len() < offset {
28728            return (stack, None);
28729        }
28730        let mut attrs = self.clone();
28731        let mut last_off = cur + attrs.pos;
28732        let mut missing = None;
28733        while let Some(attr) = attrs.next() {
28734            let Ok(attr) = attr else { break };
28735            match attr {
28736                OpGetlinkDoReply::Address(val) => {
28737                    if last_off == offset {
28738                        stack.push(("Address", last_off));
28739                        break;
28740                    }
28741                }
28742                OpGetlinkDoReply::Broadcast(val) => {
28743                    if last_off == offset {
28744                        stack.push(("Broadcast", last_off));
28745                        break;
28746                    }
28747                }
28748                OpGetlinkDoReply::Ifname(val) => {
28749                    if last_off == offset {
28750                        stack.push(("Ifname", last_off));
28751                        break;
28752                    }
28753                }
28754                OpGetlinkDoReply::Mtu(val) => {
28755                    if last_off == offset {
28756                        stack.push(("Mtu", last_off));
28757                        break;
28758                    }
28759                }
28760                OpGetlinkDoReply::Link(val) => {
28761                    if last_off == offset {
28762                        stack.push(("Link", last_off));
28763                        break;
28764                    }
28765                }
28766                OpGetlinkDoReply::Qdisc(val) => {
28767                    if last_off == offset {
28768                        stack.push(("Qdisc", last_off));
28769                        break;
28770                    }
28771                }
28772                OpGetlinkDoReply::Stats(val) => {
28773                    if last_off == offset {
28774                        stack.push(("Stats", last_off));
28775                        break;
28776                    }
28777                }
28778                OpGetlinkDoReply::Cost(val) => {
28779                    if last_off == offset {
28780                        stack.push(("Cost", last_off));
28781                        break;
28782                    }
28783                }
28784                OpGetlinkDoReply::Priority(val) => {
28785                    if last_off == offset {
28786                        stack.push(("Priority", last_off));
28787                        break;
28788                    }
28789                }
28790                OpGetlinkDoReply::Master(val) => {
28791                    if last_off == offset {
28792                        stack.push(("Master", last_off));
28793                        break;
28794                    }
28795                }
28796                OpGetlinkDoReply::Wireless(val) => {
28797                    if last_off == offset {
28798                        stack.push(("Wireless", last_off));
28799                        break;
28800                    }
28801                }
28802                OpGetlinkDoReply::Protinfo(val) => {
28803                    if last_off == offset {
28804                        stack.push(("Protinfo", last_off));
28805                        break;
28806                    }
28807                }
28808                OpGetlinkDoReply::Txqlen(val) => {
28809                    if last_off == offset {
28810                        stack.push(("Txqlen", last_off));
28811                        break;
28812                    }
28813                }
28814                OpGetlinkDoReply::Map(val) => {
28815                    if last_off == offset {
28816                        stack.push(("Map", last_off));
28817                        break;
28818                    }
28819                }
28820                OpGetlinkDoReply::Weight(val) => {
28821                    if last_off == offset {
28822                        stack.push(("Weight", last_off));
28823                        break;
28824                    }
28825                }
28826                OpGetlinkDoReply::Operstate(val) => {
28827                    if last_off == offset {
28828                        stack.push(("Operstate", last_off));
28829                        break;
28830                    }
28831                }
28832                OpGetlinkDoReply::Linkmode(val) => {
28833                    if last_off == offset {
28834                        stack.push(("Linkmode", last_off));
28835                        break;
28836                    }
28837                }
28838                OpGetlinkDoReply::Linkinfo(val) => {
28839                    (stack, missing) = val.lookup_attr(offset, missing_type);
28840                    if !stack.is_empty() {
28841                        break;
28842                    }
28843                }
28844                OpGetlinkDoReply::NetNsPid(val) => {
28845                    if last_off == offset {
28846                        stack.push(("NetNsPid", last_off));
28847                        break;
28848                    }
28849                }
28850                OpGetlinkDoReply::Ifalias(val) => {
28851                    if last_off == offset {
28852                        stack.push(("Ifalias", last_off));
28853                        break;
28854                    }
28855                }
28856                OpGetlinkDoReply::NumVf(val) => {
28857                    if last_off == offset {
28858                        stack.push(("NumVf", last_off));
28859                        break;
28860                    }
28861                }
28862                OpGetlinkDoReply::VfinfoList(val) => {
28863                    (stack, missing) = val.lookup_attr(offset, missing_type);
28864                    if !stack.is_empty() {
28865                        break;
28866                    }
28867                }
28868                OpGetlinkDoReply::Stats64(val) => {
28869                    if last_off == offset {
28870                        stack.push(("Stats64", last_off));
28871                        break;
28872                    }
28873                }
28874                OpGetlinkDoReply::VfPorts(val) => {
28875                    (stack, missing) = val.lookup_attr(offset, missing_type);
28876                    if !stack.is_empty() {
28877                        break;
28878                    }
28879                }
28880                OpGetlinkDoReply::PortSelf(val) => {
28881                    (stack, missing) = val.lookup_attr(offset, missing_type);
28882                    if !stack.is_empty() {
28883                        break;
28884                    }
28885                }
28886                OpGetlinkDoReply::AfSpec(val) => {
28887                    (stack, missing) = val.lookup_attr(offset, missing_type);
28888                    if !stack.is_empty() {
28889                        break;
28890                    }
28891                }
28892                OpGetlinkDoReply::Group(val) => {
28893                    if last_off == offset {
28894                        stack.push(("Group", last_off));
28895                        break;
28896                    }
28897                }
28898                OpGetlinkDoReply::NetNsFd(val) => {
28899                    if last_off == offset {
28900                        stack.push(("NetNsFd", last_off));
28901                        break;
28902                    }
28903                }
28904                OpGetlinkDoReply::ExtMask(val) => {
28905                    if last_off == offset {
28906                        stack.push(("ExtMask", last_off));
28907                        break;
28908                    }
28909                }
28910                OpGetlinkDoReply::Promiscuity(val) => {
28911                    if last_off == offset {
28912                        stack.push(("Promiscuity", last_off));
28913                        break;
28914                    }
28915                }
28916                OpGetlinkDoReply::NumTxQueues(val) => {
28917                    if last_off == offset {
28918                        stack.push(("NumTxQueues", last_off));
28919                        break;
28920                    }
28921                }
28922                OpGetlinkDoReply::NumRxQueues(val) => {
28923                    if last_off == offset {
28924                        stack.push(("NumRxQueues", last_off));
28925                        break;
28926                    }
28927                }
28928                OpGetlinkDoReply::Carrier(val) => {
28929                    if last_off == offset {
28930                        stack.push(("Carrier", last_off));
28931                        break;
28932                    }
28933                }
28934                OpGetlinkDoReply::PhysPortId(val) => {
28935                    if last_off == offset {
28936                        stack.push(("PhysPortId", last_off));
28937                        break;
28938                    }
28939                }
28940                OpGetlinkDoReply::CarrierChanges(val) => {
28941                    if last_off == offset {
28942                        stack.push(("CarrierChanges", last_off));
28943                        break;
28944                    }
28945                }
28946                OpGetlinkDoReply::PhysSwitchId(val) => {
28947                    if last_off == offset {
28948                        stack.push(("PhysSwitchId", last_off));
28949                        break;
28950                    }
28951                }
28952                OpGetlinkDoReply::LinkNetnsid(val) => {
28953                    if last_off == offset {
28954                        stack.push(("LinkNetnsid", last_off));
28955                        break;
28956                    }
28957                }
28958                OpGetlinkDoReply::PhysPortName(val) => {
28959                    if last_off == offset {
28960                        stack.push(("PhysPortName", last_off));
28961                        break;
28962                    }
28963                }
28964                OpGetlinkDoReply::ProtoDown(val) => {
28965                    if last_off == offset {
28966                        stack.push(("ProtoDown", last_off));
28967                        break;
28968                    }
28969                }
28970                OpGetlinkDoReply::GsoMaxSegs(val) => {
28971                    if last_off == offset {
28972                        stack.push(("GsoMaxSegs", last_off));
28973                        break;
28974                    }
28975                }
28976                OpGetlinkDoReply::GsoMaxSize(val) => {
28977                    if last_off == offset {
28978                        stack.push(("GsoMaxSize", last_off));
28979                        break;
28980                    }
28981                }
28982                OpGetlinkDoReply::Pad(val) => {
28983                    if last_off == offset {
28984                        stack.push(("Pad", last_off));
28985                        break;
28986                    }
28987                }
28988                OpGetlinkDoReply::Xdp(val) => {
28989                    (stack, missing) = val.lookup_attr(offset, missing_type);
28990                    if !stack.is_empty() {
28991                        break;
28992                    }
28993                }
28994                OpGetlinkDoReply::Event(val) => {
28995                    if last_off == offset {
28996                        stack.push(("Event", last_off));
28997                        break;
28998                    }
28999                }
29000                OpGetlinkDoReply::NewNetnsid(val) => {
29001                    if last_off == offset {
29002                        stack.push(("NewNetnsid", last_off));
29003                        break;
29004                    }
29005                }
29006                OpGetlinkDoReply::TargetNetnsid(val) => {
29007                    if last_off == offset {
29008                        stack.push(("TargetNetnsid", last_off));
29009                        break;
29010                    }
29011                }
29012                OpGetlinkDoReply::CarrierUpCount(val) => {
29013                    if last_off == offset {
29014                        stack.push(("CarrierUpCount", last_off));
29015                        break;
29016                    }
29017                }
29018                OpGetlinkDoReply::CarrierDownCount(val) => {
29019                    if last_off == offset {
29020                        stack.push(("CarrierDownCount", last_off));
29021                        break;
29022                    }
29023                }
29024                OpGetlinkDoReply::NewIfindex(val) => {
29025                    if last_off == offset {
29026                        stack.push(("NewIfindex", last_off));
29027                        break;
29028                    }
29029                }
29030                OpGetlinkDoReply::MinMtu(val) => {
29031                    if last_off == offset {
29032                        stack.push(("MinMtu", last_off));
29033                        break;
29034                    }
29035                }
29036                OpGetlinkDoReply::MaxMtu(val) => {
29037                    if last_off == offset {
29038                        stack.push(("MaxMtu", last_off));
29039                        break;
29040                    }
29041                }
29042                OpGetlinkDoReply::PropList(val) => {
29043                    (stack, missing) = val.lookup_attr(offset, missing_type);
29044                    if !stack.is_empty() {
29045                        break;
29046                    }
29047                }
29048                OpGetlinkDoReply::PermAddress(val) => {
29049                    if last_off == offset {
29050                        stack.push(("PermAddress", last_off));
29051                        break;
29052                    }
29053                }
29054                OpGetlinkDoReply::ProtoDownReason(val) => {
29055                    if last_off == offset {
29056                        stack.push(("ProtoDownReason", last_off));
29057                        break;
29058                    }
29059                }
29060                OpGetlinkDoReply::ParentDevName(val) => {
29061                    if last_off == offset {
29062                        stack.push(("ParentDevName", last_off));
29063                        break;
29064                    }
29065                }
29066                OpGetlinkDoReply::ParentDevBusName(val) => {
29067                    if last_off == offset {
29068                        stack.push(("ParentDevBusName", last_off));
29069                        break;
29070                    }
29071                }
29072                OpGetlinkDoReply::GroMaxSize(val) => {
29073                    if last_off == offset {
29074                        stack.push(("GroMaxSize", last_off));
29075                        break;
29076                    }
29077                }
29078                OpGetlinkDoReply::TsoMaxSize(val) => {
29079                    if last_off == offset {
29080                        stack.push(("TsoMaxSize", last_off));
29081                        break;
29082                    }
29083                }
29084                OpGetlinkDoReply::TsoMaxSegs(val) => {
29085                    if last_off == offset {
29086                        stack.push(("TsoMaxSegs", last_off));
29087                        break;
29088                    }
29089                }
29090                OpGetlinkDoReply::Allmulti(val) => {
29091                    if last_off == offset {
29092                        stack.push(("Allmulti", last_off));
29093                        break;
29094                    }
29095                }
29096                OpGetlinkDoReply::DevlinkPort(val) => {
29097                    if last_off == offset {
29098                        stack.push(("DevlinkPort", last_off));
29099                        break;
29100                    }
29101                }
29102                OpGetlinkDoReply::GsoIpv4MaxSize(val) => {
29103                    if last_off == offset {
29104                        stack.push(("GsoIpv4MaxSize", last_off));
29105                        break;
29106                    }
29107                }
29108                OpGetlinkDoReply::GroIpv4MaxSize(val) => {
29109                    if last_off == offset {
29110                        stack.push(("GroIpv4MaxSize", last_off));
29111                        break;
29112                    }
29113                }
29114                OpGetlinkDoReply::DpllPin(val) => {
29115                    (stack, missing) = val.lookup_attr(offset, missing_type);
29116                    if !stack.is_empty() {
29117                        break;
29118                    }
29119                }
29120                OpGetlinkDoReply::MaxPacingOffloadHorizon(val) => {
29121                    if last_off == offset {
29122                        stack.push(("MaxPacingOffloadHorizon", last_off));
29123                        break;
29124                    }
29125                }
29126                OpGetlinkDoReply::NetnsImmutable(val) => {
29127                    if last_off == offset {
29128                        stack.push(("NetnsImmutable", last_off));
29129                        break;
29130                    }
29131                }
29132                _ => {}
29133            };
29134            last_off = cur + attrs.pos;
29135        }
29136        if !stack.is_empty() {
29137            stack.push(("OpGetlinkDoReply", cur));
29138        }
29139        (stack, missing)
29140    }
29141}
29142#[derive(Debug)]
29143pub struct RequestOpGetlinkDoRequest<'r> {
29144    request: Request<'r>,
29145}
29146impl<'r> RequestOpGetlinkDoRequest<'r> {
29147    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
29148        PushOpGetlinkDoRequest::write_header(&mut request.buf_mut(), header);
29149        Self { request: request }
29150    }
29151    pub fn encode(&mut self) -> PushOpGetlinkDoRequest<&mut Vec<u8>> {
29152        PushOpGetlinkDoRequest::new_without_header(self.request.buf_mut())
29153    }
29154    pub fn into_encoder(self) -> PushOpGetlinkDoRequest<RequestBuf<'r>> {
29155        PushOpGetlinkDoRequest::new_without_header(self.request.buf)
29156    }
29157    pub fn decode_request<'buf>(
29158        buf: &'buf [u8],
29159    ) -> (PushIfinfomsg, IterableOpGetlinkDoRequest<'buf>) {
29160        OpGetlinkDoRequest::new(buf)
29161    }
29162}
29163impl NetlinkRequest for RequestOpGetlinkDoRequest<'_> {
29164    fn protocol(&self) -> Protocol {
29165        Protocol::Raw {
29166            protonum: 0u16,
29167            request_type: 18u16,
29168        }
29169    }
29170    fn flags(&self) -> u16 {
29171        self.request.flags
29172    }
29173    fn payload(&self) -> &[u8] {
29174        self.request.buf()
29175    }
29176    type ReplyType<'buf> = (PushIfinfomsg, IterableOpGetlinkDoReply<'buf>);
29177    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
29178        OpGetlinkDoReply::new(buf)
29179    }
29180    fn lookup(
29181        buf: &[u8],
29182        offset: usize,
29183        missing_type: Option<u16>,
29184    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
29185        OpGetlinkDoRequest::new(buf)
29186            .1
29187            .lookup_attr(offset, missing_type)
29188    }
29189}
29190#[doc = "Set information about a link."]
29191pub struct PushOpSetlinkDoRequest<Prev: Rec> {
29192    pub(crate) prev: Option<Prev>,
29193    pub(crate) header_offset: Option<usize>,
29194}
29195impl<Prev: Rec> Rec for PushOpSetlinkDoRequest<Prev> {
29196    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
29197        self.prev.as_mut().unwrap().as_rec_mut()
29198    }
29199    fn as_rec(&self) -> &Vec<u8> {
29200        self.prev.as_ref().unwrap().as_rec()
29201    }
29202}
29203impl<Prev: Rec> PushOpSetlinkDoRequest<Prev> {
29204    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
29205        Self::write_header(&mut prev, header);
29206        Self::new_without_header(prev)
29207    }
29208    fn new_without_header(prev: Prev) -> Self {
29209        Self {
29210            prev: Some(prev),
29211            header_offset: None,
29212        }
29213    }
29214    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
29215        prev.as_rec_mut().extend(header.as_slice());
29216    }
29217    pub fn end_nested(mut self) -> Prev {
29218        let mut prev = self.prev.take().unwrap();
29219        if let Some(header_offset) = &self.header_offset {
29220            finalize_nested_header(prev.as_rec_mut(), *header_offset);
29221        }
29222        prev
29223    }
29224    pub fn push_address(mut self, value: &[u8]) -> Self {
29225        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
29226        self.as_rec_mut().extend(value);
29227        self
29228    }
29229    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
29230        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
29231        self.as_rec_mut().extend(value);
29232        self
29233    }
29234    pub fn push_ifname(mut self, value: &CStr) -> Self {
29235        push_header(
29236            self.as_rec_mut(),
29237            3u16,
29238            value.to_bytes_with_nul().len() as u16,
29239        );
29240        self.as_rec_mut().extend(value.to_bytes_with_nul());
29241        self
29242    }
29243    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
29244        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
29245        self.as_rec_mut().extend(value);
29246        self.as_rec_mut().push(0);
29247        self
29248    }
29249    pub fn push_mtu(mut self, value: u32) -> Self {
29250        push_header(self.as_rec_mut(), 4u16, 4 as u16);
29251        self.as_rec_mut().extend(value.to_ne_bytes());
29252        self
29253    }
29254    pub fn push_link(mut self, value: u32) -> Self {
29255        push_header(self.as_rec_mut(), 5u16, 4 as u16);
29256        self.as_rec_mut().extend(value.to_ne_bytes());
29257        self
29258    }
29259    pub fn push_qdisc(mut self, value: &CStr) -> Self {
29260        push_header(
29261            self.as_rec_mut(),
29262            6u16,
29263            value.to_bytes_with_nul().len() as u16,
29264        );
29265        self.as_rec_mut().extend(value.to_bytes_with_nul());
29266        self
29267    }
29268    pub fn push_qdisc_bytes(mut self, value: &[u8]) -> Self {
29269        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
29270        self.as_rec_mut().extend(value);
29271        self.as_rec_mut().push(0);
29272        self
29273    }
29274    pub fn push_stats(mut self, value: PushRtnlLinkStats) -> Self {
29275        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
29276        self.as_rec_mut().extend(value.as_slice());
29277        self
29278    }
29279    pub fn push_cost(mut self, value: &CStr) -> Self {
29280        push_header(
29281            self.as_rec_mut(),
29282            8u16,
29283            value.to_bytes_with_nul().len() as u16,
29284        );
29285        self.as_rec_mut().extend(value.to_bytes_with_nul());
29286        self
29287    }
29288    pub fn push_cost_bytes(mut self, value: &[u8]) -> Self {
29289        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
29290        self.as_rec_mut().extend(value);
29291        self.as_rec_mut().push(0);
29292        self
29293    }
29294    pub fn push_priority(mut self, value: &CStr) -> Self {
29295        push_header(
29296            self.as_rec_mut(),
29297            9u16,
29298            value.to_bytes_with_nul().len() as u16,
29299        );
29300        self.as_rec_mut().extend(value.to_bytes_with_nul());
29301        self
29302    }
29303    pub fn push_priority_bytes(mut self, value: &[u8]) -> Self {
29304        push_header(self.as_rec_mut(), 9u16, (value.len() + 1) as u16);
29305        self.as_rec_mut().extend(value);
29306        self.as_rec_mut().push(0);
29307        self
29308    }
29309    pub fn push_master(mut self, value: u32) -> Self {
29310        push_header(self.as_rec_mut(), 10u16, 4 as u16);
29311        self.as_rec_mut().extend(value.to_ne_bytes());
29312        self
29313    }
29314    pub fn push_wireless(mut self, value: &CStr) -> Self {
29315        push_header(
29316            self.as_rec_mut(),
29317            11u16,
29318            value.to_bytes_with_nul().len() as u16,
29319        );
29320        self.as_rec_mut().extend(value.to_bytes_with_nul());
29321        self
29322    }
29323    pub fn push_wireless_bytes(mut self, value: &[u8]) -> Self {
29324        push_header(self.as_rec_mut(), 11u16, (value.len() + 1) as u16);
29325        self.as_rec_mut().extend(value);
29326        self.as_rec_mut().push(0);
29327        self
29328    }
29329    pub fn push_protinfo(mut self, value: &CStr) -> Self {
29330        push_header(
29331            self.as_rec_mut(),
29332            12u16,
29333            value.to_bytes_with_nul().len() as u16,
29334        );
29335        self.as_rec_mut().extend(value.to_bytes_with_nul());
29336        self
29337    }
29338    pub fn push_protinfo_bytes(mut self, value: &[u8]) -> Self {
29339        push_header(self.as_rec_mut(), 12u16, (value.len() + 1) as u16);
29340        self.as_rec_mut().extend(value);
29341        self.as_rec_mut().push(0);
29342        self
29343    }
29344    pub fn push_txqlen(mut self, value: u32) -> Self {
29345        push_header(self.as_rec_mut(), 13u16, 4 as u16);
29346        self.as_rec_mut().extend(value.to_ne_bytes());
29347        self
29348    }
29349    pub fn push_map(mut self, value: PushRtnlLinkIfmap) -> Self {
29350        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
29351        self.as_rec_mut().extend(value.as_slice());
29352        self
29353    }
29354    pub fn push_weight(mut self, value: u32) -> Self {
29355        push_header(self.as_rec_mut(), 15u16, 4 as u16);
29356        self.as_rec_mut().extend(value.to_ne_bytes());
29357        self
29358    }
29359    pub fn push_operstate(mut self, value: u8) -> Self {
29360        push_header(self.as_rec_mut(), 16u16, 1 as u16);
29361        self.as_rec_mut().extend(value.to_ne_bytes());
29362        self
29363    }
29364    pub fn push_linkmode(mut self, value: u8) -> Self {
29365        push_header(self.as_rec_mut(), 17u16, 1 as u16);
29366        self.as_rec_mut().extend(value.to_ne_bytes());
29367        self
29368    }
29369    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
29370        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
29371        PushLinkinfoAttrs {
29372            prev: Some(self),
29373            header_offset: Some(header_offset),
29374        }
29375    }
29376    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
29377        push_header(self.as_rec_mut(), 19u16, 4 as u16);
29378        self.as_rec_mut().extend(value.to_ne_bytes());
29379        self
29380    }
29381    pub fn push_ifalias(mut self, value: &CStr) -> Self {
29382        push_header(
29383            self.as_rec_mut(),
29384            20u16,
29385            value.to_bytes_with_nul().len() as u16,
29386        );
29387        self.as_rec_mut().extend(value.to_bytes_with_nul());
29388        self
29389    }
29390    pub fn push_ifalias_bytes(mut self, value: &[u8]) -> Self {
29391        push_header(self.as_rec_mut(), 20u16, (value.len() + 1) as u16);
29392        self.as_rec_mut().extend(value);
29393        self.as_rec_mut().push(0);
29394        self
29395    }
29396    pub fn push_num_vf(mut self, value: u32) -> Self {
29397        push_header(self.as_rec_mut(), 21u16, 4 as u16);
29398        self.as_rec_mut().extend(value.to_ne_bytes());
29399        self
29400    }
29401    pub fn nested_vfinfo_list(mut self) -> PushVfinfoListAttrs<Self> {
29402        let header_offset = push_nested_header(self.as_rec_mut(), 22u16);
29403        PushVfinfoListAttrs {
29404            prev: Some(self),
29405            header_offset: Some(header_offset),
29406        }
29407    }
29408    pub fn push_stats64(mut self, value: PushRtnlLinkStats64) -> Self {
29409        push_header(self.as_rec_mut(), 23u16, value.as_slice().len() as u16);
29410        self.as_rec_mut().extend(value.as_slice());
29411        self
29412    }
29413    pub fn nested_vf_ports(mut self) -> PushVfPortsAttrs<Self> {
29414        let header_offset = push_nested_header(self.as_rec_mut(), 24u16);
29415        PushVfPortsAttrs {
29416            prev: Some(self),
29417            header_offset: Some(header_offset),
29418        }
29419    }
29420    pub fn nested_port_self(mut self) -> PushPortSelfAttrs<Self> {
29421        let header_offset = push_nested_header(self.as_rec_mut(), 25u16);
29422        PushPortSelfAttrs {
29423            prev: Some(self),
29424            header_offset: Some(header_offset),
29425        }
29426    }
29427    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
29428        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
29429        PushAfSpecAttrs {
29430            prev: Some(self),
29431            header_offset: Some(header_offset),
29432        }
29433    }
29434    pub fn push_group(mut self, value: u32) -> Self {
29435        push_header(self.as_rec_mut(), 27u16, 4 as u16);
29436        self.as_rec_mut().extend(value.to_ne_bytes());
29437        self
29438    }
29439    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
29440        push_header(self.as_rec_mut(), 28u16, 4 as u16);
29441        self.as_rec_mut().extend(value.to_ne_bytes());
29442        self
29443    }
29444    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
29445    pub fn push_ext_mask(mut self, value: u32) -> Self {
29446        push_header(self.as_rec_mut(), 29u16, 4 as u16);
29447        self.as_rec_mut().extend(value.to_ne_bytes());
29448        self
29449    }
29450    pub fn push_promiscuity(mut self, value: u32) -> Self {
29451        push_header(self.as_rec_mut(), 30u16, 4 as u16);
29452        self.as_rec_mut().extend(value.to_ne_bytes());
29453        self
29454    }
29455    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
29456        push_header(self.as_rec_mut(), 31u16, 4 as u16);
29457        self.as_rec_mut().extend(value.to_ne_bytes());
29458        self
29459    }
29460    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
29461        push_header(self.as_rec_mut(), 32u16, 4 as u16);
29462        self.as_rec_mut().extend(value.to_ne_bytes());
29463        self
29464    }
29465    pub fn push_carrier(mut self, value: u8) -> Self {
29466        push_header(self.as_rec_mut(), 33u16, 1 as u16);
29467        self.as_rec_mut().extend(value.to_ne_bytes());
29468        self
29469    }
29470    pub fn push_phys_port_id(mut self, value: &[u8]) -> Self {
29471        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
29472        self.as_rec_mut().extend(value);
29473        self
29474    }
29475    pub fn push_carrier_changes(mut self, value: u32) -> Self {
29476        push_header(self.as_rec_mut(), 35u16, 4 as u16);
29477        self.as_rec_mut().extend(value.to_ne_bytes());
29478        self
29479    }
29480    pub fn push_phys_switch_id(mut self, value: &[u8]) -> Self {
29481        push_header(self.as_rec_mut(), 36u16, value.len() as u16);
29482        self.as_rec_mut().extend(value);
29483        self
29484    }
29485    pub fn push_link_netnsid(mut self, value: i32) -> Self {
29486        push_header(self.as_rec_mut(), 37u16, 4 as u16);
29487        self.as_rec_mut().extend(value.to_ne_bytes());
29488        self
29489    }
29490    pub fn push_phys_port_name(mut self, value: &CStr) -> Self {
29491        push_header(
29492            self.as_rec_mut(),
29493            38u16,
29494            value.to_bytes_with_nul().len() as u16,
29495        );
29496        self.as_rec_mut().extend(value.to_bytes_with_nul());
29497        self
29498    }
29499    pub fn push_phys_port_name_bytes(mut self, value: &[u8]) -> Self {
29500        push_header(self.as_rec_mut(), 38u16, (value.len() + 1) as u16);
29501        self.as_rec_mut().extend(value);
29502        self.as_rec_mut().push(0);
29503        self
29504    }
29505    pub fn push_proto_down(mut self, value: u8) -> Self {
29506        push_header(self.as_rec_mut(), 39u16, 1 as u16);
29507        self.as_rec_mut().extend(value.to_ne_bytes());
29508        self
29509    }
29510    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
29511        push_header(self.as_rec_mut(), 40u16, 4 as u16);
29512        self.as_rec_mut().extend(value.to_ne_bytes());
29513        self
29514    }
29515    pub fn push_gso_max_size(mut self, value: u32) -> Self {
29516        push_header(self.as_rec_mut(), 41u16, 4 as u16);
29517        self.as_rec_mut().extend(value.to_ne_bytes());
29518        self
29519    }
29520    pub fn push_pad(mut self, value: &[u8]) -> Self {
29521        push_header(self.as_rec_mut(), 42u16, value.len() as u16);
29522        self.as_rec_mut().extend(value);
29523        self
29524    }
29525    pub fn nested_xdp(mut self) -> PushXdpAttrs<Self> {
29526        let header_offset = push_nested_header(self.as_rec_mut(), 43u16);
29527        PushXdpAttrs {
29528            prev: Some(self),
29529            header_offset: Some(header_offset),
29530        }
29531    }
29532    pub fn push_event(mut self, value: u32) -> Self {
29533        push_header(self.as_rec_mut(), 44u16, 4 as u16);
29534        self.as_rec_mut().extend(value.to_ne_bytes());
29535        self
29536    }
29537    pub fn push_new_netnsid(mut self, value: i32) -> Self {
29538        push_header(self.as_rec_mut(), 45u16, 4 as u16);
29539        self.as_rec_mut().extend(value.to_ne_bytes());
29540        self
29541    }
29542    pub fn push_target_netnsid(mut self, value: i32) -> Self {
29543        push_header(self.as_rec_mut(), 46u16, 4 as u16);
29544        self.as_rec_mut().extend(value.to_ne_bytes());
29545        self
29546    }
29547    pub fn push_carrier_up_count(mut self, value: u32) -> Self {
29548        push_header(self.as_rec_mut(), 47u16, 4 as u16);
29549        self.as_rec_mut().extend(value.to_ne_bytes());
29550        self
29551    }
29552    pub fn push_carrier_down_count(mut self, value: u32) -> Self {
29553        push_header(self.as_rec_mut(), 48u16, 4 as u16);
29554        self.as_rec_mut().extend(value.to_ne_bytes());
29555        self
29556    }
29557    pub fn push_new_ifindex(mut self, value: i32) -> Self {
29558        push_header(self.as_rec_mut(), 49u16, 4 as u16);
29559        self.as_rec_mut().extend(value.to_ne_bytes());
29560        self
29561    }
29562    pub fn push_min_mtu(mut self, value: u32) -> Self {
29563        push_header(self.as_rec_mut(), 50u16, 4 as u16);
29564        self.as_rec_mut().extend(value.to_ne_bytes());
29565        self
29566    }
29567    pub fn push_max_mtu(mut self, value: u32) -> Self {
29568        push_header(self.as_rec_mut(), 51u16, 4 as u16);
29569        self.as_rec_mut().extend(value.to_ne_bytes());
29570        self
29571    }
29572    pub fn nested_prop_list(mut self) -> PushPropListLinkAttrs<Self> {
29573        let header_offset = push_nested_header(self.as_rec_mut(), 52u16);
29574        PushPropListLinkAttrs {
29575            prev: Some(self),
29576            header_offset: Some(header_offset),
29577        }
29578    }
29579    pub fn push_perm_address(mut self, value: &[u8]) -> Self {
29580        push_header(self.as_rec_mut(), 54u16, value.len() as u16);
29581        self.as_rec_mut().extend(value);
29582        self
29583    }
29584    pub fn push_proto_down_reason(mut self, value: &CStr) -> Self {
29585        push_header(
29586            self.as_rec_mut(),
29587            55u16,
29588            value.to_bytes_with_nul().len() as u16,
29589        );
29590        self.as_rec_mut().extend(value.to_bytes_with_nul());
29591        self
29592    }
29593    pub fn push_proto_down_reason_bytes(mut self, value: &[u8]) -> Self {
29594        push_header(self.as_rec_mut(), 55u16, (value.len() + 1) as u16);
29595        self.as_rec_mut().extend(value);
29596        self.as_rec_mut().push(0);
29597        self
29598    }
29599    pub fn push_parent_dev_name(mut self, value: &CStr) -> Self {
29600        push_header(
29601            self.as_rec_mut(),
29602            56u16,
29603            value.to_bytes_with_nul().len() as u16,
29604        );
29605        self.as_rec_mut().extend(value.to_bytes_with_nul());
29606        self
29607    }
29608    pub fn push_parent_dev_name_bytes(mut self, value: &[u8]) -> Self {
29609        push_header(self.as_rec_mut(), 56u16, (value.len() + 1) as u16);
29610        self.as_rec_mut().extend(value);
29611        self.as_rec_mut().push(0);
29612        self
29613    }
29614    pub fn push_parent_dev_bus_name(mut self, value: &CStr) -> Self {
29615        push_header(
29616            self.as_rec_mut(),
29617            57u16,
29618            value.to_bytes_with_nul().len() as u16,
29619        );
29620        self.as_rec_mut().extend(value.to_bytes_with_nul());
29621        self
29622    }
29623    pub fn push_parent_dev_bus_name_bytes(mut self, value: &[u8]) -> Self {
29624        push_header(self.as_rec_mut(), 57u16, (value.len() + 1) as u16);
29625        self.as_rec_mut().extend(value);
29626        self.as_rec_mut().push(0);
29627        self
29628    }
29629    pub fn push_gro_max_size(mut self, value: u32) -> Self {
29630        push_header(self.as_rec_mut(), 58u16, 4 as u16);
29631        self.as_rec_mut().extend(value.to_ne_bytes());
29632        self
29633    }
29634    pub fn push_tso_max_size(mut self, value: u32) -> Self {
29635        push_header(self.as_rec_mut(), 59u16, 4 as u16);
29636        self.as_rec_mut().extend(value.to_ne_bytes());
29637        self
29638    }
29639    pub fn push_tso_max_segs(mut self, value: u32) -> Self {
29640        push_header(self.as_rec_mut(), 60u16, 4 as u16);
29641        self.as_rec_mut().extend(value.to_ne_bytes());
29642        self
29643    }
29644    pub fn push_allmulti(mut self, value: u32) -> Self {
29645        push_header(self.as_rec_mut(), 61u16, 4 as u16);
29646        self.as_rec_mut().extend(value.to_ne_bytes());
29647        self
29648    }
29649    pub fn push_devlink_port(mut self, value: &[u8]) -> Self {
29650        push_header(self.as_rec_mut(), 62u16, value.len() as u16);
29651        self.as_rec_mut().extend(value);
29652        self
29653    }
29654    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
29655        push_header(self.as_rec_mut(), 63u16, 4 as u16);
29656        self.as_rec_mut().extend(value.to_ne_bytes());
29657        self
29658    }
29659    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
29660        push_header(self.as_rec_mut(), 64u16, 4 as u16);
29661        self.as_rec_mut().extend(value.to_ne_bytes());
29662        self
29663    }
29664    pub fn nested_dpll_pin(mut self) -> PushLinkDpllPinAttrs<Self> {
29665        let header_offset = push_nested_header(self.as_rec_mut(), 65u16);
29666        PushLinkDpllPinAttrs {
29667            prev: Some(self),
29668            header_offset: Some(header_offset),
29669        }
29670    }
29671    #[doc = "EDT offload horizon supported by the device (in nsec)."]
29672    pub fn push_max_pacing_offload_horizon(mut self, value: u32) -> Self {
29673        push_header(self.as_rec_mut(), 66u16, 4 as u16);
29674        self.as_rec_mut().extend(value.to_ne_bytes());
29675        self
29676    }
29677    pub fn push_netns_immutable(mut self, value: u8) -> Self {
29678        push_header(self.as_rec_mut(), 67u16, 1 as u16);
29679        self.as_rec_mut().extend(value.to_ne_bytes());
29680        self
29681    }
29682}
29683impl<Prev: Rec> Drop for PushOpSetlinkDoRequest<Prev> {
29684    fn drop(&mut self) {
29685        if let Some(prev) = &mut self.prev {
29686            if let Some(header_offset) = &self.header_offset {
29687                finalize_nested_header(prev.as_rec_mut(), *header_offset);
29688            }
29689        }
29690    }
29691}
29692#[doc = "Set information about a link."]
29693#[derive(Clone)]
29694pub enum OpSetlinkDoRequest<'a> {
29695    Address(&'a [u8]),
29696    Broadcast(&'a [u8]),
29697    Ifname(&'a CStr),
29698    Mtu(u32),
29699    Link(u32),
29700    Qdisc(&'a CStr),
29701    Stats(PushRtnlLinkStats),
29702    Cost(&'a CStr),
29703    Priority(&'a CStr),
29704    Master(u32),
29705    Wireless(&'a CStr),
29706    Protinfo(&'a CStr),
29707    Txqlen(u32),
29708    Map(PushRtnlLinkIfmap),
29709    Weight(u32),
29710    Operstate(u8),
29711    Linkmode(u8),
29712    Linkinfo(IterableLinkinfoAttrs<'a>),
29713    NetNsPid(u32),
29714    Ifalias(&'a CStr),
29715    NumVf(u32),
29716    VfinfoList(IterableVfinfoListAttrs<'a>),
29717    Stats64(PushRtnlLinkStats64),
29718    VfPorts(IterableVfPortsAttrs<'a>),
29719    PortSelf(IterablePortSelfAttrs<'a>),
29720    AfSpec(IterableAfSpecAttrs<'a>),
29721    Group(u32),
29722    NetNsFd(u32),
29723    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
29724    ExtMask(u32),
29725    Promiscuity(u32),
29726    NumTxQueues(u32),
29727    NumRxQueues(u32),
29728    Carrier(u8),
29729    PhysPortId(&'a [u8]),
29730    CarrierChanges(u32),
29731    PhysSwitchId(&'a [u8]),
29732    LinkNetnsid(i32),
29733    PhysPortName(&'a CStr),
29734    ProtoDown(u8),
29735    GsoMaxSegs(u32),
29736    GsoMaxSize(u32),
29737    Pad(&'a [u8]),
29738    Xdp(IterableXdpAttrs<'a>),
29739    Event(u32),
29740    NewNetnsid(i32),
29741    TargetNetnsid(i32),
29742    CarrierUpCount(u32),
29743    CarrierDownCount(u32),
29744    NewIfindex(i32),
29745    MinMtu(u32),
29746    MaxMtu(u32),
29747    PropList(IterablePropListLinkAttrs<'a>),
29748    PermAddress(&'a [u8]),
29749    ProtoDownReason(&'a CStr),
29750    ParentDevName(&'a CStr),
29751    ParentDevBusName(&'a CStr),
29752    GroMaxSize(u32),
29753    TsoMaxSize(u32),
29754    TsoMaxSegs(u32),
29755    Allmulti(u32),
29756    DevlinkPort(&'a [u8]),
29757    GsoIpv4MaxSize(u32),
29758    GroIpv4MaxSize(u32),
29759    DpllPin(IterableLinkDpllPinAttrs<'a>),
29760    #[doc = "EDT offload horizon supported by the device (in nsec)."]
29761    MaxPacingOffloadHorizon(u32),
29762    NetnsImmutable(u8),
29763}
29764impl<'a> IterableOpSetlinkDoRequest<'a> {
29765    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
29766        let mut iter = self.clone();
29767        iter.pos = 0;
29768        for attr in iter {
29769            if let OpSetlinkDoRequest::Address(val) = attr? {
29770                return Ok(val);
29771            }
29772        }
29773        Err(ErrorContext::new_missing(
29774            "OpSetlinkDoRequest",
29775            "Address",
29776            self.orig_loc,
29777            self.buf.as_ptr() as usize,
29778        ))
29779    }
29780    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
29781        let mut iter = self.clone();
29782        iter.pos = 0;
29783        for attr in iter {
29784            if let OpSetlinkDoRequest::Broadcast(val) = attr? {
29785                return Ok(val);
29786            }
29787        }
29788        Err(ErrorContext::new_missing(
29789            "OpSetlinkDoRequest",
29790            "Broadcast",
29791            self.orig_loc,
29792            self.buf.as_ptr() as usize,
29793        ))
29794    }
29795    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
29796        let mut iter = self.clone();
29797        iter.pos = 0;
29798        for attr in iter {
29799            if let OpSetlinkDoRequest::Ifname(val) = attr? {
29800                return Ok(val);
29801            }
29802        }
29803        Err(ErrorContext::new_missing(
29804            "OpSetlinkDoRequest",
29805            "Ifname",
29806            self.orig_loc,
29807            self.buf.as_ptr() as usize,
29808        ))
29809    }
29810    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
29811        let mut iter = self.clone();
29812        iter.pos = 0;
29813        for attr in iter {
29814            if let OpSetlinkDoRequest::Mtu(val) = attr? {
29815                return Ok(val);
29816            }
29817        }
29818        Err(ErrorContext::new_missing(
29819            "OpSetlinkDoRequest",
29820            "Mtu",
29821            self.orig_loc,
29822            self.buf.as_ptr() as usize,
29823        ))
29824    }
29825    pub fn get_link(&self) -> Result<u32, ErrorContext> {
29826        let mut iter = self.clone();
29827        iter.pos = 0;
29828        for attr in iter {
29829            if let OpSetlinkDoRequest::Link(val) = attr? {
29830                return Ok(val);
29831            }
29832        }
29833        Err(ErrorContext::new_missing(
29834            "OpSetlinkDoRequest",
29835            "Link",
29836            self.orig_loc,
29837            self.buf.as_ptr() as usize,
29838        ))
29839    }
29840    pub fn get_qdisc(&self) -> Result<&'a CStr, ErrorContext> {
29841        let mut iter = self.clone();
29842        iter.pos = 0;
29843        for attr in iter {
29844            if let OpSetlinkDoRequest::Qdisc(val) = attr? {
29845                return Ok(val);
29846            }
29847        }
29848        Err(ErrorContext::new_missing(
29849            "OpSetlinkDoRequest",
29850            "Qdisc",
29851            self.orig_loc,
29852            self.buf.as_ptr() as usize,
29853        ))
29854    }
29855    pub fn get_stats(&self) -> Result<PushRtnlLinkStats, ErrorContext> {
29856        let mut iter = self.clone();
29857        iter.pos = 0;
29858        for attr in iter {
29859            if let OpSetlinkDoRequest::Stats(val) = attr? {
29860                return Ok(val);
29861            }
29862        }
29863        Err(ErrorContext::new_missing(
29864            "OpSetlinkDoRequest",
29865            "Stats",
29866            self.orig_loc,
29867            self.buf.as_ptr() as usize,
29868        ))
29869    }
29870    pub fn get_cost(&self) -> Result<&'a CStr, ErrorContext> {
29871        let mut iter = self.clone();
29872        iter.pos = 0;
29873        for attr in iter {
29874            if let OpSetlinkDoRequest::Cost(val) = attr? {
29875                return Ok(val);
29876            }
29877        }
29878        Err(ErrorContext::new_missing(
29879            "OpSetlinkDoRequest",
29880            "Cost",
29881            self.orig_loc,
29882            self.buf.as_ptr() as usize,
29883        ))
29884    }
29885    pub fn get_priority(&self) -> Result<&'a CStr, ErrorContext> {
29886        let mut iter = self.clone();
29887        iter.pos = 0;
29888        for attr in iter {
29889            if let OpSetlinkDoRequest::Priority(val) = attr? {
29890                return Ok(val);
29891            }
29892        }
29893        Err(ErrorContext::new_missing(
29894            "OpSetlinkDoRequest",
29895            "Priority",
29896            self.orig_loc,
29897            self.buf.as_ptr() as usize,
29898        ))
29899    }
29900    pub fn get_master(&self) -> Result<u32, ErrorContext> {
29901        let mut iter = self.clone();
29902        iter.pos = 0;
29903        for attr in iter {
29904            if let OpSetlinkDoRequest::Master(val) = attr? {
29905                return Ok(val);
29906            }
29907        }
29908        Err(ErrorContext::new_missing(
29909            "OpSetlinkDoRequest",
29910            "Master",
29911            self.orig_loc,
29912            self.buf.as_ptr() as usize,
29913        ))
29914    }
29915    pub fn get_wireless(&self) -> Result<&'a CStr, ErrorContext> {
29916        let mut iter = self.clone();
29917        iter.pos = 0;
29918        for attr in iter {
29919            if let OpSetlinkDoRequest::Wireless(val) = attr? {
29920                return Ok(val);
29921            }
29922        }
29923        Err(ErrorContext::new_missing(
29924            "OpSetlinkDoRequest",
29925            "Wireless",
29926            self.orig_loc,
29927            self.buf.as_ptr() as usize,
29928        ))
29929    }
29930    pub fn get_protinfo(&self) -> Result<&'a CStr, ErrorContext> {
29931        let mut iter = self.clone();
29932        iter.pos = 0;
29933        for attr in iter {
29934            if let OpSetlinkDoRequest::Protinfo(val) = attr? {
29935                return Ok(val);
29936            }
29937        }
29938        Err(ErrorContext::new_missing(
29939            "OpSetlinkDoRequest",
29940            "Protinfo",
29941            self.orig_loc,
29942            self.buf.as_ptr() as usize,
29943        ))
29944    }
29945    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
29946        let mut iter = self.clone();
29947        iter.pos = 0;
29948        for attr in iter {
29949            if let OpSetlinkDoRequest::Txqlen(val) = attr? {
29950                return Ok(val);
29951            }
29952        }
29953        Err(ErrorContext::new_missing(
29954            "OpSetlinkDoRequest",
29955            "Txqlen",
29956            self.orig_loc,
29957            self.buf.as_ptr() as usize,
29958        ))
29959    }
29960    pub fn get_map(&self) -> Result<PushRtnlLinkIfmap, ErrorContext> {
29961        let mut iter = self.clone();
29962        iter.pos = 0;
29963        for attr in iter {
29964            if let OpSetlinkDoRequest::Map(val) = attr? {
29965                return Ok(val);
29966            }
29967        }
29968        Err(ErrorContext::new_missing(
29969            "OpSetlinkDoRequest",
29970            "Map",
29971            self.orig_loc,
29972            self.buf.as_ptr() as usize,
29973        ))
29974    }
29975    pub fn get_weight(&self) -> Result<u32, ErrorContext> {
29976        let mut iter = self.clone();
29977        iter.pos = 0;
29978        for attr in iter {
29979            if let OpSetlinkDoRequest::Weight(val) = attr? {
29980                return Ok(val);
29981            }
29982        }
29983        Err(ErrorContext::new_missing(
29984            "OpSetlinkDoRequest",
29985            "Weight",
29986            self.orig_loc,
29987            self.buf.as_ptr() as usize,
29988        ))
29989    }
29990    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
29991        let mut iter = self.clone();
29992        iter.pos = 0;
29993        for attr in iter {
29994            if let OpSetlinkDoRequest::Operstate(val) = attr? {
29995                return Ok(val);
29996            }
29997        }
29998        Err(ErrorContext::new_missing(
29999            "OpSetlinkDoRequest",
30000            "Operstate",
30001            self.orig_loc,
30002            self.buf.as_ptr() as usize,
30003        ))
30004    }
30005    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
30006        let mut iter = self.clone();
30007        iter.pos = 0;
30008        for attr in iter {
30009            if let OpSetlinkDoRequest::Linkmode(val) = attr? {
30010                return Ok(val);
30011            }
30012        }
30013        Err(ErrorContext::new_missing(
30014            "OpSetlinkDoRequest",
30015            "Linkmode",
30016            self.orig_loc,
30017            self.buf.as_ptr() as usize,
30018        ))
30019    }
30020    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
30021        let mut iter = self.clone();
30022        iter.pos = 0;
30023        for attr in iter {
30024            if let OpSetlinkDoRequest::Linkinfo(val) = attr? {
30025                return Ok(val);
30026            }
30027        }
30028        Err(ErrorContext::new_missing(
30029            "OpSetlinkDoRequest",
30030            "Linkinfo",
30031            self.orig_loc,
30032            self.buf.as_ptr() as usize,
30033        ))
30034    }
30035    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
30036        let mut iter = self.clone();
30037        iter.pos = 0;
30038        for attr in iter {
30039            if let OpSetlinkDoRequest::NetNsPid(val) = attr? {
30040                return Ok(val);
30041            }
30042        }
30043        Err(ErrorContext::new_missing(
30044            "OpSetlinkDoRequest",
30045            "NetNsPid",
30046            self.orig_loc,
30047            self.buf.as_ptr() as usize,
30048        ))
30049    }
30050    pub fn get_ifalias(&self) -> Result<&'a CStr, ErrorContext> {
30051        let mut iter = self.clone();
30052        iter.pos = 0;
30053        for attr in iter {
30054            if let OpSetlinkDoRequest::Ifalias(val) = attr? {
30055                return Ok(val);
30056            }
30057        }
30058        Err(ErrorContext::new_missing(
30059            "OpSetlinkDoRequest",
30060            "Ifalias",
30061            self.orig_loc,
30062            self.buf.as_ptr() as usize,
30063        ))
30064    }
30065    pub fn get_num_vf(&self) -> Result<u32, ErrorContext> {
30066        let mut iter = self.clone();
30067        iter.pos = 0;
30068        for attr in iter {
30069            if let OpSetlinkDoRequest::NumVf(val) = attr? {
30070                return Ok(val);
30071            }
30072        }
30073        Err(ErrorContext::new_missing(
30074            "OpSetlinkDoRequest",
30075            "NumVf",
30076            self.orig_loc,
30077            self.buf.as_ptr() as usize,
30078        ))
30079    }
30080    pub fn get_vfinfo_list(&self) -> Result<IterableVfinfoListAttrs<'a>, ErrorContext> {
30081        let mut iter = self.clone();
30082        iter.pos = 0;
30083        for attr in iter {
30084            if let OpSetlinkDoRequest::VfinfoList(val) = attr? {
30085                return Ok(val);
30086            }
30087        }
30088        Err(ErrorContext::new_missing(
30089            "OpSetlinkDoRequest",
30090            "VfinfoList",
30091            self.orig_loc,
30092            self.buf.as_ptr() as usize,
30093        ))
30094    }
30095    pub fn get_stats64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
30096        let mut iter = self.clone();
30097        iter.pos = 0;
30098        for attr in iter {
30099            if let OpSetlinkDoRequest::Stats64(val) = attr? {
30100                return Ok(val);
30101            }
30102        }
30103        Err(ErrorContext::new_missing(
30104            "OpSetlinkDoRequest",
30105            "Stats64",
30106            self.orig_loc,
30107            self.buf.as_ptr() as usize,
30108        ))
30109    }
30110    pub fn get_vf_ports(&self) -> Result<IterableVfPortsAttrs<'a>, ErrorContext> {
30111        let mut iter = self.clone();
30112        iter.pos = 0;
30113        for attr in iter {
30114            if let OpSetlinkDoRequest::VfPorts(val) = attr? {
30115                return Ok(val);
30116            }
30117        }
30118        Err(ErrorContext::new_missing(
30119            "OpSetlinkDoRequest",
30120            "VfPorts",
30121            self.orig_loc,
30122            self.buf.as_ptr() as usize,
30123        ))
30124    }
30125    pub fn get_port_self(&self) -> Result<IterablePortSelfAttrs<'a>, ErrorContext> {
30126        let mut iter = self.clone();
30127        iter.pos = 0;
30128        for attr in iter {
30129            if let OpSetlinkDoRequest::PortSelf(val) = attr? {
30130                return Ok(val);
30131            }
30132        }
30133        Err(ErrorContext::new_missing(
30134            "OpSetlinkDoRequest",
30135            "PortSelf",
30136            self.orig_loc,
30137            self.buf.as_ptr() as usize,
30138        ))
30139    }
30140    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
30141        let mut iter = self.clone();
30142        iter.pos = 0;
30143        for attr in iter {
30144            if let OpSetlinkDoRequest::AfSpec(val) = attr? {
30145                return Ok(val);
30146            }
30147        }
30148        Err(ErrorContext::new_missing(
30149            "OpSetlinkDoRequest",
30150            "AfSpec",
30151            self.orig_loc,
30152            self.buf.as_ptr() as usize,
30153        ))
30154    }
30155    pub fn get_group(&self) -> Result<u32, ErrorContext> {
30156        let mut iter = self.clone();
30157        iter.pos = 0;
30158        for attr in iter {
30159            if let OpSetlinkDoRequest::Group(val) = attr? {
30160                return Ok(val);
30161            }
30162        }
30163        Err(ErrorContext::new_missing(
30164            "OpSetlinkDoRequest",
30165            "Group",
30166            self.orig_loc,
30167            self.buf.as_ptr() as usize,
30168        ))
30169    }
30170    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
30171        let mut iter = self.clone();
30172        iter.pos = 0;
30173        for attr in iter {
30174            if let OpSetlinkDoRequest::NetNsFd(val) = attr? {
30175                return Ok(val);
30176            }
30177        }
30178        Err(ErrorContext::new_missing(
30179            "OpSetlinkDoRequest",
30180            "NetNsFd",
30181            self.orig_loc,
30182            self.buf.as_ptr() as usize,
30183        ))
30184    }
30185    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
30186    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
30187        let mut iter = self.clone();
30188        iter.pos = 0;
30189        for attr in iter {
30190            if let OpSetlinkDoRequest::ExtMask(val) = attr? {
30191                return Ok(val);
30192            }
30193        }
30194        Err(ErrorContext::new_missing(
30195            "OpSetlinkDoRequest",
30196            "ExtMask",
30197            self.orig_loc,
30198            self.buf.as_ptr() as usize,
30199        ))
30200    }
30201    pub fn get_promiscuity(&self) -> Result<u32, ErrorContext> {
30202        let mut iter = self.clone();
30203        iter.pos = 0;
30204        for attr in iter {
30205            if let OpSetlinkDoRequest::Promiscuity(val) = attr? {
30206                return Ok(val);
30207            }
30208        }
30209        Err(ErrorContext::new_missing(
30210            "OpSetlinkDoRequest",
30211            "Promiscuity",
30212            self.orig_loc,
30213            self.buf.as_ptr() as usize,
30214        ))
30215    }
30216    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
30217        let mut iter = self.clone();
30218        iter.pos = 0;
30219        for attr in iter {
30220            if let OpSetlinkDoRequest::NumTxQueues(val) = attr? {
30221                return Ok(val);
30222            }
30223        }
30224        Err(ErrorContext::new_missing(
30225            "OpSetlinkDoRequest",
30226            "NumTxQueues",
30227            self.orig_loc,
30228            self.buf.as_ptr() as usize,
30229        ))
30230    }
30231    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
30232        let mut iter = self.clone();
30233        iter.pos = 0;
30234        for attr in iter {
30235            if let OpSetlinkDoRequest::NumRxQueues(val) = attr? {
30236                return Ok(val);
30237            }
30238        }
30239        Err(ErrorContext::new_missing(
30240            "OpSetlinkDoRequest",
30241            "NumRxQueues",
30242            self.orig_loc,
30243            self.buf.as_ptr() as usize,
30244        ))
30245    }
30246    pub fn get_carrier(&self) -> Result<u8, ErrorContext> {
30247        let mut iter = self.clone();
30248        iter.pos = 0;
30249        for attr in iter {
30250            if let OpSetlinkDoRequest::Carrier(val) = attr? {
30251                return Ok(val);
30252            }
30253        }
30254        Err(ErrorContext::new_missing(
30255            "OpSetlinkDoRequest",
30256            "Carrier",
30257            self.orig_loc,
30258            self.buf.as_ptr() as usize,
30259        ))
30260    }
30261    pub fn get_phys_port_id(&self) -> Result<&'a [u8], ErrorContext> {
30262        let mut iter = self.clone();
30263        iter.pos = 0;
30264        for attr in iter {
30265            if let OpSetlinkDoRequest::PhysPortId(val) = attr? {
30266                return Ok(val);
30267            }
30268        }
30269        Err(ErrorContext::new_missing(
30270            "OpSetlinkDoRequest",
30271            "PhysPortId",
30272            self.orig_loc,
30273            self.buf.as_ptr() as usize,
30274        ))
30275    }
30276    pub fn get_carrier_changes(&self) -> Result<u32, ErrorContext> {
30277        let mut iter = self.clone();
30278        iter.pos = 0;
30279        for attr in iter {
30280            if let OpSetlinkDoRequest::CarrierChanges(val) = attr? {
30281                return Ok(val);
30282            }
30283        }
30284        Err(ErrorContext::new_missing(
30285            "OpSetlinkDoRequest",
30286            "CarrierChanges",
30287            self.orig_loc,
30288            self.buf.as_ptr() as usize,
30289        ))
30290    }
30291    pub fn get_phys_switch_id(&self) -> Result<&'a [u8], ErrorContext> {
30292        let mut iter = self.clone();
30293        iter.pos = 0;
30294        for attr in iter {
30295            if let OpSetlinkDoRequest::PhysSwitchId(val) = attr? {
30296                return Ok(val);
30297            }
30298        }
30299        Err(ErrorContext::new_missing(
30300            "OpSetlinkDoRequest",
30301            "PhysSwitchId",
30302            self.orig_loc,
30303            self.buf.as_ptr() as usize,
30304        ))
30305    }
30306    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
30307        let mut iter = self.clone();
30308        iter.pos = 0;
30309        for attr in iter {
30310            if let OpSetlinkDoRequest::LinkNetnsid(val) = attr? {
30311                return Ok(val);
30312            }
30313        }
30314        Err(ErrorContext::new_missing(
30315            "OpSetlinkDoRequest",
30316            "LinkNetnsid",
30317            self.orig_loc,
30318            self.buf.as_ptr() as usize,
30319        ))
30320    }
30321    pub fn get_phys_port_name(&self) -> Result<&'a CStr, ErrorContext> {
30322        let mut iter = self.clone();
30323        iter.pos = 0;
30324        for attr in iter {
30325            if let OpSetlinkDoRequest::PhysPortName(val) = attr? {
30326                return Ok(val);
30327            }
30328        }
30329        Err(ErrorContext::new_missing(
30330            "OpSetlinkDoRequest",
30331            "PhysPortName",
30332            self.orig_loc,
30333            self.buf.as_ptr() as usize,
30334        ))
30335    }
30336    pub fn get_proto_down(&self) -> Result<u8, ErrorContext> {
30337        let mut iter = self.clone();
30338        iter.pos = 0;
30339        for attr in iter {
30340            if let OpSetlinkDoRequest::ProtoDown(val) = attr? {
30341                return Ok(val);
30342            }
30343        }
30344        Err(ErrorContext::new_missing(
30345            "OpSetlinkDoRequest",
30346            "ProtoDown",
30347            self.orig_loc,
30348            self.buf.as_ptr() as usize,
30349        ))
30350    }
30351    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
30352        let mut iter = self.clone();
30353        iter.pos = 0;
30354        for attr in iter {
30355            if let OpSetlinkDoRequest::GsoMaxSegs(val) = attr? {
30356                return Ok(val);
30357            }
30358        }
30359        Err(ErrorContext::new_missing(
30360            "OpSetlinkDoRequest",
30361            "GsoMaxSegs",
30362            self.orig_loc,
30363            self.buf.as_ptr() as usize,
30364        ))
30365    }
30366    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
30367        let mut iter = self.clone();
30368        iter.pos = 0;
30369        for attr in iter {
30370            if let OpSetlinkDoRequest::GsoMaxSize(val) = attr? {
30371                return Ok(val);
30372            }
30373        }
30374        Err(ErrorContext::new_missing(
30375            "OpSetlinkDoRequest",
30376            "GsoMaxSize",
30377            self.orig_loc,
30378            self.buf.as_ptr() as usize,
30379        ))
30380    }
30381    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
30382        let mut iter = self.clone();
30383        iter.pos = 0;
30384        for attr in iter {
30385            if let OpSetlinkDoRequest::Pad(val) = attr? {
30386                return Ok(val);
30387            }
30388        }
30389        Err(ErrorContext::new_missing(
30390            "OpSetlinkDoRequest",
30391            "Pad",
30392            self.orig_loc,
30393            self.buf.as_ptr() as usize,
30394        ))
30395    }
30396    pub fn get_xdp(&self) -> Result<IterableXdpAttrs<'a>, ErrorContext> {
30397        let mut iter = self.clone();
30398        iter.pos = 0;
30399        for attr in iter {
30400            if let OpSetlinkDoRequest::Xdp(val) = attr? {
30401                return Ok(val);
30402            }
30403        }
30404        Err(ErrorContext::new_missing(
30405            "OpSetlinkDoRequest",
30406            "Xdp",
30407            self.orig_loc,
30408            self.buf.as_ptr() as usize,
30409        ))
30410    }
30411    pub fn get_event(&self) -> Result<u32, ErrorContext> {
30412        let mut iter = self.clone();
30413        iter.pos = 0;
30414        for attr in iter {
30415            if let OpSetlinkDoRequest::Event(val) = attr? {
30416                return Ok(val);
30417            }
30418        }
30419        Err(ErrorContext::new_missing(
30420            "OpSetlinkDoRequest",
30421            "Event",
30422            self.orig_loc,
30423            self.buf.as_ptr() as usize,
30424        ))
30425    }
30426    pub fn get_new_netnsid(&self) -> Result<i32, ErrorContext> {
30427        let mut iter = self.clone();
30428        iter.pos = 0;
30429        for attr in iter {
30430            if let OpSetlinkDoRequest::NewNetnsid(val) = attr? {
30431                return Ok(val);
30432            }
30433        }
30434        Err(ErrorContext::new_missing(
30435            "OpSetlinkDoRequest",
30436            "NewNetnsid",
30437            self.orig_loc,
30438            self.buf.as_ptr() as usize,
30439        ))
30440    }
30441    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
30442        let mut iter = self.clone();
30443        iter.pos = 0;
30444        for attr in iter {
30445            if let OpSetlinkDoRequest::TargetNetnsid(val) = attr? {
30446                return Ok(val);
30447            }
30448        }
30449        Err(ErrorContext::new_missing(
30450            "OpSetlinkDoRequest",
30451            "TargetNetnsid",
30452            self.orig_loc,
30453            self.buf.as_ptr() as usize,
30454        ))
30455    }
30456    pub fn get_carrier_up_count(&self) -> Result<u32, ErrorContext> {
30457        let mut iter = self.clone();
30458        iter.pos = 0;
30459        for attr in iter {
30460            if let OpSetlinkDoRequest::CarrierUpCount(val) = attr? {
30461                return Ok(val);
30462            }
30463        }
30464        Err(ErrorContext::new_missing(
30465            "OpSetlinkDoRequest",
30466            "CarrierUpCount",
30467            self.orig_loc,
30468            self.buf.as_ptr() as usize,
30469        ))
30470    }
30471    pub fn get_carrier_down_count(&self) -> Result<u32, ErrorContext> {
30472        let mut iter = self.clone();
30473        iter.pos = 0;
30474        for attr in iter {
30475            if let OpSetlinkDoRequest::CarrierDownCount(val) = attr? {
30476                return Ok(val);
30477            }
30478        }
30479        Err(ErrorContext::new_missing(
30480            "OpSetlinkDoRequest",
30481            "CarrierDownCount",
30482            self.orig_loc,
30483            self.buf.as_ptr() as usize,
30484        ))
30485    }
30486    pub fn get_new_ifindex(&self) -> Result<i32, ErrorContext> {
30487        let mut iter = self.clone();
30488        iter.pos = 0;
30489        for attr in iter {
30490            if let OpSetlinkDoRequest::NewIfindex(val) = attr? {
30491                return Ok(val);
30492            }
30493        }
30494        Err(ErrorContext::new_missing(
30495            "OpSetlinkDoRequest",
30496            "NewIfindex",
30497            self.orig_loc,
30498            self.buf.as_ptr() as usize,
30499        ))
30500    }
30501    pub fn get_min_mtu(&self) -> Result<u32, ErrorContext> {
30502        let mut iter = self.clone();
30503        iter.pos = 0;
30504        for attr in iter {
30505            if let OpSetlinkDoRequest::MinMtu(val) = attr? {
30506                return Ok(val);
30507            }
30508        }
30509        Err(ErrorContext::new_missing(
30510            "OpSetlinkDoRequest",
30511            "MinMtu",
30512            self.orig_loc,
30513            self.buf.as_ptr() as usize,
30514        ))
30515    }
30516    pub fn get_max_mtu(&self) -> Result<u32, ErrorContext> {
30517        let mut iter = self.clone();
30518        iter.pos = 0;
30519        for attr in iter {
30520            if let OpSetlinkDoRequest::MaxMtu(val) = attr? {
30521                return Ok(val);
30522            }
30523        }
30524        Err(ErrorContext::new_missing(
30525            "OpSetlinkDoRequest",
30526            "MaxMtu",
30527            self.orig_loc,
30528            self.buf.as_ptr() as usize,
30529        ))
30530    }
30531    pub fn get_prop_list(&self) -> Result<IterablePropListLinkAttrs<'a>, ErrorContext> {
30532        let mut iter = self.clone();
30533        iter.pos = 0;
30534        for attr in iter {
30535            if let OpSetlinkDoRequest::PropList(val) = attr? {
30536                return Ok(val);
30537            }
30538        }
30539        Err(ErrorContext::new_missing(
30540            "OpSetlinkDoRequest",
30541            "PropList",
30542            self.orig_loc,
30543            self.buf.as_ptr() as usize,
30544        ))
30545    }
30546    pub fn get_perm_address(&self) -> Result<&'a [u8], ErrorContext> {
30547        let mut iter = self.clone();
30548        iter.pos = 0;
30549        for attr in iter {
30550            if let OpSetlinkDoRequest::PermAddress(val) = attr? {
30551                return Ok(val);
30552            }
30553        }
30554        Err(ErrorContext::new_missing(
30555            "OpSetlinkDoRequest",
30556            "PermAddress",
30557            self.orig_loc,
30558            self.buf.as_ptr() as usize,
30559        ))
30560    }
30561    pub fn get_proto_down_reason(&self) -> Result<&'a CStr, ErrorContext> {
30562        let mut iter = self.clone();
30563        iter.pos = 0;
30564        for attr in iter {
30565            if let OpSetlinkDoRequest::ProtoDownReason(val) = attr? {
30566                return Ok(val);
30567            }
30568        }
30569        Err(ErrorContext::new_missing(
30570            "OpSetlinkDoRequest",
30571            "ProtoDownReason",
30572            self.orig_loc,
30573            self.buf.as_ptr() as usize,
30574        ))
30575    }
30576    pub fn get_parent_dev_name(&self) -> Result<&'a CStr, ErrorContext> {
30577        let mut iter = self.clone();
30578        iter.pos = 0;
30579        for attr in iter {
30580            if let OpSetlinkDoRequest::ParentDevName(val) = attr? {
30581                return Ok(val);
30582            }
30583        }
30584        Err(ErrorContext::new_missing(
30585            "OpSetlinkDoRequest",
30586            "ParentDevName",
30587            self.orig_loc,
30588            self.buf.as_ptr() as usize,
30589        ))
30590    }
30591    pub fn get_parent_dev_bus_name(&self) -> Result<&'a CStr, ErrorContext> {
30592        let mut iter = self.clone();
30593        iter.pos = 0;
30594        for attr in iter {
30595            if let OpSetlinkDoRequest::ParentDevBusName(val) = attr? {
30596                return Ok(val);
30597            }
30598        }
30599        Err(ErrorContext::new_missing(
30600            "OpSetlinkDoRequest",
30601            "ParentDevBusName",
30602            self.orig_loc,
30603            self.buf.as_ptr() as usize,
30604        ))
30605    }
30606    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
30607        let mut iter = self.clone();
30608        iter.pos = 0;
30609        for attr in iter {
30610            if let OpSetlinkDoRequest::GroMaxSize(val) = attr? {
30611                return Ok(val);
30612            }
30613        }
30614        Err(ErrorContext::new_missing(
30615            "OpSetlinkDoRequest",
30616            "GroMaxSize",
30617            self.orig_loc,
30618            self.buf.as_ptr() as usize,
30619        ))
30620    }
30621    pub fn get_tso_max_size(&self) -> Result<u32, ErrorContext> {
30622        let mut iter = self.clone();
30623        iter.pos = 0;
30624        for attr in iter {
30625            if let OpSetlinkDoRequest::TsoMaxSize(val) = attr? {
30626                return Ok(val);
30627            }
30628        }
30629        Err(ErrorContext::new_missing(
30630            "OpSetlinkDoRequest",
30631            "TsoMaxSize",
30632            self.orig_loc,
30633            self.buf.as_ptr() as usize,
30634        ))
30635    }
30636    pub fn get_tso_max_segs(&self) -> Result<u32, ErrorContext> {
30637        let mut iter = self.clone();
30638        iter.pos = 0;
30639        for attr in iter {
30640            if let OpSetlinkDoRequest::TsoMaxSegs(val) = attr? {
30641                return Ok(val);
30642            }
30643        }
30644        Err(ErrorContext::new_missing(
30645            "OpSetlinkDoRequest",
30646            "TsoMaxSegs",
30647            self.orig_loc,
30648            self.buf.as_ptr() as usize,
30649        ))
30650    }
30651    pub fn get_allmulti(&self) -> Result<u32, ErrorContext> {
30652        let mut iter = self.clone();
30653        iter.pos = 0;
30654        for attr in iter {
30655            if let OpSetlinkDoRequest::Allmulti(val) = attr? {
30656                return Ok(val);
30657            }
30658        }
30659        Err(ErrorContext::new_missing(
30660            "OpSetlinkDoRequest",
30661            "Allmulti",
30662            self.orig_loc,
30663            self.buf.as_ptr() as usize,
30664        ))
30665    }
30666    pub fn get_devlink_port(&self) -> Result<&'a [u8], ErrorContext> {
30667        let mut iter = self.clone();
30668        iter.pos = 0;
30669        for attr in iter {
30670            if let OpSetlinkDoRequest::DevlinkPort(val) = attr? {
30671                return Ok(val);
30672            }
30673        }
30674        Err(ErrorContext::new_missing(
30675            "OpSetlinkDoRequest",
30676            "DevlinkPort",
30677            self.orig_loc,
30678            self.buf.as_ptr() as usize,
30679        ))
30680    }
30681    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
30682        let mut iter = self.clone();
30683        iter.pos = 0;
30684        for attr in iter {
30685            if let OpSetlinkDoRequest::GsoIpv4MaxSize(val) = attr? {
30686                return Ok(val);
30687            }
30688        }
30689        Err(ErrorContext::new_missing(
30690            "OpSetlinkDoRequest",
30691            "GsoIpv4MaxSize",
30692            self.orig_loc,
30693            self.buf.as_ptr() as usize,
30694        ))
30695    }
30696    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
30697        let mut iter = self.clone();
30698        iter.pos = 0;
30699        for attr in iter {
30700            if let OpSetlinkDoRequest::GroIpv4MaxSize(val) = attr? {
30701                return Ok(val);
30702            }
30703        }
30704        Err(ErrorContext::new_missing(
30705            "OpSetlinkDoRequest",
30706            "GroIpv4MaxSize",
30707            self.orig_loc,
30708            self.buf.as_ptr() as usize,
30709        ))
30710    }
30711    pub fn get_dpll_pin(&self) -> Result<IterableLinkDpllPinAttrs<'a>, ErrorContext> {
30712        let mut iter = self.clone();
30713        iter.pos = 0;
30714        for attr in iter {
30715            if let OpSetlinkDoRequest::DpllPin(val) = attr? {
30716                return Ok(val);
30717            }
30718        }
30719        Err(ErrorContext::new_missing(
30720            "OpSetlinkDoRequest",
30721            "DpllPin",
30722            self.orig_loc,
30723            self.buf.as_ptr() as usize,
30724        ))
30725    }
30726    #[doc = "EDT offload horizon supported by the device (in nsec)."]
30727    pub fn get_max_pacing_offload_horizon(&self) -> Result<u32, ErrorContext> {
30728        let mut iter = self.clone();
30729        iter.pos = 0;
30730        for attr in iter {
30731            if let OpSetlinkDoRequest::MaxPacingOffloadHorizon(val) = attr? {
30732                return Ok(val);
30733            }
30734        }
30735        Err(ErrorContext::new_missing(
30736            "OpSetlinkDoRequest",
30737            "MaxPacingOffloadHorizon",
30738            self.orig_loc,
30739            self.buf.as_ptr() as usize,
30740        ))
30741    }
30742    pub fn get_netns_immutable(&self) -> Result<u8, ErrorContext> {
30743        let mut iter = self.clone();
30744        iter.pos = 0;
30745        for attr in iter {
30746            if let OpSetlinkDoRequest::NetnsImmutable(val) = attr? {
30747                return Ok(val);
30748            }
30749        }
30750        Err(ErrorContext::new_missing(
30751            "OpSetlinkDoRequest",
30752            "NetnsImmutable",
30753            self.orig_loc,
30754            self.buf.as_ptr() as usize,
30755        ))
30756    }
30757}
30758impl OpSetlinkDoRequest<'_> {
30759    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpSetlinkDoRequest<'a>) {
30760        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
30761        (
30762            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
30763            IterableOpSetlinkDoRequest::with_loc(attrs, buf.as_ptr() as usize),
30764        )
30765    }
30766    fn attr_from_type(r#type: u16) -> Option<&'static str> {
30767        LinkAttrs::attr_from_type(r#type)
30768    }
30769}
30770#[derive(Clone, Copy, Default)]
30771pub struct IterableOpSetlinkDoRequest<'a> {
30772    buf: &'a [u8],
30773    pos: usize,
30774    orig_loc: usize,
30775}
30776impl<'a> IterableOpSetlinkDoRequest<'a> {
30777    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
30778        Self {
30779            buf,
30780            pos: 0,
30781            orig_loc,
30782        }
30783    }
30784    pub fn get_buf(&self) -> &'a [u8] {
30785        self.buf
30786    }
30787}
30788impl<'a> Iterator for IterableOpSetlinkDoRequest<'a> {
30789    type Item = Result<OpSetlinkDoRequest<'a>, ErrorContext>;
30790    fn next(&mut self) -> Option<Self::Item> {
30791        let pos = self.pos;
30792        let mut r#type;
30793        loop {
30794            r#type = None;
30795            if self.buf.len() == self.pos {
30796                return None;
30797            }
30798            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
30799                break;
30800            };
30801            r#type = Some(header.r#type);
30802            let res = match header.r#type {
30803                1u16 => OpSetlinkDoRequest::Address({
30804                    let res = Some(next);
30805                    let Some(val) = res else { break };
30806                    val
30807                }),
30808                2u16 => OpSetlinkDoRequest::Broadcast({
30809                    let res = Some(next);
30810                    let Some(val) = res else { break };
30811                    val
30812                }),
30813                3u16 => OpSetlinkDoRequest::Ifname({
30814                    let res = CStr::from_bytes_with_nul(next).ok();
30815                    let Some(val) = res else { break };
30816                    val
30817                }),
30818                4u16 => OpSetlinkDoRequest::Mtu({
30819                    let res = parse_u32(next);
30820                    let Some(val) = res else { break };
30821                    val
30822                }),
30823                5u16 => OpSetlinkDoRequest::Link({
30824                    let res = parse_u32(next);
30825                    let Some(val) = res else { break };
30826                    val
30827                }),
30828                6u16 => OpSetlinkDoRequest::Qdisc({
30829                    let res = CStr::from_bytes_with_nul(next).ok();
30830                    let Some(val) = res else { break };
30831                    val
30832                }),
30833                7u16 => OpSetlinkDoRequest::Stats({
30834                    let res = Some(PushRtnlLinkStats::new_from_zeroed(next));
30835                    let Some(val) = res else { break };
30836                    val
30837                }),
30838                8u16 => OpSetlinkDoRequest::Cost({
30839                    let res = CStr::from_bytes_with_nul(next).ok();
30840                    let Some(val) = res else { break };
30841                    val
30842                }),
30843                9u16 => OpSetlinkDoRequest::Priority({
30844                    let res = CStr::from_bytes_with_nul(next).ok();
30845                    let Some(val) = res else { break };
30846                    val
30847                }),
30848                10u16 => OpSetlinkDoRequest::Master({
30849                    let res = parse_u32(next);
30850                    let Some(val) = res else { break };
30851                    val
30852                }),
30853                11u16 => OpSetlinkDoRequest::Wireless({
30854                    let res = CStr::from_bytes_with_nul(next).ok();
30855                    let Some(val) = res else { break };
30856                    val
30857                }),
30858                12u16 => OpSetlinkDoRequest::Protinfo({
30859                    let res = CStr::from_bytes_with_nul(next).ok();
30860                    let Some(val) = res else { break };
30861                    val
30862                }),
30863                13u16 => OpSetlinkDoRequest::Txqlen({
30864                    let res = parse_u32(next);
30865                    let Some(val) = res else { break };
30866                    val
30867                }),
30868                14u16 => OpSetlinkDoRequest::Map({
30869                    let res = PushRtnlLinkIfmap::new_from_slice(next);
30870                    let Some(val) = res else { break };
30871                    val
30872                }),
30873                15u16 => OpSetlinkDoRequest::Weight({
30874                    let res = parse_u32(next);
30875                    let Some(val) = res else { break };
30876                    val
30877                }),
30878                16u16 => OpSetlinkDoRequest::Operstate({
30879                    let res = parse_u8(next);
30880                    let Some(val) = res else { break };
30881                    val
30882                }),
30883                17u16 => OpSetlinkDoRequest::Linkmode({
30884                    let res = parse_u8(next);
30885                    let Some(val) = res else { break };
30886                    val
30887                }),
30888                18u16 => OpSetlinkDoRequest::Linkinfo({
30889                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
30890                    let Some(val) = res else { break };
30891                    val
30892                }),
30893                19u16 => OpSetlinkDoRequest::NetNsPid({
30894                    let res = parse_u32(next);
30895                    let Some(val) = res else { break };
30896                    val
30897                }),
30898                20u16 => OpSetlinkDoRequest::Ifalias({
30899                    let res = CStr::from_bytes_with_nul(next).ok();
30900                    let Some(val) = res else { break };
30901                    val
30902                }),
30903                21u16 => OpSetlinkDoRequest::NumVf({
30904                    let res = parse_u32(next);
30905                    let Some(val) = res else { break };
30906                    val
30907                }),
30908                22u16 => OpSetlinkDoRequest::VfinfoList({
30909                    let res = Some(IterableVfinfoListAttrs::with_loc(next, self.orig_loc));
30910                    let Some(val) = res else { break };
30911                    val
30912                }),
30913                23u16 => OpSetlinkDoRequest::Stats64({
30914                    let res = Some(PushRtnlLinkStats64::new_from_zeroed(next));
30915                    let Some(val) = res else { break };
30916                    val
30917                }),
30918                24u16 => OpSetlinkDoRequest::VfPorts({
30919                    let res = Some(IterableVfPortsAttrs::with_loc(next, self.orig_loc));
30920                    let Some(val) = res else { break };
30921                    val
30922                }),
30923                25u16 => OpSetlinkDoRequest::PortSelf({
30924                    let res = Some(IterablePortSelfAttrs::with_loc(next, self.orig_loc));
30925                    let Some(val) = res else { break };
30926                    val
30927                }),
30928                26u16 => OpSetlinkDoRequest::AfSpec({
30929                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
30930                    let Some(val) = res else { break };
30931                    val
30932                }),
30933                27u16 => OpSetlinkDoRequest::Group({
30934                    let res = parse_u32(next);
30935                    let Some(val) = res else { break };
30936                    val
30937                }),
30938                28u16 => OpSetlinkDoRequest::NetNsFd({
30939                    let res = parse_u32(next);
30940                    let Some(val) = res else { break };
30941                    val
30942                }),
30943                29u16 => OpSetlinkDoRequest::ExtMask({
30944                    let res = parse_u32(next);
30945                    let Some(val) = res else { break };
30946                    val
30947                }),
30948                30u16 => OpSetlinkDoRequest::Promiscuity({
30949                    let res = parse_u32(next);
30950                    let Some(val) = res else { break };
30951                    val
30952                }),
30953                31u16 => OpSetlinkDoRequest::NumTxQueues({
30954                    let res = parse_u32(next);
30955                    let Some(val) = res else { break };
30956                    val
30957                }),
30958                32u16 => OpSetlinkDoRequest::NumRxQueues({
30959                    let res = parse_u32(next);
30960                    let Some(val) = res else { break };
30961                    val
30962                }),
30963                33u16 => OpSetlinkDoRequest::Carrier({
30964                    let res = parse_u8(next);
30965                    let Some(val) = res else { break };
30966                    val
30967                }),
30968                34u16 => OpSetlinkDoRequest::PhysPortId({
30969                    let res = Some(next);
30970                    let Some(val) = res else { break };
30971                    val
30972                }),
30973                35u16 => OpSetlinkDoRequest::CarrierChanges({
30974                    let res = parse_u32(next);
30975                    let Some(val) = res else { break };
30976                    val
30977                }),
30978                36u16 => OpSetlinkDoRequest::PhysSwitchId({
30979                    let res = Some(next);
30980                    let Some(val) = res else { break };
30981                    val
30982                }),
30983                37u16 => OpSetlinkDoRequest::LinkNetnsid({
30984                    let res = parse_i32(next);
30985                    let Some(val) = res else { break };
30986                    val
30987                }),
30988                38u16 => OpSetlinkDoRequest::PhysPortName({
30989                    let res = CStr::from_bytes_with_nul(next).ok();
30990                    let Some(val) = res else { break };
30991                    val
30992                }),
30993                39u16 => OpSetlinkDoRequest::ProtoDown({
30994                    let res = parse_u8(next);
30995                    let Some(val) = res else { break };
30996                    val
30997                }),
30998                40u16 => OpSetlinkDoRequest::GsoMaxSegs({
30999                    let res = parse_u32(next);
31000                    let Some(val) = res else { break };
31001                    val
31002                }),
31003                41u16 => OpSetlinkDoRequest::GsoMaxSize({
31004                    let res = parse_u32(next);
31005                    let Some(val) = res else { break };
31006                    val
31007                }),
31008                42u16 => OpSetlinkDoRequest::Pad({
31009                    let res = Some(next);
31010                    let Some(val) = res else { break };
31011                    val
31012                }),
31013                43u16 => OpSetlinkDoRequest::Xdp({
31014                    let res = Some(IterableXdpAttrs::with_loc(next, self.orig_loc));
31015                    let Some(val) = res else { break };
31016                    val
31017                }),
31018                44u16 => OpSetlinkDoRequest::Event({
31019                    let res = parse_u32(next);
31020                    let Some(val) = res else { break };
31021                    val
31022                }),
31023                45u16 => OpSetlinkDoRequest::NewNetnsid({
31024                    let res = parse_i32(next);
31025                    let Some(val) = res else { break };
31026                    val
31027                }),
31028                46u16 => OpSetlinkDoRequest::TargetNetnsid({
31029                    let res = parse_i32(next);
31030                    let Some(val) = res else { break };
31031                    val
31032                }),
31033                47u16 => OpSetlinkDoRequest::CarrierUpCount({
31034                    let res = parse_u32(next);
31035                    let Some(val) = res else { break };
31036                    val
31037                }),
31038                48u16 => OpSetlinkDoRequest::CarrierDownCount({
31039                    let res = parse_u32(next);
31040                    let Some(val) = res else { break };
31041                    val
31042                }),
31043                49u16 => OpSetlinkDoRequest::NewIfindex({
31044                    let res = parse_i32(next);
31045                    let Some(val) = res else { break };
31046                    val
31047                }),
31048                50u16 => OpSetlinkDoRequest::MinMtu({
31049                    let res = parse_u32(next);
31050                    let Some(val) = res else { break };
31051                    val
31052                }),
31053                51u16 => OpSetlinkDoRequest::MaxMtu({
31054                    let res = parse_u32(next);
31055                    let Some(val) = res else { break };
31056                    val
31057                }),
31058                52u16 => OpSetlinkDoRequest::PropList({
31059                    let res = Some(IterablePropListLinkAttrs::with_loc(next, self.orig_loc));
31060                    let Some(val) = res else { break };
31061                    val
31062                }),
31063                54u16 => OpSetlinkDoRequest::PermAddress({
31064                    let res = Some(next);
31065                    let Some(val) = res else { break };
31066                    val
31067                }),
31068                55u16 => OpSetlinkDoRequest::ProtoDownReason({
31069                    let res = CStr::from_bytes_with_nul(next).ok();
31070                    let Some(val) = res else { break };
31071                    val
31072                }),
31073                56u16 => OpSetlinkDoRequest::ParentDevName({
31074                    let res = CStr::from_bytes_with_nul(next).ok();
31075                    let Some(val) = res else { break };
31076                    val
31077                }),
31078                57u16 => OpSetlinkDoRequest::ParentDevBusName({
31079                    let res = CStr::from_bytes_with_nul(next).ok();
31080                    let Some(val) = res else { break };
31081                    val
31082                }),
31083                58u16 => OpSetlinkDoRequest::GroMaxSize({
31084                    let res = parse_u32(next);
31085                    let Some(val) = res else { break };
31086                    val
31087                }),
31088                59u16 => OpSetlinkDoRequest::TsoMaxSize({
31089                    let res = parse_u32(next);
31090                    let Some(val) = res else { break };
31091                    val
31092                }),
31093                60u16 => OpSetlinkDoRequest::TsoMaxSegs({
31094                    let res = parse_u32(next);
31095                    let Some(val) = res else { break };
31096                    val
31097                }),
31098                61u16 => OpSetlinkDoRequest::Allmulti({
31099                    let res = parse_u32(next);
31100                    let Some(val) = res else { break };
31101                    val
31102                }),
31103                62u16 => OpSetlinkDoRequest::DevlinkPort({
31104                    let res = Some(next);
31105                    let Some(val) = res else { break };
31106                    val
31107                }),
31108                63u16 => OpSetlinkDoRequest::GsoIpv4MaxSize({
31109                    let res = parse_u32(next);
31110                    let Some(val) = res else { break };
31111                    val
31112                }),
31113                64u16 => OpSetlinkDoRequest::GroIpv4MaxSize({
31114                    let res = parse_u32(next);
31115                    let Some(val) = res else { break };
31116                    val
31117                }),
31118                65u16 => OpSetlinkDoRequest::DpllPin({
31119                    let res = Some(IterableLinkDpllPinAttrs::with_loc(next, self.orig_loc));
31120                    let Some(val) = res else { break };
31121                    val
31122                }),
31123                66u16 => OpSetlinkDoRequest::MaxPacingOffloadHorizon({
31124                    let res = parse_u32(next);
31125                    let Some(val) = res else { break };
31126                    val
31127                }),
31128                67u16 => OpSetlinkDoRequest::NetnsImmutable({
31129                    let res = parse_u8(next);
31130                    let Some(val) = res else { break };
31131                    val
31132                }),
31133                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
31134                n => continue,
31135            };
31136            return Some(Ok(res));
31137        }
31138        Some(Err(ErrorContext::new(
31139            "OpSetlinkDoRequest",
31140            r#type.and_then(|t| OpSetlinkDoRequest::attr_from_type(t)),
31141            self.orig_loc,
31142            self.buf.as_ptr().wrapping_add(pos) as usize,
31143        )))
31144    }
31145}
31146impl<'a> std::fmt::Debug for IterableOpSetlinkDoRequest<'_> {
31147    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31148        let mut fmt = f.debug_struct("OpSetlinkDoRequest");
31149        for attr in self.clone() {
31150            let attr = match attr {
31151                Ok(a) => a,
31152                Err(err) => {
31153                    fmt.finish()?;
31154                    f.write_str("Err(")?;
31155                    err.fmt(f)?;
31156                    return f.write_str(")");
31157                }
31158            };
31159            match attr {
31160                OpSetlinkDoRequest::Address(val) => fmt.field("Address", &val),
31161                OpSetlinkDoRequest::Broadcast(val) => fmt.field("Broadcast", &val),
31162                OpSetlinkDoRequest::Ifname(val) => fmt.field("Ifname", &val),
31163                OpSetlinkDoRequest::Mtu(val) => fmt.field("Mtu", &val),
31164                OpSetlinkDoRequest::Link(val) => fmt.field("Link", &val),
31165                OpSetlinkDoRequest::Qdisc(val) => fmt.field("Qdisc", &val),
31166                OpSetlinkDoRequest::Stats(val) => fmt.field("Stats", &val),
31167                OpSetlinkDoRequest::Cost(val) => fmt.field("Cost", &val),
31168                OpSetlinkDoRequest::Priority(val) => fmt.field("Priority", &val),
31169                OpSetlinkDoRequest::Master(val) => fmt.field("Master", &val),
31170                OpSetlinkDoRequest::Wireless(val) => fmt.field("Wireless", &val),
31171                OpSetlinkDoRequest::Protinfo(val) => fmt.field("Protinfo", &val),
31172                OpSetlinkDoRequest::Txqlen(val) => fmt.field("Txqlen", &val),
31173                OpSetlinkDoRequest::Map(val) => fmt.field("Map", &val),
31174                OpSetlinkDoRequest::Weight(val) => fmt.field("Weight", &val),
31175                OpSetlinkDoRequest::Operstate(val) => fmt.field("Operstate", &val),
31176                OpSetlinkDoRequest::Linkmode(val) => fmt.field("Linkmode", &val),
31177                OpSetlinkDoRequest::Linkinfo(val) => fmt.field("Linkinfo", &val),
31178                OpSetlinkDoRequest::NetNsPid(val) => fmt.field("NetNsPid", &val),
31179                OpSetlinkDoRequest::Ifalias(val) => fmt.field("Ifalias", &val),
31180                OpSetlinkDoRequest::NumVf(val) => fmt.field("NumVf", &val),
31181                OpSetlinkDoRequest::VfinfoList(val) => fmt.field("VfinfoList", &val),
31182                OpSetlinkDoRequest::Stats64(val) => fmt.field("Stats64", &val),
31183                OpSetlinkDoRequest::VfPorts(val) => fmt.field("VfPorts", &val),
31184                OpSetlinkDoRequest::PortSelf(val) => fmt.field("PortSelf", &val),
31185                OpSetlinkDoRequest::AfSpec(val) => fmt.field("AfSpec", &val),
31186                OpSetlinkDoRequest::Group(val) => fmt.field("Group", &val),
31187                OpSetlinkDoRequest::NetNsFd(val) => fmt.field("NetNsFd", &val),
31188                OpSetlinkDoRequest::ExtMask(val) => {
31189                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
31190                }
31191                OpSetlinkDoRequest::Promiscuity(val) => fmt.field("Promiscuity", &val),
31192                OpSetlinkDoRequest::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
31193                OpSetlinkDoRequest::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
31194                OpSetlinkDoRequest::Carrier(val) => fmt.field("Carrier", &val),
31195                OpSetlinkDoRequest::PhysPortId(val) => fmt.field("PhysPortId", &val),
31196                OpSetlinkDoRequest::CarrierChanges(val) => fmt.field("CarrierChanges", &val),
31197                OpSetlinkDoRequest::PhysSwitchId(val) => fmt.field("PhysSwitchId", &val),
31198                OpSetlinkDoRequest::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
31199                OpSetlinkDoRequest::PhysPortName(val) => fmt.field("PhysPortName", &val),
31200                OpSetlinkDoRequest::ProtoDown(val) => fmt.field("ProtoDown", &val),
31201                OpSetlinkDoRequest::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
31202                OpSetlinkDoRequest::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
31203                OpSetlinkDoRequest::Pad(val) => fmt.field("Pad", &val),
31204                OpSetlinkDoRequest::Xdp(val) => fmt.field("Xdp", &val),
31205                OpSetlinkDoRequest::Event(val) => fmt.field("Event", &val),
31206                OpSetlinkDoRequest::NewNetnsid(val) => fmt.field("NewNetnsid", &val),
31207                OpSetlinkDoRequest::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
31208                OpSetlinkDoRequest::CarrierUpCount(val) => fmt.field("CarrierUpCount", &val),
31209                OpSetlinkDoRequest::CarrierDownCount(val) => fmt.field("CarrierDownCount", &val),
31210                OpSetlinkDoRequest::NewIfindex(val) => fmt.field("NewIfindex", &val),
31211                OpSetlinkDoRequest::MinMtu(val) => fmt.field("MinMtu", &val),
31212                OpSetlinkDoRequest::MaxMtu(val) => fmt.field("MaxMtu", &val),
31213                OpSetlinkDoRequest::PropList(val) => fmt.field("PropList", &val),
31214                OpSetlinkDoRequest::PermAddress(val) => fmt.field("PermAddress", &val),
31215                OpSetlinkDoRequest::ProtoDownReason(val) => fmt.field("ProtoDownReason", &val),
31216                OpSetlinkDoRequest::ParentDevName(val) => fmt.field("ParentDevName", &val),
31217                OpSetlinkDoRequest::ParentDevBusName(val) => fmt.field("ParentDevBusName", &val),
31218                OpSetlinkDoRequest::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
31219                OpSetlinkDoRequest::TsoMaxSize(val) => fmt.field("TsoMaxSize", &val),
31220                OpSetlinkDoRequest::TsoMaxSegs(val) => fmt.field("TsoMaxSegs", &val),
31221                OpSetlinkDoRequest::Allmulti(val) => fmt.field("Allmulti", &val),
31222                OpSetlinkDoRequest::DevlinkPort(val) => fmt.field("DevlinkPort", &val),
31223                OpSetlinkDoRequest::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
31224                OpSetlinkDoRequest::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
31225                OpSetlinkDoRequest::DpllPin(val) => fmt.field("DpllPin", &val),
31226                OpSetlinkDoRequest::MaxPacingOffloadHorizon(val) => {
31227                    fmt.field("MaxPacingOffloadHorizon", &val)
31228                }
31229                OpSetlinkDoRequest::NetnsImmutable(val) => fmt.field("NetnsImmutable", &val),
31230            };
31231        }
31232        fmt.finish()
31233    }
31234}
31235impl IterableOpSetlinkDoRequest<'_> {
31236    pub fn lookup_attr(
31237        &self,
31238        offset: usize,
31239        missing_type: Option<u16>,
31240    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
31241        let mut stack = Vec::new();
31242        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
31243        if cur == offset + PushIfinfomsg::len() {
31244            stack.push(("OpSetlinkDoRequest", offset));
31245            return (
31246                stack,
31247                missing_type.and_then(|t| OpSetlinkDoRequest::attr_from_type(t)),
31248            );
31249        }
31250        if cur > offset || cur + self.buf.len() < offset {
31251            return (stack, None);
31252        }
31253        let mut attrs = self.clone();
31254        let mut last_off = cur + attrs.pos;
31255        let mut missing = None;
31256        while let Some(attr) = attrs.next() {
31257            let Ok(attr) = attr else { break };
31258            match attr {
31259                OpSetlinkDoRequest::Address(val) => {
31260                    if last_off == offset {
31261                        stack.push(("Address", last_off));
31262                        break;
31263                    }
31264                }
31265                OpSetlinkDoRequest::Broadcast(val) => {
31266                    if last_off == offset {
31267                        stack.push(("Broadcast", last_off));
31268                        break;
31269                    }
31270                }
31271                OpSetlinkDoRequest::Ifname(val) => {
31272                    if last_off == offset {
31273                        stack.push(("Ifname", last_off));
31274                        break;
31275                    }
31276                }
31277                OpSetlinkDoRequest::Mtu(val) => {
31278                    if last_off == offset {
31279                        stack.push(("Mtu", last_off));
31280                        break;
31281                    }
31282                }
31283                OpSetlinkDoRequest::Link(val) => {
31284                    if last_off == offset {
31285                        stack.push(("Link", last_off));
31286                        break;
31287                    }
31288                }
31289                OpSetlinkDoRequest::Qdisc(val) => {
31290                    if last_off == offset {
31291                        stack.push(("Qdisc", last_off));
31292                        break;
31293                    }
31294                }
31295                OpSetlinkDoRequest::Stats(val) => {
31296                    if last_off == offset {
31297                        stack.push(("Stats", last_off));
31298                        break;
31299                    }
31300                }
31301                OpSetlinkDoRequest::Cost(val) => {
31302                    if last_off == offset {
31303                        stack.push(("Cost", last_off));
31304                        break;
31305                    }
31306                }
31307                OpSetlinkDoRequest::Priority(val) => {
31308                    if last_off == offset {
31309                        stack.push(("Priority", last_off));
31310                        break;
31311                    }
31312                }
31313                OpSetlinkDoRequest::Master(val) => {
31314                    if last_off == offset {
31315                        stack.push(("Master", last_off));
31316                        break;
31317                    }
31318                }
31319                OpSetlinkDoRequest::Wireless(val) => {
31320                    if last_off == offset {
31321                        stack.push(("Wireless", last_off));
31322                        break;
31323                    }
31324                }
31325                OpSetlinkDoRequest::Protinfo(val) => {
31326                    if last_off == offset {
31327                        stack.push(("Protinfo", last_off));
31328                        break;
31329                    }
31330                }
31331                OpSetlinkDoRequest::Txqlen(val) => {
31332                    if last_off == offset {
31333                        stack.push(("Txqlen", last_off));
31334                        break;
31335                    }
31336                }
31337                OpSetlinkDoRequest::Map(val) => {
31338                    if last_off == offset {
31339                        stack.push(("Map", last_off));
31340                        break;
31341                    }
31342                }
31343                OpSetlinkDoRequest::Weight(val) => {
31344                    if last_off == offset {
31345                        stack.push(("Weight", last_off));
31346                        break;
31347                    }
31348                }
31349                OpSetlinkDoRequest::Operstate(val) => {
31350                    if last_off == offset {
31351                        stack.push(("Operstate", last_off));
31352                        break;
31353                    }
31354                }
31355                OpSetlinkDoRequest::Linkmode(val) => {
31356                    if last_off == offset {
31357                        stack.push(("Linkmode", last_off));
31358                        break;
31359                    }
31360                }
31361                OpSetlinkDoRequest::Linkinfo(val) => {
31362                    (stack, missing) = val.lookup_attr(offset, missing_type);
31363                    if !stack.is_empty() {
31364                        break;
31365                    }
31366                }
31367                OpSetlinkDoRequest::NetNsPid(val) => {
31368                    if last_off == offset {
31369                        stack.push(("NetNsPid", last_off));
31370                        break;
31371                    }
31372                }
31373                OpSetlinkDoRequest::Ifalias(val) => {
31374                    if last_off == offset {
31375                        stack.push(("Ifalias", last_off));
31376                        break;
31377                    }
31378                }
31379                OpSetlinkDoRequest::NumVf(val) => {
31380                    if last_off == offset {
31381                        stack.push(("NumVf", last_off));
31382                        break;
31383                    }
31384                }
31385                OpSetlinkDoRequest::VfinfoList(val) => {
31386                    (stack, missing) = val.lookup_attr(offset, missing_type);
31387                    if !stack.is_empty() {
31388                        break;
31389                    }
31390                }
31391                OpSetlinkDoRequest::Stats64(val) => {
31392                    if last_off == offset {
31393                        stack.push(("Stats64", last_off));
31394                        break;
31395                    }
31396                }
31397                OpSetlinkDoRequest::VfPorts(val) => {
31398                    (stack, missing) = val.lookup_attr(offset, missing_type);
31399                    if !stack.is_empty() {
31400                        break;
31401                    }
31402                }
31403                OpSetlinkDoRequest::PortSelf(val) => {
31404                    (stack, missing) = val.lookup_attr(offset, missing_type);
31405                    if !stack.is_empty() {
31406                        break;
31407                    }
31408                }
31409                OpSetlinkDoRequest::AfSpec(val) => {
31410                    (stack, missing) = val.lookup_attr(offset, missing_type);
31411                    if !stack.is_empty() {
31412                        break;
31413                    }
31414                }
31415                OpSetlinkDoRequest::Group(val) => {
31416                    if last_off == offset {
31417                        stack.push(("Group", last_off));
31418                        break;
31419                    }
31420                }
31421                OpSetlinkDoRequest::NetNsFd(val) => {
31422                    if last_off == offset {
31423                        stack.push(("NetNsFd", last_off));
31424                        break;
31425                    }
31426                }
31427                OpSetlinkDoRequest::ExtMask(val) => {
31428                    if last_off == offset {
31429                        stack.push(("ExtMask", last_off));
31430                        break;
31431                    }
31432                }
31433                OpSetlinkDoRequest::Promiscuity(val) => {
31434                    if last_off == offset {
31435                        stack.push(("Promiscuity", last_off));
31436                        break;
31437                    }
31438                }
31439                OpSetlinkDoRequest::NumTxQueues(val) => {
31440                    if last_off == offset {
31441                        stack.push(("NumTxQueues", last_off));
31442                        break;
31443                    }
31444                }
31445                OpSetlinkDoRequest::NumRxQueues(val) => {
31446                    if last_off == offset {
31447                        stack.push(("NumRxQueues", last_off));
31448                        break;
31449                    }
31450                }
31451                OpSetlinkDoRequest::Carrier(val) => {
31452                    if last_off == offset {
31453                        stack.push(("Carrier", last_off));
31454                        break;
31455                    }
31456                }
31457                OpSetlinkDoRequest::PhysPortId(val) => {
31458                    if last_off == offset {
31459                        stack.push(("PhysPortId", last_off));
31460                        break;
31461                    }
31462                }
31463                OpSetlinkDoRequest::CarrierChanges(val) => {
31464                    if last_off == offset {
31465                        stack.push(("CarrierChanges", last_off));
31466                        break;
31467                    }
31468                }
31469                OpSetlinkDoRequest::PhysSwitchId(val) => {
31470                    if last_off == offset {
31471                        stack.push(("PhysSwitchId", last_off));
31472                        break;
31473                    }
31474                }
31475                OpSetlinkDoRequest::LinkNetnsid(val) => {
31476                    if last_off == offset {
31477                        stack.push(("LinkNetnsid", last_off));
31478                        break;
31479                    }
31480                }
31481                OpSetlinkDoRequest::PhysPortName(val) => {
31482                    if last_off == offset {
31483                        stack.push(("PhysPortName", last_off));
31484                        break;
31485                    }
31486                }
31487                OpSetlinkDoRequest::ProtoDown(val) => {
31488                    if last_off == offset {
31489                        stack.push(("ProtoDown", last_off));
31490                        break;
31491                    }
31492                }
31493                OpSetlinkDoRequest::GsoMaxSegs(val) => {
31494                    if last_off == offset {
31495                        stack.push(("GsoMaxSegs", last_off));
31496                        break;
31497                    }
31498                }
31499                OpSetlinkDoRequest::GsoMaxSize(val) => {
31500                    if last_off == offset {
31501                        stack.push(("GsoMaxSize", last_off));
31502                        break;
31503                    }
31504                }
31505                OpSetlinkDoRequest::Pad(val) => {
31506                    if last_off == offset {
31507                        stack.push(("Pad", last_off));
31508                        break;
31509                    }
31510                }
31511                OpSetlinkDoRequest::Xdp(val) => {
31512                    (stack, missing) = val.lookup_attr(offset, missing_type);
31513                    if !stack.is_empty() {
31514                        break;
31515                    }
31516                }
31517                OpSetlinkDoRequest::Event(val) => {
31518                    if last_off == offset {
31519                        stack.push(("Event", last_off));
31520                        break;
31521                    }
31522                }
31523                OpSetlinkDoRequest::NewNetnsid(val) => {
31524                    if last_off == offset {
31525                        stack.push(("NewNetnsid", last_off));
31526                        break;
31527                    }
31528                }
31529                OpSetlinkDoRequest::TargetNetnsid(val) => {
31530                    if last_off == offset {
31531                        stack.push(("TargetNetnsid", last_off));
31532                        break;
31533                    }
31534                }
31535                OpSetlinkDoRequest::CarrierUpCount(val) => {
31536                    if last_off == offset {
31537                        stack.push(("CarrierUpCount", last_off));
31538                        break;
31539                    }
31540                }
31541                OpSetlinkDoRequest::CarrierDownCount(val) => {
31542                    if last_off == offset {
31543                        stack.push(("CarrierDownCount", last_off));
31544                        break;
31545                    }
31546                }
31547                OpSetlinkDoRequest::NewIfindex(val) => {
31548                    if last_off == offset {
31549                        stack.push(("NewIfindex", last_off));
31550                        break;
31551                    }
31552                }
31553                OpSetlinkDoRequest::MinMtu(val) => {
31554                    if last_off == offset {
31555                        stack.push(("MinMtu", last_off));
31556                        break;
31557                    }
31558                }
31559                OpSetlinkDoRequest::MaxMtu(val) => {
31560                    if last_off == offset {
31561                        stack.push(("MaxMtu", last_off));
31562                        break;
31563                    }
31564                }
31565                OpSetlinkDoRequest::PropList(val) => {
31566                    (stack, missing) = val.lookup_attr(offset, missing_type);
31567                    if !stack.is_empty() {
31568                        break;
31569                    }
31570                }
31571                OpSetlinkDoRequest::PermAddress(val) => {
31572                    if last_off == offset {
31573                        stack.push(("PermAddress", last_off));
31574                        break;
31575                    }
31576                }
31577                OpSetlinkDoRequest::ProtoDownReason(val) => {
31578                    if last_off == offset {
31579                        stack.push(("ProtoDownReason", last_off));
31580                        break;
31581                    }
31582                }
31583                OpSetlinkDoRequest::ParentDevName(val) => {
31584                    if last_off == offset {
31585                        stack.push(("ParentDevName", last_off));
31586                        break;
31587                    }
31588                }
31589                OpSetlinkDoRequest::ParentDevBusName(val) => {
31590                    if last_off == offset {
31591                        stack.push(("ParentDevBusName", last_off));
31592                        break;
31593                    }
31594                }
31595                OpSetlinkDoRequest::GroMaxSize(val) => {
31596                    if last_off == offset {
31597                        stack.push(("GroMaxSize", last_off));
31598                        break;
31599                    }
31600                }
31601                OpSetlinkDoRequest::TsoMaxSize(val) => {
31602                    if last_off == offset {
31603                        stack.push(("TsoMaxSize", last_off));
31604                        break;
31605                    }
31606                }
31607                OpSetlinkDoRequest::TsoMaxSegs(val) => {
31608                    if last_off == offset {
31609                        stack.push(("TsoMaxSegs", last_off));
31610                        break;
31611                    }
31612                }
31613                OpSetlinkDoRequest::Allmulti(val) => {
31614                    if last_off == offset {
31615                        stack.push(("Allmulti", last_off));
31616                        break;
31617                    }
31618                }
31619                OpSetlinkDoRequest::DevlinkPort(val) => {
31620                    if last_off == offset {
31621                        stack.push(("DevlinkPort", last_off));
31622                        break;
31623                    }
31624                }
31625                OpSetlinkDoRequest::GsoIpv4MaxSize(val) => {
31626                    if last_off == offset {
31627                        stack.push(("GsoIpv4MaxSize", last_off));
31628                        break;
31629                    }
31630                }
31631                OpSetlinkDoRequest::GroIpv4MaxSize(val) => {
31632                    if last_off == offset {
31633                        stack.push(("GroIpv4MaxSize", last_off));
31634                        break;
31635                    }
31636                }
31637                OpSetlinkDoRequest::DpllPin(val) => {
31638                    (stack, missing) = val.lookup_attr(offset, missing_type);
31639                    if !stack.is_empty() {
31640                        break;
31641                    }
31642                }
31643                OpSetlinkDoRequest::MaxPacingOffloadHorizon(val) => {
31644                    if last_off == offset {
31645                        stack.push(("MaxPacingOffloadHorizon", last_off));
31646                        break;
31647                    }
31648                }
31649                OpSetlinkDoRequest::NetnsImmutable(val) => {
31650                    if last_off == offset {
31651                        stack.push(("NetnsImmutable", last_off));
31652                        break;
31653                    }
31654                }
31655                _ => {}
31656            };
31657            last_off = cur + attrs.pos;
31658        }
31659        if !stack.is_empty() {
31660            stack.push(("OpSetlinkDoRequest", cur));
31661        }
31662        (stack, missing)
31663    }
31664}
31665#[doc = "Set information about a link."]
31666pub struct PushOpSetlinkDoReply<Prev: Rec> {
31667    pub(crate) prev: Option<Prev>,
31668    pub(crate) header_offset: Option<usize>,
31669}
31670impl<Prev: Rec> Rec for PushOpSetlinkDoReply<Prev> {
31671    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31672        self.prev.as_mut().unwrap().as_rec_mut()
31673    }
31674    fn as_rec(&self) -> &Vec<u8> {
31675        self.prev.as_ref().unwrap().as_rec()
31676    }
31677}
31678impl<Prev: Rec> PushOpSetlinkDoReply<Prev> {
31679    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
31680        Self::write_header(&mut prev, header);
31681        Self::new_without_header(prev)
31682    }
31683    fn new_without_header(prev: Prev) -> Self {
31684        Self {
31685            prev: Some(prev),
31686            header_offset: None,
31687        }
31688    }
31689    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
31690        prev.as_rec_mut().extend(header.as_slice());
31691    }
31692    pub fn end_nested(mut self) -> Prev {
31693        let mut prev = self.prev.take().unwrap();
31694        if let Some(header_offset) = &self.header_offset {
31695            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31696        }
31697        prev
31698    }
31699}
31700impl<Prev: Rec> Drop for PushOpSetlinkDoReply<Prev> {
31701    fn drop(&mut self) {
31702        if let Some(prev) = &mut self.prev {
31703            if let Some(header_offset) = &self.header_offset {
31704                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31705            }
31706        }
31707    }
31708}
31709#[doc = "Set information about a link."]
31710#[derive(Clone)]
31711pub enum OpSetlinkDoReply {}
31712impl<'a> IterableOpSetlinkDoReply<'a> {}
31713impl OpSetlinkDoReply {
31714    pub fn new<'a>(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpSetlinkDoReply<'a>) {
31715        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
31716        (
31717            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
31718            IterableOpSetlinkDoReply::with_loc(attrs, buf.as_ptr() as usize),
31719        )
31720    }
31721    fn attr_from_type(r#type: u16) -> Option<&'static str> {
31722        LinkAttrs::attr_from_type(r#type)
31723    }
31724}
31725#[derive(Clone, Copy, Default)]
31726pub struct IterableOpSetlinkDoReply<'a> {
31727    buf: &'a [u8],
31728    pos: usize,
31729    orig_loc: usize,
31730}
31731impl<'a> IterableOpSetlinkDoReply<'a> {
31732    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
31733        Self {
31734            buf,
31735            pos: 0,
31736            orig_loc,
31737        }
31738    }
31739    pub fn get_buf(&self) -> &'a [u8] {
31740        self.buf
31741    }
31742}
31743impl<'a> Iterator for IterableOpSetlinkDoReply<'a> {
31744    type Item = Result<OpSetlinkDoReply, ErrorContext>;
31745    fn next(&mut self) -> Option<Self::Item> {
31746        let pos = self.pos;
31747        let mut r#type;
31748        loop {
31749            r#type = None;
31750            if self.buf.len() == self.pos {
31751                return None;
31752            }
31753            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
31754                break;
31755            };
31756            r#type = Some(header.r#type);
31757            let res = match header.r#type {
31758                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
31759                n => continue,
31760            };
31761            return Some(Ok(res));
31762        }
31763        Some(Err(ErrorContext::new(
31764            "OpSetlinkDoReply",
31765            r#type.and_then(|t| OpSetlinkDoReply::attr_from_type(t)),
31766            self.orig_loc,
31767            self.buf.as_ptr().wrapping_add(pos) as usize,
31768        )))
31769    }
31770}
31771impl std::fmt::Debug for IterableOpSetlinkDoReply<'_> {
31772    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31773        let mut fmt = f.debug_struct("OpSetlinkDoReply");
31774        for attr in self.clone() {
31775            let attr = match attr {
31776                Ok(a) => a,
31777                Err(err) => {
31778                    fmt.finish()?;
31779                    f.write_str("Err(")?;
31780                    err.fmt(f)?;
31781                    return f.write_str(")");
31782                }
31783            };
31784            match attr {};
31785        }
31786        fmt.finish()
31787    }
31788}
31789impl IterableOpSetlinkDoReply<'_> {
31790    pub fn lookup_attr(
31791        &self,
31792        offset: usize,
31793        missing_type: Option<u16>,
31794    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
31795        let mut stack = Vec::new();
31796        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
31797        if cur == offset + PushIfinfomsg::len() {
31798            stack.push(("OpSetlinkDoReply", offset));
31799            return (
31800                stack,
31801                missing_type.and_then(|t| OpSetlinkDoReply::attr_from_type(t)),
31802            );
31803        }
31804        (stack, None)
31805    }
31806}
31807#[derive(Debug)]
31808pub struct RequestOpSetlinkDoRequest<'r> {
31809    request: Request<'r>,
31810}
31811impl<'r> RequestOpSetlinkDoRequest<'r> {
31812    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
31813        PushOpSetlinkDoRequest::write_header(&mut request.buf_mut(), header);
31814        Self { request: request }
31815    }
31816    pub fn encode(&mut self) -> PushOpSetlinkDoRequest<&mut Vec<u8>> {
31817        PushOpSetlinkDoRequest::new_without_header(self.request.buf_mut())
31818    }
31819    pub fn into_encoder(self) -> PushOpSetlinkDoRequest<RequestBuf<'r>> {
31820        PushOpSetlinkDoRequest::new_without_header(self.request.buf)
31821    }
31822    pub fn decode_request<'buf>(
31823        buf: &'buf [u8],
31824    ) -> (PushIfinfomsg, IterableOpSetlinkDoRequest<'buf>) {
31825        OpSetlinkDoRequest::new(buf)
31826    }
31827}
31828impl NetlinkRequest for RequestOpSetlinkDoRequest<'_> {
31829    fn protocol(&self) -> Protocol {
31830        Protocol::Raw {
31831            protonum: 0u16,
31832            request_type: 19u16,
31833        }
31834    }
31835    fn flags(&self) -> u16 {
31836        self.request.flags
31837    }
31838    fn payload(&self) -> &[u8] {
31839        self.request.buf()
31840    }
31841    type ReplyType<'buf> = (PushIfinfomsg, IterableOpSetlinkDoReply<'buf>);
31842    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
31843        OpSetlinkDoReply::new(buf)
31844    }
31845    fn lookup(
31846        buf: &[u8],
31847        offset: usize,
31848        missing_type: Option<u16>,
31849    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
31850        OpSetlinkDoRequest::new(buf)
31851            .1
31852            .lookup_attr(offset, missing_type)
31853    }
31854}
31855#[doc = "Get / dump link stats."]
31856pub struct PushOpGetstatsDumpRequest<Prev: Rec> {
31857    pub(crate) prev: Option<Prev>,
31858    pub(crate) header_offset: Option<usize>,
31859}
31860impl<Prev: Rec> Rec for PushOpGetstatsDumpRequest<Prev> {
31861    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31862        self.prev.as_mut().unwrap().as_rec_mut()
31863    }
31864    fn as_rec(&self) -> &Vec<u8> {
31865        self.prev.as_ref().unwrap().as_rec()
31866    }
31867}
31868impl<Prev: Rec> PushOpGetstatsDumpRequest<Prev> {
31869    pub fn new(mut prev: Prev, header: &PushIfStatsMsg) -> Self {
31870        Self::write_header(&mut prev, header);
31871        Self::new_without_header(prev)
31872    }
31873    fn new_without_header(prev: Prev) -> Self {
31874        Self {
31875            prev: Some(prev),
31876            header_offset: None,
31877        }
31878    }
31879    fn write_header(prev: &mut Prev, header: &PushIfStatsMsg) {
31880        prev.as_rec_mut().extend(header.as_slice());
31881    }
31882    pub fn end_nested(mut self) -> Prev {
31883        let mut prev = self.prev.take().unwrap();
31884        if let Some(header_offset) = &self.header_offset {
31885            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31886        }
31887        prev
31888    }
31889}
31890impl<Prev: Rec> Drop for PushOpGetstatsDumpRequest<Prev> {
31891    fn drop(&mut self) {
31892        if let Some(prev) = &mut self.prev {
31893            if let Some(header_offset) = &self.header_offset {
31894                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31895            }
31896        }
31897    }
31898}
31899#[doc = "Get / dump link stats."]
31900#[derive(Clone)]
31901pub enum OpGetstatsDumpRequest {}
31902impl<'a> IterableOpGetstatsDumpRequest<'a> {}
31903impl OpGetstatsDumpRequest {
31904    pub fn new<'a>(buf: &'a [u8]) -> (PushIfStatsMsg, IterableOpGetstatsDumpRequest<'a>) {
31905        let (header, attrs) = buf.split_at(buf.len().min(PushIfStatsMsg::len()));
31906        (
31907            PushIfStatsMsg::new_from_slice(header).unwrap_or_default(),
31908            IterableOpGetstatsDumpRequest::with_loc(attrs, buf.as_ptr() as usize),
31909        )
31910    }
31911    fn attr_from_type(r#type: u16) -> Option<&'static str> {
31912        StatsAttrs::attr_from_type(r#type)
31913    }
31914}
31915#[derive(Clone, Copy, Default)]
31916pub struct IterableOpGetstatsDumpRequest<'a> {
31917    buf: &'a [u8],
31918    pos: usize,
31919    orig_loc: usize,
31920}
31921impl<'a> IterableOpGetstatsDumpRequest<'a> {
31922    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
31923        Self {
31924            buf,
31925            pos: 0,
31926            orig_loc,
31927        }
31928    }
31929    pub fn get_buf(&self) -> &'a [u8] {
31930        self.buf
31931    }
31932}
31933impl<'a> Iterator for IterableOpGetstatsDumpRequest<'a> {
31934    type Item = Result<OpGetstatsDumpRequest, ErrorContext>;
31935    fn next(&mut self) -> Option<Self::Item> {
31936        let pos = self.pos;
31937        let mut r#type;
31938        loop {
31939            r#type = None;
31940            if self.buf.len() == self.pos {
31941                return None;
31942            }
31943            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
31944                break;
31945            };
31946            r#type = Some(header.r#type);
31947            let res = match header.r#type {
31948                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
31949                n => continue,
31950            };
31951            return Some(Ok(res));
31952        }
31953        Some(Err(ErrorContext::new(
31954            "OpGetstatsDumpRequest",
31955            r#type.and_then(|t| OpGetstatsDumpRequest::attr_from_type(t)),
31956            self.orig_loc,
31957            self.buf.as_ptr().wrapping_add(pos) as usize,
31958        )))
31959    }
31960}
31961impl std::fmt::Debug for IterableOpGetstatsDumpRequest<'_> {
31962    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31963        let mut fmt = f.debug_struct("OpGetstatsDumpRequest");
31964        for attr in self.clone() {
31965            let attr = match attr {
31966                Ok(a) => a,
31967                Err(err) => {
31968                    fmt.finish()?;
31969                    f.write_str("Err(")?;
31970                    err.fmt(f)?;
31971                    return f.write_str(")");
31972                }
31973            };
31974            match attr {};
31975        }
31976        fmt.finish()
31977    }
31978}
31979impl IterableOpGetstatsDumpRequest<'_> {
31980    pub fn lookup_attr(
31981        &self,
31982        offset: usize,
31983        missing_type: Option<u16>,
31984    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
31985        let mut stack = Vec::new();
31986        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
31987        if cur == offset + PushIfStatsMsg::len() {
31988            stack.push(("OpGetstatsDumpRequest", offset));
31989            return (
31990                stack,
31991                missing_type.and_then(|t| OpGetstatsDumpRequest::attr_from_type(t)),
31992            );
31993        }
31994        (stack, None)
31995    }
31996}
31997#[doc = "Get / dump link stats."]
31998pub struct PushOpGetstatsDumpReply<Prev: Rec> {
31999    pub(crate) prev: Option<Prev>,
32000    pub(crate) header_offset: Option<usize>,
32001}
32002impl<Prev: Rec> Rec for PushOpGetstatsDumpReply<Prev> {
32003    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32004        self.prev.as_mut().unwrap().as_rec_mut()
32005    }
32006    fn as_rec(&self) -> &Vec<u8> {
32007        self.prev.as_ref().unwrap().as_rec()
32008    }
32009}
32010impl<Prev: Rec> PushOpGetstatsDumpReply<Prev> {
32011    pub fn new(mut prev: Prev, header: &PushIfStatsMsg) -> Self {
32012        Self::write_header(&mut prev, header);
32013        Self::new_without_header(prev)
32014    }
32015    fn new_without_header(prev: Prev) -> Self {
32016        Self {
32017            prev: Some(prev),
32018            header_offset: None,
32019        }
32020    }
32021    fn write_header(prev: &mut Prev, header: &PushIfStatsMsg) {
32022        prev.as_rec_mut().extend(header.as_slice());
32023    }
32024    pub fn end_nested(mut self) -> Prev {
32025        let mut prev = self.prev.take().unwrap();
32026        if let Some(header_offset) = &self.header_offset {
32027            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32028        }
32029        prev
32030    }
32031    pub fn push_link_64(mut self, value: PushRtnlLinkStats64) -> Self {
32032        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32033        self.as_rec_mut().extend(value.as_slice());
32034        self
32035    }
32036    pub fn push_link_xstats(mut self, value: &[u8]) -> Self {
32037        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32038        self.as_rec_mut().extend(value);
32039        self
32040    }
32041    pub fn push_link_xstats_slave(mut self, value: &[u8]) -> Self {
32042        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32043        self.as_rec_mut().extend(value);
32044        self
32045    }
32046    pub fn nested_link_offload_xstats(mut self) -> PushLinkOffloadXstats<Self> {
32047        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
32048        PushLinkOffloadXstats {
32049            prev: Some(self),
32050            header_offset: Some(header_offset),
32051        }
32052    }
32053    pub fn push_af_spec(mut self, value: &[u8]) -> Self {
32054        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
32055        self.as_rec_mut().extend(value);
32056        self
32057    }
32058}
32059impl<Prev: Rec> Drop for PushOpGetstatsDumpReply<Prev> {
32060    fn drop(&mut self) {
32061        if let Some(prev) = &mut self.prev {
32062            if let Some(header_offset) = &self.header_offset {
32063                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32064            }
32065        }
32066    }
32067}
32068#[doc = "Get / dump link stats."]
32069#[derive(Clone)]
32070pub enum OpGetstatsDumpReply<'a> {
32071    Link64(PushRtnlLinkStats64),
32072    LinkXstats(&'a [u8]),
32073    LinkXstatsSlave(&'a [u8]),
32074    LinkOffloadXstats(IterableLinkOffloadXstats<'a>),
32075    AfSpec(&'a [u8]),
32076}
32077impl<'a> IterableOpGetstatsDumpReply<'a> {
32078    pub fn get_link_64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
32079        let mut iter = self.clone();
32080        iter.pos = 0;
32081        for attr in iter {
32082            if let OpGetstatsDumpReply::Link64(val) = attr? {
32083                return Ok(val);
32084            }
32085        }
32086        Err(ErrorContext::new_missing(
32087            "OpGetstatsDumpReply",
32088            "Link64",
32089            self.orig_loc,
32090            self.buf.as_ptr() as usize,
32091        ))
32092    }
32093    pub fn get_link_xstats(&self) -> Result<&'a [u8], ErrorContext> {
32094        let mut iter = self.clone();
32095        iter.pos = 0;
32096        for attr in iter {
32097            if let OpGetstatsDumpReply::LinkXstats(val) = attr? {
32098                return Ok(val);
32099            }
32100        }
32101        Err(ErrorContext::new_missing(
32102            "OpGetstatsDumpReply",
32103            "LinkXstats",
32104            self.orig_loc,
32105            self.buf.as_ptr() as usize,
32106        ))
32107    }
32108    pub fn get_link_xstats_slave(&self) -> Result<&'a [u8], ErrorContext> {
32109        let mut iter = self.clone();
32110        iter.pos = 0;
32111        for attr in iter {
32112            if let OpGetstatsDumpReply::LinkXstatsSlave(val) = attr? {
32113                return Ok(val);
32114            }
32115        }
32116        Err(ErrorContext::new_missing(
32117            "OpGetstatsDumpReply",
32118            "LinkXstatsSlave",
32119            self.orig_loc,
32120            self.buf.as_ptr() as usize,
32121        ))
32122    }
32123    pub fn get_link_offload_xstats(&self) -> Result<IterableLinkOffloadXstats<'a>, ErrorContext> {
32124        let mut iter = self.clone();
32125        iter.pos = 0;
32126        for attr in iter {
32127            if let OpGetstatsDumpReply::LinkOffloadXstats(val) = attr? {
32128                return Ok(val);
32129            }
32130        }
32131        Err(ErrorContext::new_missing(
32132            "OpGetstatsDumpReply",
32133            "LinkOffloadXstats",
32134            self.orig_loc,
32135            self.buf.as_ptr() as usize,
32136        ))
32137    }
32138    pub fn get_af_spec(&self) -> Result<&'a [u8], ErrorContext> {
32139        let mut iter = self.clone();
32140        iter.pos = 0;
32141        for attr in iter {
32142            if let OpGetstatsDumpReply::AfSpec(val) = attr? {
32143                return Ok(val);
32144            }
32145        }
32146        Err(ErrorContext::new_missing(
32147            "OpGetstatsDumpReply",
32148            "AfSpec",
32149            self.orig_loc,
32150            self.buf.as_ptr() as usize,
32151        ))
32152    }
32153}
32154impl OpGetstatsDumpReply<'_> {
32155    pub fn new<'a>(buf: &'a [u8]) -> (PushIfStatsMsg, IterableOpGetstatsDumpReply<'a>) {
32156        let (header, attrs) = buf.split_at(buf.len().min(PushIfStatsMsg::len()));
32157        (
32158            PushIfStatsMsg::new_from_slice(header).unwrap_or_default(),
32159            IterableOpGetstatsDumpReply::with_loc(attrs, buf.as_ptr() as usize),
32160        )
32161    }
32162    fn attr_from_type(r#type: u16) -> Option<&'static str> {
32163        StatsAttrs::attr_from_type(r#type)
32164    }
32165}
32166#[derive(Clone, Copy, Default)]
32167pub struct IterableOpGetstatsDumpReply<'a> {
32168    buf: &'a [u8],
32169    pos: usize,
32170    orig_loc: usize,
32171}
32172impl<'a> IterableOpGetstatsDumpReply<'a> {
32173    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
32174        Self {
32175            buf,
32176            pos: 0,
32177            orig_loc,
32178        }
32179    }
32180    pub fn get_buf(&self) -> &'a [u8] {
32181        self.buf
32182    }
32183}
32184impl<'a> Iterator for IterableOpGetstatsDumpReply<'a> {
32185    type Item = Result<OpGetstatsDumpReply<'a>, ErrorContext>;
32186    fn next(&mut self) -> Option<Self::Item> {
32187        let pos = self.pos;
32188        let mut r#type;
32189        loop {
32190            r#type = None;
32191            if self.buf.len() == self.pos {
32192                return None;
32193            }
32194            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
32195                break;
32196            };
32197            r#type = Some(header.r#type);
32198            let res = match header.r#type {
32199                1u16 => OpGetstatsDumpReply::Link64({
32200                    let res = Some(PushRtnlLinkStats64::new_from_zeroed(next));
32201                    let Some(val) = res else { break };
32202                    val
32203                }),
32204                2u16 => OpGetstatsDumpReply::LinkXstats({
32205                    let res = Some(next);
32206                    let Some(val) = res else { break };
32207                    val
32208                }),
32209                3u16 => OpGetstatsDumpReply::LinkXstatsSlave({
32210                    let res = Some(next);
32211                    let Some(val) = res else { break };
32212                    val
32213                }),
32214                4u16 => OpGetstatsDumpReply::LinkOffloadXstats({
32215                    let res = Some(IterableLinkOffloadXstats::with_loc(next, self.orig_loc));
32216                    let Some(val) = res else { break };
32217                    val
32218                }),
32219                5u16 => OpGetstatsDumpReply::AfSpec({
32220                    let res = Some(next);
32221                    let Some(val) = res else { break };
32222                    val
32223                }),
32224                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
32225                n => continue,
32226            };
32227            return Some(Ok(res));
32228        }
32229        Some(Err(ErrorContext::new(
32230            "OpGetstatsDumpReply",
32231            r#type.and_then(|t| OpGetstatsDumpReply::attr_from_type(t)),
32232            self.orig_loc,
32233            self.buf.as_ptr().wrapping_add(pos) as usize,
32234        )))
32235    }
32236}
32237impl<'a> std::fmt::Debug for IterableOpGetstatsDumpReply<'_> {
32238    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32239        let mut fmt = f.debug_struct("OpGetstatsDumpReply");
32240        for attr in self.clone() {
32241            let attr = match attr {
32242                Ok(a) => a,
32243                Err(err) => {
32244                    fmt.finish()?;
32245                    f.write_str("Err(")?;
32246                    err.fmt(f)?;
32247                    return f.write_str(")");
32248                }
32249            };
32250            match attr {
32251                OpGetstatsDumpReply::Link64(val) => fmt.field("Link64", &val),
32252                OpGetstatsDumpReply::LinkXstats(val) => fmt.field("LinkXstats", &val),
32253                OpGetstatsDumpReply::LinkXstatsSlave(val) => fmt.field("LinkXstatsSlave", &val),
32254                OpGetstatsDumpReply::LinkOffloadXstats(val) => fmt.field("LinkOffloadXstats", &val),
32255                OpGetstatsDumpReply::AfSpec(val) => fmt.field("AfSpec", &val),
32256            };
32257        }
32258        fmt.finish()
32259    }
32260}
32261impl IterableOpGetstatsDumpReply<'_> {
32262    pub fn lookup_attr(
32263        &self,
32264        offset: usize,
32265        missing_type: Option<u16>,
32266    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32267        let mut stack = Vec::new();
32268        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
32269        if cur == offset + PushIfStatsMsg::len() {
32270            stack.push(("OpGetstatsDumpReply", offset));
32271            return (
32272                stack,
32273                missing_type.and_then(|t| OpGetstatsDumpReply::attr_from_type(t)),
32274            );
32275        }
32276        if cur > offset || cur + self.buf.len() < offset {
32277            return (stack, None);
32278        }
32279        let mut attrs = self.clone();
32280        let mut last_off = cur + attrs.pos;
32281        let mut missing = None;
32282        while let Some(attr) = attrs.next() {
32283            let Ok(attr) = attr else { break };
32284            match attr {
32285                OpGetstatsDumpReply::Link64(val) => {
32286                    if last_off == offset {
32287                        stack.push(("Link64", last_off));
32288                        break;
32289                    }
32290                }
32291                OpGetstatsDumpReply::LinkXstats(val) => {
32292                    if last_off == offset {
32293                        stack.push(("LinkXstats", last_off));
32294                        break;
32295                    }
32296                }
32297                OpGetstatsDumpReply::LinkXstatsSlave(val) => {
32298                    if last_off == offset {
32299                        stack.push(("LinkXstatsSlave", last_off));
32300                        break;
32301                    }
32302                }
32303                OpGetstatsDumpReply::LinkOffloadXstats(val) => {
32304                    (stack, missing) = val.lookup_attr(offset, missing_type);
32305                    if !stack.is_empty() {
32306                        break;
32307                    }
32308                }
32309                OpGetstatsDumpReply::AfSpec(val) => {
32310                    if last_off == offset {
32311                        stack.push(("AfSpec", last_off));
32312                        break;
32313                    }
32314                }
32315                _ => {}
32316            };
32317            last_off = cur + attrs.pos;
32318        }
32319        if !stack.is_empty() {
32320            stack.push(("OpGetstatsDumpReply", cur));
32321        }
32322        (stack, missing)
32323    }
32324}
32325#[derive(Debug)]
32326pub struct RequestOpGetstatsDumpRequest<'r> {
32327    request: Request<'r>,
32328}
32329impl<'r> RequestOpGetstatsDumpRequest<'r> {
32330    pub fn new(mut request: Request<'r>, header: &PushIfStatsMsg) -> Self {
32331        PushOpGetstatsDumpRequest::write_header(&mut request.buf_mut(), header);
32332        Self {
32333            request: request.set_dump(),
32334        }
32335    }
32336    pub fn encode(&mut self) -> PushOpGetstatsDumpRequest<&mut Vec<u8>> {
32337        PushOpGetstatsDumpRequest::new_without_header(self.request.buf_mut())
32338    }
32339    pub fn into_encoder(self) -> PushOpGetstatsDumpRequest<RequestBuf<'r>> {
32340        PushOpGetstatsDumpRequest::new_without_header(self.request.buf)
32341    }
32342    pub fn decode_request<'buf>(
32343        buf: &'buf [u8],
32344    ) -> (PushIfStatsMsg, IterableOpGetstatsDumpRequest<'buf>) {
32345        OpGetstatsDumpRequest::new(buf)
32346    }
32347}
32348impl NetlinkRequest for RequestOpGetstatsDumpRequest<'_> {
32349    fn protocol(&self) -> Protocol {
32350        Protocol::Raw {
32351            protonum: 0u16,
32352            request_type: 94u16,
32353        }
32354    }
32355    fn flags(&self) -> u16 {
32356        self.request.flags
32357    }
32358    fn payload(&self) -> &[u8] {
32359        self.request.buf()
32360    }
32361    type ReplyType<'buf> = (PushIfStatsMsg, IterableOpGetstatsDumpReply<'buf>);
32362    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
32363        OpGetstatsDumpReply::new(buf)
32364    }
32365    fn lookup(
32366        buf: &[u8],
32367        offset: usize,
32368        missing_type: Option<u16>,
32369    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32370        OpGetstatsDumpRequest::new(buf)
32371            .1
32372            .lookup_attr(offset, missing_type)
32373    }
32374}
32375#[doc = "Get / dump link stats."]
32376pub struct PushOpGetstatsDoRequest<Prev: Rec> {
32377    pub(crate) prev: Option<Prev>,
32378    pub(crate) header_offset: Option<usize>,
32379}
32380impl<Prev: Rec> Rec for PushOpGetstatsDoRequest<Prev> {
32381    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32382        self.prev.as_mut().unwrap().as_rec_mut()
32383    }
32384    fn as_rec(&self) -> &Vec<u8> {
32385        self.prev.as_ref().unwrap().as_rec()
32386    }
32387}
32388impl<Prev: Rec> PushOpGetstatsDoRequest<Prev> {
32389    pub fn new(mut prev: Prev, header: &PushIfStatsMsg) -> Self {
32390        Self::write_header(&mut prev, header);
32391        Self::new_without_header(prev)
32392    }
32393    fn new_without_header(prev: Prev) -> Self {
32394        Self {
32395            prev: Some(prev),
32396            header_offset: None,
32397        }
32398    }
32399    fn write_header(prev: &mut Prev, header: &PushIfStatsMsg) {
32400        prev.as_rec_mut().extend(header.as_slice());
32401    }
32402    pub fn end_nested(mut self) -> Prev {
32403        let mut prev = self.prev.take().unwrap();
32404        if let Some(header_offset) = &self.header_offset {
32405            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32406        }
32407        prev
32408    }
32409}
32410impl<Prev: Rec> Drop for PushOpGetstatsDoRequest<Prev> {
32411    fn drop(&mut self) {
32412        if let Some(prev) = &mut self.prev {
32413            if let Some(header_offset) = &self.header_offset {
32414                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32415            }
32416        }
32417    }
32418}
32419#[doc = "Get / dump link stats."]
32420#[derive(Clone)]
32421pub enum OpGetstatsDoRequest {}
32422impl<'a> IterableOpGetstatsDoRequest<'a> {}
32423impl OpGetstatsDoRequest {
32424    pub fn new<'a>(buf: &'a [u8]) -> (PushIfStatsMsg, IterableOpGetstatsDoRequest<'a>) {
32425        let (header, attrs) = buf.split_at(buf.len().min(PushIfStatsMsg::len()));
32426        (
32427            PushIfStatsMsg::new_from_slice(header).unwrap_or_default(),
32428            IterableOpGetstatsDoRequest::with_loc(attrs, buf.as_ptr() as usize),
32429        )
32430    }
32431    fn attr_from_type(r#type: u16) -> Option<&'static str> {
32432        StatsAttrs::attr_from_type(r#type)
32433    }
32434}
32435#[derive(Clone, Copy, Default)]
32436pub struct IterableOpGetstatsDoRequest<'a> {
32437    buf: &'a [u8],
32438    pos: usize,
32439    orig_loc: usize,
32440}
32441impl<'a> IterableOpGetstatsDoRequest<'a> {
32442    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
32443        Self {
32444            buf,
32445            pos: 0,
32446            orig_loc,
32447        }
32448    }
32449    pub fn get_buf(&self) -> &'a [u8] {
32450        self.buf
32451    }
32452}
32453impl<'a> Iterator for IterableOpGetstatsDoRequest<'a> {
32454    type Item = Result<OpGetstatsDoRequest, ErrorContext>;
32455    fn next(&mut self) -> Option<Self::Item> {
32456        let pos = self.pos;
32457        let mut r#type;
32458        loop {
32459            r#type = None;
32460            if self.buf.len() == self.pos {
32461                return None;
32462            }
32463            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
32464                break;
32465            };
32466            r#type = Some(header.r#type);
32467            let res = match header.r#type {
32468                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
32469                n => continue,
32470            };
32471            return Some(Ok(res));
32472        }
32473        Some(Err(ErrorContext::new(
32474            "OpGetstatsDoRequest",
32475            r#type.and_then(|t| OpGetstatsDoRequest::attr_from_type(t)),
32476            self.orig_loc,
32477            self.buf.as_ptr().wrapping_add(pos) as usize,
32478        )))
32479    }
32480}
32481impl std::fmt::Debug for IterableOpGetstatsDoRequest<'_> {
32482    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32483        let mut fmt = f.debug_struct("OpGetstatsDoRequest");
32484        for attr in self.clone() {
32485            let attr = match attr {
32486                Ok(a) => a,
32487                Err(err) => {
32488                    fmt.finish()?;
32489                    f.write_str("Err(")?;
32490                    err.fmt(f)?;
32491                    return f.write_str(")");
32492                }
32493            };
32494            match attr {};
32495        }
32496        fmt.finish()
32497    }
32498}
32499impl IterableOpGetstatsDoRequest<'_> {
32500    pub fn lookup_attr(
32501        &self,
32502        offset: usize,
32503        missing_type: Option<u16>,
32504    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32505        let mut stack = Vec::new();
32506        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
32507        if cur == offset + PushIfStatsMsg::len() {
32508            stack.push(("OpGetstatsDoRequest", offset));
32509            return (
32510                stack,
32511                missing_type.and_then(|t| OpGetstatsDoRequest::attr_from_type(t)),
32512            );
32513        }
32514        (stack, None)
32515    }
32516}
32517#[doc = "Get / dump link stats."]
32518pub struct PushOpGetstatsDoReply<Prev: Rec> {
32519    pub(crate) prev: Option<Prev>,
32520    pub(crate) header_offset: Option<usize>,
32521}
32522impl<Prev: Rec> Rec for PushOpGetstatsDoReply<Prev> {
32523    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32524        self.prev.as_mut().unwrap().as_rec_mut()
32525    }
32526    fn as_rec(&self) -> &Vec<u8> {
32527        self.prev.as_ref().unwrap().as_rec()
32528    }
32529}
32530impl<Prev: Rec> PushOpGetstatsDoReply<Prev> {
32531    pub fn new(mut prev: Prev, header: &PushIfStatsMsg) -> Self {
32532        Self::write_header(&mut prev, header);
32533        Self::new_without_header(prev)
32534    }
32535    fn new_without_header(prev: Prev) -> Self {
32536        Self {
32537            prev: Some(prev),
32538            header_offset: None,
32539        }
32540    }
32541    fn write_header(prev: &mut Prev, header: &PushIfStatsMsg) {
32542        prev.as_rec_mut().extend(header.as_slice());
32543    }
32544    pub fn end_nested(mut self) -> Prev {
32545        let mut prev = self.prev.take().unwrap();
32546        if let Some(header_offset) = &self.header_offset {
32547            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32548        }
32549        prev
32550    }
32551    pub fn push_link_64(mut self, value: PushRtnlLinkStats64) -> Self {
32552        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32553        self.as_rec_mut().extend(value.as_slice());
32554        self
32555    }
32556    pub fn push_link_xstats(mut self, value: &[u8]) -> Self {
32557        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32558        self.as_rec_mut().extend(value);
32559        self
32560    }
32561    pub fn push_link_xstats_slave(mut self, value: &[u8]) -> Self {
32562        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32563        self.as_rec_mut().extend(value);
32564        self
32565    }
32566    pub fn nested_link_offload_xstats(mut self) -> PushLinkOffloadXstats<Self> {
32567        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
32568        PushLinkOffloadXstats {
32569            prev: Some(self),
32570            header_offset: Some(header_offset),
32571        }
32572    }
32573    pub fn push_af_spec(mut self, value: &[u8]) -> Self {
32574        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
32575        self.as_rec_mut().extend(value);
32576        self
32577    }
32578}
32579impl<Prev: Rec> Drop for PushOpGetstatsDoReply<Prev> {
32580    fn drop(&mut self) {
32581        if let Some(prev) = &mut self.prev {
32582            if let Some(header_offset) = &self.header_offset {
32583                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32584            }
32585        }
32586    }
32587}
32588#[doc = "Get / dump link stats."]
32589#[derive(Clone)]
32590pub enum OpGetstatsDoReply<'a> {
32591    Link64(PushRtnlLinkStats64),
32592    LinkXstats(&'a [u8]),
32593    LinkXstatsSlave(&'a [u8]),
32594    LinkOffloadXstats(IterableLinkOffloadXstats<'a>),
32595    AfSpec(&'a [u8]),
32596}
32597impl<'a> IterableOpGetstatsDoReply<'a> {
32598    pub fn get_link_64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
32599        let mut iter = self.clone();
32600        iter.pos = 0;
32601        for attr in iter {
32602            if let OpGetstatsDoReply::Link64(val) = attr? {
32603                return Ok(val);
32604            }
32605        }
32606        Err(ErrorContext::new_missing(
32607            "OpGetstatsDoReply",
32608            "Link64",
32609            self.orig_loc,
32610            self.buf.as_ptr() as usize,
32611        ))
32612    }
32613    pub fn get_link_xstats(&self) -> Result<&'a [u8], ErrorContext> {
32614        let mut iter = self.clone();
32615        iter.pos = 0;
32616        for attr in iter {
32617            if let OpGetstatsDoReply::LinkXstats(val) = attr? {
32618                return Ok(val);
32619            }
32620        }
32621        Err(ErrorContext::new_missing(
32622            "OpGetstatsDoReply",
32623            "LinkXstats",
32624            self.orig_loc,
32625            self.buf.as_ptr() as usize,
32626        ))
32627    }
32628    pub fn get_link_xstats_slave(&self) -> Result<&'a [u8], ErrorContext> {
32629        let mut iter = self.clone();
32630        iter.pos = 0;
32631        for attr in iter {
32632            if let OpGetstatsDoReply::LinkXstatsSlave(val) = attr? {
32633                return Ok(val);
32634            }
32635        }
32636        Err(ErrorContext::new_missing(
32637            "OpGetstatsDoReply",
32638            "LinkXstatsSlave",
32639            self.orig_loc,
32640            self.buf.as_ptr() as usize,
32641        ))
32642    }
32643    pub fn get_link_offload_xstats(&self) -> Result<IterableLinkOffloadXstats<'a>, ErrorContext> {
32644        let mut iter = self.clone();
32645        iter.pos = 0;
32646        for attr in iter {
32647            if let OpGetstatsDoReply::LinkOffloadXstats(val) = attr? {
32648                return Ok(val);
32649            }
32650        }
32651        Err(ErrorContext::new_missing(
32652            "OpGetstatsDoReply",
32653            "LinkOffloadXstats",
32654            self.orig_loc,
32655            self.buf.as_ptr() as usize,
32656        ))
32657    }
32658    pub fn get_af_spec(&self) -> Result<&'a [u8], ErrorContext> {
32659        let mut iter = self.clone();
32660        iter.pos = 0;
32661        for attr in iter {
32662            if let OpGetstatsDoReply::AfSpec(val) = attr? {
32663                return Ok(val);
32664            }
32665        }
32666        Err(ErrorContext::new_missing(
32667            "OpGetstatsDoReply",
32668            "AfSpec",
32669            self.orig_loc,
32670            self.buf.as_ptr() as usize,
32671        ))
32672    }
32673}
32674impl OpGetstatsDoReply<'_> {
32675    pub fn new<'a>(buf: &'a [u8]) -> (PushIfStatsMsg, IterableOpGetstatsDoReply<'a>) {
32676        let (header, attrs) = buf.split_at(buf.len().min(PushIfStatsMsg::len()));
32677        (
32678            PushIfStatsMsg::new_from_slice(header).unwrap_or_default(),
32679            IterableOpGetstatsDoReply::with_loc(attrs, buf.as_ptr() as usize),
32680        )
32681    }
32682    fn attr_from_type(r#type: u16) -> Option<&'static str> {
32683        StatsAttrs::attr_from_type(r#type)
32684    }
32685}
32686#[derive(Clone, Copy, Default)]
32687pub struct IterableOpGetstatsDoReply<'a> {
32688    buf: &'a [u8],
32689    pos: usize,
32690    orig_loc: usize,
32691}
32692impl<'a> IterableOpGetstatsDoReply<'a> {
32693    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
32694        Self {
32695            buf,
32696            pos: 0,
32697            orig_loc,
32698        }
32699    }
32700    pub fn get_buf(&self) -> &'a [u8] {
32701        self.buf
32702    }
32703}
32704impl<'a> Iterator for IterableOpGetstatsDoReply<'a> {
32705    type Item = Result<OpGetstatsDoReply<'a>, ErrorContext>;
32706    fn next(&mut self) -> Option<Self::Item> {
32707        let pos = self.pos;
32708        let mut r#type;
32709        loop {
32710            r#type = None;
32711            if self.buf.len() == self.pos {
32712                return None;
32713            }
32714            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
32715                break;
32716            };
32717            r#type = Some(header.r#type);
32718            let res = match header.r#type {
32719                1u16 => OpGetstatsDoReply::Link64({
32720                    let res = Some(PushRtnlLinkStats64::new_from_zeroed(next));
32721                    let Some(val) = res else { break };
32722                    val
32723                }),
32724                2u16 => OpGetstatsDoReply::LinkXstats({
32725                    let res = Some(next);
32726                    let Some(val) = res else { break };
32727                    val
32728                }),
32729                3u16 => OpGetstatsDoReply::LinkXstatsSlave({
32730                    let res = Some(next);
32731                    let Some(val) = res else { break };
32732                    val
32733                }),
32734                4u16 => OpGetstatsDoReply::LinkOffloadXstats({
32735                    let res = Some(IterableLinkOffloadXstats::with_loc(next, self.orig_loc));
32736                    let Some(val) = res else { break };
32737                    val
32738                }),
32739                5u16 => OpGetstatsDoReply::AfSpec({
32740                    let res = Some(next);
32741                    let Some(val) = res else { break };
32742                    val
32743                }),
32744                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
32745                n => continue,
32746            };
32747            return Some(Ok(res));
32748        }
32749        Some(Err(ErrorContext::new(
32750            "OpGetstatsDoReply",
32751            r#type.and_then(|t| OpGetstatsDoReply::attr_from_type(t)),
32752            self.orig_loc,
32753            self.buf.as_ptr().wrapping_add(pos) as usize,
32754        )))
32755    }
32756}
32757impl<'a> std::fmt::Debug for IterableOpGetstatsDoReply<'_> {
32758    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32759        let mut fmt = f.debug_struct("OpGetstatsDoReply");
32760        for attr in self.clone() {
32761            let attr = match attr {
32762                Ok(a) => a,
32763                Err(err) => {
32764                    fmt.finish()?;
32765                    f.write_str("Err(")?;
32766                    err.fmt(f)?;
32767                    return f.write_str(")");
32768                }
32769            };
32770            match attr {
32771                OpGetstatsDoReply::Link64(val) => fmt.field("Link64", &val),
32772                OpGetstatsDoReply::LinkXstats(val) => fmt.field("LinkXstats", &val),
32773                OpGetstatsDoReply::LinkXstatsSlave(val) => fmt.field("LinkXstatsSlave", &val),
32774                OpGetstatsDoReply::LinkOffloadXstats(val) => fmt.field("LinkOffloadXstats", &val),
32775                OpGetstatsDoReply::AfSpec(val) => fmt.field("AfSpec", &val),
32776            };
32777        }
32778        fmt.finish()
32779    }
32780}
32781impl IterableOpGetstatsDoReply<'_> {
32782    pub fn lookup_attr(
32783        &self,
32784        offset: usize,
32785        missing_type: Option<u16>,
32786    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32787        let mut stack = Vec::new();
32788        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
32789        if cur == offset + PushIfStatsMsg::len() {
32790            stack.push(("OpGetstatsDoReply", offset));
32791            return (
32792                stack,
32793                missing_type.and_then(|t| OpGetstatsDoReply::attr_from_type(t)),
32794            );
32795        }
32796        if cur > offset || cur + self.buf.len() < offset {
32797            return (stack, None);
32798        }
32799        let mut attrs = self.clone();
32800        let mut last_off = cur + attrs.pos;
32801        let mut missing = None;
32802        while let Some(attr) = attrs.next() {
32803            let Ok(attr) = attr else { break };
32804            match attr {
32805                OpGetstatsDoReply::Link64(val) => {
32806                    if last_off == offset {
32807                        stack.push(("Link64", last_off));
32808                        break;
32809                    }
32810                }
32811                OpGetstatsDoReply::LinkXstats(val) => {
32812                    if last_off == offset {
32813                        stack.push(("LinkXstats", last_off));
32814                        break;
32815                    }
32816                }
32817                OpGetstatsDoReply::LinkXstatsSlave(val) => {
32818                    if last_off == offset {
32819                        stack.push(("LinkXstatsSlave", last_off));
32820                        break;
32821                    }
32822                }
32823                OpGetstatsDoReply::LinkOffloadXstats(val) => {
32824                    (stack, missing) = val.lookup_attr(offset, missing_type);
32825                    if !stack.is_empty() {
32826                        break;
32827                    }
32828                }
32829                OpGetstatsDoReply::AfSpec(val) => {
32830                    if last_off == offset {
32831                        stack.push(("AfSpec", last_off));
32832                        break;
32833                    }
32834                }
32835                _ => {}
32836            };
32837            last_off = cur + attrs.pos;
32838        }
32839        if !stack.is_empty() {
32840            stack.push(("OpGetstatsDoReply", cur));
32841        }
32842        (stack, missing)
32843    }
32844}
32845#[derive(Debug)]
32846pub struct RequestOpGetstatsDoRequest<'r> {
32847    request: Request<'r>,
32848}
32849impl<'r> RequestOpGetstatsDoRequest<'r> {
32850    pub fn new(mut request: Request<'r>, header: &PushIfStatsMsg) -> Self {
32851        PushOpGetstatsDoRequest::write_header(&mut request.buf_mut(), header);
32852        Self { request: request }
32853    }
32854    pub fn encode(&mut self) -> PushOpGetstatsDoRequest<&mut Vec<u8>> {
32855        PushOpGetstatsDoRequest::new_without_header(self.request.buf_mut())
32856    }
32857    pub fn into_encoder(self) -> PushOpGetstatsDoRequest<RequestBuf<'r>> {
32858        PushOpGetstatsDoRequest::new_without_header(self.request.buf)
32859    }
32860    pub fn decode_request<'buf>(
32861        buf: &'buf [u8],
32862    ) -> (PushIfStatsMsg, IterableOpGetstatsDoRequest<'buf>) {
32863        OpGetstatsDoRequest::new(buf)
32864    }
32865}
32866impl NetlinkRequest for RequestOpGetstatsDoRequest<'_> {
32867    fn protocol(&self) -> Protocol {
32868        Protocol::Raw {
32869            protonum: 0u16,
32870            request_type: 94u16,
32871        }
32872    }
32873    fn flags(&self) -> u16 {
32874        self.request.flags
32875    }
32876    fn payload(&self) -> &[u8] {
32877        self.request.buf()
32878    }
32879    type ReplyType<'buf> = (PushIfStatsMsg, IterableOpGetstatsDoReply<'buf>);
32880    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
32881        OpGetstatsDoReply::new(buf)
32882    }
32883    fn lookup(
32884        buf: &[u8],
32885        offset: usize,
32886        missing_type: Option<u16>,
32887    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32888        OpGetstatsDoRequest::new(buf)
32889            .1
32890            .lookup_attr(offset, missing_type)
32891    }
32892}
32893#[derive(Debug)]
32894pub struct ChainedFinal<'a> {
32895    inner: Chained<'a>,
32896}
32897#[derive(Debug)]
32898pub struct Chained<'a> {
32899    buf: RequestBuf<'a>,
32900    first_seq: u32,
32901    lookups: Vec<(&'static str, LookupFn)>,
32902    last_header_offset: usize,
32903    last_kind: Option<RequestInfo>,
32904}
32905impl<'a> ChainedFinal<'a> {
32906    pub fn into_chained(self) -> Chained<'a> {
32907        self.inner
32908    }
32909    pub fn buf(&self) -> &Vec<u8> {
32910        self.inner.buf()
32911    }
32912    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
32913        self.inner.buf_mut()
32914    }
32915    fn get_index(&self, seq: u32) -> Option<u32> {
32916        let min = self.inner.first_seq;
32917        let max = min.wrapping_add(self.inner.lookups.len() as u32);
32918        return if min <= max {
32919            (min..max).contains(&seq).then(|| seq - min)
32920        } else if min <= seq {
32921            Some(seq - min)
32922        } else if seq < max {
32923            Some(u32::MAX - min + seq)
32924        } else {
32925            None
32926        };
32927    }
32928}
32929impl crate::traits::NetlinkChained for ChainedFinal<'_> {
32930    fn protonum(&self) -> u16 {
32931        PROTONUM
32932    }
32933    fn payload(&self) -> &[u8] {
32934        self.buf()
32935    }
32936    fn chain_len(&self) -> usize {
32937        self.inner.lookups.len()
32938    }
32939    fn get_index(&self, seq: u32) -> Option<usize> {
32940        self.get_index(seq).map(|n| n as usize)
32941    }
32942    fn name(&self, index: usize) -> &'static str {
32943        self.inner.lookups[index].0
32944    }
32945    fn lookup(&self, index: usize) -> LookupFn {
32946        self.inner.lookups[index].1
32947    }
32948}
32949impl Chained<'static> {
32950    pub fn new(first_seq: u32) -> Self {
32951        Self::new_from_buf(Vec::new(), first_seq)
32952    }
32953    pub fn new_from_buf(buf: Vec<u8>, first_seq: u32) -> Self {
32954        Self {
32955            buf: RequestBuf::Own(buf),
32956            first_seq,
32957            lookups: Vec::new(),
32958            last_header_offset: 0,
32959            last_kind: None,
32960        }
32961    }
32962    pub fn into_buf(self) -> Vec<u8> {
32963        match self.buf {
32964            RequestBuf::Own(buf) => buf,
32965            _ => unreachable!(),
32966        }
32967    }
32968}
32969impl<'a> Chained<'a> {
32970    pub fn new_with_buf(buf: &'a mut Vec<u8>, first_seq: u32) -> Self {
32971        Self {
32972            buf: RequestBuf::Ref(buf),
32973            first_seq,
32974            lookups: Vec::new(),
32975            last_header_offset: 0,
32976            last_kind: None,
32977        }
32978    }
32979    pub fn finalize(mut self) -> ChainedFinal<'a> {
32980        self.update_header();
32981        ChainedFinal { inner: self }
32982    }
32983    pub fn request(&mut self) -> Request<'_> {
32984        self.update_header();
32985        self.last_header_offset = self.buf().len();
32986        self.buf_mut()
32987            .extend_from_slice(PushNlmsghdr::new().as_slice());
32988        let mut request = Request::new_extend(self.buf.buf_mut());
32989        self.last_kind = None;
32990        request.writeback = Some(&mut self.last_kind);
32991        request
32992    }
32993    pub fn buf(&self) -> &Vec<u8> {
32994        self.buf.buf()
32995    }
32996    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
32997        self.buf.buf_mut()
32998    }
32999    fn update_header(&mut self) {
33000        let Some(RequestInfo {
33001            protocol,
33002            flags,
33003            name,
33004            lookup,
33005        }) = self.last_kind
33006        else {
33007            if !self.buf().is_empty() {
33008                assert_eq!(
33009                    self.last_header_offset + PushNlmsghdr::len(),
33010                    self.buf().len()
33011                );
33012                self.buf.buf_mut().truncate(self.last_header_offset);
33013            }
33014            return;
33015        };
33016        let header_offset = self.last_header_offset;
33017        let request_type = match protocol {
33018            Protocol::Raw { request_type, .. } => request_type,
33019            Protocol::Generic(_) => unreachable!(),
33020        };
33021        let index = self.lookups.len();
33022        let seq = self.first_seq.wrapping_add(index as u32);
33023        self.lookups.push((name, lookup));
33024        let buf = self.buf_mut();
33025        align(buf);
33026        let mut header = PushNlmsghdr::new();
33027        header.set_len((buf.len() - header_offset) as u32);
33028        header.set_type(request_type);
33029        header.set_flags(flags | consts::NLM_F_REQUEST as u16 | consts::NLM_F_ACK as u16);
33030        header.set_seq(seq);
33031        buf[header_offset..(header_offset + 16)].clone_from_slice(header.as_slice());
33032    }
33033}
33034use crate::traits::LookupFn;
33035use crate::utils::RequestBuf;
33036#[derive(Debug)]
33037pub struct Request<'buf> {
33038    buf: RequestBuf<'buf>,
33039    flags: u16,
33040    writeback: Option<&'buf mut Option<RequestInfo>>,
33041}
33042#[allow(unused)]
33043#[derive(Debug, Clone)]
33044pub struct RequestInfo {
33045    protocol: Protocol,
33046    flags: u16,
33047    name: &'static str,
33048    lookup: LookupFn,
33049}
33050impl Request<'static> {
33051    pub fn new() -> Self {
33052        Self::new_from_buf(Vec::new())
33053    }
33054    pub fn new_from_buf(buf: Vec<u8>) -> Self {
33055        Self {
33056            flags: 0,
33057            buf: RequestBuf::Own(buf),
33058            writeback: None,
33059        }
33060    }
33061    pub fn into_buf(self) -> Vec<u8> {
33062        match self.buf {
33063            RequestBuf::Own(buf) => buf,
33064            _ => unreachable!(),
33065        }
33066    }
33067}
33068impl<'buf> Request<'buf> {
33069    pub fn new_with_buf(buf: &'buf mut Vec<u8>) -> Self {
33070        buf.clear();
33071        Self::new_extend(buf)
33072    }
33073    pub fn new_extend(buf: &'buf mut Vec<u8>) -> Self {
33074        Self {
33075            flags: 0,
33076            buf: RequestBuf::Ref(buf),
33077            writeback: None,
33078        }
33079    }
33080    fn do_writeback(&mut self, protocol: Protocol, name: &'static str, lookup: LookupFn) {
33081        let Some(writeback) = &mut self.writeback else {
33082            return;
33083        };
33084        **writeback = Some(RequestInfo {
33085            protocol,
33086            flags: self.flags,
33087            name,
33088            lookup,
33089        })
33090    }
33091    pub fn buf(&self) -> &Vec<u8> {
33092        self.buf.buf()
33093    }
33094    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
33095        self.buf.buf_mut()
33096    }
33097    #[doc = "Set `NLM_F_CREATE` flag"]
33098    pub fn set_create(mut self) -> Self {
33099        self.flags |= consts::NLM_F_CREATE as u16;
33100        self
33101    }
33102    #[doc = "Set `NLM_F_EXCL` flag"]
33103    pub fn set_excl(mut self) -> Self {
33104        self.flags |= consts::NLM_F_EXCL as u16;
33105        self
33106    }
33107    #[doc = "Set `NLM_F_REPLACE` flag"]
33108    pub fn set_replace(mut self) -> Self {
33109        self.flags |= consts::NLM_F_REPLACE as u16;
33110        self
33111    }
33112    #[doc = "Set `NLM_F_CREATE` and `NLM_F_REPLACE` flag"]
33113    pub fn set_change(self) -> Self {
33114        self.set_create().set_replace()
33115    }
33116    #[doc = "Set `NLM_F_APPEND` flag"]
33117    pub fn set_append(mut self) -> Self {
33118        self.flags |= consts::NLM_F_APPEND as u16;
33119        self
33120    }
33121    #[doc = "Set `NLM_F_DUMP` flag"]
33122    fn set_dump(mut self) -> Self {
33123        self.flags |= consts::NLM_F_DUMP as u16;
33124        self
33125    }
33126    pub fn op_newlink_do_request(self, header: &PushIfinfomsg) -> RequestOpNewlinkDoRequest<'buf> {
33127        let mut res = RequestOpNewlinkDoRequest::new(self, header);
33128        res.request.do_writeback(
33129            res.protocol(),
33130            "op-newlink-do-request",
33131            RequestOpNewlinkDoRequest::lookup,
33132        );
33133        res
33134    }
33135    pub fn op_dellink_do_request(self, header: &PushIfinfomsg) -> RequestOpDellinkDoRequest<'buf> {
33136        let mut res = RequestOpDellinkDoRequest::new(self, header);
33137        res.request.do_writeback(
33138            res.protocol(),
33139            "op-dellink-do-request",
33140            RequestOpDellinkDoRequest::lookup,
33141        );
33142        res
33143    }
33144    pub fn op_getlink_dump_request(
33145        self,
33146        header: &PushIfinfomsg,
33147    ) -> RequestOpGetlinkDumpRequest<'buf> {
33148        let mut res = RequestOpGetlinkDumpRequest::new(self, header);
33149        res.request.do_writeback(
33150            res.protocol(),
33151            "op-getlink-dump-request",
33152            RequestOpGetlinkDumpRequest::lookup,
33153        );
33154        res
33155    }
33156    pub fn op_getlink_do_request(self, header: &PushIfinfomsg) -> RequestOpGetlinkDoRequest<'buf> {
33157        let mut res = RequestOpGetlinkDoRequest::new(self, header);
33158        res.request.do_writeback(
33159            res.protocol(),
33160            "op-getlink-do-request",
33161            RequestOpGetlinkDoRequest::lookup,
33162        );
33163        res
33164    }
33165    pub fn op_setlink_do_request(self, header: &PushIfinfomsg) -> RequestOpSetlinkDoRequest<'buf> {
33166        let mut res = RequestOpSetlinkDoRequest::new(self, header);
33167        res.request.do_writeback(
33168            res.protocol(),
33169            "op-setlink-do-request",
33170            RequestOpSetlinkDoRequest::lookup,
33171        );
33172        res
33173    }
33174    pub fn op_getstats_dump_request(
33175        self,
33176        header: &PushIfStatsMsg,
33177    ) -> RequestOpGetstatsDumpRequest<'buf> {
33178        let mut res = RequestOpGetstatsDumpRequest::new(self, header);
33179        res.request.do_writeback(
33180            res.protocol(),
33181            "op-getstats-dump-request",
33182            RequestOpGetstatsDumpRequest::lookup,
33183        );
33184        res
33185    }
33186    pub fn op_getstats_do_request(
33187        self,
33188        header: &PushIfStatsMsg,
33189    ) -> RequestOpGetstatsDoRequest<'buf> {
33190        let mut res = RequestOpGetstatsDoRequest::new(self, header);
33191        res.request.do_writeback(
33192            res.protocol(),
33193            "op-getstats-do-request",
33194            RequestOpGetstatsDoRequest::lookup,
33195        );
33196        res
33197    }
33198}