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<'a> LinkAttrs<'a> {
1603    pub fn new(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        if self.buf.len() == self.pos {
1702            return None;
1703        }
1704        let pos = self.pos;
1705        let mut r#type = None;
1706        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
1707            r#type = Some(header.r#type);
1708            let res = match header.r#type {
1709                1u16 => LinkAttrs::Address({
1710                    let res = Some(next);
1711                    let Some(val) = res else { break };
1712                    val
1713                }),
1714                2u16 => LinkAttrs::Broadcast({
1715                    let res = Some(next);
1716                    let Some(val) = res else { break };
1717                    val
1718                }),
1719                3u16 => LinkAttrs::Ifname({
1720                    let res = CStr::from_bytes_with_nul(next).ok();
1721                    let Some(val) = res else { break };
1722                    val
1723                }),
1724                4u16 => LinkAttrs::Mtu({
1725                    let res = parse_u32(next);
1726                    let Some(val) = res else { break };
1727                    val
1728                }),
1729                5u16 => LinkAttrs::Link({
1730                    let res = parse_u32(next);
1731                    let Some(val) = res else { break };
1732                    val
1733                }),
1734                6u16 => LinkAttrs::Qdisc({
1735                    let res = CStr::from_bytes_with_nul(next).ok();
1736                    let Some(val) = res else { break };
1737                    val
1738                }),
1739                7u16 => LinkAttrs::Stats({
1740                    let res = PushRtnlLinkStats::new_from_slice(next);
1741                    let Some(val) = res else { break };
1742                    val
1743                }),
1744                8u16 => LinkAttrs::Cost({
1745                    let res = CStr::from_bytes_with_nul(next).ok();
1746                    let Some(val) = res else { break };
1747                    val
1748                }),
1749                9u16 => LinkAttrs::Priority({
1750                    let res = CStr::from_bytes_with_nul(next).ok();
1751                    let Some(val) = res else { break };
1752                    val
1753                }),
1754                10u16 => LinkAttrs::Master({
1755                    let res = parse_u32(next);
1756                    let Some(val) = res else { break };
1757                    val
1758                }),
1759                11u16 => LinkAttrs::Wireless({
1760                    let res = CStr::from_bytes_with_nul(next).ok();
1761                    let Some(val) = res else { break };
1762                    val
1763                }),
1764                12u16 => LinkAttrs::Protinfo({
1765                    let res = CStr::from_bytes_with_nul(next).ok();
1766                    let Some(val) = res else { break };
1767                    val
1768                }),
1769                13u16 => LinkAttrs::Txqlen({
1770                    let res = parse_u32(next);
1771                    let Some(val) = res else { break };
1772                    val
1773                }),
1774                14u16 => LinkAttrs::Map({
1775                    let res = PushRtnlLinkIfmap::new_from_slice(next);
1776                    let Some(val) = res else { break };
1777                    val
1778                }),
1779                15u16 => LinkAttrs::Weight({
1780                    let res = parse_u32(next);
1781                    let Some(val) = res else { break };
1782                    val
1783                }),
1784                16u16 => LinkAttrs::Operstate({
1785                    let res = parse_u8(next);
1786                    let Some(val) = res else { break };
1787                    val
1788                }),
1789                17u16 => LinkAttrs::Linkmode({
1790                    let res = parse_u8(next);
1791                    let Some(val) = res else { break };
1792                    val
1793                }),
1794                18u16 => LinkAttrs::Linkinfo({
1795                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
1796                    let Some(val) = res else { break };
1797                    val
1798                }),
1799                19u16 => LinkAttrs::NetNsPid({
1800                    let res = parse_u32(next);
1801                    let Some(val) = res else { break };
1802                    val
1803                }),
1804                20u16 => LinkAttrs::Ifalias({
1805                    let res = CStr::from_bytes_with_nul(next).ok();
1806                    let Some(val) = res else { break };
1807                    val
1808                }),
1809                21u16 => LinkAttrs::NumVf({
1810                    let res = parse_u32(next);
1811                    let Some(val) = res else { break };
1812                    val
1813                }),
1814                22u16 => LinkAttrs::VfinfoList({
1815                    let res = Some(IterableVfinfoListAttrs::with_loc(next, self.orig_loc));
1816                    let Some(val) = res else { break };
1817                    val
1818                }),
1819                23u16 => LinkAttrs::Stats64({
1820                    let res = PushRtnlLinkStats64::new_from_slice(next);
1821                    let Some(val) = res else { break };
1822                    val
1823                }),
1824                24u16 => LinkAttrs::VfPorts({
1825                    let res = Some(IterableVfPortsAttrs::with_loc(next, self.orig_loc));
1826                    let Some(val) = res else { break };
1827                    val
1828                }),
1829                25u16 => LinkAttrs::PortSelf({
1830                    let res = Some(IterablePortSelfAttrs::with_loc(next, self.orig_loc));
1831                    let Some(val) = res else { break };
1832                    val
1833                }),
1834                26u16 => LinkAttrs::AfSpec({
1835                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
1836                    let Some(val) = res else { break };
1837                    val
1838                }),
1839                27u16 => LinkAttrs::Group({
1840                    let res = parse_u32(next);
1841                    let Some(val) = res else { break };
1842                    val
1843                }),
1844                28u16 => LinkAttrs::NetNsFd({
1845                    let res = parse_u32(next);
1846                    let Some(val) = res else { break };
1847                    val
1848                }),
1849                29u16 => LinkAttrs::ExtMask({
1850                    let res = parse_u32(next);
1851                    let Some(val) = res else { break };
1852                    val
1853                }),
1854                30u16 => LinkAttrs::Promiscuity({
1855                    let res = parse_u32(next);
1856                    let Some(val) = res else { break };
1857                    val
1858                }),
1859                31u16 => LinkAttrs::NumTxQueues({
1860                    let res = parse_u32(next);
1861                    let Some(val) = res else { break };
1862                    val
1863                }),
1864                32u16 => LinkAttrs::NumRxQueues({
1865                    let res = parse_u32(next);
1866                    let Some(val) = res else { break };
1867                    val
1868                }),
1869                33u16 => LinkAttrs::Carrier({
1870                    let res = parse_u8(next);
1871                    let Some(val) = res else { break };
1872                    val
1873                }),
1874                34u16 => LinkAttrs::PhysPortId({
1875                    let res = Some(next);
1876                    let Some(val) = res else { break };
1877                    val
1878                }),
1879                35u16 => LinkAttrs::CarrierChanges({
1880                    let res = parse_u32(next);
1881                    let Some(val) = res else { break };
1882                    val
1883                }),
1884                36u16 => LinkAttrs::PhysSwitchId({
1885                    let res = Some(next);
1886                    let Some(val) = res else { break };
1887                    val
1888                }),
1889                37u16 => LinkAttrs::LinkNetnsid({
1890                    let res = parse_i32(next);
1891                    let Some(val) = res else { break };
1892                    val
1893                }),
1894                38u16 => LinkAttrs::PhysPortName({
1895                    let res = CStr::from_bytes_with_nul(next).ok();
1896                    let Some(val) = res else { break };
1897                    val
1898                }),
1899                39u16 => LinkAttrs::ProtoDown({
1900                    let res = parse_u8(next);
1901                    let Some(val) = res else { break };
1902                    val
1903                }),
1904                40u16 => LinkAttrs::GsoMaxSegs({
1905                    let res = parse_u32(next);
1906                    let Some(val) = res else { break };
1907                    val
1908                }),
1909                41u16 => LinkAttrs::GsoMaxSize({
1910                    let res = parse_u32(next);
1911                    let Some(val) = res else { break };
1912                    val
1913                }),
1914                42u16 => LinkAttrs::Pad({
1915                    let res = Some(next);
1916                    let Some(val) = res else { break };
1917                    val
1918                }),
1919                43u16 => LinkAttrs::Xdp({
1920                    let res = Some(IterableXdpAttrs::with_loc(next, self.orig_loc));
1921                    let Some(val) = res else { break };
1922                    val
1923                }),
1924                44u16 => LinkAttrs::Event({
1925                    let res = parse_u32(next);
1926                    let Some(val) = res else { break };
1927                    val
1928                }),
1929                45u16 => LinkAttrs::NewNetnsid({
1930                    let res = parse_i32(next);
1931                    let Some(val) = res else { break };
1932                    val
1933                }),
1934                46u16 => LinkAttrs::TargetNetnsid({
1935                    let res = parse_i32(next);
1936                    let Some(val) = res else { break };
1937                    val
1938                }),
1939                47u16 => LinkAttrs::CarrierUpCount({
1940                    let res = parse_u32(next);
1941                    let Some(val) = res else { break };
1942                    val
1943                }),
1944                48u16 => LinkAttrs::CarrierDownCount({
1945                    let res = parse_u32(next);
1946                    let Some(val) = res else { break };
1947                    val
1948                }),
1949                49u16 => LinkAttrs::NewIfindex({
1950                    let res = parse_i32(next);
1951                    let Some(val) = res else { break };
1952                    val
1953                }),
1954                50u16 => LinkAttrs::MinMtu({
1955                    let res = parse_u32(next);
1956                    let Some(val) = res else { break };
1957                    val
1958                }),
1959                51u16 => LinkAttrs::MaxMtu({
1960                    let res = parse_u32(next);
1961                    let Some(val) = res else { break };
1962                    val
1963                }),
1964                52u16 => LinkAttrs::PropList({
1965                    let res = Some(IterablePropListLinkAttrs::with_loc(next, self.orig_loc));
1966                    let Some(val) = res else { break };
1967                    val
1968                }),
1969                53u16 => LinkAttrs::AltIfname({
1970                    let res = CStr::from_bytes_with_nul(next).ok();
1971                    let Some(val) = res else { break };
1972                    val
1973                }),
1974                54u16 => LinkAttrs::PermAddress({
1975                    let res = Some(next);
1976                    let Some(val) = res else { break };
1977                    val
1978                }),
1979                55u16 => LinkAttrs::ProtoDownReason({
1980                    let res = CStr::from_bytes_with_nul(next).ok();
1981                    let Some(val) = res else { break };
1982                    val
1983                }),
1984                56u16 => LinkAttrs::ParentDevName({
1985                    let res = CStr::from_bytes_with_nul(next).ok();
1986                    let Some(val) = res else { break };
1987                    val
1988                }),
1989                57u16 => LinkAttrs::ParentDevBusName({
1990                    let res = CStr::from_bytes_with_nul(next).ok();
1991                    let Some(val) = res else { break };
1992                    val
1993                }),
1994                58u16 => LinkAttrs::GroMaxSize({
1995                    let res = parse_u32(next);
1996                    let Some(val) = res else { break };
1997                    val
1998                }),
1999                59u16 => LinkAttrs::TsoMaxSize({
2000                    let res = parse_u32(next);
2001                    let Some(val) = res else { break };
2002                    val
2003                }),
2004                60u16 => LinkAttrs::TsoMaxSegs({
2005                    let res = parse_u32(next);
2006                    let Some(val) = res else { break };
2007                    val
2008                }),
2009                61u16 => LinkAttrs::Allmulti({
2010                    let res = parse_u32(next);
2011                    let Some(val) = res else { break };
2012                    val
2013                }),
2014                62u16 => LinkAttrs::DevlinkPort({
2015                    let res = Some(next);
2016                    let Some(val) = res else { break };
2017                    val
2018                }),
2019                63u16 => LinkAttrs::GsoIpv4MaxSize({
2020                    let res = parse_u32(next);
2021                    let Some(val) = res else { break };
2022                    val
2023                }),
2024                64u16 => LinkAttrs::GroIpv4MaxSize({
2025                    let res = parse_u32(next);
2026                    let Some(val) = res else { break };
2027                    val
2028                }),
2029                65u16 => LinkAttrs::DpllPin({
2030                    let res = Some(IterableLinkDpllPinAttrs::with_loc(next, self.orig_loc));
2031                    let Some(val) = res else { break };
2032                    val
2033                }),
2034                66u16 => LinkAttrs::MaxPacingOffloadHorizon({
2035                    let res = parse_u32(next);
2036                    let Some(val) = res else { break };
2037                    val
2038                }),
2039                67u16 => LinkAttrs::NetnsImmutable({
2040                    let res = parse_u8(next);
2041                    let Some(val) = res else { break };
2042                    val
2043                }),
2044                n => {
2045                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
2046                        break;
2047                    } else {
2048                        continue;
2049                    }
2050                }
2051            };
2052            return Some(Ok(res));
2053        }
2054        Some(Err(ErrorContext::new(
2055            "LinkAttrs",
2056            r#type.and_then(|t| LinkAttrs::attr_from_type(t)),
2057            self.orig_loc,
2058            self.buf.as_ptr().wrapping_add(pos) as usize,
2059        )))
2060    }
2061}
2062impl<'a> std::fmt::Debug for IterableLinkAttrs<'_> {
2063    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2064        let mut fmt = f.debug_struct("LinkAttrs");
2065        for attr in self.clone() {
2066            let attr = match attr {
2067                Ok(a) => a,
2068                Err(err) => {
2069                    fmt.finish()?;
2070                    f.write_str("Err(")?;
2071                    err.fmt(f)?;
2072                    return f.write_str(")");
2073                }
2074            };
2075            match attr {
2076                LinkAttrs::Address(val) => fmt.field("Address", &val),
2077                LinkAttrs::Broadcast(val) => fmt.field("Broadcast", &val),
2078                LinkAttrs::Ifname(val) => fmt.field("Ifname", &val),
2079                LinkAttrs::Mtu(val) => fmt.field("Mtu", &val),
2080                LinkAttrs::Link(val) => fmt.field("Link", &val),
2081                LinkAttrs::Qdisc(val) => fmt.field("Qdisc", &val),
2082                LinkAttrs::Stats(val) => fmt.field("Stats", &val),
2083                LinkAttrs::Cost(val) => fmt.field("Cost", &val),
2084                LinkAttrs::Priority(val) => fmt.field("Priority", &val),
2085                LinkAttrs::Master(val) => fmt.field("Master", &val),
2086                LinkAttrs::Wireless(val) => fmt.field("Wireless", &val),
2087                LinkAttrs::Protinfo(val) => fmt.field("Protinfo", &val),
2088                LinkAttrs::Txqlen(val) => fmt.field("Txqlen", &val),
2089                LinkAttrs::Map(val) => fmt.field("Map", &val),
2090                LinkAttrs::Weight(val) => fmt.field("Weight", &val),
2091                LinkAttrs::Operstate(val) => fmt.field("Operstate", &val),
2092                LinkAttrs::Linkmode(val) => fmt.field("Linkmode", &val),
2093                LinkAttrs::Linkinfo(val) => fmt.field("Linkinfo", &val),
2094                LinkAttrs::NetNsPid(val) => fmt.field("NetNsPid", &val),
2095                LinkAttrs::Ifalias(val) => fmt.field("Ifalias", &val),
2096                LinkAttrs::NumVf(val) => fmt.field("NumVf", &val),
2097                LinkAttrs::VfinfoList(val) => fmt.field("VfinfoList", &val),
2098                LinkAttrs::Stats64(val) => fmt.field("Stats64", &val),
2099                LinkAttrs::VfPorts(val) => fmt.field("VfPorts", &val),
2100                LinkAttrs::PortSelf(val) => fmt.field("PortSelf", &val),
2101                LinkAttrs::AfSpec(val) => fmt.field("AfSpec", &val),
2102                LinkAttrs::Group(val) => fmt.field("Group", &val),
2103                LinkAttrs::NetNsFd(val) => fmt.field("NetNsFd", &val),
2104                LinkAttrs::ExtMask(val) => {
2105                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
2106                }
2107                LinkAttrs::Promiscuity(val) => fmt.field("Promiscuity", &val),
2108                LinkAttrs::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
2109                LinkAttrs::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
2110                LinkAttrs::Carrier(val) => fmt.field("Carrier", &val),
2111                LinkAttrs::PhysPortId(val) => fmt.field("PhysPortId", &val),
2112                LinkAttrs::CarrierChanges(val) => fmt.field("CarrierChanges", &val),
2113                LinkAttrs::PhysSwitchId(val) => fmt.field("PhysSwitchId", &val),
2114                LinkAttrs::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
2115                LinkAttrs::PhysPortName(val) => fmt.field("PhysPortName", &val),
2116                LinkAttrs::ProtoDown(val) => fmt.field("ProtoDown", &val),
2117                LinkAttrs::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
2118                LinkAttrs::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
2119                LinkAttrs::Pad(val) => fmt.field("Pad", &val),
2120                LinkAttrs::Xdp(val) => fmt.field("Xdp", &val),
2121                LinkAttrs::Event(val) => fmt.field("Event", &val),
2122                LinkAttrs::NewNetnsid(val) => fmt.field("NewNetnsid", &val),
2123                LinkAttrs::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
2124                LinkAttrs::CarrierUpCount(val) => fmt.field("CarrierUpCount", &val),
2125                LinkAttrs::CarrierDownCount(val) => fmt.field("CarrierDownCount", &val),
2126                LinkAttrs::NewIfindex(val) => fmt.field("NewIfindex", &val),
2127                LinkAttrs::MinMtu(val) => fmt.field("MinMtu", &val),
2128                LinkAttrs::MaxMtu(val) => fmt.field("MaxMtu", &val),
2129                LinkAttrs::PropList(val) => fmt.field("PropList", &val),
2130                LinkAttrs::AltIfname(val) => fmt.field("AltIfname", &val),
2131                LinkAttrs::PermAddress(val) => fmt.field("PermAddress", &val),
2132                LinkAttrs::ProtoDownReason(val) => fmt.field("ProtoDownReason", &val),
2133                LinkAttrs::ParentDevName(val) => fmt.field("ParentDevName", &val),
2134                LinkAttrs::ParentDevBusName(val) => fmt.field("ParentDevBusName", &val),
2135                LinkAttrs::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
2136                LinkAttrs::TsoMaxSize(val) => fmt.field("TsoMaxSize", &val),
2137                LinkAttrs::TsoMaxSegs(val) => fmt.field("TsoMaxSegs", &val),
2138                LinkAttrs::Allmulti(val) => fmt.field("Allmulti", &val),
2139                LinkAttrs::DevlinkPort(val) => fmt.field("DevlinkPort", &val),
2140                LinkAttrs::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
2141                LinkAttrs::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
2142                LinkAttrs::DpllPin(val) => fmt.field("DpllPin", &val),
2143                LinkAttrs::MaxPacingOffloadHorizon(val) => {
2144                    fmt.field("MaxPacingOffloadHorizon", &val)
2145                }
2146                LinkAttrs::NetnsImmutable(val) => fmt.field("NetnsImmutable", &val),
2147            };
2148        }
2149        fmt.finish()
2150    }
2151}
2152impl IterableLinkAttrs<'_> {
2153    pub fn lookup_attr(
2154        &self,
2155        offset: usize,
2156        missing_type: Option<u16>,
2157    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2158        let mut stack = Vec::new();
2159        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2160        if cur == offset {
2161            stack.push(("LinkAttrs", offset));
2162            return (
2163                stack,
2164                missing_type.and_then(|t| LinkAttrs::attr_from_type(t)),
2165            );
2166        }
2167        if cur > offset || cur + self.buf.len() < offset {
2168            return (stack, None);
2169        }
2170        let mut attrs = self.clone();
2171        let mut last_off = cur + attrs.pos;
2172        let mut missing = None;
2173        while let Some(attr) = attrs.next() {
2174            let Ok(attr) = attr else { break };
2175            match attr {
2176                LinkAttrs::Address(val) => {
2177                    if last_off == offset {
2178                        stack.push(("Address", last_off));
2179                        break;
2180                    }
2181                }
2182                LinkAttrs::Broadcast(val) => {
2183                    if last_off == offset {
2184                        stack.push(("Broadcast", last_off));
2185                        break;
2186                    }
2187                }
2188                LinkAttrs::Ifname(val) => {
2189                    if last_off == offset {
2190                        stack.push(("Ifname", last_off));
2191                        break;
2192                    }
2193                }
2194                LinkAttrs::Mtu(val) => {
2195                    if last_off == offset {
2196                        stack.push(("Mtu", last_off));
2197                        break;
2198                    }
2199                }
2200                LinkAttrs::Link(val) => {
2201                    if last_off == offset {
2202                        stack.push(("Link", last_off));
2203                        break;
2204                    }
2205                }
2206                LinkAttrs::Qdisc(val) => {
2207                    if last_off == offset {
2208                        stack.push(("Qdisc", last_off));
2209                        break;
2210                    }
2211                }
2212                LinkAttrs::Stats(val) => {
2213                    if last_off == offset {
2214                        stack.push(("Stats", last_off));
2215                        break;
2216                    }
2217                }
2218                LinkAttrs::Cost(val) => {
2219                    if last_off == offset {
2220                        stack.push(("Cost", last_off));
2221                        break;
2222                    }
2223                }
2224                LinkAttrs::Priority(val) => {
2225                    if last_off == offset {
2226                        stack.push(("Priority", last_off));
2227                        break;
2228                    }
2229                }
2230                LinkAttrs::Master(val) => {
2231                    if last_off == offset {
2232                        stack.push(("Master", last_off));
2233                        break;
2234                    }
2235                }
2236                LinkAttrs::Wireless(val) => {
2237                    if last_off == offset {
2238                        stack.push(("Wireless", last_off));
2239                        break;
2240                    }
2241                }
2242                LinkAttrs::Protinfo(val) => {
2243                    if last_off == offset {
2244                        stack.push(("Protinfo", last_off));
2245                        break;
2246                    }
2247                }
2248                LinkAttrs::Txqlen(val) => {
2249                    if last_off == offset {
2250                        stack.push(("Txqlen", last_off));
2251                        break;
2252                    }
2253                }
2254                LinkAttrs::Map(val) => {
2255                    if last_off == offset {
2256                        stack.push(("Map", last_off));
2257                        break;
2258                    }
2259                }
2260                LinkAttrs::Weight(val) => {
2261                    if last_off == offset {
2262                        stack.push(("Weight", last_off));
2263                        break;
2264                    }
2265                }
2266                LinkAttrs::Operstate(val) => {
2267                    if last_off == offset {
2268                        stack.push(("Operstate", last_off));
2269                        break;
2270                    }
2271                }
2272                LinkAttrs::Linkmode(val) => {
2273                    if last_off == offset {
2274                        stack.push(("Linkmode", last_off));
2275                        break;
2276                    }
2277                }
2278                LinkAttrs::Linkinfo(val) => {
2279                    (stack, missing) = val.lookup_attr(offset, missing_type);
2280                    if !stack.is_empty() {
2281                        break;
2282                    }
2283                }
2284                LinkAttrs::NetNsPid(val) => {
2285                    if last_off == offset {
2286                        stack.push(("NetNsPid", last_off));
2287                        break;
2288                    }
2289                }
2290                LinkAttrs::Ifalias(val) => {
2291                    if last_off == offset {
2292                        stack.push(("Ifalias", last_off));
2293                        break;
2294                    }
2295                }
2296                LinkAttrs::NumVf(val) => {
2297                    if last_off == offset {
2298                        stack.push(("NumVf", last_off));
2299                        break;
2300                    }
2301                }
2302                LinkAttrs::VfinfoList(val) => {
2303                    (stack, missing) = val.lookup_attr(offset, missing_type);
2304                    if !stack.is_empty() {
2305                        break;
2306                    }
2307                }
2308                LinkAttrs::Stats64(val) => {
2309                    if last_off == offset {
2310                        stack.push(("Stats64", last_off));
2311                        break;
2312                    }
2313                }
2314                LinkAttrs::VfPorts(val) => {
2315                    (stack, missing) = val.lookup_attr(offset, missing_type);
2316                    if !stack.is_empty() {
2317                        break;
2318                    }
2319                }
2320                LinkAttrs::PortSelf(val) => {
2321                    (stack, missing) = val.lookup_attr(offset, missing_type);
2322                    if !stack.is_empty() {
2323                        break;
2324                    }
2325                }
2326                LinkAttrs::AfSpec(val) => {
2327                    (stack, missing) = val.lookup_attr(offset, missing_type);
2328                    if !stack.is_empty() {
2329                        break;
2330                    }
2331                }
2332                LinkAttrs::Group(val) => {
2333                    if last_off == offset {
2334                        stack.push(("Group", last_off));
2335                        break;
2336                    }
2337                }
2338                LinkAttrs::NetNsFd(val) => {
2339                    if last_off == offset {
2340                        stack.push(("NetNsFd", last_off));
2341                        break;
2342                    }
2343                }
2344                LinkAttrs::ExtMask(val) => {
2345                    if last_off == offset {
2346                        stack.push(("ExtMask", last_off));
2347                        break;
2348                    }
2349                }
2350                LinkAttrs::Promiscuity(val) => {
2351                    if last_off == offset {
2352                        stack.push(("Promiscuity", last_off));
2353                        break;
2354                    }
2355                }
2356                LinkAttrs::NumTxQueues(val) => {
2357                    if last_off == offset {
2358                        stack.push(("NumTxQueues", last_off));
2359                        break;
2360                    }
2361                }
2362                LinkAttrs::NumRxQueues(val) => {
2363                    if last_off == offset {
2364                        stack.push(("NumRxQueues", last_off));
2365                        break;
2366                    }
2367                }
2368                LinkAttrs::Carrier(val) => {
2369                    if last_off == offset {
2370                        stack.push(("Carrier", last_off));
2371                        break;
2372                    }
2373                }
2374                LinkAttrs::PhysPortId(val) => {
2375                    if last_off == offset {
2376                        stack.push(("PhysPortId", last_off));
2377                        break;
2378                    }
2379                }
2380                LinkAttrs::CarrierChanges(val) => {
2381                    if last_off == offset {
2382                        stack.push(("CarrierChanges", last_off));
2383                        break;
2384                    }
2385                }
2386                LinkAttrs::PhysSwitchId(val) => {
2387                    if last_off == offset {
2388                        stack.push(("PhysSwitchId", last_off));
2389                        break;
2390                    }
2391                }
2392                LinkAttrs::LinkNetnsid(val) => {
2393                    if last_off == offset {
2394                        stack.push(("LinkNetnsid", last_off));
2395                        break;
2396                    }
2397                }
2398                LinkAttrs::PhysPortName(val) => {
2399                    if last_off == offset {
2400                        stack.push(("PhysPortName", last_off));
2401                        break;
2402                    }
2403                }
2404                LinkAttrs::ProtoDown(val) => {
2405                    if last_off == offset {
2406                        stack.push(("ProtoDown", last_off));
2407                        break;
2408                    }
2409                }
2410                LinkAttrs::GsoMaxSegs(val) => {
2411                    if last_off == offset {
2412                        stack.push(("GsoMaxSegs", last_off));
2413                        break;
2414                    }
2415                }
2416                LinkAttrs::GsoMaxSize(val) => {
2417                    if last_off == offset {
2418                        stack.push(("GsoMaxSize", last_off));
2419                        break;
2420                    }
2421                }
2422                LinkAttrs::Pad(val) => {
2423                    if last_off == offset {
2424                        stack.push(("Pad", last_off));
2425                        break;
2426                    }
2427                }
2428                LinkAttrs::Xdp(val) => {
2429                    (stack, missing) = val.lookup_attr(offset, missing_type);
2430                    if !stack.is_empty() {
2431                        break;
2432                    }
2433                }
2434                LinkAttrs::Event(val) => {
2435                    if last_off == offset {
2436                        stack.push(("Event", last_off));
2437                        break;
2438                    }
2439                }
2440                LinkAttrs::NewNetnsid(val) => {
2441                    if last_off == offset {
2442                        stack.push(("NewNetnsid", last_off));
2443                        break;
2444                    }
2445                }
2446                LinkAttrs::TargetNetnsid(val) => {
2447                    if last_off == offset {
2448                        stack.push(("TargetNetnsid", last_off));
2449                        break;
2450                    }
2451                }
2452                LinkAttrs::CarrierUpCount(val) => {
2453                    if last_off == offset {
2454                        stack.push(("CarrierUpCount", last_off));
2455                        break;
2456                    }
2457                }
2458                LinkAttrs::CarrierDownCount(val) => {
2459                    if last_off == offset {
2460                        stack.push(("CarrierDownCount", last_off));
2461                        break;
2462                    }
2463                }
2464                LinkAttrs::NewIfindex(val) => {
2465                    if last_off == offset {
2466                        stack.push(("NewIfindex", last_off));
2467                        break;
2468                    }
2469                }
2470                LinkAttrs::MinMtu(val) => {
2471                    if last_off == offset {
2472                        stack.push(("MinMtu", last_off));
2473                        break;
2474                    }
2475                }
2476                LinkAttrs::MaxMtu(val) => {
2477                    if last_off == offset {
2478                        stack.push(("MaxMtu", last_off));
2479                        break;
2480                    }
2481                }
2482                LinkAttrs::PropList(val) => {
2483                    (stack, missing) = val.lookup_attr(offset, missing_type);
2484                    if !stack.is_empty() {
2485                        break;
2486                    }
2487                }
2488                LinkAttrs::AltIfname(val) => {
2489                    if last_off == offset {
2490                        stack.push(("AltIfname", last_off));
2491                        break;
2492                    }
2493                }
2494                LinkAttrs::PermAddress(val) => {
2495                    if last_off == offset {
2496                        stack.push(("PermAddress", last_off));
2497                        break;
2498                    }
2499                }
2500                LinkAttrs::ProtoDownReason(val) => {
2501                    if last_off == offset {
2502                        stack.push(("ProtoDownReason", last_off));
2503                        break;
2504                    }
2505                }
2506                LinkAttrs::ParentDevName(val) => {
2507                    if last_off == offset {
2508                        stack.push(("ParentDevName", last_off));
2509                        break;
2510                    }
2511                }
2512                LinkAttrs::ParentDevBusName(val) => {
2513                    if last_off == offset {
2514                        stack.push(("ParentDevBusName", last_off));
2515                        break;
2516                    }
2517                }
2518                LinkAttrs::GroMaxSize(val) => {
2519                    if last_off == offset {
2520                        stack.push(("GroMaxSize", last_off));
2521                        break;
2522                    }
2523                }
2524                LinkAttrs::TsoMaxSize(val) => {
2525                    if last_off == offset {
2526                        stack.push(("TsoMaxSize", last_off));
2527                        break;
2528                    }
2529                }
2530                LinkAttrs::TsoMaxSegs(val) => {
2531                    if last_off == offset {
2532                        stack.push(("TsoMaxSegs", last_off));
2533                        break;
2534                    }
2535                }
2536                LinkAttrs::Allmulti(val) => {
2537                    if last_off == offset {
2538                        stack.push(("Allmulti", last_off));
2539                        break;
2540                    }
2541                }
2542                LinkAttrs::DevlinkPort(val) => {
2543                    if last_off == offset {
2544                        stack.push(("DevlinkPort", last_off));
2545                        break;
2546                    }
2547                }
2548                LinkAttrs::GsoIpv4MaxSize(val) => {
2549                    if last_off == offset {
2550                        stack.push(("GsoIpv4MaxSize", last_off));
2551                        break;
2552                    }
2553                }
2554                LinkAttrs::GroIpv4MaxSize(val) => {
2555                    if last_off == offset {
2556                        stack.push(("GroIpv4MaxSize", last_off));
2557                        break;
2558                    }
2559                }
2560                LinkAttrs::DpllPin(val) => {
2561                    (stack, missing) = val.lookup_attr(offset, missing_type);
2562                    if !stack.is_empty() {
2563                        break;
2564                    }
2565                }
2566                LinkAttrs::MaxPacingOffloadHorizon(val) => {
2567                    if last_off == offset {
2568                        stack.push(("MaxPacingOffloadHorizon", last_off));
2569                        break;
2570                    }
2571                }
2572                LinkAttrs::NetnsImmutable(val) => {
2573                    if last_off == offset {
2574                        stack.push(("NetnsImmutable", last_off));
2575                        break;
2576                    }
2577                }
2578                _ => {}
2579            };
2580            last_off = cur + attrs.pos;
2581        }
2582        if !stack.is_empty() {
2583            stack.push(("LinkAttrs", cur));
2584        }
2585        (stack, missing)
2586    }
2587}
2588#[derive(Clone)]
2589pub enum PropListLinkAttrs<'a> {
2590    AltIfname(&'a CStr),
2591}
2592impl<'a> IterablePropListLinkAttrs<'a> {
2593    pub fn get_alt_ifname(&self) -> Result<&'a CStr, ErrorContext> {
2594        let mut iter = self.clone();
2595        iter.pos = 0;
2596        for attr in iter {
2597            if let PropListLinkAttrs::AltIfname(val) = attr? {
2598                return Ok(val);
2599            }
2600        }
2601        Err(ErrorContext::new_missing(
2602            "PropListLinkAttrs",
2603            "AltIfname",
2604            self.orig_loc,
2605            self.buf.as_ptr() as usize,
2606        ))
2607    }
2608}
2609impl<'a> PropListLinkAttrs<'a> {
2610    pub fn new(buf: &'a [u8]) -> IterablePropListLinkAttrs<'a> {
2611        IterablePropListLinkAttrs::with_loc(buf, buf.as_ptr() as usize)
2612    }
2613    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2614        let res = match r#type {
2615            1u16 => "AltIfname",
2616            _ => return None,
2617        };
2618        Some(res)
2619    }
2620}
2621#[derive(Clone, Copy, Default)]
2622pub struct IterablePropListLinkAttrs<'a> {
2623    buf: &'a [u8],
2624    pos: usize,
2625    orig_loc: usize,
2626}
2627impl<'a> IterablePropListLinkAttrs<'a> {
2628    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2629        Self {
2630            buf,
2631            pos: 0,
2632            orig_loc,
2633        }
2634    }
2635    pub fn get_buf(&self) -> &'a [u8] {
2636        self.buf
2637    }
2638}
2639impl<'a> Iterator for IterablePropListLinkAttrs<'a> {
2640    type Item = Result<PropListLinkAttrs<'a>, ErrorContext>;
2641    fn next(&mut self) -> Option<Self::Item> {
2642        if self.buf.len() == self.pos {
2643            return None;
2644        }
2645        let pos = self.pos;
2646        let mut r#type = None;
2647        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
2648            r#type = Some(header.r#type);
2649            let res = match header.r#type {
2650                1u16 => PropListLinkAttrs::AltIfname({
2651                    let res = CStr::from_bytes_with_nul(next).ok();
2652                    let Some(val) = res else { break };
2653                    val
2654                }),
2655                n => {
2656                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
2657                        break;
2658                    } else {
2659                        continue;
2660                    }
2661                }
2662            };
2663            return Some(Ok(res));
2664        }
2665        Some(Err(ErrorContext::new(
2666            "PropListLinkAttrs",
2667            r#type.and_then(|t| PropListLinkAttrs::attr_from_type(t)),
2668            self.orig_loc,
2669            self.buf.as_ptr().wrapping_add(pos) as usize,
2670        )))
2671    }
2672}
2673impl<'a> std::fmt::Debug for IterablePropListLinkAttrs<'_> {
2674    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2675        let mut fmt = f.debug_struct("PropListLinkAttrs");
2676        for attr in self.clone() {
2677            let attr = match attr {
2678                Ok(a) => a,
2679                Err(err) => {
2680                    fmt.finish()?;
2681                    f.write_str("Err(")?;
2682                    err.fmt(f)?;
2683                    return f.write_str(")");
2684                }
2685            };
2686            match attr {
2687                PropListLinkAttrs::AltIfname(val) => fmt.field("AltIfname", &val),
2688            };
2689        }
2690        fmt.finish()
2691    }
2692}
2693impl IterablePropListLinkAttrs<'_> {
2694    pub fn lookup_attr(
2695        &self,
2696        offset: usize,
2697        missing_type: Option<u16>,
2698    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2699        let mut stack = Vec::new();
2700        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2701        if cur == offset {
2702            stack.push(("PropListLinkAttrs", offset));
2703            return (
2704                stack,
2705                missing_type.and_then(|t| PropListLinkAttrs::attr_from_type(t)),
2706            );
2707        }
2708        if cur > offset || cur + self.buf.len() < offset {
2709            return (stack, None);
2710        }
2711        let mut attrs = self.clone();
2712        let mut last_off = cur + attrs.pos;
2713        while let Some(attr) = attrs.next() {
2714            let Ok(attr) = attr else { break };
2715            match attr {
2716                PropListLinkAttrs::AltIfname(val) => {
2717                    if last_off == offset {
2718                        stack.push(("AltIfname", last_off));
2719                        break;
2720                    }
2721                }
2722                _ => {}
2723            };
2724            last_off = cur + attrs.pos;
2725        }
2726        if !stack.is_empty() {
2727            stack.push(("PropListLinkAttrs", cur));
2728        }
2729        (stack, None)
2730    }
2731}
2732#[derive(Clone)]
2733pub enum AfSpecAttrs<'a> {
2734    Inet(IterableIflaAttrs<'a>),
2735    Inet6(IterableIfla6Attrs<'a>),
2736    Mctp(IterableMctpAttrs<'a>),
2737}
2738impl<'a> IterableAfSpecAttrs<'a> {
2739    pub fn get_inet(&self) -> Result<IterableIflaAttrs<'a>, ErrorContext> {
2740        let mut iter = self.clone();
2741        iter.pos = 0;
2742        for attr in iter {
2743            if let AfSpecAttrs::Inet(val) = attr? {
2744                return Ok(val);
2745            }
2746        }
2747        Err(ErrorContext::new_missing(
2748            "AfSpecAttrs",
2749            "Inet",
2750            self.orig_loc,
2751            self.buf.as_ptr() as usize,
2752        ))
2753    }
2754    pub fn get_inet6(&self) -> Result<IterableIfla6Attrs<'a>, ErrorContext> {
2755        let mut iter = self.clone();
2756        iter.pos = 0;
2757        for attr in iter {
2758            if let AfSpecAttrs::Inet6(val) = attr? {
2759                return Ok(val);
2760            }
2761        }
2762        Err(ErrorContext::new_missing(
2763            "AfSpecAttrs",
2764            "Inet6",
2765            self.orig_loc,
2766            self.buf.as_ptr() as usize,
2767        ))
2768    }
2769    pub fn get_mctp(&self) -> Result<IterableMctpAttrs<'a>, ErrorContext> {
2770        let mut iter = self.clone();
2771        iter.pos = 0;
2772        for attr in iter {
2773            if let AfSpecAttrs::Mctp(val) = attr? {
2774                return Ok(val);
2775            }
2776        }
2777        Err(ErrorContext::new_missing(
2778            "AfSpecAttrs",
2779            "Mctp",
2780            self.orig_loc,
2781            self.buf.as_ptr() as usize,
2782        ))
2783    }
2784}
2785impl<'a> AfSpecAttrs<'a> {
2786    pub fn new(buf: &'a [u8]) -> IterableAfSpecAttrs<'a> {
2787        IterableAfSpecAttrs::with_loc(buf, buf.as_ptr() as usize)
2788    }
2789    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2790        let res = match r#type {
2791            2u16 => "Inet",
2792            10u16 => "Inet6",
2793            45u16 => "Mctp",
2794            _ => return None,
2795        };
2796        Some(res)
2797    }
2798}
2799#[derive(Clone, Copy, Default)]
2800pub struct IterableAfSpecAttrs<'a> {
2801    buf: &'a [u8],
2802    pos: usize,
2803    orig_loc: usize,
2804}
2805impl<'a> IterableAfSpecAttrs<'a> {
2806    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2807        Self {
2808            buf,
2809            pos: 0,
2810            orig_loc,
2811        }
2812    }
2813    pub fn get_buf(&self) -> &'a [u8] {
2814        self.buf
2815    }
2816}
2817impl<'a> Iterator for IterableAfSpecAttrs<'a> {
2818    type Item = Result<AfSpecAttrs<'a>, ErrorContext>;
2819    fn next(&mut self) -> Option<Self::Item> {
2820        if self.buf.len() == self.pos {
2821            return None;
2822        }
2823        let pos = self.pos;
2824        let mut r#type = None;
2825        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
2826            r#type = Some(header.r#type);
2827            let res = match header.r#type {
2828                2u16 => AfSpecAttrs::Inet({
2829                    let res = Some(IterableIflaAttrs::with_loc(next, self.orig_loc));
2830                    let Some(val) = res else { break };
2831                    val
2832                }),
2833                10u16 => AfSpecAttrs::Inet6({
2834                    let res = Some(IterableIfla6Attrs::with_loc(next, self.orig_loc));
2835                    let Some(val) = res else { break };
2836                    val
2837                }),
2838                45u16 => AfSpecAttrs::Mctp({
2839                    let res = Some(IterableMctpAttrs::with_loc(next, self.orig_loc));
2840                    let Some(val) = res else { break };
2841                    val
2842                }),
2843                n => {
2844                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
2845                        break;
2846                    } else {
2847                        continue;
2848                    }
2849                }
2850            };
2851            return Some(Ok(res));
2852        }
2853        Some(Err(ErrorContext::new(
2854            "AfSpecAttrs",
2855            r#type.and_then(|t| AfSpecAttrs::attr_from_type(t)),
2856            self.orig_loc,
2857            self.buf.as_ptr().wrapping_add(pos) as usize,
2858        )))
2859    }
2860}
2861impl<'a> std::fmt::Debug for IterableAfSpecAttrs<'_> {
2862    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2863        let mut fmt = f.debug_struct("AfSpecAttrs");
2864        for attr in self.clone() {
2865            let attr = match attr {
2866                Ok(a) => a,
2867                Err(err) => {
2868                    fmt.finish()?;
2869                    f.write_str("Err(")?;
2870                    err.fmt(f)?;
2871                    return f.write_str(")");
2872                }
2873            };
2874            match attr {
2875                AfSpecAttrs::Inet(val) => fmt.field("Inet", &val),
2876                AfSpecAttrs::Inet6(val) => fmt.field("Inet6", &val),
2877                AfSpecAttrs::Mctp(val) => fmt.field("Mctp", &val),
2878            };
2879        }
2880        fmt.finish()
2881    }
2882}
2883impl IterableAfSpecAttrs<'_> {
2884    pub fn lookup_attr(
2885        &self,
2886        offset: usize,
2887        missing_type: Option<u16>,
2888    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2889        let mut stack = Vec::new();
2890        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2891        if cur == offset {
2892            stack.push(("AfSpecAttrs", offset));
2893            return (
2894                stack,
2895                missing_type.and_then(|t| AfSpecAttrs::attr_from_type(t)),
2896            );
2897        }
2898        if cur > offset || cur + self.buf.len() < offset {
2899            return (stack, None);
2900        }
2901        let mut attrs = self.clone();
2902        let mut last_off = cur + attrs.pos;
2903        let mut missing = None;
2904        while let Some(attr) = attrs.next() {
2905            let Ok(attr) = attr else { break };
2906            match attr {
2907                AfSpecAttrs::Inet(val) => {
2908                    (stack, missing) = val.lookup_attr(offset, missing_type);
2909                    if !stack.is_empty() {
2910                        break;
2911                    }
2912                }
2913                AfSpecAttrs::Inet6(val) => {
2914                    (stack, missing) = val.lookup_attr(offset, missing_type);
2915                    if !stack.is_empty() {
2916                        break;
2917                    }
2918                }
2919                AfSpecAttrs::Mctp(val) => {
2920                    (stack, missing) = val.lookup_attr(offset, missing_type);
2921                    if !stack.is_empty() {
2922                        break;
2923                    }
2924                }
2925                _ => {}
2926            };
2927            last_off = cur + attrs.pos;
2928        }
2929        if !stack.is_empty() {
2930            stack.push(("AfSpecAttrs", cur));
2931        }
2932        (stack, missing)
2933    }
2934}
2935#[derive(Clone)]
2936pub enum VfinfoListAttrs<'a> {
2937    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2938    Info(IterableVfinfoAttrs<'a>),
2939}
2940impl<'a> IterableVfinfoListAttrs<'a> {
2941    #[doc = "Attribute may repeat multiple times (treat it as array)"]
2942    pub fn get_info(
2943        &self,
2944    ) -> MultiAttrIterable<Self, VfinfoListAttrs<'a>, IterableVfinfoAttrs<'a>> {
2945        MultiAttrIterable::new(self.clone(), |variant| {
2946            if let VfinfoListAttrs::Info(val) = variant {
2947                Some(val)
2948            } else {
2949                None
2950            }
2951        })
2952    }
2953}
2954impl<'a> VfinfoListAttrs<'a> {
2955    pub fn new(buf: &'a [u8]) -> IterableVfinfoListAttrs<'a> {
2956        IterableVfinfoListAttrs::with_loc(buf, buf.as_ptr() as usize)
2957    }
2958    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2959        let res = match r#type {
2960            1u16 => "Info",
2961            _ => return None,
2962        };
2963        Some(res)
2964    }
2965}
2966#[derive(Clone, Copy, Default)]
2967pub struct IterableVfinfoListAttrs<'a> {
2968    buf: &'a [u8],
2969    pos: usize,
2970    orig_loc: usize,
2971}
2972impl<'a> IterableVfinfoListAttrs<'a> {
2973    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2974        Self {
2975            buf,
2976            pos: 0,
2977            orig_loc,
2978        }
2979    }
2980    pub fn get_buf(&self) -> &'a [u8] {
2981        self.buf
2982    }
2983}
2984impl<'a> Iterator for IterableVfinfoListAttrs<'a> {
2985    type Item = Result<VfinfoListAttrs<'a>, ErrorContext>;
2986    fn next(&mut self) -> Option<Self::Item> {
2987        if self.buf.len() == self.pos {
2988            return None;
2989        }
2990        let pos = self.pos;
2991        let mut r#type = None;
2992        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
2993            r#type = Some(header.r#type);
2994            let res = match header.r#type {
2995                1u16 => VfinfoListAttrs::Info({
2996                    let res = Some(IterableVfinfoAttrs::with_loc(next, self.orig_loc));
2997                    let Some(val) = res else { break };
2998                    val
2999                }),
3000                n => {
3001                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
3002                        break;
3003                    } else {
3004                        continue;
3005                    }
3006                }
3007            };
3008            return Some(Ok(res));
3009        }
3010        Some(Err(ErrorContext::new(
3011            "VfinfoListAttrs",
3012            r#type.and_then(|t| VfinfoListAttrs::attr_from_type(t)),
3013            self.orig_loc,
3014            self.buf.as_ptr().wrapping_add(pos) as usize,
3015        )))
3016    }
3017}
3018impl<'a> std::fmt::Debug for IterableVfinfoListAttrs<'_> {
3019    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3020        let mut fmt = f.debug_struct("VfinfoListAttrs");
3021        for attr in self.clone() {
3022            let attr = match attr {
3023                Ok(a) => a,
3024                Err(err) => {
3025                    fmt.finish()?;
3026                    f.write_str("Err(")?;
3027                    err.fmt(f)?;
3028                    return f.write_str(")");
3029                }
3030            };
3031            match attr {
3032                VfinfoListAttrs::Info(val) => fmt.field("Info", &val),
3033            };
3034        }
3035        fmt.finish()
3036    }
3037}
3038impl IterableVfinfoListAttrs<'_> {
3039    pub fn lookup_attr(
3040        &self,
3041        offset: usize,
3042        missing_type: Option<u16>,
3043    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3044        let mut stack = Vec::new();
3045        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3046        if cur == offset {
3047            stack.push(("VfinfoListAttrs", offset));
3048            return (
3049                stack,
3050                missing_type.and_then(|t| VfinfoListAttrs::attr_from_type(t)),
3051            );
3052        }
3053        if cur > offset || cur + self.buf.len() < offset {
3054            return (stack, None);
3055        }
3056        let mut attrs = self.clone();
3057        let mut last_off = cur + attrs.pos;
3058        let mut missing = None;
3059        while let Some(attr) = attrs.next() {
3060            let Ok(attr) = attr else { break };
3061            match attr {
3062                VfinfoListAttrs::Info(val) => {
3063                    (stack, missing) = val.lookup_attr(offset, missing_type);
3064                    if !stack.is_empty() {
3065                        break;
3066                    }
3067                }
3068                _ => {}
3069            };
3070            last_off = cur + attrs.pos;
3071        }
3072        if !stack.is_empty() {
3073            stack.push(("VfinfoListAttrs", cur));
3074        }
3075        (stack, missing)
3076    }
3077}
3078#[derive(Clone)]
3079pub enum VfinfoAttrs<'a> {
3080    Mac(PushIflaVfMac),
3081    Vlan(PushIflaVfVlan),
3082    TxRate(PushIflaVfTxRate),
3083    Spoofchk(PushIflaVfSpoofchk),
3084    LinkState(PushIflaVfLinkState),
3085    Rate(PushIflaVfRate),
3086    RssQueryEn(PushIflaVfRssQueryEn),
3087    Stats(IterableVfStatsAttrs<'a>),
3088    Trust(PushIflaVfTrust),
3089    IbNodeGuid(PushIflaVfGuid),
3090    IbPortGuid(PushIflaVfGuid),
3091    VlanList(IterableVfVlanAttrs<'a>),
3092    Broadcast(&'a [u8]),
3093}
3094impl<'a> IterableVfinfoAttrs<'a> {
3095    pub fn get_mac(&self) -> Result<PushIflaVfMac, ErrorContext> {
3096        let mut iter = self.clone();
3097        iter.pos = 0;
3098        for attr in iter {
3099            if let VfinfoAttrs::Mac(val) = attr? {
3100                return Ok(val);
3101            }
3102        }
3103        Err(ErrorContext::new_missing(
3104            "VfinfoAttrs",
3105            "Mac",
3106            self.orig_loc,
3107            self.buf.as_ptr() as usize,
3108        ))
3109    }
3110    pub fn get_vlan(&self) -> Result<PushIflaVfVlan, ErrorContext> {
3111        let mut iter = self.clone();
3112        iter.pos = 0;
3113        for attr in iter {
3114            if let VfinfoAttrs::Vlan(val) = attr? {
3115                return Ok(val);
3116            }
3117        }
3118        Err(ErrorContext::new_missing(
3119            "VfinfoAttrs",
3120            "Vlan",
3121            self.orig_loc,
3122            self.buf.as_ptr() as usize,
3123        ))
3124    }
3125    pub fn get_tx_rate(&self) -> Result<PushIflaVfTxRate, ErrorContext> {
3126        let mut iter = self.clone();
3127        iter.pos = 0;
3128        for attr in iter {
3129            if let VfinfoAttrs::TxRate(val) = attr? {
3130                return Ok(val);
3131            }
3132        }
3133        Err(ErrorContext::new_missing(
3134            "VfinfoAttrs",
3135            "TxRate",
3136            self.orig_loc,
3137            self.buf.as_ptr() as usize,
3138        ))
3139    }
3140    pub fn get_spoofchk(&self) -> Result<PushIflaVfSpoofchk, ErrorContext> {
3141        let mut iter = self.clone();
3142        iter.pos = 0;
3143        for attr in iter {
3144            if let VfinfoAttrs::Spoofchk(val) = attr? {
3145                return Ok(val);
3146            }
3147        }
3148        Err(ErrorContext::new_missing(
3149            "VfinfoAttrs",
3150            "Spoofchk",
3151            self.orig_loc,
3152            self.buf.as_ptr() as usize,
3153        ))
3154    }
3155    pub fn get_link_state(&self) -> Result<PushIflaVfLinkState, ErrorContext> {
3156        let mut iter = self.clone();
3157        iter.pos = 0;
3158        for attr in iter {
3159            if let VfinfoAttrs::LinkState(val) = attr? {
3160                return Ok(val);
3161            }
3162        }
3163        Err(ErrorContext::new_missing(
3164            "VfinfoAttrs",
3165            "LinkState",
3166            self.orig_loc,
3167            self.buf.as_ptr() as usize,
3168        ))
3169    }
3170    pub fn get_rate(&self) -> Result<PushIflaVfRate, ErrorContext> {
3171        let mut iter = self.clone();
3172        iter.pos = 0;
3173        for attr in iter {
3174            if let VfinfoAttrs::Rate(val) = attr? {
3175                return Ok(val);
3176            }
3177        }
3178        Err(ErrorContext::new_missing(
3179            "VfinfoAttrs",
3180            "Rate",
3181            self.orig_loc,
3182            self.buf.as_ptr() as usize,
3183        ))
3184    }
3185    pub fn get_rss_query_en(&self) -> Result<PushIflaVfRssQueryEn, ErrorContext> {
3186        let mut iter = self.clone();
3187        iter.pos = 0;
3188        for attr in iter {
3189            if let VfinfoAttrs::RssQueryEn(val) = attr? {
3190                return Ok(val);
3191            }
3192        }
3193        Err(ErrorContext::new_missing(
3194            "VfinfoAttrs",
3195            "RssQueryEn",
3196            self.orig_loc,
3197            self.buf.as_ptr() as usize,
3198        ))
3199    }
3200    pub fn get_stats(&self) -> Result<IterableVfStatsAttrs<'a>, ErrorContext> {
3201        let mut iter = self.clone();
3202        iter.pos = 0;
3203        for attr in iter {
3204            if let VfinfoAttrs::Stats(val) = attr? {
3205                return Ok(val);
3206            }
3207        }
3208        Err(ErrorContext::new_missing(
3209            "VfinfoAttrs",
3210            "Stats",
3211            self.orig_loc,
3212            self.buf.as_ptr() as usize,
3213        ))
3214    }
3215    pub fn get_trust(&self) -> Result<PushIflaVfTrust, ErrorContext> {
3216        let mut iter = self.clone();
3217        iter.pos = 0;
3218        for attr in iter {
3219            if let VfinfoAttrs::Trust(val) = attr? {
3220                return Ok(val);
3221            }
3222        }
3223        Err(ErrorContext::new_missing(
3224            "VfinfoAttrs",
3225            "Trust",
3226            self.orig_loc,
3227            self.buf.as_ptr() as usize,
3228        ))
3229    }
3230    pub fn get_ib_node_guid(&self) -> Result<PushIflaVfGuid, ErrorContext> {
3231        let mut iter = self.clone();
3232        iter.pos = 0;
3233        for attr in iter {
3234            if let VfinfoAttrs::IbNodeGuid(val) = attr? {
3235                return Ok(val);
3236            }
3237        }
3238        Err(ErrorContext::new_missing(
3239            "VfinfoAttrs",
3240            "IbNodeGuid",
3241            self.orig_loc,
3242            self.buf.as_ptr() as usize,
3243        ))
3244    }
3245    pub fn get_ib_port_guid(&self) -> Result<PushIflaVfGuid, ErrorContext> {
3246        let mut iter = self.clone();
3247        iter.pos = 0;
3248        for attr in iter {
3249            if let VfinfoAttrs::IbPortGuid(val) = attr? {
3250                return Ok(val);
3251            }
3252        }
3253        Err(ErrorContext::new_missing(
3254            "VfinfoAttrs",
3255            "IbPortGuid",
3256            self.orig_loc,
3257            self.buf.as_ptr() as usize,
3258        ))
3259    }
3260    pub fn get_vlan_list(&self) -> Result<IterableVfVlanAttrs<'a>, ErrorContext> {
3261        let mut iter = self.clone();
3262        iter.pos = 0;
3263        for attr in iter {
3264            if let VfinfoAttrs::VlanList(val) = attr? {
3265                return Ok(val);
3266            }
3267        }
3268        Err(ErrorContext::new_missing(
3269            "VfinfoAttrs",
3270            "VlanList",
3271            self.orig_loc,
3272            self.buf.as_ptr() as usize,
3273        ))
3274    }
3275    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
3276        let mut iter = self.clone();
3277        iter.pos = 0;
3278        for attr in iter {
3279            if let VfinfoAttrs::Broadcast(val) = attr? {
3280                return Ok(val);
3281            }
3282        }
3283        Err(ErrorContext::new_missing(
3284            "VfinfoAttrs",
3285            "Broadcast",
3286            self.orig_loc,
3287            self.buf.as_ptr() as usize,
3288        ))
3289    }
3290}
3291impl<'a> VfinfoAttrs<'a> {
3292    pub fn new(buf: &'a [u8]) -> IterableVfinfoAttrs<'a> {
3293        IterableVfinfoAttrs::with_loc(buf, buf.as_ptr() as usize)
3294    }
3295    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3296        let res = match r#type {
3297            1u16 => "Mac",
3298            2u16 => "Vlan",
3299            3u16 => "TxRate",
3300            4u16 => "Spoofchk",
3301            5u16 => "LinkState",
3302            6u16 => "Rate",
3303            7u16 => "RssQueryEn",
3304            8u16 => "Stats",
3305            9u16 => "Trust",
3306            10u16 => "IbNodeGuid",
3307            11u16 => "IbPortGuid",
3308            12u16 => "VlanList",
3309            13u16 => "Broadcast",
3310            _ => return None,
3311        };
3312        Some(res)
3313    }
3314}
3315#[derive(Clone, Copy, Default)]
3316pub struct IterableVfinfoAttrs<'a> {
3317    buf: &'a [u8],
3318    pos: usize,
3319    orig_loc: usize,
3320}
3321impl<'a> IterableVfinfoAttrs<'a> {
3322    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3323        Self {
3324            buf,
3325            pos: 0,
3326            orig_loc,
3327        }
3328    }
3329    pub fn get_buf(&self) -> &'a [u8] {
3330        self.buf
3331    }
3332}
3333impl<'a> Iterator for IterableVfinfoAttrs<'a> {
3334    type Item = Result<VfinfoAttrs<'a>, ErrorContext>;
3335    fn next(&mut self) -> Option<Self::Item> {
3336        if self.buf.len() == self.pos {
3337            return None;
3338        }
3339        let pos = self.pos;
3340        let mut r#type = None;
3341        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
3342            r#type = Some(header.r#type);
3343            let res = match header.r#type {
3344                1u16 => VfinfoAttrs::Mac({
3345                    let res = PushIflaVfMac::new_from_slice(next);
3346                    let Some(val) = res else { break };
3347                    val
3348                }),
3349                2u16 => VfinfoAttrs::Vlan({
3350                    let res = PushIflaVfVlan::new_from_slice(next);
3351                    let Some(val) = res else { break };
3352                    val
3353                }),
3354                3u16 => VfinfoAttrs::TxRate({
3355                    let res = PushIflaVfTxRate::new_from_slice(next);
3356                    let Some(val) = res else { break };
3357                    val
3358                }),
3359                4u16 => VfinfoAttrs::Spoofchk({
3360                    let res = PushIflaVfSpoofchk::new_from_slice(next);
3361                    let Some(val) = res else { break };
3362                    val
3363                }),
3364                5u16 => VfinfoAttrs::LinkState({
3365                    let res = PushIflaVfLinkState::new_from_slice(next);
3366                    let Some(val) = res else { break };
3367                    val
3368                }),
3369                6u16 => VfinfoAttrs::Rate({
3370                    let res = PushIflaVfRate::new_from_slice(next);
3371                    let Some(val) = res else { break };
3372                    val
3373                }),
3374                7u16 => VfinfoAttrs::RssQueryEn({
3375                    let res = PushIflaVfRssQueryEn::new_from_slice(next);
3376                    let Some(val) = res else { break };
3377                    val
3378                }),
3379                8u16 => VfinfoAttrs::Stats({
3380                    let res = Some(IterableVfStatsAttrs::with_loc(next, self.orig_loc));
3381                    let Some(val) = res else { break };
3382                    val
3383                }),
3384                9u16 => VfinfoAttrs::Trust({
3385                    let res = PushIflaVfTrust::new_from_slice(next);
3386                    let Some(val) = res else { break };
3387                    val
3388                }),
3389                10u16 => VfinfoAttrs::IbNodeGuid({
3390                    let res = PushIflaVfGuid::new_from_slice(next);
3391                    let Some(val) = res else { break };
3392                    val
3393                }),
3394                11u16 => VfinfoAttrs::IbPortGuid({
3395                    let res = PushIflaVfGuid::new_from_slice(next);
3396                    let Some(val) = res else { break };
3397                    val
3398                }),
3399                12u16 => VfinfoAttrs::VlanList({
3400                    let res = Some(IterableVfVlanAttrs::with_loc(next, self.orig_loc));
3401                    let Some(val) = res else { break };
3402                    val
3403                }),
3404                13u16 => VfinfoAttrs::Broadcast({
3405                    let res = Some(next);
3406                    let Some(val) = res else { break };
3407                    val
3408                }),
3409                n => {
3410                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
3411                        break;
3412                    } else {
3413                        continue;
3414                    }
3415                }
3416            };
3417            return Some(Ok(res));
3418        }
3419        Some(Err(ErrorContext::new(
3420            "VfinfoAttrs",
3421            r#type.and_then(|t| VfinfoAttrs::attr_from_type(t)),
3422            self.orig_loc,
3423            self.buf.as_ptr().wrapping_add(pos) as usize,
3424        )))
3425    }
3426}
3427impl<'a> std::fmt::Debug for IterableVfinfoAttrs<'_> {
3428    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3429        let mut fmt = f.debug_struct("VfinfoAttrs");
3430        for attr in self.clone() {
3431            let attr = match attr {
3432                Ok(a) => a,
3433                Err(err) => {
3434                    fmt.finish()?;
3435                    f.write_str("Err(")?;
3436                    err.fmt(f)?;
3437                    return f.write_str(")");
3438                }
3439            };
3440            match attr {
3441                VfinfoAttrs::Mac(val) => fmt.field("Mac", &val),
3442                VfinfoAttrs::Vlan(val) => fmt.field("Vlan", &val),
3443                VfinfoAttrs::TxRate(val) => fmt.field("TxRate", &val),
3444                VfinfoAttrs::Spoofchk(val) => fmt.field("Spoofchk", &val),
3445                VfinfoAttrs::LinkState(val) => fmt.field("LinkState", &val),
3446                VfinfoAttrs::Rate(val) => fmt.field("Rate", &val),
3447                VfinfoAttrs::RssQueryEn(val) => fmt.field("RssQueryEn", &val),
3448                VfinfoAttrs::Stats(val) => fmt.field("Stats", &val),
3449                VfinfoAttrs::Trust(val) => fmt.field("Trust", &val),
3450                VfinfoAttrs::IbNodeGuid(val) => fmt.field("IbNodeGuid", &val),
3451                VfinfoAttrs::IbPortGuid(val) => fmt.field("IbPortGuid", &val),
3452                VfinfoAttrs::VlanList(val) => fmt.field("VlanList", &val),
3453                VfinfoAttrs::Broadcast(val) => fmt.field("Broadcast", &val),
3454            };
3455        }
3456        fmt.finish()
3457    }
3458}
3459impl IterableVfinfoAttrs<'_> {
3460    pub fn lookup_attr(
3461        &self,
3462        offset: usize,
3463        missing_type: Option<u16>,
3464    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3465        let mut stack = Vec::new();
3466        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3467        if cur == offset {
3468            stack.push(("VfinfoAttrs", offset));
3469            return (
3470                stack,
3471                missing_type.and_then(|t| VfinfoAttrs::attr_from_type(t)),
3472            );
3473        }
3474        if cur > offset || cur + self.buf.len() < offset {
3475            return (stack, None);
3476        }
3477        let mut attrs = self.clone();
3478        let mut last_off = cur + attrs.pos;
3479        let mut missing = None;
3480        while let Some(attr) = attrs.next() {
3481            let Ok(attr) = attr else { break };
3482            match attr {
3483                VfinfoAttrs::Mac(val) => {
3484                    if last_off == offset {
3485                        stack.push(("Mac", last_off));
3486                        break;
3487                    }
3488                }
3489                VfinfoAttrs::Vlan(val) => {
3490                    if last_off == offset {
3491                        stack.push(("Vlan", last_off));
3492                        break;
3493                    }
3494                }
3495                VfinfoAttrs::TxRate(val) => {
3496                    if last_off == offset {
3497                        stack.push(("TxRate", last_off));
3498                        break;
3499                    }
3500                }
3501                VfinfoAttrs::Spoofchk(val) => {
3502                    if last_off == offset {
3503                        stack.push(("Spoofchk", last_off));
3504                        break;
3505                    }
3506                }
3507                VfinfoAttrs::LinkState(val) => {
3508                    if last_off == offset {
3509                        stack.push(("LinkState", last_off));
3510                        break;
3511                    }
3512                }
3513                VfinfoAttrs::Rate(val) => {
3514                    if last_off == offset {
3515                        stack.push(("Rate", last_off));
3516                        break;
3517                    }
3518                }
3519                VfinfoAttrs::RssQueryEn(val) => {
3520                    if last_off == offset {
3521                        stack.push(("RssQueryEn", last_off));
3522                        break;
3523                    }
3524                }
3525                VfinfoAttrs::Stats(val) => {
3526                    (stack, missing) = val.lookup_attr(offset, missing_type);
3527                    if !stack.is_empty() {
3528                        break;
3529                    }
3530                }
3531                VfinfoAttrs::Trust(val) => {
3532                    if last_off == offset {
3533                        stack.push(("Trust", last_off));
3534                        break;
3535                    }
3536                }
3537                VfinfoAttrs::IbNodeGuid(val) => {
3538                    if last_off == offset {
3539                        stack.push(("IbNodeGuid", last_off));
3540                        break;
3541                    }
3542                }
3543                VfinfoAttrs::IbPortGuid(val) => {
3544                    if last_off == offset {
3545                        stack.push(("IbPortGuid", last_off));
3546                        break;
3547                    }
3548                }
3549                VfinfoAttrs::VlanList(val) => {
3550                    (stack, missing) = val.lookup_attr(offset, missing_type);
3551                    if !stack.is_empty() {
3552                        break;
3553                    }
3554                }
3555                VfinfoAttrs::Broadcast(val) => {
3556                    if last_off == offset {
3557                        stack.push(("Broadcast", last_off));
3558                        break;
3559                    }
3560                }
3561                _ => {}
3562            };
3563            last_off = cur + attrs.pos;
3564        }
3565        if !stack.is_empty() {
3566            stack.push(("VfinfoAttrs", cur));
3567        }
3568        (stack, missing)
3569    }
3570}
3571#[derive(Clone)]
3572pub enum VfStatsAttrs<'a> {
3573    RxPackets(u64),
3574    TxPackets(u64),
3575    RxBytes(u64),
3576    TxBytes(u64),
3577    Broadcast(u64),
3578    Multicast(u64),
3579    Pad(&'a [u8]),
3580    RxDropped(u64),
3581    TxDropped(u64),
3582}
3583impl<'a> IterableVfStatsAttrs<'a> {
3584    pub fn get_rx_packets(&self) -> Result<u64, ErrorContext> {
3585        let mut iter = self.clone();
3586        iter.pos = 0;
3587        for attr in iter {
3588            if let VfStatsAttrs::RxPackets(val) = attr? {
3589                return Ok(val);
3590            }
3591        }
3592        Err(ErrorContext::new_missing(
3593            "VfStatsAttrs",
3594            "RxPackets",
3595            self.orig_loc,
3596            self.buf.as_ptr() as usize,
3597        ))
3598    }
3599    pub fn get_tx_packets(&self) -> Result<u64, ErrorContext> {
3600        let mut iter = self.clone();
3601        iter.pos = 0;
3602        for attr in iter {
3603            if let VfStatsAttrs::TxPackets(val) = attr? {
3604                return Ok(val);
3605            }
3606        }
3607        Err(ErrorContext::new_missing(
3608            "VfStatsAttrs",
3609            "TxPackets",
3610            self.orig_loc,
3611            self.buf.as_ptr() as usize,
3612        ))
3613    }
3614    pub fn get_rx_bytes(&self) -> Result<u64, ErrorContext> {
3615        let mut iter = self.clone();
3616        iter.pos = 0;
3617        for attr in iter {
3618            if let VfStatsAttrs::RxBytes(val) = attr? {
3619                return Ok(val);
3620            }
3621        }
3622        Err(ErrorContext::new_missing(
3623            "VfStatsAttrs",
3624            "RxBytes",
3625            self.orig_loc,
3626            self.buf.as_ptr() as usize,
3627        ))
3628    }
3629    pub fn get_tx_bytes(&self) -> Result<u64, ErrorContext> {
3630        let mut iter = self.clone();
3631        iter.pos = 0;
3632        for attr in iter {
3633            if let VfStatsAttrs::TxBytes(val) = attr? {
3634                return Ok(val);
3635            }
3636        }
3637        Err(ErrorContext::new_missing(
3638            "VfStatsAttrs",
3639            "TxBytes",
3640            self.orig_loc,
3641            self.buf.as_ptr() as usize,
3642        ))
3643    }
3644    pub fn get_broadcast(&self) -> Result<u64, ErrorContext> {
3645        let mut iter = self.clone();
3646        iter.pos = 0;
3647        for attr in iter {
3648            if let VfStatsAttrs::Broadcast(val) = attr? {
3649                return Ok(val);
3650            }
3651        }
3652        Err(ErrorContext::new_missing(
3653            "VfStatsAttrs",
3654            "Broadcast",
3655            self.orig_loc,
3656            self.buf.as_ptr() as usize,
3657        ))
3658    }
3659    pub fn get_multicast(&self) -> Result<u64, ErrorContext> {
3660        let mut iter = self.clone();
3661        iter.pos = 0;
3662        for attr in iter {
3663            if let VfStatsAttrs::Multicast(val) = attr? {
3664                return Ok(val);
3665            }
3666        }
3667        Err(ErrorContext::new_missing(
3668            "VfStatsAttrs",
3669            "Multicast",
3670            self.orig_loc,
3671            self.buf.as_ptr() as usize,
3672        ))
3673    }
3674    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
3675        let mut iter = self.clone();
3676        iter.pos = 0;
3677        for attr in iter {
3678            if let VfStatsAttrs::Pad(val) = attr? {
3679                return Ok(val);
3680            }
3681        }
3682        Err(ErrorContext::new_missing(
3683            "VfStatsAttrs",
3684            "Pad",
3685            self.orig_loc,
3686            self.buf.as_ptr() as usize,
3687        ))
3688    }
3689    pub fn get_rx_dropped(&self) -> Result<u64, ErrorContext> {
3690        let mut iter = self.clone();
3691        iter.pos = 0;
3692        for attr in iter {
3693            if let VfStatsAttrs::RxDropped(val) = attr? {
3694                return Ok(val);
3695            }
3696        }
3697        Err(ErrorContext::new_missing(
3698            "VfStatsAttrs",
3699            "RxDropped",
3700            self.orig_loc,
3701            self.buf.as_ptr() as usize,
3702        ))
3703    }
3704    pub fn get_tx_dropped(&self) -> Result<u64, ErrorContext> {
3705        let mut iter = self.clone();
3706        iter.pos = 0;
3707        for attr in iter {
3708            if let VfStatsAttrs::TxDropped(val) = attr? {
3709                return Ok(val);
3710            }
3711        }
3712        Err(ErrorContext::new_missing(
3713            "VfStatsAttrs",
3714            "TxDropped",
3715            self.orig_loc,
3716            self.buf.as_ptr() as usize,
3717        ))
3718    }
3719}
3720impl<'a> VfStatsAttrs<'a> {
3721    pub fn new(buf: &'a [u8]) -> IterableVfStatsAttrs<'a> {
3722        IterableVfStatsAttrs::with_loc(buf, buf.as_ptr() as usize)
3723    }
3724    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3725        let res = match r#type {
3726            0u16 => "RxPackets",
3727            1u16 => "TxPackets",
3728            2u16 => "RxBytes",
3729            3u16 => "TxBytes",
3730            4u16 => "Broadcast",
3731            5u16 => "Multicast",
3732            6u16 => "Pad",
3733            7u16 => "RxDropped",
3734            8u16 => "TxDropped",
3735            _ => return None,
3736        };
3737        Some(res)
3738    }
3739}
3740#[derive(Clone, Copy, Default)]
3741pub struct IterableVfStatsAttrs<'a> {
3742    buf: &'a [u8],
3743    pos: usize,
3744    orig_loc: usize,
3745}
3746impl<'a> IterableVfStatsAttrs<'a> {
3747    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3748        Self {
3749            buf,
3750            pos: 0,
3751            orig_loc,
3752        }
3753    }
3754    pub fn get_buf(&self) -> &'a [u8] {
3755        self.buf
3756    }
3757}
3758impl<'a> Iterator for IterableVfStatsAttrs<'a> {
3759    type Item = Result<VfStatsAttrs<'a>, ErrorContext>;
3760    fn next(&mut self) -> Option<Self::Item> {
3761        if self.buf.len() == self.pos {
3762            return None;
3763        }
3764        let pos = self.pos;
3765        let mut r#type = None;
3766        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
3767            r#type = Some(header.r#type);
3768            let res = match header.r#type {
3769                0u16 => VfStatsAttrs::RxPackets({
3770                    let res = parse_u64(next);
3771                    let Some(val) = res else { break };
3772                    val
3773                }),
3774                1u16 => VfStatsAttrs::TxPackets({
3775                    let res = parse_u64(next);
3776                    let Some(val) = res else { break };
3777                    val
3778                }),
3779                2u16 => VfStatsAttrs::RxBytes({
3780                    let res = parse_u64(next);
3781                    let Some(val) = res else { break };
3782                    val
3783                }),
3784                3u16 => VfStatsAttrs::TxBytes({
3785                    let res = parse_u64(next);
3786                    let Some(val) = res else { break };
3787                    val
3788                }),
3789                4u16 => VfStatsAttrs::Broadcast({
3790                    let res = parse_u64(next);
3791                    let Some(val) = res else { break };
3792                    val
3793                }),
3794                5u16 => VfStatsAttrs::Multicast({
3795                    let res = parse_u64(next);
3796                    let Some(val) = res else { break };
3797                    val
3798                }),
3799                6u16 => VfStatsAttrs::Pad({
3800                    let res = Some(next);
3801                    let Some(val) = res else { break };
3802                    val
3803                }),
3804                7u16 => VfStatsAttrs::RxDropped({
3805                    let res = parse_u64(next);
3806                    let Some(val) = res else { break };
3807                    val
3808                }),
3809                8u16 => VfStatsAttrs::TxDropped({
3810                    let res = parse_u64(next);
3811                    let Some(val) = res else { break };
3812                    val
3813                }),
3814                n => {
3815                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
3816                        break;
3817                    } else {
3818                        continue;
3819                    }
3820                }
3821            };
3822            return Some(Ok(res));
3823        }
3824        Some(Err(ErrorContext::new(
3825            "VfStatsAttrs",
3826            r#type.and_then(|t| VfStatsAttrs::attr_from_type(t)),
3827            self.orig_loc,
3828            self.buf.as_ptr().wrapping_add(pos) as usize,
3829        )))
3830    }
3831}
3832impl<'a> std::fmt::Debug for IterableVfStatsAttrs<'_> {
3833    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3834        let mut fmt = f.debug_struct("VfStatsAttrs");
3835        for attr in self.clone() {
3836            let attr = match attr {
3837                Ok(a) => a,
3838                Err(err) => {
3839                    fmt.finish()?;
3840                    f.write_str("Err(")?;
3841                    err.fmt(f)?;
3842                    return f.write_str(")");
3843                }
3844            };
3845            match attr {
3846                VfStatsAttrs::RxPackets(val) => fmt.field("RxPackets", &val),
3847                VfStatsAttrs::TxPackets(val) => fmt.field("TxPackets", &val),
3848                VfStatsAttrs::RxBytes(val) => fmt.field("RxBytes", &val),
3849                VfStatsAttrs::TxBytes(val) => fmt.field("TxBytes", &val),
3850                VfStatsAttrs::Broadcast(val) => fmt.field("Broadcast", &val),
3851                VfStatsAttrs::Multicast(val) => fmt.field("Multicast", &val),
3852                VfStatsAttrs::Pad(val) => fmt.field("Pad", &val),
3853                VfStatsAttrs::RxDropped(val) => fmt.field("RxDropped", &val),
3854                VfStatsAttrs::TxDropped(val) => fmt.field("TxDropped", &val),
3855            };
3856        }
3857        fmt.finish()
3858    }
3859}
3860impl IterableVfStatsAttrs<'_> {
3861    pub fn lookup_attr(
3862        &self,
3863        offset: usize,
3864        missing_type: Option<u16>,
3865    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3866        let mut stack = Vec::new();
3867        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3868        if cur == offset {
3869            stack.push(("VfStatsAttrs", offset));
3870            return (
3871                stack,
3872                missing_type.and_then(|t| VfStatsAttrs::attr_from_type(t)),
3873            );
3874        }
3875        if cur > offset || cur + self.buf.len() < offset {
3876            return (stack, None);
3877        }
3878        let mut attrs = self.clone();
3879        let mut last_off = cur + attrs.pos;
3880        while let Some(attr) = attrs.next() {
3881            let Ok(attr) = attr else { break };
3882            match attr {
3883                VfStatsAttrs::RxPackets(val) => {
3884                    if last_off == offset {
3885                        stack.push(("RxPackets", last_off));
3886                        break;
3887                    }
3888                }
3889                VfStatsAttrs::TxPackets(val) => {
3890                    if last_off == offset {
3891                        stack.push(("TxPackets", last_off));
3892                        break;
3893                    }
3894                }
3895                VfStatsAttrs::RxBytes(val) => {
3896                    if last_off == offset {
3897                        stack.push(("RxBytes", last_off));
3898                        break;
3899                    }
3900                }
3901                VfStatsAttrs::TxBytes(val) => {
3902                    if last_off == offset {
3903                        stack.push(("TxBytes", last_off));
3904                        break;
3905                    }
3906                }
3907                VfStatsAttrs::Broadcast(val) => {
3908                    if last_off == offset {
3909                        stack.push(("Broadcast", last_off));
3910                        break;
3911                    }
3912                }
3913                VfStatsAttrs::Multicast(val) => {
3914                    if last_off == offset {
3915                        stack.push(("Multicast", last_off));
3916                        break;
3917                    }
3918                }
3919                VfStatsAttrs::Pad(val) => {
3920                    if last_off == offset {
3921                        stack.push(("Pad", last_off));
3922                        break;
3923                    }
3924                }
3925                VfStatsAttrs::RxDropped(val) => {
3926                    if last_off == offset {
3927                        stack.push(("RxDropped", last_off));
3928                        break;
3929                    }
3930                }
3931                VfStatsAttrs::TxDropped(val) => {
3932                    if last_off == offset {
3933                        stack.push(("TxDropped", last_off));
3934                        break;
3935                    }
3936                }
3937                _ => {}
3938            };
3939            last_off = cur + attrs.pos;
3940        }
3941        if !stack.is_empty() {
3942            stack.push(("VfStatsAttrs", cur));
3943        }
3944        (stack, None)
3945    }
3946}
3947#[derive(Clone)]
3948pub enum VfVlanAttrs {
3949    #[doc = "Attribute may repeat multiple times (treat it as array)"]
3950    Info(PushIflaVfVlanInfo),
3951}
3952impl<'a> IterableVfVlanAttrs<'a> {
3953    #[doc = "Attribute may repeat multiple times (treat it as array)"]
3954    pub fn get_info(&self) -> MultiAttrIterable<Self, VfVlanAttrs, PushIflaVfVlanInfo> {
3955        MultiAttrIterable::new(self.clone(), |variant| {
3956            if let VfVlanAttrs::Info(val) = variant {
3957                Some(val)
3958            } else {
3959                None
3960            }
3961        })
3962    }
3963}
3964impl VfVlanAttrs {
3965    pub fn new(buf: &'_ [u8]) -> IterableVfVlanAttrs<'_> {
3966        IterableVfVlanAttrs::with_loc(buf, buf.as_ptr() as usize)
3967    }
3968    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3969        let res = match r#type {
3970            1u16 => "Info",
3971            _ => return None,
3972        };
3973        Some(res)
3974    }
3975}
3976#[derive(Clone, Copy, Default)]
3977pub struct IterableVfVlanAttrs<'a> {
3978    buf: &'a [u8],
3979    pos: usize,
3980    orig_loc: usize,
3981}
3982impl<'a> IterableVfVlanAttrs<'a> {
3983    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3984        Self {
3985            buf,
3986            pos: 0,
3987            orig_loc,
3988        }
3989    }
3990    pub fn get_buf(&self) -> &'a [u8] {
3991        self.buf
3992    }
3993}
3994impl<'a> Iterator for IterableVfVlanAttrs<'a> {
3995    type Item = Result<VfVlanAttrs, ErrorContext>;
3996    fn next(&mut self) -> Option<Self::Item> {
3997        if self.buf.len() == self.pos {
3998            return None;
3999        }
4000        let pos = self.pos;
4001        let mut r#type = None;
4002        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
4003            r#type = Some(header.r#type);
4004            let res = match header.r#type {
4005                1u16 => VfVlanAttrs::Info({
4006                    let res = PushIflaVfVlanInfo::new_from_slice(next);
4007                    let Some(val) = res else { break };
4008                    val
4009                }),
4010                n => {
4011                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
4012                        break;
4013                    } else {
4014                        continue;
4015                    }
4016                }
4017            };
4018            return Some(Ok(res));
4019        }
4020        Some(Err(ErrorContext::new(
4021            "VfVlanAttrs",
4022            r#type.and_then(|t| VfVlanAttrs::attr_from_type(t)),
4023            self.orig_loc,
4024            self.buf.as_ptr().wrapping_add(pos) as usize,
4025        )))
4026    }
4027}
4028impl std::fmt::Debug for IterableVfVlanAttrs<'_> {
4029    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4030        let mut fmt = f.debug_struct("VfVlanAttrs");
4031        for attr in self.clone() {
4032            let attr = match attr {
4033                Ok(a) => a,
4034                Err(err) => {
4035                    fmt.finish()?;
4036                    f.write_str("Err(")?;
4037                    err.fmt(f)?;
4038                    return f.write_str(")");
4039                }
4040            };
4041            match attr {
4042                VfVlanAttrs::Info(val) => fmt.field("Info", &val),
4043            };
4044        }
4045        fmt.finish()
4046    }
4047}
4048impl IterableVfVlanAttrs<'_> {
4049    pub fn lookup_attr(
4050        &self,
4051        offset: usize,
4052        missing_type: Option<u16>,
4053    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4054        let mut stack = Vec::new();
4055        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4056        if cur == offset {
4057            stack.push(("VfVlanAttrs", offset));
4058            return (
4059                stack,
4060                missing_type.and_then(|t| VfVlanAttrs::attr_from_type(t)),
4061            );
4062        }
4063        if cur > offset || cur + self.buf.len() < offset {
4064            return (stack, None);
4065        }
4066        let mut attrs = self.clone();
4067        let mut last_off = cur + attrs.pos;
4068        while let Some(attr) = attrs.next() {
4069            let Ok(attr) = attr else { break };
4070            match attr {
4071                VfVlanAttrs::Info(val) => {
4072                    if last_off == offset {
4073                        stack.push(("Info", last_off));
4074                        break;
4075                    }
4076                }
4077                _ => {}
4078            };
4079            last_off = cur + attrs.pos;
4080        }
4081        if !stack.is_empty() {
4082            stack.push(("VfVlanAttrs", cur));
4083        }
4084        (stack, None)
4085    }
4086}
4087#[derive(Clone)]
4088pub enum VfPortsAttrs {}
4089impl<'a> IterableVfPortsAttrs<'a> {}
4090impl VfPortsAttrs {
4091    pub fn new(buf: &'_ [u8]) -> IterableVfPortsAttrs<'_> {
4092        IterableVfPortsAttrs::with_loc(buf, buf.as_ptr() as usize)
4093    }
4094    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4095        None
4096    }
4097}
4098#[derive(Clone, Copy, Default)]
4099pub struct IterableVfPortsAttrs<'a> {
4100    buf: &'a [u8],
4101    pos: usize,
4102    orig_loc: usize,
4103}
4104impl<'a> IterableVfPortsAttrs<'a> {
4105    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4106        Self {
4107            buf,
4108            pos: 0,
4109            orig_loc,
4110        }
4111    }
4112    pub fn get_buf(&self) -> &'a [u8] {
4113        self.buf
4114    }
4115}
4116impl<'a> Iterator for IterableVfPortsAttrs<'a> {
4117    type Item = Result<VfPortsAttrs, ErrorContext>;
4118    fn next(&mut self) -> Option<Self::Item> {
4119        if self.buf.len() == self.pos {
4120            return None;
4121        }
4122        let pos = self.pos;
4123        let mut r#type = None;
4124        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
4125            r#type = Some(header.r#type);
4126            let res = match header.r#type {
4127                n => {
4128                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
4129                        break;
4130                    } else {
4131                        continue;
4132                    }
4133                }
4134            };
4135            return Some(Ok(res));
4136        }
4137        Some(Err(ErrorContext::new(
4138            "VfPortsAttrs",
4139            r#type.and_then(|t| VfPortsAttrs::attr_from_type(t)),
4140            self.orig_loc,
4141            self.buf.as_ptr().wrapping_add(pos) as usize,
4142        )))
4143    }
4144}
4145impl std::fmt::Debug for IterableVfPortsAttrs<'_> {
4146    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4147        let mut fmt = f.debug_struct("VfPortsAttrs");
4148        for attr in self.clone() {
4149            let attr = match attr {
4150                Ok(a) => a,
4151                Err(err) => {
4152                    fmt.finish()?;
4153                    f.write_str("Err(")?;
4154                    err.fmt(f)?;
4155                    return f.write_str(")");
4156                }
4157            };
4158            match attr {};
4159        }
4160        fmt.finish()
4161    }
4162}
4163impl IterableVfPortsAttrs<'_> {
4164    pub fn lookup_attr(
4165        &self,
4166        offset: usize,
4167        missing_type: Option<u16>,
4168    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4169        let mut stack = Vec::new();
4170        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4171        if cur == offset {
4172            stack.push(("VfPortsAttrs", offset));
4173            return (
4174                stack,
4175                missing_type.and_then(|t| VfPortsAttrs::attr_from_type(t)),
4176            );
4177        }
4178        (stack, None)
4179    }
4180}
4181#[derive(Clone)]
4182pub enum PortSelfAttrs {}
4183impl<'a> IterablePortSelfAttrs<'a> {}
4184impl PortSelfAttrs {
4185    pub fn new(buf: &'_ [u8]) -> IterablePortSelfAttrs<'_> {
4186        IterablePortSelfAttrs::with_loc(buf, buf.as_ptr() as usize)
4187    }
4188    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4189        None
4190    }
4191}
4192#[derive(Clone, Copy, Default)]
4193pub struct IterablePortSelfAttrs<'a> {
4194    buf: &'a [u8],
4195    pos: usize,
4196    orig_loc: usize,
4197}
4198impl<'a> IterablePortSelfAttrs<'a> {
4199    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4200        Self {
4201            buf,
4202            pos: 0,
4203            orig_loc,
4204        }
4205    }
4206    pub fn get_buf(&self) -> &'a [u8] {
4207        self.buf
4208    }
4209}
4210impl<'a> Iterator for IterablePortSelfAttrs<'a> {
4211    type Item = Result<PortSelfAttrs, ErrorContext>;
4212    fn next(&mut self) -> Option<Self::Item> {
4213        if self.buf.len() == self.pos {
4214            return None;
4215        }
4216        let pos = self.pos;
4217        let mut r#type = None;
4218        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
4219            r#type = Some(header.r#type);
4220            let res = match header.r#type {
4221                n => {
4222                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
4223                        break;
4224                    } else {
4225                        continue;
4226                    }
4227                }
4228            };
4229            return Some(Ok(res));
4230        }
4231        Some(Err(ErrorContext::new(
4232            "PortSelfAttrs",
4233            r#type.and_then(|t| PortSelfAttrs::attr_from_type(t)),
4234            self.orig_loc,
4235            self.buf.as_ptr().wrapping_add(pos) as usize,
4236        )))
4237    }
4238}
4239impl std::fmt::Debug for IterablePortSelfAttrs<'_> {
4240    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4241        let mut fmt = f.debug_struct("PortSelfAttrs");
4242        for attr in self.clone() {
4243            let attr = match attr {
4244                Ok(a) => a,
4245                Err(err) => {
4246                    fmt.finish()?;
4247                    f.write_str("Err(")?;
4248                    err.fmt(f)?;
4249                    return f.write_str(")");
4250                }
4251            };
4252            match attr {};
4253        }
4254        fmt.finish()
4255    }
4256}
4257impl IterablePortSelfAttrs<'_> {
4258    pub fn lookup_attr(
4259        &self,
4260        offset: usize,
4261        missing_type: Option<u16>,
4262    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4263        let mut stack = Vec::new();
4264        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4265        if cur == offset {
4266            stack.push(("PortSelfAttrs", offset));
4267            return (
4268                stack,
4269                missing_type.and_then(|t| PortSelfAttrs::attr_from_type(t)),
4270            );
4271        }
4272        (stack, None)
4273    }
4274}
4275#[derive(Clone)]
4276pub enum LinkinfoAttrs<'a> {
4277    Kind(&'a CStr),
4278    Data(LinkinfoDataMsg<'a>),
4279    Xstats(&'a [u8]),
4280    SlaveKind(&'a CStr),
4281    SlaveData(LinkinfoMemberDataMsg<'a>),
4282}
4283impl<'a> IterableLinkinfoAttrs<'a> {
4284    pub fn get_kind(&self) -> Result<&'a CStr, ErrorContext> {
4285        let mut iter = self.clone();
4286        iter.pos = 0;
4287        for attr in iter {
4288            if let LinkinfoAttrs::Kind(val) = attr? {
4289                return Ok(val);
4290            }
4291        }
4292        Err(ErrorContext::new_missing(
4293            "LinkinfoAttrs",
4294            "Kind",
4295            self.orig_loc,
4296            self.buf.as_ptr() as usize,
4297        ))
4298    }
4299    pub fn get_data(&self) -> Result<LinkinfoDataMsg<'a>, ErrorContext> {
4300        let mut iter = self.clone();
4301        iter.pos = 0;
4302        for attr in iter {
4303            if let LinkinfoAttrs::Data(val) = attr? {
4304                return Ok(val);
4305            }
4306        }
4307        Err(ErrorContext::new_missing(
4308            "LinkinfoAttrs",
4309            "Data",
4310            self.orig_loc,
4311            self.buf.as_ptr() as usize,
4312        ))
4313    }
4314    pub fn get_xstats(&self) -> Result<&'a [u8], ErrorContext> {
4315        let mut iter = self.clone();
4316        iter.pos = 0;
4317        for attr in iter {
4318            if let LinkinfoAttrs::Xstats(val) = attr? {
4319                return Ok(val);
4320            }
4321        }
4322        Err(ErrorContext::new_missing(
4323            "LinkinfoAttrs",
4324            "Xstats",
4325            self.orig_loc,
4326            self.buf.as_ptr() as usize,
4327        ))
4328    }
4329    pub fn get_slave_kind(&self) -> Result<&'a CStr, ErrorContext> {
4330        let mut iter = self.clone();
4331        iter.pos = 0;
4332        for attr in iter {
4333            if let LinkinfoAttrs::SlaveKind(val) = attr? {
4334                return Ok(val);
4335            }
4336        }
4337        Err(ErrorContext::new_missing(
4338            "LinkinfoAttrs",
4339            "SlaveKind",
4340            self.orig_loc,
4341            self.buf.as_ptr() as usize,
4342        ))
4343    }
4344    pub fn get_slave_data(&self) -> Result<LinkinfoMemberDataMsg<'a>, ErrorContext> {
4345        let mut iter = self.clone();
4346        iter.pos = 0;
4347        for attr in iter {
4348            if let LinkinfoAttrs::SlaveData(val) = attr? {
4349                return Ok(val);
4350            }
4351        }
4352        Err(ErrorContext::new_missing(
4353            "LinkinfoAttrs",
4354            "SlaveData",
4355            self.orig_loc,
4356            self.buf.as_ptr() as usize,
4357        ))
4358    }
4359}
4360#[derive(Debug, Clone)]
4361pub enum LinkinfoDataMsg<'a> {
4362    Bond(IterableLinkinfoBondAttrs<'a>),
4363    Bridge(IterableLinkinfoBridgeAttrs<'a>),
4364    Erspan(IterableLinkinfoGreAttrs<'a>),
4365    Gre(IterableLinkinfoGreAttrs<'a>),
4366    Gretap(IterableLinkinfoGreAttrs<'a>),
4367    Ip6gre(IterableLinkinfoGre6Attrs<'a>),
4368    Geneve(IterableLinkinfoGeneveAttrs<'a>),
4369    Ipip(IterableLinkinfoIptunAttrs<'a>),
4370    Ip6tnl(IterableLinkinfoIp6tnlAttrs<'a>),
4371    Sit(IterableLinkinfoIptunAttrs<'a>),
4372    Tun(IterableLinkinfoTunAttrs<'a>),
4373    Vlan(IterableLinkinfoVlanAttrs<'a>),
4374    Vrf(IterableLinkinfoVrfAttrs<'a>),
4375    Vti(IterableLinkinfoVtiAttrs<'a>),
4376    Vti6(IterableLinkinfoVti6Attrs<'a>),
4377    Netkit(IterableLinkinfoNetkitAttrs<'a>),
4378    Ovpn(IterableLinkinfoOvpnAttrs<'a>),
4379}
4380impl<'a> LinkinfoDataMsg<'a> {
4381    fn select_with_loc(selector: &'a CStr, buf: &'a [u8], loc: usize) -> Option<Self> {
4382        match selector.to_bytes() {
4383            b"bond" => Some(LinkinfoDataMsg::Bond(IterableLinkinfoBondAttrs::with_loc(
4384                buf, loc,
4385            ))),
4386            b"bridge" => Some(LinkinfoDataMsg::Bridge(
4387                IterableLinkinfoBridgeAttrs::with_loc(buf, loc),
4388            )),
4389            b"erspan" => Some(LinkinfoDataMsg::Erspan(IterableLinkinfoGreAttrs::with_loc(
4390                buf, loc,
4391            ))),
4392            b"gre" => Some(LinkinfoDataMsg::Gre(IterableLinkinfoGreAttrs::with_loc(
4393                buf, loc,
4394            ))),
4395            b"gretap" => Some(LinkinfoDataMsg::Gretap(IterableLinkinfoGreAttrs::with_loc(
4396                buf, loc,
4397            ))),
4398            b"ip6gre" => Some(LinkinfoDataMsg::Ip6gre(
4399                IterableLinkinfoGre6Attrs::with_loc(buf, loc),
4400            )),
4401            b"geneve" => Some(LinkinfoDataMsg::Geneve(
4402                IterableLinkinfoGeneveAttrs::with_loc(buf, loc),
4403            )),
4404            b"ipip" => Some(LinkinfoDataMsg::Ipip(IterableLinkinfoIptunAttrs::with_loc(
4405                buf, loc,
4406            ))),
4407            b"ip6tnl" => Some(LinkinfoDataMsg::Ip6tnl(
4408                IterableLinkinfoIp6tnlAttrs::with_loc(buf, loc),
4409            )),
4410            b"sit" => Some(LinkinfoDataMsg::Sit(IterableLinkinfoIptunAttrs::with_loc(
4411                buf, loc,
4412            ))),
4413            b"tun" => Some(LinkinfoDataMsg::Tun(IterableLinkinfoTunAttrs::with_loc(
4414                buf, loc,
4415            ))),
4416            b"vlan" => Some(LinkinfoDataMsg::Vlan(IterableLinkinfoVlanAttrs::with_loc(
4417                buf, loc,
4418            ))),
4419            b"vrf" => Some(LinkinfoDataMsg::Vrf(IterableLinkinfoVrfAttrs::with_loc(
4420                buf, loc,
4421            ))),
4422            b"vti" => Some(LinkinfoDataMsg::Vti(IterableLinkinfoVtiAttrs::with_loc(
4423                buf, loc,
4424            ))),
4425            b"vti6" => Some(LinkinfoDataMsg::Vti6(IterableLinkinfoVti6Attrs::with_loc(
4426                buf, loc,
4427            ))),
4428            b"netkit" => Some(LinkinfoDataMsg::Netkit(
4429                IterableLinkinfoNetkitAttrs::with_loc(buf, loc),
4430            )),
4431            b"ovpn" => Some(LinkinfoDataMsg::Ovpn(IterableLinkinfoOvpnAttrs::with_loc(
4432                buf, loc,
4433            ))),
4434            _ => None,
4435        }
4436    }
4437}
4438#[derive(Debug, Clone)]
4439pub enum LinkinfoMemberDataMsg<'a> {
4440    Bridge(IterableLinkinfoBrportAttrs<'a>),
4441    Bond(IterableBondSlaveAttrs<'a>),
4442}
4443impl<'a> LinkinfoMemberDataMsg<'a> {
4444    fn select_with_loc(selector: &'a CStr, buf: &'a [u8], loc: usize) -> Option<Self> {
4445        match selector.to_bytes() {
4446            b"bridge" => Some(LinkinfoMemberDataMsg::Bridge(
4447                IterableLinkinfoBrportAttrs::with_loc(buf, loc),
4448            )),
4449            b"bond" => Some(LinkinfoMemberDataMsg::Bond(
4450                IterableBondSlaveAttrs::with_loc(buf, loc),
4451            )),
4452            _ => None,
4453        }
4454    }
4455}
4456impl<'a> LinkinfoAttrs<'a> {
4457    pub fn new(buf: &'a [u8]) -> IterableLinkinfoAttrs<'a> {
4458        IterableLinkinfoAttrs::with_loc(buf, buf.as_ptr() as usize)
4459    }
4460    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4461        let res = match r#type {
4462            1u16 => "Kind",
4463            2u16 => "Data",
4464            3u16 => "Xstats",
4465            4u16 => "SlaveKind",
4466            5u16 => "SlaveData",
4467            _ => return None,
4468        };
4469        Some(res)
4470    }
4471}
4472#[derive(Clone, Copy, Default)]
4473pub struct IterableLinkinfoAttrs<'a> {
4474    buf: &'a [u8],
4475    pos: usize,
4476    orig_loc: usize,
4477}
4478impl<'a> IterableLinkinfoAttrs<'a> {
4479    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4480        Self {
4481            buf,
4482            pos: 0,
4483            orig_loc,
4484        }
4485    }
4486    pub fn get_buf(&self) -> &'a [u8] {
4487        self.buf
4488    }
4489}
4490impl<'a> Iterator for IterableLinkinfoAttrs<'a> {
4491    type Item = Result<LinkinfoAttrs<'a>, ErrorContext>;
4492    fn next(&mut self) -> Option<Self::Item> {
4493        if self.buf.len() == self.pos {
4494            return None;
4495        }
4496        let pos = self.pos;
4497        let mut r#type = None;
4498        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
4499            r#type = Some(header.r#type);
4500            let res = match header.r#type {
4501                1u16 => LinkinfoAttrs::Kind({
4502                    let res = CStr::from_bytes_with_nul(next).ok();
4503                    let Some(val) = res else { break };
4504                    val
4505                }),
4506                2u16 => LinkinfoAttrs::Data({
4507                    let res = {
4508                        let Ok(selector) = self.get_kind() else { break };
4509                        LinkinfoDataMsg::select_with_loc(selector, next, self.orig_loc)
4510                    };
4511                    let Some(val) = res else { break };
4512                    val
4513                }),
4514                3u16 => LinkinfoAttrs::Xstats({
4515                    let res = Some(next);
4516                    let Some(val) = res else { break };
4517                    val
4518                }),
4519                4u16 => LinkinfoAttrs::SlaveKind({
4520                    let res = CStr::from_bytes_with_nul(next).ok();
4521                    let Some(val) = res else { break };
4522                    val
4523                }),
4524                5u16 => LinkinfoAttrs::SlaveData({
4525                    let res = {
4526                        let Ok(selector) = self.get_slave_kind() else {
4527                            break;
4528                        };
4529                        LinkinfoMemberDataMsg::select_with_loc(selector, next, self.orig_loc)
4530                    };
4531                    let Some(val) = res else { break };
4532                    val
4533                }),
4534                n => {
4535                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
4536                        break;
4537                    } else {
4538                        continue;
4539                    }
4540                }
4541            };
4542            return Some(Ok(res));
4543        }
4544        Some(Err(ErrorContext::new(
4545            "LinkinfoAttrs",
4546            r#type.and_then(|t| LinkinfoAttrs::attr_from_type(t)),
4547            self.orig_loc,
4548            self.buf.as_ptr().wrapping_add(pos) as usize,
4549        )))
4550    }
4551}
4552impl<'a> std::fmt::Debug for IterableLinkinfoAttrs<'_> {
4553    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4554        let mut fmt = f.debug_struct("LinkinfoAttrs");
4555        for attr in self.clone() {
4556            let attr = match attr {
4557                Ok(a) => a,
4558                Err(err) => {
4559                    fmt.finish()?;
4560                    f.write_str("Err(")?;
4561                    err.fmt(f)?;
4562                    return f.write_str(")");
4563                }
4564            };
4565            match attr {
4566                LinkinfoAttrs::Kind(val) => fmt.field("Kind", &val),
4567                LinkinfoAttrs::Data(val) => fmt.field("Data", &val),
4568                LinkinfoAttrs::Xstats(val) => fmt.field("Xstats", &val),
4569                LinkinfoAttrs::SlaveKind(val) => fmt.field("SlaveKind", &val),
4570                LinkinfoAttrs::SlaveData(val) => fmt.field("SlaveData", &val),
4571            };
4572        }
4573        fmt.finish()
4574    }
4575}
4576impl IterableLinkinfoAttrs<'_> {
4577    pub fn lookup_attr(
4578        &self,
4579        offset: usize,
4580        missing_type: Option<u16>,
4581    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4582        let mut stack = Vec::new();
4583        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4584        if cur == offset {
4585            stack.push(("LinkinfoAttrs", offset));
4586            return (
4587                stack,
4588                missing_type.and_then(|t| LinkinfoAttrs::attr_from_type(t)),
4589            );
4590        }
4591        if cur > offset || cur + self.buf.len() < offset {
4592            return (stack, None);
4593        }
4594        let mut attrs = self.clone();
4595        let mut last_off = cur + attrs.pos;
4596        while let Some(attr) = attrs.next() {
4597            let Ok(attr) = attr else { break };
4598            match attr {
4599                LinkinfoAttrs::Kind(val) => {
4600                    if last_off == offset {
4601                        stack.push(("Kind", last_off));
4602                        break;
4603                    }
4604                }
4605                LinkinfoAttrs::Data(val) => {
4606                    if last_off == offset {
4607                        stack.push(("Data", last_off));
4608                        break;
4609                    }
4610                }
4611                LinkinfoAttrs::Xstats(val) => {
4612                    if last_off == offset {
4613                        stack.push(("Xstats", last_off));
4614                        break;
4615                    }
4616                }
4617                LinkinfoAttrs::SlaveKind(val) => {
4618                    if last_off == offset {
4619                        stack.push(("SlaveKind", last_off));
4620                        break;
4621                    }
4622                }
4623                LinkinfoAttrs::SlaveData(val) => {
4624                    if last_off == offset {
4625                        stack.push(("SlaveData", last_off));
4626                        break;
4627                    }
4628                }
4629                _ => {}
4630            };
4631            last_off = cur + attrs.pos;
4632        }
4633        if !stack.is_empty() {
4634            stack.push(("LinkinfoAttrs", cur));
4635        }
4636        (stack, None)
4637    }
4638}
4639#[derive(Clone)]
4640pub enum LinkinfoBondAttrs<'a> {
4641    Mode(u8),
4642    ActiveSlave(u32),
4643    Miimon(u32),
4644    Updelay(u32),
4645    Downdelay(u32),
4646    UseCarrier(u8),
4647    ArpInterval(u32),
4648    ArpIpTarget(IterableArrayIpv4Addr<'a>),
4649    ArpValidate(u32),
4650    ArpAllTargets(u32),
4651    Primary(u32),
4652    PrimaryReselect(u8),
4653    FailOverMac(u8),
4654    XmitHashPolicy(u8),
4655    ResendIgmp(u32),
4656    NumPeerNotif(u8),
4657    AllSlavesActive(u8),
4658    MinLinks(u32),
4659    LpInterval(u32),
4660    PacketsPerSlave(u32),
4661    AdLacpRate(u8),
4662    AdSelect(u8),
4663    AdInfo(IterableBondAdInfoAttrs<'a>),
4664    AdActorSysPrio(u16),
4665    AdUserPortKey(u16),
4666    AdActorSystem(&'a [u8]),
4667    TlbDynamicLb(u8),
4668    PeerNotifDelay(u32),
4669    AdLacpActive(u8),
4670    MissedMax(u8),
4671    NsIp6Target(IterableArrayBinary<'a>),
4672    CoupledControl(u8),
4673}
4674impl<'a> IterableLinkinfoBondAttrs<'a> {
4675    pub fn get_mode(&self) -> Result<u8, ErrorContext> {
4676        let mut iter = self.clone();
4677        iter.pos = 0;
4678        for attr in iter {
4679            if let LinkinfoBondAttrs::Mode(val) = attr? {
4680                return Ok(val);
4681            }
4682        }
4683        Err(ErrorContext::new_missing(
4684            "LinkinfoBondAttrs",
4685            "Mode",
4686            self.orig_loc,
4687            self.buf.as_ptr() as usize,
4688        ))
4689    }
4690    pub fn get_active_slave(&self) -> Result<u32, ErrorContext> {
4691        let mut iter = self.clone();
4692        iter.pos = 0;
4693        for attr in iter {
4694            if let LinkinfoBondAttrs::ActiveSlave(val) = attr? {
4695                return Ok(val);
4696            }
4697        }
4698        Err(ErrorContext::new_missing(
4699            "LinkinfoBondAttrs",
4700            "ActiveSlave",
4701            self.orig_loc,
4702            self.buf.as_ptr() as usize,
4703        ))
4704    }
4705    pub fn get_miimon(&self) -> Result<u32, ErrorContext> {
4706        let mut iter = self.clone();
4707        iter.pos = 0;
4708        for attr in iter {
4709            if let LinkinfoBondAttrs::Miimon(val) = attr? {
4710                return Ok(val);
4711            }
4712        }
4713        Err(ErrorContext::new_missing(
4714            "LinkinfoBondAttrs",
4715            "Miimon",
4716            self.orig_loc,
4717            self.buf.as_ptr() as usize,
4718        ))
4719    }
4720    pub fn get_updelay(&self) -> Result<u32, ErrorContext> {
4721        let mut iter = self.clone();
4722        iter.pos = 0;
4723        for attr in iter {
4724            if let LinkinfoBondAttrs::Updelay(val) = attr? {
4725                return Ok(val);
4726            }
4727        }
4728        Err(ErrorContext::new_missing(
4729            "LinkinfoBondAttrs",
4730            "Updelay",
4731            self.orig_loc,
4732            self.buf.as_ptr() as usize,
4733        ))
4734    }
4735    pub fn get_downdelay(&self) -> Result<u32, ErrorContext> {
4736        let mut iter = self.clone();
4737        iter.pos = 0;
4738        for attr in iter {
4739            if let LinkinfoBondAttrs::Downdelay(val) = attr? {
4740                return Ok(val);
4741            }
4742        }
4743        Err(ErrorContext::new_missing(
4744            "LinkinfoBondAttrs",
4745            "Downdelay",
4746            self.orig_loc,
4747            self.buf.as_ptr() as usize,
4748        ))
4749    }
4750    pub fn get_use_carrier(&self) -> Result<u8, ErrorContext> {
4751        let mut iter = self.clone();
4752        iter.pos = 0;
4753        for attr in iter {
4754            if let LinkinfoBondAttrs::UseCarrier(val) = attr? {
4755                return Ok(val);
4756            }
4757        }
4758        Err(ErrorContext::new_missing(
4759            "LinkinfoBondAttrs",
4760            "UseCarrier",
4761            self.orig_loc,
4762            self.buf.as_ptr() as usize,
4763        ))
4764    }
4765    pub fn get_arp_interval(&self) -> Result<u32, ErrorContext> {
4766        let mut iter = self.clone();
4767        iter.pos = 0;
4768        for attr in iter {
4769            if let LinkinfoBondAttrs::ArpInterval(val) = attr? {
4770                return Ok(val);
4771            }
4772        }
4773        Err(ErrorContext::new_missing(
4774            "LinkinfoBondAttrs",
4775            "ArpInterval",
4776            self.orig_loc,
4777            self.buf.as_ptr() as usize,
4778        ))
4779    }
4780    pub fn get_arp_ip_target(
4781        &self,
4782    ) -> Result<ArrayIterable<IterableArrayIpv4Addr<'a>, std::net::Ipv4Addr>, ErrorContext> {
4783        for attr in self.clone() {
4784            if let LinkinfoBondAttrs::ArpIpTarget(val) = attr? {
4785                return Ok(ArrayIterable::new(val));
4786            }
4787        }
4788        Err(ErrorContext::new_missing(
4789            "LinkinfoBondAttrs",
4790            "ArpIpTarget",
4791            self.orig_loc,
4792            self.buf.as_ptr() as usize,
4793        ))
4794    }
4795    pub fn get_arp_validate(&self) -> Result<u32, ErrorContext> {
4796        let mut iter = self.clone();
4797        iter.pos = 0;
4798        for attr in iter {
4799            if let LinkinfoBondAttrs::ArpValidate(val) = attr? {
4800                return Ok(val);
4801            }
4802        }
4803        Err(ErrorContext::new_missing(
4804            "LinkinfoBondAttrs",
4805            "ArpValidate",
4806            self.orig_loc,
4807            self.buf.as_ptr() as usize,
4808        ))
4809    }
4810    pub fn get_arp_all_targets(&self) -> Result<u32, ErrorContext> {
4811        let mut iter = self.clone();
4812        iter.pos = 0;
4813        for attr in iter {
4814            if let LinkinfoBondAttrs::ArpAllTargets(val) = attr? {
4815                return Ok(val);
4816            }
4817        }
4818        Err(ErrorContext::new_missing(
4819            "LinkinfoBondAttrs",
4820            "ArpAllTargets",
4821            self.orig_loc,
4822            self.buf.as_ptr() as usize,
4823        ))
4824    }
4825    pub fn get_primary(&self) -> Result<u32, ErrorContext> {
4826        let mut iter = self.clone();
4827        iter.pos = 0;
4828        for attr in iter {
4829            if let LinkinfoBondAttrs::Primary(val) = attr? {
4830                return Ok(val);
4831            }
4832        }
4833        Err(ErrorContext::new_missing(
4834            "LinkinfoBondAttrs",
4835            "Primary",
4836            self.orig_loc,
4837            self.buf.as_ptr() as usize,
4838        ))
4839    }
4840    pub fn get_primary_reselect(&self) -> Result<u8, ErrorContext> {
4841        let mut iter = self.clone();
4842        iter.pos = 0;
4843        for attr in iter {
4844            if let LinkinfoBondAttrs::PrimaryReselect(val) = attr? {
4845                return Ok(val);
4846            }
4847        }
4848        Err(ErrorContext::new_missing(
4849            "LinkinfoBondAttrs",
4850            "PrimaryReselect",
4851            self.orig_loc,
4852            self.buf.as_ptr() as usize,
4853        ))
4854    }
4855    pub fn get_fail_over_mac(&self) -> Result<u8, ErrorContext> {
4856        let mut iter = self.clone();
4857        iter.pos = 0;
4858        for attr in iter {
4859            if let LinkinfoBondAttrs::FailOverMac(val) = attr? {
4860                return Ok(val);
4861            }
4862        }
4863        Err(ErrorContext::new_missing(
4864            "LinkinfoBondAttrs",
4865            "FailOverMac",
4866            self.orig_loc,
4867            self.buf.as_ptr() as usize,
4868        ))
4869    }
4870    pub fn get_xmit_hash_policy(&self) -> Result<u8, ErrorContext> {
4871        let mut iter = self.clone();
4872        iter.pos = 0;
4873        for attr in iter {
4874            if let LinkinfoBondAttrs::XmitHashPolicy(val) = attr? {
4875                return Ok(val);
4876            }
4877        }
4878        Err(ErrorContext::new_missing(
4879            "LinkinfoBondAttrs",
4880            "XmitHashPolicy",
4881            self.orig_loc,
4882            self.buf.as_ptr() as usize,
4883        ))
4884    }
4885    pub fn get_resend_igmp(&self) -> Result<u32, ErrorContext> {
4886        let mut iter = self.clone();
4887        iter.pos = 0;
4888        for attr in iter {
4889            if let LinkinfoBondAttrs::ResendIgmp(val) = attr? {
4890                return Ok(val);
4891            }
4892        }
4893        Err(ErrorContext::new_missing(
4894            "LinkinfoBondAttrs",
4895            "ResendIgmp",
4896            self.orig_loc,
4897            self.buf.as_ptr() as usize,
4898        ))
4899    }
4900    pub fn get_num_peer_notif(&self) -> Result<u8, ErrorContext> {
4901        let mut iter = self.clone();
4902        iter.pos = 0;
4903        for attr in iter {
4904            if let LinkinfoBondAttrs::NumPeerNotif(val) = attr? {
4905                return Ok(val);
4906            }
4907        }
4908        Err(ErrorContext::new_missing(
4909            "LinkinfoBondAttrs",
4910            "NumPeerNotif",
4911            self.orig_loc,
4912            self.buf.as_ptr() as usize,
4913        ))
4914    }
4915    pub fn get_all_slaves_active(&self) -> Result<u8, ErrorContext> {
4916        let mut iter = self.clone();
4917        iter.pos = 0;
4918        for attr in iter {
4919            if let LinkinfoBondAttrs::AllSlavesActive(val) = attr? {
4920                return Ok(val);
4921            }
4922        }
4923        Err(ErrorContext::new_missing(
4924            "LinkinfoBondAttrs",
4925            "AllSlavesActive",
4926            self.orig_loc,
4927            self.buf.as_ptr() as usize,
4928        ))
4929    }
4930    pub fn get_min_links(&self) -> Result<u32, ErrorContext> {
4931        let mut iter = self.clone();
4932        iter.pos = 0;
4933        for attr in iter {
4934            if let LinkinfoBondAttrs::MinLinks(val) = attr? {
4935                return Ok(val);
4936            }
4937        }
4938        Err(ErrorContext::new_missing(
4939            "LinkinfoBondAttrs",
4940            "MinLinks",
4941            self.orig_loc,
4942            self.buf.as_ptr() as usize,
4943        ))
4944    }
4945    pub fn get_lp_interval(&self) -> Result<u32, ErrorContext> {
4946        let mut iter = self.clone();
4947        iter.pos = 0;
4948        for attr in iter {
4949            if let LinkinfoBondAttrs::LpInterval(val) = attr? {
4950                return Ok(val);
4951            }
4952        }
4953        Err(ErrorContext::new_missing(
4954            "LinkinfoBondAttrs",
4955            "LpInterval",
4956            self.orig_loc,
4957            self.buf.as_ptr() as usize,
4958        ))
4959    }
4960    pub fn get_packets_per_slave(&self) -> Result<u32, ErrorContext> {
4961        let mut iter = self.clone();
4962        iter.pos = 0;
4963        for attr in iter {
4964            if let LinkinfoBondAttrs::PacketsPerSlave(val) = attr? {
4965                return Ok(val);
4966            }
4967        }
4968        Err(ErrorContext::new_missing(
4969            "LinkinfoBondAttrs",
4970            "PacketsPerSlave",
4971            self.orig_loc,
4972            self.buf.as_ptr() as usize,
4973        ))
4974    }
4975    pub fn get_ad_lacp_rate(&self) -> Result<u8, ErrorContext> {
4976        let mut iter = self.clone();
4977        iter.pos = 0;
4978        for attr in iter {
4979            if let LinkinfoBondAttrs::AdLacpRate(val) = attr? {
4980                return Ok(val);
4981            }
4982        }
4983        Err(ErrorContext::new_missing(
4984            "LinkinfoBondAttrs",
4985            "AdLacpRate",
4986            self.orig_loc,
4987            self.buf.as_ptr() as usize,
4988        ))
4989    }
4990    pub fn get_ad_select(&self) -> Result<u8, ErrorContext> {
4991        let mut iter = self.clone();
4992        iter.pos = 0;
4993        for attr in iter {
4994            if let LinkinfoBondAttrs::AdSelect(val) = attr? {
4995                return Ok(val);
4996            }
4997        }
4998        Err(ErrorContext::new_missing(
4999            "LinkinfoBondAttrs",
5000            "AdSelect",
5001            self.orig_loc,
5002            self.buf.as_ptr() as usize,
5003        ))
5004    }
5005    pub fn get_ad_info(&self) -> Result<IterableBondAdInfoAttrs<'a>, ErrorContext> {
5006        let mut iter = self.clone();
5007        iter.pos = 0;
5008        for attr in iter {
5009            if let LinkinfoBondAttrs::AdInfo(val) = attr? {
5010                return Ok(val);
5011            }
5012        }
5013        Err(ErrorContext::new_missing(
5014            "LinkinfoBondAttrs",
5015            "AdInfo",
5016            self.orig_loc,
5017            self.buf.as_ptr() as usize,
5018        ))
5019    }
5020    pub fn get_ad_actor_sys_prio(&self) -> Result<u16, ErrorContext> {
5021        let mut iter = self.clone();
5022        iter.pos = 0;
5023        for attr in iter {
5024            if let LinkinfoBondAttrs::AdActorSysPrio(val) = attr? {
5025                return Ok(val);
5026            }
5027        }
5028        Err(ErrorContext::new_missing(
5029            "LinkinfoBondAttrs",
5030            "AdActorSysPrio",
5031            self.orig_loc,
5032            self.buf.as_ptr() as usize,
5033        ))
5034    }
5035    pub fn get_ad_user_port_key(&self) -> Result<u16, ErrorContext> {
5036        let mut iter = self.clone();
5037        iter.pos = 0;
5038        for attr in iter {
5039            if let LinkinfoBondAttrs::AdUserPortKey(val) = attr? {
5040                return Ok(val);
5041            }
5042        }
5043        Err(ErrorContext::new_missing(
5044            "LinkinfoBondAttrs",
5045            "AdUserPortKey",
5046            self.orig_loc,
5047            self.buf.as_ptr() as usize,
5048        ))
5049    }
5050    pub fn get_ad_actor_system(&self) -> Result<&'a [u8], ErrorContext> {
5051        let mut iter = self.clone();
5052        iter.pos = 0;
5053        for attr in iter {
5054            if let LinkinfoBondAttrs::AdActorSystem(val) = attr? {
5055                return Ok(val);
5056            }
5057        }
5058        Err(ErrorContext::new_missing(
5059            "LinkinfoBondAttrs",
5060            "AdActorSystem",
5061            self.orig_loc,
5062            self.buf.as_ptr() as usize,
5063        ))
5064    }
5065    pub fn get_tlb_dynamic_lb(&self) -> Result<u8, ErrorContext> {
5066        let mut iter = self.clone();
5067        iter.pos = 0;
5068        for attr in iter {
5069            if let LinkinfoBondAttrs::TlbDynamicLb(val) = attr? {
5070                return Ok(val);
5071            }
5072        }
5073        Err(ErrorContext::new_missing(
5074            "LinkinfoBondAttrs",
5075            "TlbDynamicLb",
5076            self.orig_loc,
5077            self.buf.as_ptr() as usize,
5078        ))
5079    }
5080    pub fn get_peer_notif_delay(&self) -> Result<u32, ErrorContext> {
5081        let mut iter = self.clone();
5082        iter.pos = 0;
5083        for attr in iter {
5084            if let LinkinfoBondAttrs::PeerNotifDelay(val) = attr? {
5085                return Ok(val);
5086            }
5087        }
5088        Err(ErrorContext::new_missing(
5089            "LinkinfoBondAttrs",
5090            "PeerNotifDelay",
5091            self.orig_loc,
5092            self.buf.as_ptr() as usize,
5093        ))
5094    }
5095    pub fn get_ad_lacp_active(&self) -> Result<u8, ErrorContext> {
5096        let mut iter = self.clone();
5097        iter.pos = 0;
5098        for attr in iter {
5099            if let LinkinfoBondAttrs::AdLacpActive(val) = attr? {
5100                return Ok(val);
5101            }
5102        }
5103        Err(ErrorContext::new_missing(
5104            "LinkinfoBondAttrs",
5105            "AdLacpActive",
5106            self.orig_loc,
5107            self.buf.as_ptr() as usize,
5108        ))
5109    }
5110    pub fn get_missed_max(&self) -> Result<u8, ErrorContext> {
5111        let mut iter = self.clone();
5112        iter.pos = 0;
5113        for attr in iter {
5114            if let LinkinfoBondAttrs::MissedMax(val) = attr? {
5115                return Ok(val);
5116            }
5117        }
5118        Err(ErrorContext::new_missing(
5119            "LinkinfoBondAttrs",
5120            "MissedMax",
5121            self.orig_loc,
5122            self.buf.as_ptr() as usize,
5123        ))
5124    }
5125    pub fn get_ns_ip6_target(
5126        &self,
5127    ) -> Result<ArrayIterable<IterableArrayBinary<'a>, &'a [u8]>, ErrorContext> {
5128        for attr in self.clone() {
5129            if let LinkinfoBondAttrs::NsIp6Target(val) = attr? {
5130                return Ok(ArrayIterable::new(val));
5131            }
5132        }
5133        Err(ErrorContext::new_missing(
5134            "LinkinfoBondAttrs",
5135            "NsIp6Target",
5136            self.orig_loc,
5137            self.buf.as_ptr() as usize,
5138        ))
5139    }
5140    pub fn get_coupled_control(&self) -> Result<u8, ErrorContext> {
5141        let mut iter = self.clone();
5142        iter.pos = 0;
5143        for attr in iter {
5144            if let LinkinfoBondAttrs::CoupledControl(val) = attr? {
5145                return Ok(val);
5146            }
5147        }
5148        Err(ErrorContext::new_missing(
5149            "LinkinfoBondAttrs",
5150            "CoupledControl",
5151            self.orig_loc,
5152            self.buf.as_ptr() as usize,
5153        ))
5154    }
5155}
5156#[derive(Clone, Copy, Default)]
5157pub struct IterableArrayIpv4Addr<'a> {
5158    buf: &'a [u8],
5159    pos: usize,
5160    orig_loc: usize,
5161}
5162impl<'a> IterableArrayIpv4Addr<'a> {
5163    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5164        Self {
5165            buf,
5166            pos: 0,
5167            orig_loc,
5168        }
5169    }
5170    pub fn get_buf(&self) -> &'a [u8] {
5171        self.buf
5172    }
5173}
5174impl<'a> Iterator for IterableArrayIpv4Addr<'a> {
5175    type Item = Result<std::net::Ipv4Addr, ErrorContext>;
5176    fn next(&mut self) -> Option<Self::Item> {
5177        if self.buf.len() == self.pos {
5178            return None;
5179        }
5180        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
5181            {
5182                let Some(res) = parse_be_u32(next).map(Ipv4Addr::from_bits) else {
5183                    break;
5184                };
5185                return Some(Ok(res));
5186            }
5187        }
5188        Some(Err(ErrorContext::new(
5189            "Ipv4Addr",
5190            None,
5191            self.orig_loc,
5192            self.buf.as_ptr().wrapping_add(self.pos) as usize,
5193        )))
5194    }
5195}
5196#[derive(Clone, Copy, Default)]
5197pub struct IterableArrayBinary<'a> {
5198    buf: &'a [u8],
5199    pos: usize,
5200    orig_loc: usize,
5201}
5202impl<'a> IterableArrayBinary<'a> {
5203    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5204        Self {
5205            buf,
5206            pos: 0,
5207            orig_loc,
5208        }
5209    }
5210    pub fn get_buf(&self) -> &'a [u8] {
5211        self.buf
5212    }
5213}
5214impl<'a> Iterator for IterableArrayBinary<'a> {
5215    type Item = Result<&'a [u8], ErrorContext>;
5216    fn next(&mut self) -> Option<Self::Item> {
5217        if self.buf.len() == self.pos {
5218            return None;
5219        }
5220        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
5221            {
5222                let Some(res) = Some(next) else { break };
5223                return Some(Ok(res));
5224            }
5225        }
5226        Some(Err(ErrorContext::new(
5227            "Binary",
5228            None,
5229            self.orig_loc,
5230            self.buf.as_ptr().wrapping_add(self.pos) as usize,
5231        )))
5232    }
5233}
5234impl<'a> LinkinfoBondAttrs<'a> {
5235    pub fn new(buf: &'a [u8]) -> IterableLinkinfoBondAttrs<'a> {
5236        IterableLinkinfoBondAttrs::with_loc(buf, buf.as_ptr() as usize)
5237    }
5238    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5239        let res = match r#type {
5240            1u16 => "Mode",
5241            2u16 => "ActiveSlave",
5242            3u16 => "Miimon",
5243            4u16 => "Updelay",
5244            5u16 => "Downdelay",
5245            6u16 => "UseCarrier",
5246            7u16 => "ArpInterval",
5247            8u16 => "ArpIpTarget",
5248            9u16 => "ArpValidate",
5249            10u16 => "ArpAllTargets",
5250            11u16 => "Primary",
5251            12u16 => "PrimaryReselect",
5252            13u16 => "FailOverMac",
5253            14u16 => "XmitHashPolicy",
5254            15u16 => "ResendIgmp",
5255            16u16 => "NumPeerNotif",
5256            17u16 => "AllSlavesActive",
5257            18u16 => "MinLinks",
5258            19u16 => "LpInterval",
5259            20u16 => "PacketsPerSlave",
5260            21u16 => "AdLacpRate",
5261            22u16 => "AdSelect",
5262            23u16 => "AdInfo",
5263            24u16 => "AdActorSysPrio",
5264            25u16 => "AdUserPortKey",
5265            26u16 => "AdActorSystem",
5266            27u16 => "TlbDynamicLb",
5267            28u16 => "PeerNotifDelay",
5268            29u16 => "AdLacpActive",
5269            30u16 => "MissedMax",
5270            31u16 => "NsIp6Target",
5271            32u16 => "CoupledControl",
5272            _ => return None,
5273        };
5274        Some(res)
5275    }
5276}
5277#[derive(Clone, Copy, Default)]
5278pub struct IterableLinkinfoBondAttrs<'a> {
5279    buf: &'a [u8],
5280    pos: usize,
5281    orig_loc: usize,
5282}
5283impl<'a> IterableLinkinfoBondAttrs<'a> {
5284    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5285        Self {
5286            buf,
5287            pos: 0,
5288            orig_loc,
5289        }
5290    }
5291    pub fn get_buf(&self) -> &'a [u8] {
5292        self.buf
5293    }
5294}
5295impl<'a> Iterator for IterableLinkinfoBondAttrs<'a> {
5296    type Item = Result<LinkinfoBondAttrs<'a>, ErrorContext>;
5297    fn next(&mut self) -> Option<Self::Item> {
5298        if self.buf.len() == self.pos {
5299            return None;
5300        }
5301        let pos = self.pos;
5302        let mut r#type = None;
5303        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
5304            r#type = Some(header.r#type);
5305            let res = match header.r#type {
5306                1u16 => LinkinfoBondAttrs::Mode({
5307                    let res = parse_u8(next);
5308                    let Some(val) = res else { break };
5309                    val
5310                }),
5311                2u16 => LinkinfoBondAttrs::ActiveSlave({
5312                    let res = parse_u32(next);
5313                    let Some(val) = res else { break };
5314                    val
5315                }),
5316                3u16 => LinkinfoBondAttrs::Miimon({
5317                    let res = parse_u32(next);
5318                    let Some(val) = res else { break };
5319                    val
5320                }),
5321                4u16 => LinkinfoBondAttrs::Updelay({
5322                    let res = parse_u32(next);
5323                    let Some(val) = res else { break };
5324                    val
5325                }),
5326                5u16 => LinkinfoBondAttrs::Downdelay({
5327                    let res = parse_u32(next);
5328                    let Some(val) = res else { break };
5329                    val
5330                }),
5331                6u16 => LinkinfoBondAttrs::UseCarrier({
5332                    let res = parse_u8(next);
5333                    let Some(val) = res else { break };
5334                    val
5335                }),
5336                7u16 => LinkinfoBondAttrs::ArpInterval({
5337                    let res = parse_u32(next);
5338                    let Some(val) = res else { break };
5339                    val
5340                }),
5341                8u16 => LinkinfoBondAttrs::ArpIpTarget({
5342                    let res = Some(IterableArrayIpv4Addr::with_loc(next, self.orig_loc));
5343                    let Some(val) = res else { break };
5344                    val
5345                }),
5346                9u16 => LinkinfoBondAttrs::ArpValidate({
5347                    let res = parse_u32(next);
5348                    let Some(val) = res else { break };
5349                    val
5350                }),
5351                10u16 => LinkinfoBondAttrs::ArpAllTargets({
5352                    let res = parse_u32(next);
5353                    let Some(val) = res else { break };
5354                    val
5355                }),
5356                11u16 => LinkinfoBondAttrs::Primary({
5357                    let res = parse_u32(next);
5358                    let Some(val) = res else { break };
5359                    val
5360                }),
5361                12u16 => LinkinfoBondAttrs::PrimaryReselect({
5362                    let res = parse_u8(next);
5363                    let Some(val) = res else { break };
5364                    val
5365                }),
5366                13u16 => LinkinfoBondAttrs::FailOverMac({
5367                    let res = parse_u8(next);
5368                    let Some(val) = res else { break };
5369                    val
5370                }),
5371                14u16 => LinkinfoBondAttrs::XmitHashPolicy({
5372                    let res = parse_u8(next);
5373                    let Some(val) = res else { break };
5374                    val
5375                }),
5376                15u16 => LinkinfoBondAttrs::ResendIgmp({
5377                    let res = parse_u32(next);
5378                    let Some(val) = res else { break };
5379                    val
5380                }),
5381                16u16 => LinkinfoBondAttrs::NumPeerNotif({
5382                    let res = parse_u8(next);
5383                    let Some(val) = res else { break };
5384                    val
5385                }),
5386                17u16 => LinkinfoBondAttrs::AllSlavesActive({
5387                    let res = parse_u8(next);
5388                    let Some(val) = res else { break };
5389                    val
5390                }),
5391                18u16 => LinkinfoBondAttrs::MinLinks({
5392                    let res = parse_u32(next);
5393                    let Some(val) = res else { break };
5394                    val
5395                }),
5396                19u16 => LinkinfoBondAttrs::LpInterval({
5397                    let res = parse_u32(next);
5398                    let Some(val) = res else { break };
5399                    val
5400                }),
5401                20u16 => LinkinfoBondAttrs::PacketsPerSlave({
5402                    let res = parse_u32(next);
5403                    let Some(val) = res else { break };
5404                    val
5405                }),
5406                21u16 => LinkinfoBondAttrs::AdLacpRate({
5407                    let res = parse_u8(next);
5408                    let Some(val) = res else { break };
5409                    val
5410                }),
5411                22u16 => LinkinfoBondAttrs::AdSelect({
5412                    let res = parse_u8(next);
5413                    let Some(val) = res else { break };
5414                    val
5415                }),
5416                23u16 => LinkinfoBondAttrs::AdInfo({
5417                    let res = Some(IterableBondAdInfoAttrs::with_loc(next, self.orig_loc));
5418                    let Some(val) = res else { break };
5419                    val
5420                }),
5421                24u16 => LinkinfoBondAttrs::AdActorSysPrio({
5422                    let res = parse_u16(next);
5423                    let Some(val) = res else { break };
5424                    val
5425                }),
5426                25u16 => LinkinfoBondAttrs::AdUserPortKey({
5427                    let res = parse_u16(next);
5428                    let Some(val) = res else { break };
5429                    val
5430                }),
5431                26u16 => LinkinfoBondAttrs::AdActorSystem({
5432                    let res = Some(next);
5433                    let Some(val) = res else { break };
5434                    val
5435                }),
5436                27u16 => LinkinfoBondAttrs::TlbDynamicLb({
5437                    let res = parse_u8(next);
5438                    let Some(val) = res else { break };
5439                    val
5440                }),
5441                28u16 => LinkinfoBondAttrs::PeerNotifDelay({
5442                    let res = parse_u32(next);
5443                    let Some(val) = res else { break };
5444                    val
5445                }),
5446                29u16 => LinkinfoBondAttrs::AdLacpActive({
5447                    let res = parse_u8(next);
5448                    let Some(val) = res else { break };
5449                    val
5450                }),
5451                30u16 => LinkinfoBondAttrs::MissedMax({
5452                    let res = parse_u8(next);
5453                    let Some(val) = res else { break };
5454                    val
5455                }),
5456                31u16 => LinkinfoBondAttrs::NsIp6Target({
5457                    let res = Some(IterableArrayBinary::with_loc(next, self.orig_loc));
5458                    let Some(val) = res else { break };
5459                    val
5460                }),
5461                32u16 => LinkinfoBondAttrs::CoupledControl({
5462                    let res = parse_u8(next);
5463                    let Some(val) = res else { break };
5464                    val
5465                }),
5466                n => {
5467                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
5468                        break;
5469                    } else {
5470                        continue;
5471                    }
5472                }
5473            };
5474            return Some(Ok(res));
5475        }
5476        Some(Err(ErrorContext::new(
5477            "LinkinfoBondAttrs",
5478            r#type.and_then(|t| LinkinfoBondAttrs::attr_from_type(t)),
5479            self.orig_loc,
5480            self.buf.as_ptr().wrapping_add(pos) as usize,
5481        )))
5482    }
5483}
5484impl std::fmt::Debug for IterableArrayIpv4Addr<'_> {
5485    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5486        fmt.debug_list().entries(self.clone()).finish()
5487    }
5488}
5489impl std::fmt::Debug for IterableArrayBinary<'_> {
5490    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5491        fmt.debug_list().entries(self.clone()).finish()
5492    }
5493}
5494impl<'a> std::fmt::Debug for IterableLinkinfoBondAttrs<'_> {
5495    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5496        let mut fmt = f.debug_struct("LinkinfoBondAttrs");
5497        for attr in self.clone() {
5498            let attr = match attr {
5499                Ok(a) => a,
5500                Err(err) => {
5501                    fmt.finish()?;
5502                    f.write_str("Err(")?;
5503                    err.fmt(f)?;
5504                    return f.write_str(")");
5505                }
5506            };
5507            match attr {
5508                LinkinfoBondAttrs::Mode(val) => fmt.field("Mode", &val),
5509                LinkinfoBondAttrs::ActiveSlave(val) => fmt.field("ActiveSlave", &val),
5510                LinkinfoBondAttrs::Miimon(val) => fmt.field("Miimon", &val),
5511                LinkinfoBondAttrs::Updelay(val) => fmt.field("Updelay", &val),
5512                LinkinfoBondAttrs::Downdelay(val) => fmt.field("Downdelay", &val),
5513                LinkinfoBondAttrs::UseCarrier(val) => fmt.field("UseCarrier", &val),
5514                LinkinfoBondAttrs::ArpInterval(val) => fmt.field("ArpInterval", &val),
5515                LinkinfoBondAttrs::ArpIpTarget(val) => fmt.field("ArpIpTarget", &val),
5516                LinkinfoBondAttrs::ArpValidate(val) => fmt.field("ArpValidate", &val),
5517                LinkinfoBondAttrs::ArpAllTargets(val) => fmt.field("ArpAllTargets", &val),
5518                LinkinfoBondAttrs::Primary(val) => fmt.field("Primary", &val),
5519                LinkinfoBondAttrs::PrimaryReselect(val) => fmt.field("PrimaryReselect", &val),
5520                LinkinfoBondAttrs::FailOverMac(val) => fmt.field("FailOverMac", &val),
5521                LinkinfoBondAttrs::XmitHashPolicy(val) => fmt.field("XmitHashPolicy", &val),
5522                LinkinfoBondAttrs::ResendIgmp(val) => fmt.field("ResendIgmp", &val),
5523                LinkinfoBondAttrs::NumPeerNotif(val) => fmt.field("NumPeerNotif", &val),
5524                LinkinfoBondAttrs::AllSlavesActive(val) => fmt.field("AllSlavesActive", &val),
5525                LinkinfoBondAttrs::MinLinks(val) => fmt.field("MinLinks", &val),
5526                LinkinfoBondAttrs::LpInterval(val) => fmt.field("LpInterval", &val),
5527                LinkinfoBondAttrs::PacketsPerSlave(val) => fmt.field("PacketsPerSlave", &val),
5528                LinkinfoBondAttrs::AdLacpRate(val) => fmt.field("AdLacpRate", &val),
5529                LinkinfoBondAttrs::AdSelect(val) => fmt.field("AdSelect", &val),
5530                LinkinfoBondAttrs::AdInfo(val) => fmt.field("AdInfo", &val),
5531                LinkinfoBondAttrs::AdActorSysPrio(val) => fmt.field("AdActorSysPrio", &val),
5532                LinkinfoBondAttrs::AdUserPortKey(val) => fmt.field("AdUserPortKey", &val),
5533                LinkinfoBondAttrs::AdActorSystem(val) => fmt.field("AdActorSystem", &val),
5534                LinkinfoBondAttrs::TlbDynamicLb(val) => fmt.field("TlbDynamicLb", &val),
5535                LinkinfoBondAttrs::PeerNotifDelay(val) => fmt.field("PeerNotifDelay", &val),
5536                LinkinfoBondAttrs::AdLacpActive(val) => fmt.field("AdLacpActive", &val),
5537                LinkinfoBondAttrs::MissedMax(val) => fmt.field("MissedMax", &val),
5538                LinkinfoBondAttrs::NsIp6Target(val) => fmt.field("NsIp6Target", &val),
5539                LinkinfoBondAttrs::CoupledControl(val) => fmt.field("CoupledControl", &val),
5540            };
5541        }
5542        fmt.finish()
5543    }
5544}
5545impl IterableLinkinfoBondAttrs<'_> {
5546    pub fn lookup_attr(
5547        &self,
5548        offset: usize,
5549        missing_type: Option<u16>,
5550    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5551        let mut stack = Vec::new();
5552        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5553        if cur == offset {
5554            stack.push(("LinkinfoBondAttrs", offset));
5555            return (
5556                stack,
5557                missing_type.and_then(|t| LinkinfoBondAttrs::attr_from_type(t)),
5558            );
5559        }
5560        if cur > offset || cur + self.buf.len() < offset {
5561            return (stack, None);
5562        }
5563        let mut attrs = self.clone();
5564        let mut last_off = cur + attrs.pos;
5565        let mut missing = None;
5566        while let Some(attr) = attrs.next() {
5567            let Ok(attr) = attr else { break };
5568            match attr {
5569                LinkinfoBondAttrs::Mode(val) => {
5570                    if last_off == offset {
5571                        stack.push(("Mode", last_off));
5572                        break;
5573                    }
5574                }
5575                LinkinfoBondAttrs::ActiveSlave(val) => {
5576                    if last_off == offset {
5577                        stack.push(("ActiveSlave", last_off));
5578                        break;
5579                    }
5580                }
5581                LinkinfoBondAttrs::Miimon(val) => {
5582                    if last_off == offset {
5583                        stack.push(("Miimon", last_off));
5584                        break;
5585                    }
5586                }
5587                LinkinfoBondAttrs::Updelay(val) => {
5588                    if last_off == offset {
5589                        stack.push(("Updelay", last_off));
5590                        break;
5591                    }
5592                }
5593                LinkinfoBondAttrs::Downdelay(val) => {
5594                    if last_off == offset {
5595                        stack.push(("Downdelay", last_off));
5596                        break;
5597                    }
5598                }
5599                LinkinfoBondAttrs::UseCarrier(val) => {
5600                    if last_off == offset {
5601                        stack.push(("UseCarrier", last_off));
5602                        break;
5603                    }
5604                }
5605                LinkinfoBondAttrs::ArpInterval(val) => {
5606                    if last_off == offset {
5607                        stack.push(("ArpInterval", last_off));
5608                        break;
5609                    }
5610                }
5611                LinkinfoBondAttrs::ArpIpTarget(val) => {
5612                    if last_off == offset {
5613                        stack.push(("ArpIpTarget", last_off));
5614                        break;
5615                    }
5616                }
5617                LinkinfoBondAttrs::ArpValidate(val) => {
5618                    if last_off == offset {
5619                        stack.push(("ArpValidate", last_off));
5620                        break;
5621                    }
5622                }
5623                LinkinfoBondAttrs::ArpAllTargets(val) => {
5624                    if last_off == offset {
5625                        stack.push(("ArpAllTargets", last_off));
5626                        break;
5627                    }
5628                }
5629                LinkinfoBondAttrs::Primary(val) => {
5630                    if last_off == offset {
5631                        stack.push(("Primary", last_off));
5632                        break;
5633                    }
5634                }
5635                LinkinfoBondAttrs::PrimaryReselect(val) => {
5636                    if last_off == offset {
5637                        stack.push(("PrimaryReselect", last_off));
5638                        break;
5639                    }
5640                }
5641                LinkinfoBondAttrs::FailOverMac(val) => {
5642                    if last_off == offset {
5643                        stack.push(("FailOverMac", last_off));
5644                        break;
5645                    }
5646                }
5647                LinkinfoBondAttrs::XmitHashPolicy(val) => {
5648                    if last_off == offset {
5649                        stack.push(("XmitHashPolicy", last_off));
5650                        break;
5651                    }
5652                }
5653                LinkinfoBondAttrs::ResendIgmp(val) => {
5654                    if last_off == offset {
5655                        stack.push(("ResendIgmp", last_off));
5656                        break;
5657                    }
5658                }
5659                LinkinfoBondAttrs::NumPeerNotif(val) => {
5660                    if last_off == offset {
5661                        stack.push(("NumPeerNotif", last_off));
5662                        break;
5663                    }
5664                }
5665                LinkinfoBondAttrs::AllSlavesActive(val) => {
5666                    if last_off == offset {
5667                        stack.push(("AllSlavesActive", last_off));
5668                        break;
5669                    }
5670                }
5671                LinkinfoBondAttrs::MinLinks(val) => {
5672                    if last_off == offset {
5673                        stack.push(("MinLinks", last_off));
5674                        break;
5675                    }
5676                }
5677                LinkinfoBondAttrs::LpInterval(val) => {
5678                    if last_off == offset {
5679                        stack.push(("LpInterval", last_off));
5680                        break;
5681                    }
5682                }
5683                LinkinfoBondAttrs::PacketsPerSlave(val) => {
5684                    if last_off == offset {
5685                        stack.push(("PacketsPerSlave", last_off));
5686                        break;
5687                    }
5688                }
5689                LinkinfoBondAttrs::AdLacpRate(val) => {
5690                    if last_off == offset {
5691                        stack.push(("AdLacpRate", last_off));
5692                        break;
5693                    }
5694                }
5695                LinkinfoBondAttrs::AdSelect(val) => {
5696                    if last_off == offset {
5697                        stack.push(("AdSelect", last_off));
5698                        break;
5699                    }
5700                }
5701                LinkinfoBondAttrs::AdInfo(val) => {
5702                    (stack, missing) = val.lookup_attr(offset, missing_type);
5703                    if !stack.is_empty() {
5704                        break;
5705                    }
5706                }
5707                LinkinfoBondAttrs::AdActorSysPrio(val) => {
5708                    if last_off == offset {
5709                        stack.push(("AdActorSysPrio", last_off));
5710                        break;
5711                    }
5712                }
5713                LinkinfoBondAttrs::AdUserPortKey(val) => {
5714                    if last_off == offset {
5715                        stack.push(("AdUserPortKey", last_off));
5716                        break;
5717                    }
5718                }
5719                LinkinfoBondAttrs::AdActorSystem(val) => {
5720                    if last_off == offset {
5721                        stack.push(("AdActorSystem", last_off));
5722                        break;
5723                    }
5724                }
5725                LinkinfoBondAttrs::TlbDynamicLb(val) => {
5726                    if last_off == offset {
5727                        stack.push(("TlbDynamicLb", last_off));
5728                        break;
5729                    }
5730                }
5731                LinkinfoBondAttrs::PeerNotifDelay(val) => {
5732                    if last_off == offset {
5733                        stack.push(("PeerNotifDelay", last_off));
5734                        break;
5735                    }
5736                }
5737                LinkinfoBondAttrs::AdLacpActive(val) => {
5738                    if last_off == offset {
5739                        stack.push(("AdLacpActive", last_off));
5740                        break;
5741                    }
5742                }
5743                LinkinfoBondAttrs::MissedMax(val) => {
5744                    if last_off == offset {
5745                        stack.push(("MissedMax", last_off));
5746                        break;
5747                    }
5748                }
5749                LinkinfoBondAttrs::NsIp6Target(val) => {
5750                    if last_off == offset {
5751                        stack.push(("NsIp6Target", last_off));
5752                        break;
5753                    }
5754                }
5755                LinkinfoBondAttrs::CoupledControl(val) => {
5756                    if last_off == offset {
5757                        stack.push(("CoupledControl", last_off));
5758                        break;
5759                    }
5760                }
5761                _ => {}
5762            };
5763            last_off = cur + attrs.pos;
5764        }
5765        if !stack.is_empty() {
5766            stack.push(("LinkinfoBondAttrs", cur));
5767        }
5768        (stack, missing)
5769    }
5770}
5771#[derive(Clone)]
5772pub enum BondAdInfoAttrs<'a> {
5773    Aggregator(u16),
5774    NumPorts(u16),
5775    ActorKey(u16),
5776    PartnerKey(u16),
5777    PartnerMac(&'a [u8]),
5778}
5779impl<'a> IterableBondAdInfoAttrs<'a> {
5780    pub fn get_aggregator(&self) -> Result<u16, ErrorContext> {
5781        let mut iter = self.clone();
5782        iter.pos = 0;
5783        for attr in iter {
5784            if let BondAdInfoAttrs::Aggregator(val) = attr? {
5785                return Ok(val);
5786            }
5787        }
5788        Err(ErrorContext::new_missing(
5789            "BondAdInfoAttrs",
5790            "Aggregator",
5791            self.orig_loc,
5792            self.buf.as_ptr() as usize,
5793        ))
5794    }
5795    pub fn get_num_ports(&self) -> Result<u16, ErrorContext> {
5796        let mut iter = self.clone();
5797        iter.pos = 0;
5798        for attr in iter {
5799            if let BondAdInfoAttrs::NumPorts(val) = attr? {
5800                return Ok(val);
5801            }
5802        }
5803        Err(ErrorContext::new_missing(
5804            "BondAdInfoAttrs",
5805            "NumPorts",
5806            self.orig_loc,
5807            self.buf.as_ptr() as usize,
5808        ))
5809    }
5810    pub fn get_actor_key(&self) -> Result<u16, ErrorContext> {
5811        let mut iter = self.clone();
5812        iter.pos = 0;
5813        for attr in iter {
5814            if let BondAdInfoAttrs::ActorKey(val) = attr? {
5815                return Ok(val);
5816            }
5817        }
5818        Err(ErrorContext::new_missing(
5819            "BondAdInfoAttrs",
5820            "ActorKey",
5821            self.orig_loc,
5822            self.buf.as_ptr() as usize,
5823        ))
5824    }
5825    pub fn get_partner_key(&self) -> Result<u16, ErrorContext> {
5826        let mut iter = self.clone();
5827        iter.pos = 0;
5828        for attr in iter {
5829            if let BondAdInfoAttrs::PartnerKey(val) = attr? {
5830                return Ok(val);
5831            }
5832        }
5833        Err(ErrorContext::new_missing(
5834            "BondAdInfoAttrs",
5835            "PartnerKey",
5836            self.orig_loc,
5837            self.buf.as_ptr() as usize,
5838        ))
5839    }
5840    pub fn get_partner_mac(&self) -> Result<&'a [u8], ErrorContext> {
5841        let mut iter = self.clone();
5842        iter.pos = 0;
5843        for attr in iter {
5844            if let BondAdInfoAttrs::PartnerMac(val) = attr? {
5845                return Ok(val);
5846            }
5847        }
5848        Err(ErrorContext::new_missing(
5849            "BondAdInfoAttrs",
5850            "PartnerMac",
5851            self.orig_loc,
5852            self.buf.as_ptr() as usize,
5853        ))
5854    }
5855}
5856impl<'a> BondAdInfoAttrs<'a> {
5857    pub fn new(buf: &'a [u8]) -> IterableBondAdInfoAttrs<'a> {
5858        IterableBondAdInfoAttrs::with_loc(buf, buf.as_ptr() as usize)
5859    }
5860    fn attr_from_type(r#type: u16) -> Option<&'static str> {
5861        let res = match r#type {
5862            1u16 => "Aggregator",
5863            2u16 => "NumPorts",
5864            3u16 => "ActorKey",
5865            4u16 => "PartnerKey",
5866            5u16 => "PartnerMac",
5867            _ => return None,
5868        };
5869        Some(res)
5870    }
5871}
5872#[derive(Clone, Copy, Default)]
5873pub struct IterableBondAdInfoAttrs<'a> {
5874    buf: &'a [u8],
5875    pos: usize,
5876    orig_loc: usize,
5877}
5878impl<'a> IterableBondAdInfoAttrs<'a> {
5879    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
5880        Self {
5881            buf,
5882            pos: 0,
5883            orig_loc,
5884        }
5885    }
5886    pub fn get_buf(&self) -> &'a [u8] {
5887        self.buf
5888    }
5889}
5890impl<'a> Iterator for IterableBondAdInfoAttrs<'a> {
5891    type Item = Result<BondAdInfoAttrs<'a>, ErrorContext>;
5892    fn next(&mut self) -> Option<Self::Item> {
5893        if self.buf.len() == self.pos {
5894            return None;
5895        }
5896        let pos = self.pos;
5897        let mut r#type = None;
5898        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
5899            r#type = Some(header.r#type);
5900            let res = match header.r#type {
5901                1u16 => BondAdInfoAttrs::Aggregator({
5902                    let res = parse_u16(next);
5903                    let Some(val) = res else { break };
5904                    val
5905                }),
5906                2u16 => BondAdInfoAttrs::NumPorts({
5907                    let res = parse_u16(next);
5908                    let Some(val) = res else { break };
5909                    val
5910                }),
5911                3u16 => BondAdInfoAttrs::ActorKey({
5912                    let res = parse_u16(next);
5913                    let Some(val) = res else { break };
5914                    val
5915                }),
5916                4u16 => BondAdInfoAttrs::PartnerKey({
5917                    let res = parse_u16(next);
5918                    let Some(val) = res else { break };
5919                    val
5920                }),
5921                5u16 => BondAdInfoAttrs::PartnerMac({
5922                    let res = Some(next);
5923                    let Some(val) = res else { break };
5924                    val
5925                }),
5926                n => {
5927                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
5928                        break;
5929                    } else {
5930                        continue;
5931                    }
5932                }
5933            };
5934            return Some(Ok(res));
5935        }
5936        Some(Err(ErrorContext::new(
5937            "BondAdInfoAttrs",
5938            r#type.and_then(|t| BondAdInfoAttrs::attr_from_type(t)),
5939            self.orig_loc,
5940            self.buf.as_ptr().wrapping_add(pos) as usize,
5941        )))
5942    }
5943}
5944impl<'a> std::fmt::Debug for IterableBondAdInfoAttrs<'_> {
5945    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5946        let mut fmt = f.debug_struct("BondAdInfoAttrs");
5947        for attr in self.clone() {
5948            let attr = match attr {
5949                Ok(a) => a,
5950                Err(err) => {
5951                    fmt.finish()?;
5952                    f.write_str("Err(")?;
5953                    err.fmt(f)?;
5954                    return f.write_str(")");
5955                }
5956            };
5957            match attr {
5958                BondAdInfoAttrs::Aggregator(val) => fmt.field("Aggregator", &val),
5959                BondAdInfoAttrs::NumPorts(val) => fmt.field("NumPorts", &val),
5960                BondAdInfoAttrs::ActorKey(val) => fmt.field("ActorKey", &val),
5961                BondAdInfoAttrs::PartnerKey(val) => fmt.field("PartnerKey", &val),
5962                BondAdInfoAttrs::PartnerMac(val) => fmt.field("PartnerMac", &val),
5963            };
5964        }
5965        fmt.finish()
5966    }
5967}
5968impl IterableBondAdInfoAttrs<'_> {
5969    pub fn lookup_attr(
5970        &self,
5971        offset: usize,
5972        missing_type: Option<u16>,
5973    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5974        let mut stack = Vec::new();
5975        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
5976        if cur == offset {
5977            stack.push(("BondAdInfoAttrs", offset));
5978            return (
5979                stack,
5980                missing_type.and_then(|t| BondAdInfoAttrs::attr_from_type(t)),
5981            );
5982        }
5983        if cur > offset || cur + self.buf.len() < offset {
5984            return (stack, None);
5985        }
5986        let mut attrs = self.clone();
5987        let mut last_off = cur + attrs.pos;
5988        while let Some(attr) = attrs.next() {
5989            let Ok(attr) = attr else { break };
5990            match attr {
5991                BondAdInfoAttrs::Aggregator(val) => {
5992                    if last_off == offset {
5993                        stack.push(("Aggregator", last_off));
5994                        break;
5995                    }
5996                }
5997                BondAdInfoAttrs::NumPorts(val) => {
5998                    if last_off == offset {
5999                        stack.push(("NumPorts", last_off));
6000                        break;
6001                    }
6002                }
6003                BondAdInfoAttrs::ActorKey(val) => {
6004                    if last_off == offset {
6005                        stack.push(("ActorKey", last_off));
6006                        break;
6007                    }
6008                }
6009                BondAdInfoAttrs::PartnerKey(val) => {
6010                    if last_off == offset {
6011                        stack.push(("PartnerKey", last_off));
6012                        break;
6013                    }
6014                }
6015                BondAdInfoAttrs::PartnerMac(val) => {
6016                    if last_off == offset {
6017                        stack.push(("PartnerMac", last_off));
6018                        break;
6019                    }
6020                }
6021                _ => {}
6022            };
6023            last_off = cur + attrs.pos;
6024        }
6025        if !stack.is_empty() {
6026            stack.push(("BondAdInfoAttrs", cur));
6027        }
6028        (stack, None)
6029    }
6030}
6031#[derive(Clone)]
6032pub enum BondSlaveAttrs<'a> {
6033    State(u8),
6034    MiiStatus(u8),
6035    LinkFailureCount(u32),
6036    PermHwaddr(&'a [u8]),
6037    QueueId(u16),
6038    AdAggregatorId(u16),
6039    AdActorOperPortState(u8),
6040    AdPartnerOperPortState(u16),
6041    Prio(u32),
6042}
6043impl<'a> IterableBondSlaveAttrs<'a> {
6044    pub fn get_state(&self) -> Result<u8, ErrorContext> {
6045        let mut iter = self.clone();
6046        iter.pos = 0;
6047        for attr in iter {
6048            if let BondSlaveAttrs::State(val) = attr? {
6049                return Ok(val);
6050            }
6051        }
6052        Err(ErrorContext::new_missing(
6053            "BondSlaveAttrs",
6054            "State",
6055            self.orig_loc,
6056            self.buf.as_ptr() as usize,
6057        ))
6058    }
6059    pub fn get_mii_status(&self) -> Result<u8, ErrorContext> {
6060        let mut iter = self.clone();
6061        iter.pos = 0;
6062        for attr in iter {
6063            if let BondSlaveAttrs::MiiStatus(val) = attr? {
6064                return Ok(val);
6065            }
6066        }
6067        Err(ErrorContext::new_missing(
6068            "BondSlaveAttrs",
6069            "MiiStatus",
6070            self.orig_loc,
6071            self.buf.as_ptr() as usize,
6072        ))
6073    }
6074    pub fn get_link_failure_count(&self) -> Result<u32, ErrorContext> {
6075        let mut iter = self.clone();
6076        iter.pos = 0;
6077        for attr in iter {
6078            if let BondSlaveAttrs::LinkFailureCount(val) = attr? {
6079                return Ok(val);
6080            }
6081        }
6082        Err(ErrorContext::new_missing(
6083            "BondSlaveAttrs",
6084            "LinkFailureCount",
6085            self.orig_loc,
6086            self.buf.as_ptr() as usize,
6087        ))
6088    }
6089    pub fn get_perm_hwaddr(&self) -> Result<&'a [u8], ErrorContext> {
6090        let mut iter = self.clone();
6091        iter.pos = 0;
6092        for attr in iter {
6093            if let BondSlaveAttrs::PermHwaddr(val) = attr? {
6094                return Ok(val);
6095            }
6096        }
6097        Err(ErrorContext::new_missing(
6098            "BondSlaveAttrs",
6099            "PermHwaddr",
6100            self.orig_loc,
6101            self.buf.as_ptr() as usize,
6102        ))
6103    }
6104    pub fn get_queue_id(&self) -> Result<u16, ErrorContext> {
6105        let mut iter = self.clone();
6106        iter.pos = 0;
6107        for attr in iter {
6108            if let BondSlaveAttrs::QueueId(val) = attr? {
6109                return Ok(val);
6110            }
6111        }
6112        Err(ErrorContext::new_missing(
6113            "BondSlaveAttrs",
6114            "QueueId",
6115            self.orig_loc,
6116            self.buf.as_ptr() as usize,
6117        ))
6118    }
6119    pub fn get_ad_aggregator_id(&self) -> Result<u16, ErrorContext> {
6120        let mut iter = self.clone();
6121        iter.pos = 0;
6122        for attr in iter {
6123            if let BondSlaveAttrs::AdAggregatorId(val) = attr? {
6124                return Ok(val);
6125            }
6126        }
6127        Err(ErrorContext::new_missing(
6128            "BondSlaveAttrs",
6129            "AdAggregatorId",
6130            self.orig_loc,
6131            self.buf.as_ptr() as usize,
6132        ))
6133    }
6134    pub fn get_ad_actor_oper_port_state(&self) -> Result<u8, ErrorContext> {
6135        let mut iter = self.clone();
6136        iter.pos = 0;
6137        for attr in iter {
6138            if let BondSlaveAttrs::AdActorOperPortState(val) = attr? {
6139                return Ok(val);
6140            }
6141        }
6142        Err(ErrorContext::new_missing(
6143            "BondSlaveAttrs",
6144            "AdActorOperPortState",
6145            self.orig_loc,
6146            self.buf.as_ptr() as usize,
6147        ))
6148    }
6149    pub fn get_ad_partner_oper_port_state(&self) -> Result<u16, ErrorContext> {
6150        let mut iter = self.clone();
6151        iter.pos = 0;
6152        for attr in iter {
6153            if let BondSlaveAttrs::AdPartnerOperPortState(val) = attr? {
6154                return Ok(val);
6155            }
6156        }
6157        Err(ErrorContext::new_missing(
6158            "BondSlaveAttrs",
6159            "AdPartnerOperPortState",
6160            self.orig_loc,
6161            self.buf.as_ptr() as usize,
6162        ))
6163    }
6164    pub fn get_prio(&self) -> Result<u32, ErrorContext> {
6165        let mut iter = self.clone();
6166        iter.pos = 0;
6167        for attr in iter {
6168            if let BondSlaveAttrs::Prio(val) = attr? {
6169                return Ok(val);
6170            }
6171        }
6172        Err(ErrorContext::new_missing(
6173            "BondSlaveAttrs",
6174            "Prio",
6175            self.orig_loc,
6176            self.buf.as_ptr() as usize,
6177        ))
6178    }
6179}
6180impl<'a> BondSlaveAttrs<'a> {
6181    pub fn new(buf: &'a [u8]) -> IterableBondSlaveAttrs<'a> {
6182        IterableBondSlaveAttrs::with_loc(buf, buf.as_ptr() as usize)
6183    }
6184    fn attr_from_type(r#type: u16) -> Option<&'static str> {
6185        let res = match r#type {
6186            1u16 => "State",
6187            2u16 => "MiiStatus",
6188            3u16 => "LinkFailureCount",
6189            4u16 => "PermHwaddr",
6190            5u16 => "QueueId",
6191            6u16 => "AdAggregatorId",
6192            7u16 => "AdActorOperPortState",
6193            8u16 => "AdPartnerOperPortState",
6194            9u16 => "Prio",
6195            _ => return None,
6196        };
6197        Some(res)
6198    }
6199}
6200#[derive(Clone, Copy, Default)]
6201pub struct IterableBondSlaveAttrs<'a> {
6202    buf: &'a [u8],
6203    pos: usize,
6204    orig_loc: usize,
6205}
6206impl<'a> IterableBondSlaveAttrs<'a> {
6207    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
6208        Self {
6209            buf,
6210            pos: 0,
6211            orig_loc,
6212        }
6213    }
6214    pub fn get_buf(&self) -> &'a [u8] {
6215        self.buf
6216    }
6217}
6218impl<'a> Iterator for IterableBondSlaveAttrs<'a> {
6219    type Item = Result<BondSlaveAttrs<'a>, ErrorContext>;
6220    fn next(&mut self) -> Option<Self::Item> {
6221        if self.buf.len() == self.pos {
6222            return None;
6223        }
6224        let pos = self.pos;
6225        let mut r#type = None;
6226        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
6227            r#type = Some(header.r#type);
6228            let res = match header.r#type {
6229                1u16 => BondSlaveAttrs::State({
6230                    let res = parse_u8(next);
6231                    let Some(val) = res else { break };
6232                    val
6233                }),
6234                2u16 => BondSlaveAttrs::MiiStatus({
6235                    let res = parse_u8(next);
6236                    let Some(val) = res else { break };
6237                    val
6238                }),
6239                3u16 => BondSlaveAttrs::LinkFailureCount({
6240                    let res = parse_u32(next);
6241                    let Some(val) = res else { break };
6242                    val
6243                }),
6244                4u16 => BondSlaveAttrs::PermHwaddr({
6245                    let res = Some(next);
6246                    let Some(val) = res else { break };
6247                    val
6248                }),
6249                5u16 => BondSlaveAttrs::QueueId({
6250                    let res = parse_u16(next);
6251                    let Some(val) = res else { break };
6252                    val
6253                }),
6254                6u16 => BondSlaveAttrs::AdAggregatorId({
6255                    let res = parse_u16(next);
6256                    let Some(val) = res else { break };
6257                    val
6258                }),
6259                7u16 => BondSlaveAttrs::AdActorOperPortState({
6260                    let res = parse_u8(next);
6261                    let Some(val) = res else { break };
6262                    val
6263                }),
6264                8u16 => BondSlaveAttrs::AdPartnerOperPortState({
6265                    let res = parse_u16(next);
6266                    let Some(val) = res else { break };
6267                    val
6268                }),
6269                9u16 => BondSlaveAttrs::Prio({
6270                    let res = parse_u32(next);
6271                    let Some(val) = res else { break };
6272                    val
6273                }),
6274                n => {
6275                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
6276                        break;
6277                    } else {
6278                        continue;
6279                    }
6280                }
6281            };
6282            return Some(Ok(res));
6283        }
6284        Some(Err(ErrorContext::new(
6285            "BondSlaveAttrs",
6286            r#type.and_then(|t| BondSlaveAttrs::attr_from_type(t)),
6287            self.orig_loc,
6288            self.buf.as_ptr().wrapping_add(pos) as usize,
6289        )))
6290    }
6291}
6292impl<'a> std::fmt::Debug for IterableBondSlaveAttrs<'_> {
6293    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6294        let mut fmt = f.debug_struct("BondSlaveAttrs");
6295        for attr in self.clone() {
6296            let attr = match attr {
6297                Ok(a) => a,
6298                Err(err) => {
6299                    fmt.finish()?;
6300                    f.write_str("Err(")?;
6301                    err.fmt(f)?;
6302                    return f.write_str(")");
6303                }
6304            };
6305            match attr {
6306                BondSlaveAttrs::State(val) => fmt.field("State", &val),
6307                BondSlaveAttrs::MiiStatus(val) => fmt.field("MiiStatus", &val),
6308                BondSlaveAttrs::LinkFailureCount(val) => fmt.field("LinkFailureCount", &val),
6309                BondSlaveAttrs::PermHwaddr(val) => fmt.field("PermHwaddr", &val),
6310                BondSlaveAttrs::QueueId(val) => fmt.field("QueueId", &val),
6311                BondSlaveAttrs::AdAggregatorId(val) => fmt.field("AdAggregatorId", &val),
6312                BondSlaveAttrs::AdActorOperPortState(val) => {
6313                    fmt.field("AdActorOperPortState", &val)
6314                }
6315                BondSlaveAttrs::AdPartnerOperPortState(val) => {
6316                    fmt.field("AdPartnerOperPortState", &val)
6317                }
6318                BondSlaveAttrs::Prio(val) => fmt.field("Prio", &val),
6319            };
6320        }
6321        fmt.finish()
6322    }
6323}
6324impl IterableBondSlaveAttrs<'_> {
6325    pub fn lookup_attr(
6326        &self,
6327        offset: usize,
6328        missing_type: Option<u16>,
6329    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
6330        let mut stack = Vec::new();
6331        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
6332        if cur == offset {
6333            stack.push(("BondSlaveAttrs", offset));
6334            return (
6335                stack,
6336                missing_type.and_then(|t| BondSlaveAttrs::attr_from_type(t)),
6337            );
6338        }
6339        if cur > offset || cur + self.buf.len() < offset {
6340            return (stack, None);
6341        }
6342        let mut attrs = self.clone();
6343        let mut last_off = cur + attrs.pos;
6344        while let Some(attr) = attrs.next() {
6345            let Ok(attr) = attr else { break };
6346            match attr {
6347                BondSlaveAttrs::State(val) => {
6348                    if last_off == offset {
6349                        stack.push(("State", last_off));
6350                        break;
6351                    }
6352                }
6353                BondSlaveAttrs::MiiStatus(val) => {
6354                    if last_off == offset {
6355                        stack.push(("MiiStatus", last_off));
6356                        break;
6357                    }
6358                }
6359                BondSlaveAttrs::LinkFailureCount(val) => {
6360                    if last_off == offset {
6361                        stack.push(("LinkFailureCount", last_off));
6362                        break;
6363                    }
6364                }
6365                BondSlaveAttrs::PermHwaddr(val) => {
6366                    if last_off == offset {
6367                        stack.push(("PermHwaddr", last_off));
6368                        break;
6369                    }
6370                }
6371                BondSlaveAttrs::QueueId(val) => {
6372                    if last_off == offset {
6373                        stack.push(("QueueId", last_off));
6374                        break;
6375                    }
6376                }
6377                BondSlaveAttrs::AdAggregatorId(val) => {
6378                    if last_off == offset {
6379                        stack.push(("AdAggregatorId", last_off));
6380                        break;
6381                    }
6382                }
6383                BondSlaveAttrs::AdActorOperPortState(val) => {
6384                    if last_off == offset {
6385                        stack.push(("AdActorOperPortState", last_off));
6386                        break;
6387                    }
6388                }
6389                BondSlaveAttrs::AdPartnerOperPortState(val) => {
6390                    if last_off == offset {
6391                        stack.push(("AdPartnerOperPortState", last_off));
6392                        break;
6393                    }
6394                }
6395                BondSlaveAttrs::Prio(val) => {
6396                    if last_off == offset {
6397                        stack.push(("Prio", last_off));
6398                        break;
6399                    }
6400                }
6401                _ => {}
6402            };
6403            last_off = cur + attrs.pos;
6404        }
6405        if !stack.is_empty() {
6406            stack.push(("BondSlaveAttrs", cur));
6407        }
6408        (stack, None)
6409    }
6410}
6411#[derive(Clone)]
6412pub enum LinkinfoBridgeAttrs<'a> {
6413    ForwardDelay(u32),
6414    HelloTime(u32),
6415    MaxAge(u32),
6416    AgeingTime(u32),
6417    StpState(u32),
6418    Priority(u16),
6419    VlanFiltering(u8),
6420    VlanProtocol(u16),
6421    GroupFwdMask(u16),
6422    RootId(PushIflaBridgeId),
6423    BridgeId(PushIflaBridgeId),
6424    RootPort(u16),
6425    RootPathCost(u32),
6426    TopologyChange(u8),
6427    TopologyChangeDetected(u8),
6428    HelloTimer(u64),
6429    TcnTimer(u64),
6430    TopologyChangeTimer(u64),
6431    GcTimer(u64),
6432    GroupAddr(&'a [u8]),
6433    FdbFlush(&'a [u8]),
6434    McastRouter(u8),
6435    McastSnooping(u8),
6436    McastQueryUseIfaddr(u8),
6437    McastQuerier(u8),
6438    McastHashElasticity(u32),
6439    McastHashMax(u32),
6440    McastLastMemberCnt(u32),
6441    McastStartupQueryCnt(u32),
6442    McastLastMemberIntvl(u64),
6443    McastMembershipIntvl(u64),
6444    McastQuerierIntvl(u64),
6445    McastQueryIntvl(u64),
6446    McastQueryResponseIntvl(u64),
6447    McastStartupQueryIntvl(u64),
6448    NfCallIptables(u8),
6449    NfCallIp6tables(u8),
6450    NfCallArptables(u8),
6451    VlanDefaultPvid(u16),
6452    Pad(&'a [u8]),
6453    VlanStatsEnabled(u8),
6454    McastStatsEnabled(u8),
6455    McastIgmpVersion(u8),
6456    McastMldVersion(u8),
6457    VlanStatsPerPort(u8),
6458    MultiBoolopt(PushBrBooloptMulti),
6459    McastQuerierState(&'a [u8]),
6460    FdbNLearned(u32),
6461    FdbMaxLearned(u32),
6462}
6463impl<'a> IterableLinkinfoBridgeAttrs<'a> {
6464    pub fn get_forward_delay(&self) -> Result<u32, ErrorContext> {
6465        let mut iter = self.clone();
6466        iter.pos = 0;
6467        for attr in iter {
6468            if let LinkinfoBridgeAttrs::ForwardDelay(val) = attr? {
6469                return Ok(val);
6470            }
6471        }
6472        Err(ErrorContext::new_missing(
6473            "LinkinfoBridgeAttrs",
6474            "ForwardDelay",
6475            self.orig_loc,
6476            self.buf.as_ptr() as usize,
6477        ))
6478    }
6479    pub fn get_hello_time(&self) -> Result<u32, ErrorContext> {
6480        let mut iter = self.clone();
6481        iter.pos = 0;
6482        for attr in iter {
6483            if let LinkinfoBridgeAttrs::HelloTime(val) = attr? {
6484                return Ok(val);
6485            }
6486        }
6487        Err(ErrorContext::new_missing(
6488            "LinkinfoBridgeAttrs",
6489            "HelloTime",
6490            self.orig_loc,
6491            self.buf.as_ptr() as usize,
6492        ))
6493    }
6494    pub fn get_max_age(&self) -> Result<u32, ErrorContext> {
6495        let mut iter = self.clone();
6496        iter.pos = 0;
6497        for attr in iter {
6498            if let LinkinfoBridgeAttrs::MaxAge(val) = attr? {
6499                return Ok(val);
6500            }
6501        }
6502        Err(ErrorContext::new_missing(
6503            "LinkinfoBridgeAttrs",
6504            "MaxAge",
6505            self.orig_loc,
6506            self.buf.as_ptr() as usize,
6507        ))
6508    }
6509    pub fn get_ageing_time(&self) -> Result<u32, ErrorContext> {
6510        let mut iter = self.clone();
6511        iter.pos = 0;
6512        for attr in iter {
6513            if let LinkinfoBridgeAttrs::AgeingTime(val) = attr? {
6514                return Ok(val);
6515            }
6516        }
6517        Err(ErrorContext::new_missing(
6518            "LinkinfoBridgeAttrs",
6519            "AgeingTime",
6520            self.orig_loc,
6521            self.buf.as_ptr() as usize,
6522        ))
6523    }
6524    pub fn get_stp_state(&self) -> Result<u32, ErrorContext> {
6525        let mut iter = self.clone();
6526        iter.pos = 0;
6527        for attr in iter {
6528            if let LinkinfoBridgeAttrs::StpState(val) = attr? {
6529                return Ok(val);
6530            }
6531        }
6532        Err(ErrorContext::new_missing(
6533            "LinkinfoBridgeAttrs",
6534            "StpState",
6535            self.orig_loc,
6536            self.buf.as_ptr() as usize,
6537        ))
6538    }
6539    pub fn get_priority(&self) -> Result<u16, ErrorContext> {
6540        let mut iter = self.clone();
6541        iter.pos = 0;
6542        for attr in iter {
6543            if let LinkinfoBridgeAttrs::Priority(val) = attr? {
6544                return Ok(val);
6545            }
6546        }
6547        Err(ErrorContext::new_missing(
6548            "LinkinfoBridgeAttrs",
6549            "Priority",
6550            self.orig_loc,
6551            self.buf.as_ptr() as usize,
6552        ))
6553    }
6554    pub fn get_vlan_filtering(&self) -> Result<u8, ErrorContext> {
6555        let mut iter = self.clone();
6556        iter.pos = 0;
6557        for attr in iter {
6558            if let LinkinfoBridgeAttrs::VlanFiltering(val) = attr? {
6559                return Ok(val);
6560            }
6561        }
6562        Err(ErrorContext::new_missing(
6563            "LinkinfoBridgeAttrs",
6564            "VlanFiltering",
6565            self.orig_loc,
6566            self.buf.as_ptr() as usize,
6567        ))
6568    }
6569    pub fn get_vlan_protocol(&self) -> Result<u16, ErrorContext> {
6570        let mut iter = self.clone();
6571        iter.pos = 0;
6572        for attr in iter {
6573            if let LinkinfoBridgeAttrs::VlanProtocol(val) = attr? {
6574                return Ok(val);
6575            }
6576        }
6577        Err(ErrorContext::new_missing(
6578            "LinkinfoBridgeAttrs",
6579            "VlanProtocol",
6580            self.orig_loc,
6581            self.buf.as_ptr() as usize,
6582        ))
6583    }
6584    pub fn get_group_fwd_mask(&self) -> Result<u16, ErrorContext> {
6585        let mut iter = self.clone();
6586        iter.pos = 0;
6587        for attr in iter {
6588            if let LinkinfoBridgeAttrs::GroupFwdMask(val) = attr? {
6589                return Ok(val);
6590            }
6591        }
6592        Err(ErrorContext::new_missing(
6593            "LinkinfoBridgeAttrs",
6594            "GroupFwdMask",
6595            self.orig_loc,
6596            self.buf.as_ptr() as usize,
6597        ))
6598    }
6599    pub fn get_root_id(&self) -> Result<PushIflaBridgeId, ErrorContext> {
6600        let mut iter = self.clone();
6601        iter.pos = 0;
6602        for attr in iter {
6603            if let LinkinfoBridgeAttrs::RootId(val) = attr? {
6604                return Ok(val);
6605            }
6606        }
6607        Err(ErrorContext::new_missing(
6608            "LinkinfoBridgeAttrs",
6609            "RootId",
6610            self.orig_loc,
6611            self.buf.as_ptr() as usize,
6612        ))
6613    }
6614    pub fn get_bridge_id(&self) -> Result<PushIflaBridgeId, ErrorContext> {
6615        let mut iter = self.clone();
6616        iter.pos = 0;
6617        for attr in iter {
6618            if let LinkinfoBridgeAttrs::BridgeId(val) = attr? {
6619                return Ok(val);
6620            }
6621        }
6622        Err(ErrorContext::new_missing(
6623            "LinkinfoBridgeAttrs",
6624            "BridgeId",
6625            self.orig_loc,
6626            self.buf.as_ptr() as usize,
6627        ))
6628    }
6629    pub fn get_root_port(&self) -> Result<u16, ErrorContext> {
6630        let mut iter = self.clone();
6631        iter.pos = 0;
6632        for attr in iter {
6633            if let LinkinfoBridgeAttrs::RootPort(val) = attr? {
6634                return Ok(val);
6635            }
6636        }
6637        Err(ErrorContext::new_missing(
6638            "LinkinfoBridgeAttrs",
6639            "RootPort",
6640            self.orig_loc,
6641            self.buf.as_ptr() as usize,
6642        ))
6643    }
6644    pub fn get_root_path_cost(&self) -> Result<u32, ErrorContext> {
6645        let mut iter = self.clone();
6646        iter.pos = 0;
6647        for attr in iter {
6648            if let LinkinfoBridgeAttrs::RootPathCost(val) = attr? {
6649                return Ok(val);
6650            }
6651        }
6652        Err(ErrorContext::new_missing(
6653            "LinkinfoBridgeAttrs",
6654            "RootPathCost",
6655            self.orig_loc,
6656            self.buf.as_ptr() as usize,
6657        ))
6658    }
6659    pub fn get_topology_change(&self) -> Result<u8, ErrorContext> {
6660        let mut iter = self.clone();
6661        iter.pos = 0;
6662        for attr in iter {
6663            if let LinkinfoBridgeAttrs::TopologyChange(val) = attr? {
6664                return Ok(val);
6665            }
6666        }
6667        Err(ErrorContext::new_missing(
6668            "LinkinfoBridgeAttrs",
6669            "TopologyChange",
6670            self.orig_loc,
6671            self.buf.as_ptr() as usize,
6672        ))
6673    }
6674    pub fn get_topology_change_detected(&self) -> Result<u8, ErrorContext> {
6675        let mut iter = self.clone();
6676        iter.pos = 0;
6677        for attr in iter {
6678            if let LinkinfoBridgeAttrs::TopologyChangeDetected(val) = attr? {
6679                return Ok(val);
6680            }
6681        }
6682        Err(ErrorContext::new_missing(
6683            "LinkinfoBridgeAttrs",
6684            "TopologyChangeDetected",
6685            self.orig_loc,
6686            self.buf.as_ptr() as usize,
6687        ))
6688    }
6689    pub fn get_hello_timer(&self) -> Result<u64, ErrorContext> {
6690        let mut iter = self.clone();
6691        iter.pos = 0;
6692        for attr in iter {
6693            if let LinkinfoBridgeAttrs::HelloTimer(val) = attr? {
6694                return Ok(val);
6695            }
6696        }
6697        Err(ErrorContext::new_missing(
6698            "LinkinfoBridgeAttrs",
6699            "HelloTimer",
6700            self.orig_loc,
6701            self.buf.as_ptr() as usize,
6702        ))
6703    }
6704    pub fn get_tcn_timer(&self) -> Result<u64, ErrorContext> {
6705        let mut iter = self.clone();
6706        iter.pos = 0;
6707        for attr in iter {
6708            if let LinkinfoBridgeAttrs::TcnTimer(val) = attr? {
6709                return Ok(val);
6710            }
6711        }
6712        Err(ErrorContext::new_missing(
6713            "LinkinfoBridgeAttrs",
6714            "TcnTimer",
6715            self.orig_loc,
6716            self.buf.as_ptr() as usize,
6717        ))
6718    }
6719    pub fn get_topology_change_timer(&self) -> Result<u64, ErrorContext> {
6720        let mut iter = self.clone();
6721        iter.pos = 0;
6722        for attr in iter {
6723            if let LinkinfoBridgeAttrs::TopologyChangeTimer(val) = attr? {
6724                return Ok(val);
6725            }
6726        }
6727        Err(ErrorContext::new_missing(
6728            "LinkinfoBridgeAttrs",
6729            "TopologyChangeTimer",
6730            self.orig_loc,
6731            self.buf.as_ptr() as usize,
6732        ))
6733    }
6734    pub fn get_gc_timer(&self) -> Result<u64, ErrorContext> {
6735        let mut iter = self.clone();
6736        iter.pos = 0;
6737        for attr in iter {
6738            if let LinkinfoBridgeAttrs::GcTimer(val) = attr? {
6739                return Ok(val);
6740            }
6741        }
6742        Err(ErrorContext::new_missing(
6743            "LinkinfoBridgeAttrs",
6744            "GcTimer",
6745            self.orig_loc,
6746            self.buf.as_ptr() as usize,
6747        ))
6748    }
6749    pub fn get_group_addr(&self) -> Result<&'a [u8], ErrorContext> {
6750        let mut iter = self.clone();
6751        iter.pos = 0;
6752        for attr in iter {
6753            if let LinkinfoBridgeAttrs::GroupAddr(val) = attr? {
6754                return Ok(val);
6755            }
6756        }
6757        Err(ErrorContext::new_missing(
6758            "LinkinfoBridgeAttrs",
6759            "GroupAddr",
6760            self.orig_loc,
6761            self.buf.as_ptr() as usize,
6762        ))
6763    }
6764    pub fn get_fdb_flush(&self) -> Result<&'a [u8], ErrorContext> {
6765        let mut iter = self.clone();
6766        iter.pos = 0;
6767        for attr in iter {
6768            if let LinkinfoBridgeAttrs::FdbFlush(val) = attr? {
6769                return Ok(val);
6770            }
6771        }
6772        Err(ErrorContext::new_missing(
6773            "LinkinfoBridgeAttrs",
6774            "FdbFlush",
6775            self.orig_loc,
6776            self.buf.as_ptr() as usize,
6777        ))
6778    }
6779    pub fn get_mcast_router(&self) -> Result<u8, ErrorContext> {
6780        let mut iter = self.clone();
6781        iter.pos = 0;
6782        for attr in iter {
6783            if let LinkinfoBridgeAttrs::McastRouter(val) = attr? {
6784                return Ok(val);
6785            }
6786        }
6787        Err(ErrorContext::new_missing(
6788            "LinkinfoBridgeAttrs",
6789            "McastRouter",
6790            self.orig_loc,
6791            self.buf.as_ptr() as usize,
6792        ))
6793    }
6794    pub fn get_mcast_snooping(&self) -> Result<u8, ErrorContext> {
6795        let mut iter = self.clone();
6796        iter.pos = 0;
6797        for attr in iter {
6798            if let LinkinfoBridgeAttrs::McastSnooping(val) = attr? {
6799                return Ok(val);
6800            }
6801        }
6802        Err(ErrorContext::new_missing(
6803            "LinkinfoBridgeAttrs",
6804            "McastSnooping",
6805            self.orig_loc,
6806            self.buf.as_ptr() as usize,
6807        ))
6808    }
6809    pub fn get_mcast_query_use_ifaddr(&self) -> Result<u8, ErrorContext> {
6810        let mut iter = self.clone();
6811        iter.pos = 0;
6812        for attr in iter {
6813            if let LinkinfoBridgeAttrs::McastQueryUseIfaddr(val) = attr? {
6814                return Ok(val);
6815            }
6816        }
6817        Err(ErrorContext::new_missing(
6818            "LinkinfoBridgeAttrs",
6819            "McastQueryUseIfaddr",
6820            self.orig_loc,
6821            self.buf.as_ptr() as usize,
6822        ))
6823    }
6824    pub fn get_mcast_querier(&self) -> Result<u8, ErrorContext> {
6825        let mut iter = self.clone();
6826        iter.pos = 0;
6827        for attr in iter {
6828            if let LinkinfoBridgeAttrs::McastQuerier(val) = attr? {
6829                return Ok(val);
6830            }
6831        }
6832        Err(ErrorContext::new_missing(
6833            "LinkinfoBridgeAttrs",
6834            "McastQuerier",
6835            self.orig_loc,
6836            self.buf.as_ptr() as usize,
6837        ))
6838    }
6839    pub fn get_mcast_hash_elasticity(&self) -> Result<u32, ErrorContext> {
6840        let mut iter = self.clone();
6841        iter.pos = 0;
6842        for attr in iter {
6843            if let LinkinfoBridgeAttrs::McastHashElasticity(val) = attr? {
6844                return Ok(val);
6845            }
6846        }
6847        Err(ErrorContext::new_missing(
6848            "LinkinfoBridgeAttrs",
6849            "McastHashElasticity",
6850            self.orig_loc,
6851            self.buf.as_ptr() as usize,
6852        ))
6853    }
6854    pub fn get_mcast_hash_max(&self) -> Result<u32, ErrorContext> {
6855        let mut iter = self.clone();
6856        iter.pos = 0;
6857        for attr in iter {
6858            if let LinkinfoBridgeAttrs::McastHashMax(val) = attr? {
6859                return Ok(val);
6860            }
6861        }
6862        Err(ErrorContext::new_missing(
6863            "LinkinfoBridgeAttrs",
6864            "McastHashMax",
6865            self.orig_loc,
6866            self.buf.as_ptr() as usize,
6867        ))
6868    }
6869    pub fn get_mcast_last_member_cnt(&self) -> Result<u32, ErrorContext> {
6870        let mut iter = self.clone();
6871        iter.pos = 0;
6872        for attr in iter {
6873            if let LinkinfoBridgeAttrs::McastLastMemberCnt(val) = attr? {
6874                return Ok(val);
6875            }
6876        }
6877        Err(ErrorContext::new_missing(
6878            "LinkinfoBridgeAttrs",
6879            "McastLastMemberCnt",
6880            self.orig_loc,
6881            self.buf.as_ptr() as usize,
6882        ))
6883    }
6884    pub fn get_mcast_startup_query_cnt(&self) -> Result<u32, ErrorContext> {
6885        let mut iter = self.clone();
6886        iter.pos = 0;
6887        for attr in iter {
6888            if let LinkinfoBridgeAttrs::McastStartupQueryCnt(val) = attr? {
6889                return Ok(val);
6890            }
6891        }
6892        Err(ErrorContext::new_missing(
6893            "LinkinfoBridgeAttrs",
6894            "McastStartupQueryCnt",
6895            self.orig_loc,
6896            self.buf.as_ptr() as usize,
6897        ))
6898    }
6899    pub fn get_mcast_last_member_intvl(&self) -> Result<u64, ErrorContext> {
6900        let mut iter = self.clone();
6901        iter.pos = 0;
6902        for attr in iter {
6903            if let LinkinfoBridgeAttrs::McastLastMemberIntvl(val) = attr? {
6904                return Ok(val);
6905            }
6906        }
6907        Err(ErrorContext::new_missing(
6908            "LinkinfoBridgeAttrs",
6909            "McastLastMemberIntvl",
6910            self.orig_loc,
6911            self.buf.as_ptr() as usize,
6912        ))
6913    }
6914    pub fn get_mcast_membership_intvl(&self) -> Result<u64, ErrorContext> {
6915        let mut iter = self.clone();
6916        iter.pos = 0;
6917        for attr in iter {
6918            if let LinkinfoBridgeAttrs::McastMembershipIntvl(val) = attr? {
6919                return Ok(val);
6920            }
6921        }
6922        Err(ErrorContext::new_missing(
6923            "LinkinfoBridgeAttrs",
6924            "McastMembershipIntvl",
6925            self.orig_loc,
6926            self.buf.as_ptr() as usize,
6927        ))
6928    }
6929    pub fn get_mcast_querier_intvl(&self) -> Result<u64, ErrorContext> {
6930        let mut iter = self.clone();
6931        iter.pos = 0;
6932        for attr in iter {
6933            if let LinkinfoBridgeAttrs::McastQuerierIntvl(val) = attr? {
6934                return Ok(val);
6935            }
6936        }
6937        Err(ErrorContext::new_missing(
6938            "LinkinfoBridgeAttrs",
6939            "McastQuerierIntvl",
6940            self.orig_loc,
6941            self.buf.as_ptr() as usize,
6942        ))
6943    }
6944    pub fn get_mcast_query_intvl(&self) -> Result<u64, ErrorContext> {
6945        let mut iter = self.clone();
6946        iter.pos = 0;
6947        for attr in iter {
6948            if let LinkinfoBridgeAttrs::McastQueryIntvl(val) = attr? {
6949                return Ok(val);
6950            }
6951        }
6952        Err(ErrorContext::new_missing(
6953            "LinkinfoBridgeAttrs",
6954            "McastQueryIntvl",
6955            self.orig_loc,
6956            self.buf.as_ptr() as usize,
6957        ))
6958    }
6959    pub fn get_mcast_query_response_intvl(&self) -> Result<u64, ErrorContext> {
6960        let mut iter = self.clone();
6961        iter.pos = 0;
6962        for attr in iter {
6963            if let LinkinfoBridgeAttrs::McastQueryResponseIntvl(val) = attr? {
6964                return Ok(val);
6965            }
6966        }
6967        Err(ErrorContext::new_missing(
6968            "LinkinfoBridgeAttrs",
6969            "McastQueryResponseIntvl",
6970            self.orig_loc,
6971            self.buf.as_ptr() as usize,
6972        ))
6973    }
6974    pub fn get_mcast_startup_query_intvl(&self) -> Result<u64, ErrorContext> {
6975        let mut iter = self.clone();
6976        iter.pos = 0;
6977        for attr in iter {
6978            if let LinkinfoBridgeAttrs::McastStartupQueryIntvl(val) = attr? {
6979                return Ok(val);
6980            }
6981        }
6982        Err(ErrorContext::new_missing(
6983            "LinkinfoBridgeAttrs",
6984            "McastStartupQueryIntvl",
6985            self.orig_loc,
6986            self.buf.as_ptr() as usize,
6987        ))
6988    }
6989    pub fn get_nf_call_iptables(&self) -> Result<u8, ErrorContext> {
6990        let mut iter = self.clone();
6991        iter.pos = 0;
6992        for attr in iter {
6993            if let LinkinfoBridgeAttrs::NfCallIptables(val) = attr? {
6994                return Ok(val);
6995            }
6996        }
6997        Err(ErrorContext::new_missing(
6998            "LinkinfoBridgeAttrs",
6999            "NfCallIptables",
7000            self.orig_loc,
7001            self.buf.as_ptr() as usize,
7002        ))
7003    }
7004    pub fn get_nf_call_ip6tables(&self) -> Result<u8, ErrorContext> {
7005        let mut iter = self.clone();
7006        iter.pos = 0;
7007        for attr in iter {
7008            if let LinkinfoBridgeAttrs::NfCallIp6tables(val) = attr? {
7009                return Ok(val);
7010            }
7011        }
7012        Err(ErrorContext::new_missing(
7013            "LinkinfoBridgeAttrs",
7014            "NfCallIp6tables",
7015            self.orig_loc,
7016            self.buf.as_ptr() as usize,
7017        ))
7018    }
7019    pub fn get_nf_call_arptables(&self) -> Result<u8, ErrorContext> {
7020        let mut iter = self.clone();
7021        iter.pos = 0;
7022        for attr in iter {
7023            if let LinkinfoBridgeAttrs::NfCallArptables(val) = attr? {
7024                return Ok(val);
7025            }
7026        }
7027        Err(ErrorContext::new_missing(
7028            "LinkinfoBridgeAttrs",
7029            "NfCallArptables",
7030            self.orig_loc,
7031            self.buf.as_ptr() as usize,
7032        ))
7033    }
7034    pub fn get_vlan_default_pvid(&self) -> Result<u16, ErrorContext> {
7035        let mut iter = self.clone();
7036        iter.pos = 0;
7037        for attr in iter {
7038            if let LinkinfoBridgeAttrs::VlanDefaultPvid(val) = attr? {
7039                return Ok(val);
7040            }
7041        }
7042        Err(ErrorContext::new_missing(
7043            "LinkinfoBridgeAttrs",
7044            "VlanDefaultPvid",
7045            self.orig_loc,
7046            self.buf.as_ptr() as usize,
7047        ))
7048    }
7049    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
7050        let mut iter = self.clone();
7051        iter.pos = 0;
7052        for attr in iter {
7053            if let LinkinfoBridgeAttrs::Pad(val) = attr? {
7054                return Ok(val);
7055            }
7056        }
7057        Err(ErrorContext::new_missing(
7058            "LinkinfoBridgeAttrs",
7059            "Pad",
7060            self.orig_loc,
7061            self.buf.as_ptr() as usize,
7062        ))
7063    }
7064    pub fn get_vlan_stats_enabled(&self) -> Result<u8, ErrorContext> {
7065        let mut iter = self.clone();
7066        iter.pos = 0;
7067        for attr in iter {
7068            if let LinkinfoBridgeAttrs::VlanStatsEnabled(val) = attr? {
7069                return Ok(val);
7070            }
7071        }
7072        Err(ErrorContext::new_missing(
7073            "LinkinfoBridgeAttrs",
7074            "VlanStatsEnabled",
7075            self.orig_loc,
7076            self.buf.as_ptr() as usize,
7077        ))
7078    }
7079    pub fn get_mcast_stats_enabled(&self) -> Result<u8, ErrorContext> {
7080        let mut iter = self.clone();
7081        iter.pos = 0;
7082        for attr in iter {
7083            if let LinkinfoBridgeAttrs::McastStatsEnabled(val) = attr? {
7084                return Ok(val);
7085            }
7086        }
7087        Err(ErrorContext::new_missing(
7088            "LinkinfoBridgeAttrs",
7089            "McastStatsEnabled",
7090            self.orig_loc,
7091            self.buf.as_ptr() as usize,
7092        ))
7093    }
7094    pub fn get_mcast_igmp_version(&self) -> Result<u8, ErrorContext> {
7095        let mut iter = self.clone();
7096        iter.pos = 0;
7097        for attr in iter {
7098            if let LinkinfoBridgeAttrs::McastIgmpVersion(val) = attr? {
7099                return Ok(val);
7100            }
7101        }
7102        Err(ErrorContext::new_missing(
7103            "LinkinfoBridgeAttrs",
7104            "McastIgmpVersion",
7105            self.orig_loc,
7106            self.buf.as_ptr() as usize,
7107        ))
7108    }
7109    pub fn get_mcast_mld_version(&self) -> Result<u8, ErrorContext> {
7110        let mut iter = self.clone();
7111        iter.pos = 0;
7112        for attr in iter {
7113            if let LinkinfoBridgeAttrs::McastMldVersion(val) = attr? {
7114                return Ok(val);
7115            }
7116        }
7117        Err(ErrorContext::new_missing(
7118            "LinkinfoBridgeAttrs",
7119            "McastMldVersion",
7120            self.orig_loc,
7121            self.buf.as_ptr() as usize,
7122        ))
7123    }
7124    pub fn get_vlan_stats_per_port(&self) -> Result<u8, ErrorContext> {
7125        let mut iter = self.clone();
7126        iter.pos = 0;
7127        for attr in iter {
7128            if let LinkinfoBridgeAttrs::VlanStatsPerPort(val) = attr? {
7129                return Ok(val);
7130            }
7131        }
7132        Err(ErrorContext::new_missing(
7133            "LinkinfoBridgeAttrs",
7134            "VlanStatsPerPort",
7135            self.orig_loc,
7136            self.buf.as_ptr() as usize,
7137        ))
7138    }
7139    pub fn get_multi_boolopt(&self) -> Result<PushBrBooloptMulti, ErrorContext> {
7140        let mut iter = self.clone();
7141        iter.pos = 0;
7142        for attr in iter {
7143            if let LinkinfoBridgeAttrs::MultiBoolopt(val) = attr? {
7144                return Ok(val);
7145            }
7146        }
7147        Err(ErrorContext::new_missing(
7148            "LinkinfoBridgeAttrs",
7149            "MultiBoolopt",
7150            self.orig_loc,
7151            self.buf.as_ptr() as usize,
7152        ))
7153    }
7154    pub fn get_mcast_querier_state(&self) -> Result<&'a [u8], ErrorContext> {
7155        let mut iter = self.clone();
7156        iter.pos = 0;
7157        for attr in iter {
7158            if let LinkinfoBridgeAttrs::McastQuerierState(val) = attr? {
7159                return Ok(val);
7160            }
7161        }
7162        Err(ErrorContext::new_missing(
7163            "LinkinfoBridgeAttrs",
7164            "McastQuerierState",
7165            self.orig_loc,
7166            self.buf.as_ptr() as usize,
7167        ))
7168    }
7169    pub fn get_fdb_n_learned(&self) -> Result<u32, ErrorContext> {
7170        let mut iter = self.clone();
7171        iter.pos = 0;
7172        for attr in iter {
7173            if let LinkinfoBridgeAttrs::FdbNLearned(val) = attr? {
7174                return Ok(val);
7175            }
7176        }
7177        Err(ErrorContext::new_missing(
7178            "LinkinfoBridgeAttrs",
7179            "FdbNLearned",
7180            self.orig_loc,
7181            self.buf.as_ptr() as usize,
7182        ))
7183    }
7184    pub fn get_fdb_max_learned(&self) -> Result<u32, ErrorContext> {
7185        let mut iter = self.clone();
7186        iter.pos = 0;
7187        for attr in iter {
7188            if let LinkinfoBridgeAttrs::FdbMaxLearned(val) = attr? {
7189                return Ok(val);
7190            }
7191        }
7192        Err(ErrorContext::new_missing(
7193            "LinkinfoBridgeAttrs",
7194            "FdbMaxLearned",
7195            self.orig_loc,
7196            self.buf.as_ptr() as usize,
7197        ))
7198    }
7199}
7200impl<'a> LinkinfoBridgeAttrs<'a> {
7201    pub fn new(buf: &'a [u8]) -> IterableLinkinfoBridgeAttrs<'a> {
7202        IterableLinkinfoBridgeAttrs::with_loc(buf, buf.as_ptr() as usize)
7203    }
7204    fn attr_from_type(r#type: u16) -> Option<&'static str> {
7205        let res = match r#type {
7206            1u16 => "ForwardDelay",
7207            2u16 => "HelloTime",
7208            3u16 => "MaxAge",
7209            4u16 => "AgeingTime",
7210            5u16 => "StpState",
7211            6u16 => "Priority",
7212            7u16 => "VlanFiltering",
7213            8u16 => "VlanProtocol",
7214            9u16 => "GroupFwdMask",
7215            10u16 => "RootId",
7216            11u16 => "BridgeId",
7217            12u16 => "RootPort",
7218            13u16 => "RootPathCost",
7219            14u16 => "TopologyChange",
7220            15u16 => "TopologyChangeDetected",
7221            16u16 => "HelloTimer",
7222            17u16 => "TcnTimer",
7223            18u16 => "TopologyChangeTimer",
7224            19u16 => "GcTimer",
7225            20u16 => "GroupAddr",
7226            21u16 => "FdbFlush",
7227            22u16 => "McastRouter",
7228            23u16 => "McastSnooping",
7229            24u16 => "McastQueryUseIfaddr",
7230            25u16 => "McastQuerier",
7231            26u16 => "McastHashElasticity",
7232            27u16 => "McastHashMax",
7233            28u16 => "McastLastMemberCnt",
7234            29u16 => "McastStartupQueryCnt",
7235            30u16 => "McastLastMemberIntvl",
7236            31u16 => "McastMembershipIntvl",
7237            32u16 => "McastQuerierIntvl",
7238            33u16 => "McastQueryIntvl",
7239            34u16 => "McastQueryResponseIntvl",
7240            35u16 => "McastStartupQueryIntvl",
7241            36u16 => "NfCallIptables",
7242            37u16 => "NfCallIp6tables",
7243            38u16 => "NfCallArptables",
7244            39u16 => "VlanDefaultPvid",
7245            40u16 => "Pad",
7246            41u16 => "VlanStatsEnabled",
7247            42u16 => "McastStatsEnabled",
7248            43u16 => "McastIgmpVersion",
7249            44u16 => "McastMldVersion",
7250            45u16 => "VlanStatsPerPort",
7251            46u16 => "MultiBoolopt",
7252            47u16 => "McastQuerierState",
7253            48u16 => "FdbNLearned",
7254            49u16 => "FdbMaxLearned",
7255            _ => return None,
7256        };
7257        Some(res)
7258    }
7259}
7260#[derive(Clone, Copy, Default)]
7261pub struct IterableLinkinfoBridgeAttrs<'a> {
7262    buf: &'a [u8],
7263    pos: usize,
7264    orig_loc: usize,
7265}
7266impl<'a> IterableLinkinfoBridgeAttrs<'a> {
7267    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
7268        Self {
7269            buf,
7270            pos: 0,
7271            orig_loc,
7272        }
7273    }
7274    pub fn get_buf(&self) -> &'a [u8] {
7275        self.buf
7276    }
7277}
7278impl<'a> Iterator for IterableLinkinfoBridgeAttrs<'a> {
7279    type Item = Result<LinkinfoBridgeAttrs<'a>, ErrorContext>;
7280    fn next(&mut self) -> Option<Self::Item> {
7281        if self.buf.len() == self.pos {
7282            return None;
7283        }
7284        let pos = self.pos;
7285        let mut r#type = None;
7286        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
7287            r#type = Some(header.r#type);
7288            let res = match header.r#type {
7289                1u16 => LinkinfoBridgeAttrs::ForwardDelay({
7290                    let res = parse_u32(next);
7291                    let Some(val) = res else { break };
7292                    val
7293                }),
7294                2u16 => LinkinfoBridgeAttrs::HelloTime({
7295                    let res = parse_u32(next);
7296                    let Some(val) = res else { break };
7297                    val
7298                }),
7299                3u16 => LinkinfoBridgeAttrs::MaxAge({
7300                    let res = parse_u32(next);
7301                    let Some(val) = res else { break };
7302                    val
7303                }),
7304                4u16 => LinkinfoBridgeAttrs::AgeingTime({
7305                    let res = parse_u32(next);
7306                    let Some(val) = res else { break };
7307                    val
7308                }),
7309                5u16 => LinkinfoBridgeAttrs::StpState({
7310                    let res = parse_u32(next);
7311                    let Some(val) = res else { break };
7312                    val
7313                }),
7314                6u16 => LinkinfoBridgeAttrs::Priority({
7315                    let res = parse_u16(next);
7316                    let Some(val) = res else { break };
7317                    val
7318                }),
7319                7u16 => LinkinfoBridgeAttrs::VlanFiltering({
7320                    let res = parse_u8(next);
7321                    let Some(val) = res else { break };
7322                    val
7323                }),
7324                8u16 => LinkinfoBridgeAttrs::VlanProtocol({
7325                    let res = parse_u16(next);
7326                    let Some(val) = res else { break };
7327                    val
7328                }),
7329                9u16 => LinkinfoBridgeAttrs::GroupFwdMask({
7330                    let res = parse_u16(next);
7331                    let Some(val) = res else { break };
7332                    val
7333                }),
7334                10u16 => LinkinfoBridgeAttrs::RootId({
7335                    let res = PushIflaBridgeId::new_from_slice(next);
7336                    let Some(val) = res else { break };
7337                    val
7338                }),
7339                11u16 => LinkinfoBridgeAttrs::BridgeId({
7340                    let res = PushIflaBridgeId::new_from_slice(next);
7341                    let Some(val) = res else { break };
7342                    val
7343                }),
7344                12u16 => LinkinfoBridgeAttrs::RootPort({
7345                    let res = parse_u16(next);
7346                    let Some(val) = res else { break };
7347                    val
7348                }),
7349                13u16 => LinkinfoBridgeAttrs::RootPathCost({
7350                    let res = parse_u32(next);
7351                    let Some(val) = res else { break };
7352                    val
7353                }),
7354                14u16 => LinkinfoBridgeAttrs::TopologyChange({
7355                    let res = parse_u8(next);
7356                    let Some(val) = res else { break };
7357                    val
7358                }),
7359                15u16 => LinkinfoBridgeAttrs::TopologyChangeDetected({
7360                    let res = parse_u8(next);
7361                    let Some(val) = res else { break };
7362                    val
7363                }),
7364                16u16 => LinkinfoBridgeAttrs::HelloTimer({
7365                    let res = parse_u64(next);
7366                    let Some(val) = res else { break };
7367                    val
7368                }),
7369                17u16 => LinkinfoBridgeAttrs::TcnTimer({
7370                    let res = parse_u64(next);
7371                    let Some(val) = res else { break };
7372                    val
7373                }),
7374                18u16 => LinkinfoBridgeAttrs::TopologyChangeTimer({
7375                    let res = parse_u64(next);
7376                    let Some(val) = res else { break };
7377                    val
7378                }),
7379                19u16 => LinkinfoBridgeAttrs::GcTimer({
7380                    let res = parse_u64(next);
7381                    let Some(val) = res else { break };
7382                    val
7383                }),
7384                20u16 => LinkinfoBridgeAttrs::GroupAddr({
7385                    let res = Some(next);
7386                    let Some(val) = res else { break };
7387                    val
7388                }),
7389                21u16 => LinkinfoBridgeAttrs::FdbFlush({
7390                    let res = Some(next);
7391                    let Some(val) = res else { break };
7392                    val
7393                }),
7394                22u16 => LinkinfoBridgeAttrs::McastRouter({
7395                    let res = parse_u8(next);
7396                    let Some(val) = res else { break };
7397                    val
7398                }),
7399                23u16 => LinkinfoBridgeAttrs::McastSnooping({
7400                    let res = parse_u8(next);
7401                    let Some(val) = res else { break };
7402                    val
7403                }),
7404                24u16 => LinkinfoBridgeAttrs::McastQueryUseIfaddr({
7405                    let res = parse_u8(next);
7406                    let Some(val) = res else { break };
7407                    val
7408                }),
7409                25u16 => LinkinfoBridgeAttrs::McastQuerier({
7410                    let res = parse_u8(next);
7411                    let Some(val) = res else { break };
7412                    val
7413                }),
7414                26u16 => LinkinfoBridgeAttrs::McastHashElasticity({
7415                    let res = parse_u32(next);
7416                    let Some(val) = res else { break };
7417                    val
7418                }),
7419                27u16 => LinkinfoBridgeAttrs::McastHashMax({
7420                    let res = parse_u32(next);
7421                    let Some(val) = res else { break };
7422                    val
7423                }),
7424                28u16 => LinkinfoBridgeAttrs::McastLastMemberCnt({
7425                    let res = parse_u32(next);
7426                    let Some(val) = res else { break };
7427                    val
7428                }),
7429                29u16 => LinkinfoBridgeAttrs::McastStartupQueryCnt({
7430                    let res = parse_u32(next);
7431                    let Some(val) = res else { break };
7432                    val
7433                }),
7434                30u16 => LinkinfoBridgeAttrs::McastLastMemberIntvl({
7435                    let res = parse_u64(next);
7436                    let Some(val) = res else { break };
7437                    val
7438                }),
7439                31u16 => LinkinfoBridgeAttrs::McastMembershipIntvl({
7440                    let res = parse_u64(next);
7441                    let Some(val) = res else { break };
7442                    val
7443                }),
7444                32u16 => LinkinfoBridgeAttrs::McastQuerierIntvl({
7445                    let res = parse_u64(next);
7446                    let Some(val) = res else { break };
7447                    val
7448                }),
7449                33u16 => LinkinfoBridgeAttrs::McastQueryIntvl({
7450                    let res = parse_u64(next);
7451                    let Some(val) = res else { break };
7452                    val
7453                }),
7454                34u16 => LinkinfoBridgeAttrs::McastQueryResponseIntvl({
7455                    let res = parse_u64(next);
7456                    let Some(val) = res else { break };
7457                    val
7458                }),
7459                35u16 => LinkinfoBridgeAttrs::McastStartupQueryIntvl({
7460                    let res = parse_u64(next);
7461                    let Some(val) = res else { break };
7462                    val
7463                }),
7464                36u16 => LinkinfoBridgeAttrs::NfCallIptables({
7465                    let res = parse_u8(next);
7466                    let Some(val) = res else { break };
7467                    val
7468                }),
7469                37u16 => LinkinfoBridgeAttrs::NfCallIp6tables({
7470                    let res = parse_u8(next);
7471                    let Some(val) = res else { break };
7472                    val
7473                }),
7474                38u16 => LinkinfoBridgeAttrs::NfCallArptables({
7475                    let res = parse_u8(next);
7476                    let Some(val) = res else { break };
7477                    val
7478                }),
7479                39u16 => LinkinfoBridgeAttrs::VlanDefaultPvid({
7480                    let res = parse_u16(next);
7481                    let Some(val) = res else { break };
7482                    val
7483                }),
7484                40u16 => LinkinfoBridgeAttrs::Pad({
7485                    let res = Some(next);
7486                    let Some(val) = res else { break };
7487                    val
7488                }),
7489                41u16 => LinkinfoBridgeAttrs::VlanStatsEnabled({
7490                    let res = parse_u8(next);
7491                    let Some(val) = res else { break };
7492                    val
7493                }),
7494                42u16 => LinkinfoBridgeAttrs::McastStatsEnabled({
7495                    let res = parse_u8(next);
7496                    let Some(val) = res else { break };
7497                    val
7498                }),
7499                43u16 => LinkinfoBridgeAttrs::McastIgmpVersion({
7500                    let res = parse_u8(next);
7501                    let Some(val) = res else { break };
7502                    val
7503                }),
7504                44u16 => LinkinfoBridgeAttrs::McastMldVersion({
7505                    let res = parse_u8(next);
7506                    let Some(val) = res else { break };
7507                    val
7508                }),
7509                45u16 => LinkinfoBridgeAttrs::VlanStatsPerPort({
7510                    let res = parse_u8(next);
7511                    let Some(val) = res else { break };
7512                    val
7513                }),
7514                46u16 => LinkinfoBridgeAttrs::MultiBoolopt({
7515                    let res = PushBrBooloptMulti::new_from_slice(next);
7516                    let Some(val) = res else { break };
7517                    val
7518                }),
7519                47u16 => LinkinfoBridgeAttrs::McastQuerierState({
7520                    let res = Some(next);
7521                    let Some(val) = res else { break };
7522                    val
7523                }),
7524                48u16 => LinkinfoBridgeAttrs::FdbNLearned({
7525                    let res = parse_u32(next);
7526                    let Some(val) = res else { break };
7527                    val
7528                }),
7529                49u16 => LinkinfoBridgeAttrs::FdbMaxLearned({
7530                    let res = parse_u32(next);
7531                    let Some(val) = res else { break };
7532                    val
7533                }),
7534                n => {
7535                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
7536                        break;
7537                    } else {
7538                        continue;
7539                    }
7540                }
7541            };
7542            return Some(Ok(res));
7543        }
7544        Some(Err(ErrorContext::new(
7545            "LinkinfoBridgeAttrs",
7546            r#type.and_then(|t| LinkinfoBridgeAttrs::attr_from_type(t)),
7547            self.orig_loc,
7548            self.buf.as_ptr().wrapping_add(pos) as usize,
7549        )))
7550    }
7551}
7552impl<'a> std::fmt::Debug for IterableLinkinfoBridgeAttrs<'_> {
7553    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7554        let mut fmt = f.debug_struct("LinkinfoBridgeAttrs");
7555        for attr in self.clone() {
7556            let attr = match attr {
7557                Ok(a) => a,
7558                Err(err) => {
7559                    fmt.finish()?;
7560                    f.write_str("Err(")?;
7561                    err.fmt(f)?;
7562                    return f.write_str(")");
7563                }
7564            };
7565            match attr {
7566                LinkinfoBridgeAttrs::ForwardDelay(val) => fmt.field("ForwardDelay", &val),
7567                LinkinfoBridgeAttrs::HelloTime(val) => fmt.field("HelloTime", &val),
7568                LinkinfoBridgeAttrs::MaxAge(val) => fmt.field("MaxAge", &val),
7569                LinkinfoBridgeAttrs::AgeingTime(val) => fmt.field("AgeingTime", &val),
7570                LinkinfoBridgeAttrs::StpState(val) => fmt.field("StpState", &val),
7571                LinkinfoBridgeAttrs::Priority(val) => fmt.field("Priority", &val),
7572                LinkinfoBridgeAttrs::VlanFiltering(val) => fmt.field("VlanFiltering", &val),
7573                LinkinfoBridgeAttrs::VlanProtocol(val) => fmt.field("VlanProtocol", &val),
7574                LinkinfoBridgeAttrs::GroupFwdMask(val) => fmt.field("GroupFwdMask", &val),
7575                LinkinfoBridgeAttrs::RootId(val) => fmt.field("RootId", &val),
7576                LinkinfoBridgeAttrs::BridgeId(val) => fmt.field("BridgeId", &val),
7577                LinkinfoBridgeAttrs::RootPort(val) => fmt.field("RootPort", &val),
7578                LinkinfoBridgeAttrs::RootPathCost(val) => fmt.field("RootPathCost", &val),
7579                LinkinfoBridgeAttrs::TopologyChange(val) => fmt.field("TopologyChange", &val),
7580                LinkinfoBridgeAttrs::TopologyChangeDetected(val) => {
7581                    fmt.field("TopologyChangeDetected", &val)
7582                }
7583                LinkinfoBridgeAttrs::HelloTimer(val) => fmt.field("HelloTimer", &val),
7584                LinkinfoBridgeAttrs::TcnTimer(val) => fmt.field("TcnTimer", &val),
7585                LinkinfoBridgeAttrs::TopologyChangeTimer(val) => {
7586                    fmt.field("TopologyChangeTimer", &val)
7587                }
7588                LinkinfoBridgeAttrs::GcTimer(val) => fmt.field("GcTimer", &val),
7589                LinkinfoBridgeAttrs::GroupAddr(val) => fmt.field("GroupAddr", &val),
7590                LinkinfoBridgeAttrs::FdbFlush(val) => fmt.field("FdbFlush", &val),
7591                LinkinfoBridgeAttrs::McastRouter(val) => fmt.field("McastRouter", &val),
7592                LinkinfoBridgeAttrs::McastSnooping(val) => fmt.field("McastSnooping", &val),
7593                LinkinfoBridgeAttrs::McastQueryUseIfaddr(val) => {
7594                    fmt.field("McastQueryUseIfaddr", &val)
7595                }
7596                LinkinfoBridgeAttrs::McastQuerier(val) => fmt.field("McastQuerier", &val),
7597                LinkinfoBridgeAttrs::McastHashElasticity(val) => {
7598                    fmt.field("McastHashElasticity", &val)
7599                }
7600                LinkinfoBridgeAttrs::McastHashMax(val) => fmt.field("McastHashMax", &val),
7601                LinkinfoBridgeAttrs::McastLastMemberCnt(val) => {
7602                    fmt.field("McastLastMemberCnt", &val)
7603                }
7604                LinkinfoBridgeAttrs::McastStartupQueryCnt(val) => {
7605                    fmt.field("McastStartupQueryCnt", &val)
7606                }
7607                LinkinfoBridgeAttrs::McastLastMemberIntvl(val) => {
7608                    fmt.field("McastLastMemberIntvl", &val)
7609                }
7610                LinkinfoBridgeAttrs::McastMembershipIntvl(val) => {
7611                    fmt.field("McastMembershipIntvl", &val)
7612                }
7613                LinkinfoBridgeAttrs::McastQuerierIntvl(val) => fmt.field("McastQuerierIntvl", &val),
7614                LinkinfoBridgeAttrs::McastQueryIntvl(val) => fmt.field("McastQueryIntvl", &val),
7615                LinkinfoBridgeAttrs::McastQueryResponseIntvl(val) => {
7616                    fmt.field("McastQueryResponseIntvl", &val)
7617                }
7618                LinkinfoBridgeAttrs::McastStartupQueryIntvl(val) => {
7619                    fmt.field("McastStartupQueryIntvl", &val)
7620                }
7621                LinkinfoBridgeAttrs::NfCallIptables(val) => fmt.field("NfCallIptables", &val),
7622                LinkinfoBridgeAttrs::NfCallIp6tables(val) => fmt.field("NfCallIp6tables", &val),
7623                LinkinfoBridgeAttrs::NfCallArptables(val) => fmt.field("NfCallArptables", &val),
7624                LinkinfoBridgeAttrs::VlanDefaultPvid(val) => fmt.field("VlanDefaultPvid", &val),
7625                LinkinfoBridgeAttrs::Pad(val) => fmt.field("Pad", &val),
7626                LinkinfoBridgeAttrs::VlanStatsEnabled(val) => fmt.field("VlanStatsEnabled", &val),
7627                LinkinfoBridgeAttrs::McastStatsEnabled(val) => fmt.field("McastStatsEnabled", &val),
7628                LinkinfoBridgeAttrs::McastIgmpVersion(val) => fmt.field("McastIgmpVersion", &val),
7629                LinkinfoBridgeAttrs::McastMldVersion(val) => fmt.field("McastMldVersion", &val),
7630                LinkinfoBridgeAttrs::VlanStatsPerPort(val) => fmt.field("VlanStatsPerPort", &val),
7631                LinkinfoBridgeAttrs::MultiBoolopt(val) => fmt.field("MultiBoolopt", &val),
7632                LinkinfoBridgeAttrs::McastQuerierState(val) => fmt.field("McastQuerierState", &val),
7633                LinkinfoBridgeAttrs::FdbNLearned(val) => fmt.field("FdbNLearned", &val),
7634                LinkinfoBridgeAttrs::FdbMaxLearned(val) => fmt.field("FdbMaxLearned", &val),
7635            };
7636        }
7637        fmt.finish()
7638    }
7639}
7640impl IterableLinkinfoBridgeAttrs<'_> {
7641    pub fn lookup_attr(
7642        &self,
7643        offset: usize,
7644        missing_type: Option<u16>,
7645    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
7646        let mut stack = Vec::new();
7647        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
7648        if cur == offset {
7649            stack.push(("LinkinfoBridgeAttrs", offset));
7650            return (
7651                stack,
7652                missing_type.and_then(|t| LinkinfoBridgeAttrs::attr_from_type(t)),
7653            );
7654        }
7655        if cur > offset || cur + self.buf.len() < offset {
7656            return (stack, None);
7657        }
7658        let mut attrs = self.clone();
7659        let mut last_off = cur + attrs.pos;
7660        while let Some(attr) = attrs.next() {
7661            let Ok(attr) = attr else { break };
7662            match attr {
7663                LinkinfoBridgeAttrs::ForwardDelay(val) => {
7664                    if last_off == offset {
7665                        stack.push(("ForwardDelay", last_off));
7666                        break;
7667                    }
7668                }
7669                LinkinfoBridgeAttrs::HelloTime(val) => {
7670                    if last_off == offset {
7671                        stack.push(("HelloTime", last_off));
7672                        break;
7673                    }
7674                }
7675                LinkinfoBridgeAttrs::MaxAge(val) => {
7676                    if last_off == offset {
7677                        stack.push(("MaxAge", last_off));
7678                        break;
7679                    }
7680                }
7681                LinkinfoBridgeAttrs::AgeingTime(val) => {
7682                    if last_off == offset {
7683                        stack.push(("AgeingTime", last_off));
7684                        break;
7685                    }
7686                }
7687                LinkinfoBridgeAttrs::StpState(val) => {
7688                    if last_off == offset {
7689                        stack.push(("StpState", last_off));
7690                        break;
7691                    }
7692                }
7693                LinkinfoBridgeAttrs::Priority(val) => {
7694                    if last_off == offset {
7695                        stack.push(("Priority", last_off));
7696                        break;
7697                    }
7698                }
7699                LinkinfoBridgeAttrs::VlanFiltering(val) => {
7700                    if last_off == offset {
7701                        stack.push(("VlanFiltering", last_off));
7702                        break;
7703                    }
7704                }
7705                LinkinfoBridgeAttrs::VlanProtocol(val) => {
7706                    if last_off == offset {
7707                        stack.push(("VlanProtocol", last_off));
7708                        break;
7709                    }
7710                }
7711                LinkinfoBridgeAttrs::GroupFwdMask(val) => {
7712                    if last_off == offset {
7713                        stack.push(("GroupFwdMask", last_off));
7714                        break;
7715                    }
7716                }
7717                LinkinfoBridgeAttrs::RootId(val) => {
7718                    if last_off == offset {
7719                        stack.push(("RootId", last_off));
7720                        break;
7721                    }
7722                }
7723                LinkinfoBridgeAttrs::BridgeId(val) => {
7724                    if last_off == offset {
7725                        stack.push(("BridgeId", last_off));
7726                        break;
7727                    }
7728                }
7729                LinkinfoBridgeAttrs::RootPort(val) => {
7730                    if last_off == offset {
7731                        stack.push(("RootPort", last_off));
7732                        break;
7733                    }
7734                }
7735                LinkinfoBridgeAttrs::RootPathCost(val) => {
7736                    if last_off == offset {
7737                        stack.push(("RootPathCost", last_off));
7738                        break;
7739                    }
7740                }
7741                LinkinfoBridgeAttrs::TopologyChange(val) => {
7742                    if last_off == offset {
7743                        stack.push(("TopologyChange", last_off));
7744                        break;
7745                    }
7746                }
7747                LinkinfoBridgeAttrs::TopologyChangeDetected(val) => {
7748                    if last_off == offset {
7749                        stack.push(("TopologyChangeDetected", last_off));
7750                        break;
7751                    }
7752                }
7753                LinkinfoBridgeAttrs::HelloTimer(val) => {
7754                    if last_off == offset {
7755                        stack.push(("HelloTimer", last_off));
7756                        break;
7757                    }
7758                }
7759                LinkinfoBridgeAttrs::TcnTimer(val) => {
7760                    if last_off == offset {
7761                        stack.push(("TcnTimer", last_off));
7762                        break;
7763                    }
7764                }
7765                LinkinfoBridgeAttrs::TopologyChangeTimer(val) => {
7766                    if last_off == offset {
7767                        stack.push(("TopologyChangeTimer", last_off));
7768                        break;
7769                    }
7770                }
7771                LinkinfoBridgeAttrs::GcTimer(val) => {
7772                    if last_off == offset {
7773                        stack.push(("GcTimer", last_off));
7774                        break;
7775                    }
7776                }
7777                LinkinfoBridgeAttrs::GroupAddr(val) => {
7778                    if last_off == offset {
7779                        stack.push(("GroupAddr", last_off));
7780                        break;
7781                    }
7782                }
7783                LinkinfoBridgeAttrs::FdbFlush(val) => {
7784                    if last_off == offset {
7785                        stack.push(("FdbFlush", last_off));
7786                        break;
7787                    }
7788                }
7789                LinkinfoBridgeAttrs::McastRouter(val) => {
7790                    if last_off == offset {
7791                        stack.push(("McastRouter", last_off));
7792                        break;
7793                    }
7794                }
7795                LinkinfoBridgeAttrs::McastSnooping(val) => {
7796                    if last_off == offset {
7797                        stack.push(("McastSnooping", last_off));
7798                        break;
7799                    }
7800                }
7801                LinkinfoBridgeAttrs::McastQueryUseIfaddr(val) => {
7802                    if last_off == offset {
7803                        stack.push(("McastQueryUseIfaddr", last_off));
7804                        break;
7805                    }
7806                }
7807                LinkinfoBridgeAttrs::McastQuerier(val) => {
7808                    if last_off == offset {
7809                        stack.push(("McastQuerier", last_off));
7810                        break;
7811                    }
7812                }
7813                LinkinfoBridgeAttrs::McastHashElasticity(val) => {
7814                    if last_off == offset {
7815                        stack.push(("McastHashElasticity", last_off));
7816                        break;
7817                    }
7818                }
7819                LinkinfoBridgeAttrs::McastHashMax(val) => {
7820                    if last_off == offset {
7821                        stack.push(("McastHashMax", last_off));
7822                        break;
7823                    }
7824                }
7825                LinkinfoBridgeAttrs::McastLastMemberCnt(val) => {
7826                    if last_off == offset {
7827                        stack.push(("McastLastMemberCnt", last_off));
7828                        break;
7829                    }
7830                }
7831                LinkinfoBridgeAttrs::McastStartupQueryCnt(val) => {
7832                    if last_off == offset {
7833                        stack.push(("McastStartupQueryCnt", last_off));
7834                        break;
7835                    }
7836                }
7837                LinkinfoBridgeAttrs::McastLastMemberIntvl(val) => {
7838                    if last_off == offset {
7839                        stack.push(("McastLastMemberIntvl", last_off));
7840                        break;
7841                    }
7842                }
7843                LinkinfoBridgeAttrs::McastMembershipIntvl(val) => {
7844                    if last_off == offset {
7845                        stack.push(("McastMembershipIntvl", last_off));
7846                        break;
7847                    }
7848                }
7849                LinkinfoBridgeAttrs::McastQuerierIntvl(val) => {
7850                    if last_off == offset {
7851                        stack.push(("McastQuerierIntvl", last_off));
7852                        break;
7853                    }
7854                }
7855                LinkinfoBridgeAttrs::McastQueryIntvl(val) => {
7856                    if last_off == offset {
7857                        stack.push(("McastQueryIntvl", last_off));
7858                        break;
7859                    }
7860                }
7861                LinkinfoBridgeAttrs::McastQueryResponseIntvl(val) => {
7862                    if last_off == offset {
7863                        stack.push(("McastQueryResponseIntvl", last_off));
7864                        break;
7865                    }
7866                }
7867                LinkinfoBridgeAttrs::McastStartupQueryIntvl(val) => {
7868                    if last_off == offset {
7869                        stack.push(("McastStartupQueryIntvl", last_off));
7870                        break;
7871                    }
7872                }
7873                LinkinfoBridgeAttrs::NfCallIptables(val) => {
7874                    if last_off == offset {
7875                        stack.push(("NfCallIptables", last_off));
7876                        break;
7877                    }
7878                }
7879                LinkinfoBridgeAttrs::NfCallIp6tables(val) => {
7880                    if last_off == offset {
7881                        stack.push(("NfCallIp6tables", last_off));
7882                        break;
7883                    }
7884                }
7885                LinkinfoBridgeAttrs::NfCallArptables(val) => {
7886                    if last_off == offset {
7887                        stack.push(("NfCallArptables", last_off));
7888                        break;
7889                    }
7890                }
7891                LinkinfoBridgeAttrs::VlanDefaultPvid(val) => {
7892                    if last_off == offset {
7893                        stack.push(("VlanDefaultPvid", last_off));
7894                        break;
7895                    }
7896                }
7897                LinkinfoBridgeAttrs::Pad(val) => {
7898                    if last_off == offset {
7899                        stack.push(("Pad", last_off));
7900                        break;
7901                    }
7902                }
7903                LinkinfoBridgeAttrs::VlanStatsEnabled(val) => {
7904                    if last_off == offset {
7905                        stack.push(("VlanStatsEnabled", last_off));
7906                        break;
7907                    }
7908                }
7909                LinkinfoBridgeAttrs::McastStatsEnabled(val) => {
7910                    if last_off == offset {
7911                        stack.push(("McastStatsEnabled", last_off));
7912                        break;
7913                    }
7914                }
7915                LinkinfoBridgeAttrs::McastIgmpVersion(val) => {
7916                    if last_off == offset {
7917                        stack.push(("McastIgmpVersion", last_off));
7918                        break;
7919                    }
7920                }
7921                LinkinfoBridgeAttrs::McastMldVersion(val) => {
7922                    if last_off == offset {
7923                        stack.push(("McastMldVersion", last_off));
7924                        break;
7925                    }
7926                }
7927                LinkinfoBridgeAttrs::VlanStatsPerPort(val) => {
7928                    if last_off == offset {
7929                        stack.push(("VlanStatsPerPort", last_off));
7930                        break;
7931                    }
7932                }
7933                LinkinfoBridgeAttrs::MultiBoolopt(val) => {
7934                    if last_off == offset {
7935                        stack.push(("MultiBoolopt", last_off));
7936                        break;
7937                    }
7938                }
7939                LinkinfoBridgeAttrs::McastQuerierState(val) => {
7940                    if last_off == offset {
7941                        stack.push(("McastQuerierState", last_off));
7942                        break;
7943                    }
7944                }
7945                LinkinfoBridgeAttrs::FdbNLearned(val) => {
7946                    if last_off == offset {
7947                        stack.push(("FdbNLearned", last_off));
7948                        break;
7949                    }
7950                }
7951                LinkinfoBridgeAttrs::FdbMaxLearned(val) => {
7952                    if last_off == offset {
7953                        stack.push(("FdbMaxLearned", last_off));
7954                        break;
7955                    }
7956                }
7957                _ => {}
7958            };
7959            last_off = cur + attrs.pos;
7960        }
7961        if !stack.is_empty() {
7962            stack.push(("LinkinfoBridgeAttrs", cur));
7963        }
7964        (stack, None)
7965    }
7966}
7967#[derive(Clone)]
7968pub enum LinkinfoBrportAttrs<'a> {
7969    State(u8),
7970    Priority(u16),
7971    Cost(u32),
7972    Mode(()),
7973    Guard(()),
7974    Protect(()),
7975    FastLeave(()),
7976    Learning(()),
7977    UnicastFlood(()),
7978    Proxyarp(()),
7979    LearningSync(()),
7980    ProxyarpWifi(()),
7981    RootId(PushIflaBridgeId),
7982    BridgeId(PushIflaBridgeId),
7983    DesignatedPort(u16),
7984    DesignatedCost(u16),
7985    Id(u16),
7986    No(u16),
7987    TopologyChangeAck(u8),
7988    ConfigPending(u8),
7989    MessageAgeTimer(u64),
7990    ForwardDelayTimer(u64),
7991    HoldTimer(u64),
7992    Flush(()),
7993    MulticastRouter(u8),
7994    Pad(&'a [u8]),
7995    McastFlood(()),
7996    McastToUcast(()),
7997    VlanTunnel(()),
7998    BcastFlood(()),
7999    GroupFwdMask(u16),
8000    NeighSuppress(()),
8001    Isolated(()),
8002    BackupPort(u32),
8003    MrpRingOpen(()),
8004    MrpInOpen(()),
8005    McastEhtHostsLimit(u32),
8006    McastEhtHostsCnt(u32),
8007    Locked(()),
8008    Mab(()),
8009    McastNGroups(u32),
8010    McastMaxGroups(u32),
8011    NeighVlanSuppress(()),
8012    BackupNhid(u32),
8013}
8014impl<'a> IterableLinkinfoBrportAttrs<'a> {
8015    pub fn get_state(&self) -> Result<u8, ErrorContext> {
8016        let mut iter = self.clone();
8017        iter.pos = 0;
8018        for attr in iter {
8019            if let LinkinfoBrportAttrs::State(val) = attr? {
8020                return Ok(val);
8021            }
8022        }
8023        Err(ErrorContext::new_missing(
8024            "LinkinfoBrportAttrs",
8025            "State",
8026            self.orig_loc,
8027            self.buf.as_ptr() as usize,
8028        ))
8029    }
8030    pub fn get_priority(&self) -> Result<u16, ErrorContext> {
8031        let mut iter = self.clone();
8032        iter.pos = 0;
8033        for attr in iter {
8034            if let LinkinfoBrportAttrs::Priority(val) = attr? {
8035                return Ok(val);
8036            }
8037        }
8038        Err(ErrorContext::new_missing(
8039            "LinkinfoBrportAttrs",
8040            "Priority",
8041            self.orig_loc,
8042            self.buf.as_ptr() as usize,
8043        ))
8044    }
8045    pub fn get_cost(&self) -> Result<u32, ErrorContext> {
8046        let mut iter = self.clone();
8047        iter.pos = 0;
8048        for attr in iter {
8049            if let LinkinfoBrportAttrs::Cost(val) = attr? {
8050                return Ok(val);
8051            }
8052        }
8053        Err(ErrorContext::new_missing(
8054            "LinkinfoBrportAttrs",
8055            "Cost",
8056            self.orig_loc,
8057            self.buf.as_ptr() as usize,
8058        ))
8059    }
8060    pub fn get_mode(&self) -> Result<(), ErrorContext> {
8061        let mut iter = self.clone();
8062        iter.pos = 0;
8063        for attr in iter {
8064            if let LinkinfoBrportAttrs::Mode(val) = attr? {
8065                return Ok(val);
8066            }
8067        }
8068        Err(ErrorContext::new_missing(
8069            "LinkinfoBrportAttrs",
8070            "Mode",
8071            self.orig_loc,
8072            self.buf.as_ptr() as usize,
8073        ))
8074    }
8075    pub fn get_guard(&self) -> Result<(), ErrorContext> {
8076        let mut iter = self.clone();
8077        iter.pos = 0;
8078        for attr in iter {
8079            if let LinkinfoBrportAttrs::Guard(val) = attr? {
8080                return Ok(val);
8081            }
8082        }
8083        Err(ErrorContext::new_missing(
8084            "LinkinfoBrportAttrs",
8085            "Guard",
8086            self.orig_loc,
8087            self.buf.as_ptr() as usize,
8088        ))
8089    }
8090    pub fn get_protect(&self) -> Result<(), ErrorContext> {
8091        let mut iter = self.clone();
8092        iter.pos = 0;
8093        for attr in iter {
8094            if let LinkinfoBrportAttrs::Protect(val) = attr? {
8095                return Ok(val);
8096            }
8097        }
8098        Err(ErrorContext::new_missing(
8099            "LinkinfoBrportAttrs",
8100            "Protect",
8101            self.orig_loc,
8102            self.buf.as_ptr() as usize,
8103        ))
8104    }
8105    pub fn get_fast_leave(&self) -> Result<(), ErrorContext> {
8106        let mut iter = self.clone();
8107        iter.pos = 0;
8108        for attr in iter {
8109            if let LinkinfoBrportAttrs::FastLeave(val) = attr? {
8110                return Ok(val);
8111            }
8112        }
8113        Err(ErrorContext::new_missing(
8114            "LinkinfoBrportAttrs",
8115            "FastLeave",
8116            self.orig_loc,
8117            self.buf.as_ptr() as usize,
8118        ))
8119    }
8120    pub fn get_learning(&self) -> Result<(), ErrorContext> {
8121        let mut iter = self.clone();
8122        iter.pos = 0;
8123        for attr in iter {
8124            if let LinkinfoBrportAttrs::Learning(val) = attr? {
8125                return Ok(val);
8126            }
8127        }
8128        Err(ErrorContext::new_missing(
8129            "LinkinfoBrportAttrs",
8130            "Learning",
8131            self.orig_loc,
8132            self.buf.as_ptr() as usize,
8133        ))
8134    }
8135    pub fn get_unicast_flood(&self) -> Result<(), ErrorContext> {
8136        let mut iter = self.clone();
8137        iter.pos = 0;
8138        for attr in iter {
8139            if let LinkinfoBrportAttrs::UnicastFlood(val) = attr? {
8140                return Ok(val);
8141            }
8142        }
8143        Err(ErrorContext::new_missing(
8144            "LinkinfoBrportAttrs",
8145            "UnicastFlood",
8146            self.orig_loc,
8147            self.buf.as_ptr() as usize,
8148        ))
8149    }
8150    pub fn get_proxyarp(&self) -> Result<(), ErrorContext> {
8151        let mut iter = self.clone();
8152        iter.pos = 0;
8153        for attr in iter {
8154            if let LinkinfoBrportAttrs::Proxyarp(val) = attr? {
8155                return Ok(val);
8156            }
8157        }
8158        Err(ErrorContext::new_missing(
8159            "LinkinfoBrportAttrs",
8160            "Proxyarp",
8161            self.orig_loc,
8162            self.buf.as_ptr() as usize,
8163        ))
8164    }
8165    pub fn get_learning_sync(&self) -> Result<(), ErrorContext> {
8166        let mut iter = self.clone();
8167        iter.pos = 0;
8168        for attr in iter {
8169            if let LinkinfoBrportAttrs::LearningSync(val) = attr? {
8170                return Ok(val);
8171            }
8172        }
8173        Err(ErrorContext::new_missing(
8174            "LinkinfoBrportAttrs",
8175            "LearningSync",
8176            self.orig_loc,
8177            self.buf.as_ptr() as usize,
8178        ))
8179    }
8180    pub fn get_proxyarp_wifi(&self) -> Result<(), ErrorContext> {
8181        let mut iter = self.clone();
8182        iter.pos = 0;
8183        for attr in iter {
8184            if let LinkinfoBrportAttrs::ProxyarpWifi(val) = attr? {
8185                return Ok(val);
8186            }
8187        }
8188        Err(ErrorContext::new_missing(
8189            "LinkinfoBrportAttrs",
8190            "ProxyarpWifi",
8191            self.orig_loc,
8192            self.buf.as_ptr() as usize,
8193        ))
8194    }
8195    pub fn get_root_id(&self) -> Result<PushIflaBridgeId, ErrorContext> {
8196        let mut iter = self.clone();
8197        iter.pos = 0;
8198        for attr in iter {
8199            if let LinkinfoBrportAttrs::RootId(val) = attr? {
8200                return Ok(val);
8201            }
8202        }
8203        Err(ErrorContext::new_missing(
8204            "LinkinfoBrportAttrs",
8205            "RootId",
8206            self.orig_loc,
8207            self.buf.as_ptr() as usize,
8208        ))
8209    }
8210    pub fn get_bridge_id(&self) -> Result<PushIflaBridgeId, ErrorContext> {
8211        let mut iter = self.clone();
8212        iter.pos = 0;
8213        for attr in iter {
8214            if let LinkinfoBrportAttrs::BridgeId(val) = attr? {
8215                return Ok(val);
8216            }
8217        }
8218        Err(ErrorContext::new_missing(
8219            "LinkinfoBrportAttrs",
8220            "BridgeId",
8221            self.orig_loc,
8222            self.buf.as_ptr() as usize,
8223        ))
8224    }
8225    pub fn get_designated_port(&self) -> Result<u16, ErrorContext> {
8226        let mut iter = self.clone();
8227        iter.pos = 0;
8228        for attr in iter {
8229            if let LinkinfoBrportAttrs::DesignatedPort(val) = attr? {
8230                return Ok(val);
8231            }
8232        }
8233        Err(ErrorContext::new_missing(
8234            "LinkinfoBrportAttrs",
8235            "DesignatedPort",
8236            self.orig_loc,
8237            self.buf.as_ptr() as usize,
8238        ))
8239    }
8240    pub fn get_designated_cost(&self) -> Result<u16, ErrorContext> {
8241        let mut iter = self.clone();
8242        iter.pos = 0;
8243        for attr in iter {
8244            if let LinkinfoBrportAttrs::DesignatedCost(val) = attr? {
8245                return Ok(val);
8246            }
8247        }
8248        Err(ErrorContext::new_missing(
8249            "LinkinfoBrportAttrs",
8250            "DesignatedCost",
8251            self.orig_loc,
8252            self.buf.as_ptr() as usize,
8253        ))
8254    }
8255    pub fn get_id(&self) -> Result<u16, ErrorContext> {
8256        let mut iter = self.clone();
8257        iter.pos = 0;
8258        for attr in iter {
8259            if let LinkinfoBrportAttrs::Id(val) = attr? {
8260                return Ok(val);
8261            }
8262        }
8263        Err(ErrorContext::new_missing(
8264            "LinkinfoBrportAttrs",
8265            "Id",
8266            self.orig_loc,
8267            self.buf.as_ptr() as usize,
8268        ))
8269    }
8270    pub fn get_no(&self) -> Result<u16, ErrorContext> {
8271        let mut iter = self.clone();
8272        iter.pos = 0;
8273        for attr in iter {
8274            if let LinkinfoBrportAttrs::No(val) = attr? {
8275                return Ok(val);
8276            }
8277        }
8278        Err(ErrorContext::new_missing(
8279            "LinkinfoBrportAttrs",
8280            "No",
8281            self.orig_loc,
8282            self.buf.as_ptr() as usize,
8283        ))
8284    }
8285    pub fn get_topology_change_ack(&self) -> Result<u8, ErrorContext> {
8286        let mut iter = self.clone();
8287        iter.pos = 0;
8288        for attr in iter {
8289            if let LinkinfoBrportAttrs::TopologyChangeAck(val) = attr? {
8290                return Ok(val);
8291            }
8292        }
8293        Err(ErrorContext::new_missing(
8294            "LinkinfoBrportAttrs",
8295            "TopologyChangeAck",
8296            self.orig_loc,
8297            self.buf.as_ptr() as usize,
8298        ))
8299    }
8300    pub fn get_config_pending(&self) -> Result<u8, ErrorContext> {
8301        let mut iter = self.clone();
8302        iter.pos = 0;
8303        for attr in iter {
8304            if let LinkinfoBrportAttrs::ConfigPending(val) = attr? {
8305                return Ok(val);
8306            }
8307        }
8308        Err(ErrorContext::new_missing(
8309            "LinkinfoBrportAttrs",
8310            "ConfigPending",
8311            self.orig_loc,
8312            self.buf.as_ptr() as usize,
8313        ))
8314    }
8315    pub fn get_message_age_timer(&self) -> Result<u64, ErrorContext> {
8316        let mut iter = self.clone();
8317        iter.pos = 0;
8318        for attr in iter {
8319            if let LinkinfoBrportAttrs::MessageAgeTimer(val) = attr? {
8320                return Ok(val);
8321            }
8322        }
8323        Err(ErrorContext::new_missing(
8324            "LinkinfoBrportAttrs",
8325            "MessageAgeTimer",
8326            self.orig_loc,
8327            self.buf.as_ptr() as usize,
8328        ))
8329    }
8330    pub fn get_forward_delay_timer(&self) -> Result<u64, ErrorContext> {
8331        let mut iter = self.clone();
8332        iter.pos = 0;
8333        for attr in iter {
8334            if let LinkinfoBrportAttrs::ForwardDelayTimer(val) = attr? {
8335                return Ok(val);
8336            }
8337        }
8338        Err(ErrorContext::new_missing(
8339            "LinkinfoBrportAttrs",
8340            "ForwardDelayTimer",
8341            self.orig_loc,
8342            self.buf.as_ptr() as usize,
8343        ))
8344    }
8345    pub fn get_hold_timer(&self) -> Result<u64, ErrorContext> {
8346        let mut iter = self.clone();
8347        iter.pos = 0;
8348        for attr in iter {
8349            if let LinkinfoBrportAttrs::HoldTimer(val) = attr? {
8350                return Ok(val);
8351            }
8352        }
8353        Err(ErrorContext::new_missing(
8354            "LinkinfoBrportAttrs",
8355            "HoldTimer",
8356            self.orig_loc,
8357            self.buf.as_ptr() as usize,
8358        ))
8359    }
8360    pub fn get_flush(&self) -> Result<(), ErrorContext> {
8361        let mut iter = self.clone();
8362        iter.pos = 0;
8363        for attr in iter {
8364            if let LinkinfoBrportAttrs::Flush(val) = attr? {
8365                return Ok(val);
8366            }
8367        }
8368        Err(ErrorContext::new_missing(
8369            "LinkinfoBrportAttrs",
8370            "Flush",
8371            self.orig_loc,
8372            self.buf.as_ptr() as usize,
8373        ))
8374    }
8375    pub fn get_multicast_router(&self) -> Result<u8, ErrorContext> {
8376        let mut iter = self.clone();
8377        iter.pos = 0;
8378        for attr in iter {
8379            if let LinkinfoBrportAttrs::MulticastRouter(val) = attr? {
8380                return Ok(val);
8381            }
8382        }
8383        Err(ErrorContext::new_missing(
8384            "LinkinfoBrportAttrs",
8385            "MulticastRouter",
8386            self.orig_loc,
8387            self.buf.as_ptr() as usize,
8388        ))
8389    }
8390    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
8391        let mut iter = self.clone();
8392        iter.pos = 0;
8393        for attr in iter {
8394            if let LinkinfoBrportAttrs::Pad(val) = attr? {
8395                return Ok(val);
8396            }
8397        }
8398        Err(ErrorContext::new_missing(
8399            "LinkinfoBrportAttrs",
8400            "Pad",
8401            self.orig_loc,
8402            self.buf.as_ptr() as usize,
8403        ))
8404    }
8405    pub fn get_mcast_flood(&self) -> Result<(), ErrorContext> {
8406        let mut iter = self.clone();
8407        iter.pos = 0;
8408        for attr in iter {
8409            if let LinkinfoBrportAttrs::McastFlood(val) = attr? {
8410                return Ok(val);
8411            }
8412        }
8413        Err(ErrorContext::new_missing(
8414            "LinkinfoBrportAttrs",
8415            "McastFlood",
8416            self.orig_loc,
8417            self.buf.as_ptr() as usize,
8418        ))
8419    }
8420    pub fn get_mcast_to_ucast(&self) -> Result<(), ErrorContext> {
8421        let mut iter = self.clone();
8422        iter.pos = 0;
8423        for attr in iter {
8424            if let LinkinfoBrportAttrs::McastToUcast(val) = attr? {
8425                return Ok(val);
8426            }
8427        }
8428        Err(ErrorContext::new_missing(
8429            "LinkinfoBrportAttrs",
8430            "McastToUcast",
8431            self.orig_loc,
8432            self.buf.as_ptr() as usize,
8433        ))
8434    }
8435    pub fn get_vlan_tunnel(&self) -> Result<(), ErrorContext> {
8436        let mut iter = self.clone();
8437        iter.pos = 0;
8438        for attr in iter {
8439            if let LinkinfoBrportAttrs::VlanTunnel(val) = attr? {
8440                return Ok(val);
8441            }
8442        }
8443        Err(ErrorContext::new_missing(
8444            "LinkinfoBrportAttrs",
8445            "VlanTunnel",
8446            self.orig_loc,
8447            self.buf.as_ptr() as usize,
8448        ))
8449    }
8450    pub fn get_bcast_flood(&self) -> Result<(), ErrorContext> {
8451        let mut iter = self.clone();
8452        iter.pos = 0;
8453        for attr in iter {
8454            if let LinkinfoBrportAttrs::BcastFlood(val) = attr? {
8455                return Ok(val);
8456            }
8457        }
8458        Err(ErrorContext::new_missing(
8459            "LinkinfoBrportAttrs",
8460            "BcastFlood",
8461            self.orig_loc,
8462            self.buf.as_ptr() as usize,
8463        ))
8464    }
8465    pub fn get_group_fwd_mask(&self) -> Result<u16, ErrorContext> {
8466        let mut iter = self.clone();
8467        iter.pos = 0;
8468        for attr in iter {
8469            if let LinkinfoBrportAttrs::GroupFwdMask(val) = attr? {
8470                return Ok(val);
8471            }
8472        }
8473        Err(ErrorContext::new_missing(
8474            "LinkinfoBrportAttrs",
8475            "GroupFwdMask",
8476            self.orig_loc,
8477            self.buf.as_ptr() as usize,
8478        ))
8479    }
8480    pub fn get_neigh_suppress(&self) -> Result<(), ErrorContext> {
8481        let mut iter = self.clone();
8482        iter.pos = 0;
8483        for attr in iter {
8484            if let LinkinfoBrportAttrs::NeighSuppress(val) = attr? {
8485                return Ok(val);
8486            }
8487        }
8488        Err(ErrorContext::new_missing(
8489            "LinkinfoBrportAttrs",
8490            "NeighSuppress",
8491            self.orig_loc,
8492            self.buf.as_ptr() as usize,
8493        ))
8494    }
8495    pub fn get_isolated(&self) -> Result<(), ErrorContext> {
8496        let mut iter = self.clone();
8497        iter.pos = 0;
8498        for attr in iter {
8499            if let LinkinfoBrportAttrs::Isolated(val) = attr? {
8500                return Ok(val);
8501            }
8502        }
8503        Err(ErrorContext::new_missing(
8504            "LinkinfoBrportAttrs",
8505            "Isolated",
8506            self.orig_loc,
8507            self.buf.as_ptr() as usize,
8508        ))
8509    }
8510    pub fn get_backup_port(&self) -> Result<u32, ErrorContext> {
8511        let mut iter = self.clone();
8512        iter.pos = 0;
8513        for attr in iter {
8514            if let LinkinfoBrportAttrs::BackupPort(val) = attr? {
8515                return Ok(val);
8516            }
8517        }
8518        Err(ErrorContext::new_missing(
8519            "LinkinfoBrportAttrs",
8520            "BackupPort",
8521            self.orig_loc,
8522            self.buf.as_ptr() as usize,
8523        ))
8524    }
8525    pub fn get_mrp_ring_open(&self) -> Result<(), ErrorContext> {
8526        let mut iter = self.clone();
8527        iter.pos = 0;
8528        for attr in iter {
8529            if let LinkinfoBrportAttrs::MrpRingOpen(val) = attr? {
8530                return Ok(val);
8531            }
8532        }
8533        Err(ErrorContext::new_missing(
8534            "LinkinfoBrportAttrs",
8535            "MrpRingOpen",
8536            self.orig_loc,
8537            self.buf.as_ptr() as usize,
8538        ))
8539    }
8540    pub fn get_mrp_in_open(&self) -> Result<(), ErrorContext> {
8541        let mut iter = self.clone();
8542        iter.pos = 0;
8543        for attr in iter {
8544            if let LinkinfoBrportAttrs::MrpInOpen(val) = attr? {
8545                return Ok(val);
8546            }
8547        }
8548        Err(ErrorContext::new_missing(
8549            "LinkinfoBrportAttrs",
8550            "MrpInOpen",
8551            self.orig_loc,
8552            self.buf.as_ptr() as usize,
8553        ))
8554    }
8555    pub fn get_mcast_eht_hosts_limit(&self) -> Result<u32, ErrorContext> {
8556        let mut iter = self.clone();
8557        iter.pos = 0;
8558        for attr in iter {
8559            if let LinkinfoBrportAttrs::McastEhtHostsLimit(val) = attr? {
8560                return Ok(val);
8561            }
8562        }
8563        Err(ErrorContext::new_missing(
8564            "LinkinfoBrportAttrs",
8565            "McastEhtHostsLimit",
8566            self.orig_loc,
8567            self.buf.as_ptr() as usize,
8568        ))
8569    }
8570    pub fn get_mcast_eht_hosts_cnt(&self) -> Result<u32, ErrorContext> {
8571        let mut iter = self.clone();
8572        iter.pos = 0;
8573        for attr in iter {
8574            if let LinkinfoBrportAttrs::McastEhtHostsCnt(val) = attr? {
8575                return Ok(val);
8576            }
8577        }
8578        Err(ErrorContext::new_missing(
8579            "LinkinfoBrportAttrs",
8580            "McastEhtHostsCnt",
8581            self.orig_loc,
8582            self.buf.as_ptr() as usize,
8583        ))
8584    }
8585    pub fn get_locked(&self) -> Result<(), ErrorContext> {
8586        let mut iter = self.clone();
8587        iter.pos = 0;
8588        for attr in iter {
8589            if let LinkinfoBrportAttrs::Locked(val) = attr? {
8590                return Ok(val);
8591            }
8592        }
8593        Err(ErrorContext::new_missing(
8594            "LinkinfoBrportAttrs",
8595            "Locked",
8596            self.orig_loc,
8597            self.buf.as_ptr() as usize,
8598        ))
8599    }
8600    pub fn get_mab(&self) -> Result<(), ErrorContext> {
8601        let mut iter = self.clone();
8602        iter.pos = 0;
8603        for attr in iter {
8604            if let LinkinfoBrportAttrs::Mab(val) = attr? {
8605                return Ok(val);
8606            }
8607        }
8608        Err(ErrorContext::new_missing(
8609            "LinkinfoBrportAttrs",
8610            "Mab",
8611            self.orig_loc,
8612            self.buf.as_ptr() as usize,
8613        ))
8614    }
8615    pub fn get_mcast_n_groups(&self) -> Result<u32, ErrorContext> {
8616        let mut iter = self.clone();
8617        iter.pos = 0;
8618        for attr in iter {
8619            if let LinkinfoBrportAttrs::McastNGroups(val) = attr? {
8620                return Ok(val);
8621            }
8622        }
8623        Err(ErrorContext::new_missing(
8624            "LinkinfoBrportAttrs",
8625            "McastNGroups",
8626            self.orig_loc,
8627            self.buf.as_ptr() as usize,
8628        ))
8629    }
8630    pub fn get_mcast_max_groups(&self) -> Result<u32, ErrorContext> {
8631        let mut iter = self.clone();
8632        iter.pos = 0;
8633        for attr in iter {
8634            if let LinkinfoBrportAttrs::McastMaxGroups(val) = attr? {
8635                return Ok(val);
8636            }
8637        }
8638        Err(ErrorContext::new_missing(
8639            "LinkinfoBrportAttrs",
8640            "McastMaxGroups",
8641            self.orig_loc,
8642            self.buf.as_ptr() as usize,
8643        ))
8644    }
8645    pub fn get_neigh_vlan_suppress(&self) -> Result<(), ErrorContext> {
8646        let mut iter = self.clone();
8647        iter.pos = 0;
8648        for attr in iter {
8649            if let LinkinfoBrportAttrs::NeighVlanSuppress(val) = attr? {
8650                return Ok(val);
8651            }
8652        }
8653        Err(ErrorContext::new_missing(
8654            "LinkinfoBrportAttrs",
8655            "NeighVlanSuppress",
8656            self.orig_loc,
8657            self.buf.as_ptr() as usize,
8658        ))
8659    }
8660    pub fn get_backup_nhid(&self) -> Result<u32, ErrorContext> {
8661        let mut iter = self.clone();
8662        iter.pos = 0;
8663        for attr in iter {
8664            if let LinkinfoBrportAttrs::BackupNhid(val) = attr? {
8665                return Ok(val);
8666            }
8667        }
8668        Err(ErrorContext::new_missing(
8669            "LinkinfoBrportAttrs",
8670            "BackupNhid",
8671            self.orig_loc,
8672            self.buf.as_ptr() as usize,
8673        ))
8674    }
8675}
8676impl<'a> LinkinfoBrportAttrs<'a> {
8677    pub fn new(buf: &'a [u8]) -> IterableLinkinfoBrportAttrs<'a> {
8678        IterableLinkinfoBrportAttrs::with_loc(buf, buf.as_ptr() as usize)
8679    }
8680    fn attr_from_type(r#type: u16) -> Option<&'static str> {
8681        let res = match r#type {
8682            1u16 => "State",
8683            2u16 => "Priority",
8684            3u16 => "Cost",
8685            4u16 => "Mode",
8686            5u16 => "Guard",
8687            6u16 => "Protect",
8688            7u16 => "FastLeave",
8689            8u16 => "Learning",
8690            9u16 => "UnicastFlood",
8691            10u16 => "Proxyarp",
8692            11u16 => "LearningSync",
8693            12u16 => "ProxyarpWifi",
8694            13u16 => "RootId",
8695            14u16 => "BridgeId",
8696            15u16 => "DesignatedPort",
8697            16u16 => "DesignatedCost",
8698            17u16 => "Id",
8699            18u16 => "No",
8700            19u16 => "TopologyChangeAck",
8701            20u16 => "ConfigPending",
8702            21u16 => "MessageAgeTimer",
8703            22u16 => "ForwardDelayTimer",
8704            23u16 => "HoldTimer",
8705            24u16 => "Flush",
8706            25u16 => "MulticastRouter",
8707            26u16 => "Pad",
8708            27u16 => "McastFlood",
8709            28u16 => "McastToUcast",
8710            29u16 => "VlanTunnel",
8711            30u16 => "BcastFlood",
8712            31u16 => "GroupFwdMask",
8713            32u16 => "NeighSuppress",
8714            33u16 => "Isolated",
8715            34u16 => "BackupPort",
8716            35u16 => "MrpRingOpen",
8717            36u16 => "MrpInOpen",
8718            37u16 => "McastEhtHostsLimit",
8719            38u16 => "McastEhtHostsCnt",
8720            39u16 => "Locked",
8721            40u16 => "Mab",
8722            41u16 => "McastNGroups",
8723            42u16 => "McastMaxGroups",
8724            43u16 => "NeighVlanSuppress",
8725            44u16 => "BackupNhid",
8726            _ => return None,
8727        };
8728        Some(res)
8729    }
8730}
8731#[derive(Clone, Copy, Default)]
8732pub struct IterableLinkinfoBrportAttrs<'a> {
8733    buf: &'a [u8],
8734    pos: usize,
8735    orig_loc: usize,
8736}
8737impl<'a> IterableLinkinfoBrportAttrs<'a> {
8738    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
8739        Self {
8740            buf,
8741            pos: 0,
8742            orig_loc,
8743        }
8744    }
8745    pub fn get_buf(&self) -> &'a [u8] {
8746        self.buf
8747    }
8748}
8749impl<'a> Iterator for IterableLinkinfoBrportAttrs<'a> {
8750    type Item = Result<LinkinfoBrportAttrs<'a>, ErrorContext>;
8751    fn next(&mut self) -> Option<Self::Item> {
8752        if self.buf.len() == self.pos {
8753            return None;
8754        }
8755        let pos = self.pos;
8756        let mut r#type = None;
8757        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
8758            r#type = Some(header.r#type);
8759            let res = match header.r#type {
8760                1u16 => LinkinfoBrportAttrs::State({
8761                    let res = parse_u8(next);
8762                    let Some(val) = res else { break };
8763                    val
8764                }),
8765                2u16 => LinkinfoBrportAttrs::Priority({
8766                    let res = parse_u16(next);
8767                    let Some(val) = res else { break };
8768                    val
8769                }),
8770                3u16 => LinkinfoBrportAttrs::Cost({
8771                    let res = parse_u32(next);
8772                    let Some(val) = res else { break };
8773                    val
8774                }),
8775                4u16 => LinkinfoBrportAttrs::Mode(()),
8776                5u16 => LinkinfoBrportAttrs::Guard(()),
8777                6u16 => LinkinfoBrportAttrs::Protect(()),
8778                7u16 => LinkinfoBrportAttrs::FastLeave(()),
8779                8u16 => LinkinfoBrportAttrs::Learning(()),
8780                9u16 => LinkinfoBrportAttrs::UnicastFlood(()),
8781                10u16 => LinkinfoBrportAttrs::Proxyarp(()),
8782                11u16 => LinkinfoBrportAttrs::LearningSync(()),
8783                12u16 => LinkinfoBrportAttrs::ProxyarpWifi(()),
8784                13u16 => LinkinfoBrportAttrs::RootId({
8785                    let res = PushIflaBridgeId::new_from_slice(next);
8786                    let Some(val) = res else { break };
8787                    val
8788                }),
8789                14u16 => LinkinfoBrportAttrs::BridgeId({
8790                    let res = PushIflaBridgeId::new_from_slice(next);
8791                    let Some(val) = res else { break };
8792                    val
8793                }),
8794                15u16 => LinkinfoBrportAttrs::DesignatedPort({
8795                    let res = parse_u16(next);
8796                    let Some(val) = res else { break };
8797                    val
8798                }),
8799                16u16 => LinkinfoBrportAttrs::DesignatedCost({
8800                    let res = parse_u16(next);
8801                    let Some(val) = res else { break };
8802                    val
8803                }),
8804                17u16 => LinkinfoBrportAttrs::Id({
8805                    let res = parse_u16(next);
8806                    let Some(val) = res else { break };
8807                    val
8808                }),
8809                18u16 => LinkinfoBrportAttrs::No({
8810                    let res = parse_u16(next);
8811                    let Some(val) = res else { break };
8812                    val
8813                }),
8814                19u16 => LinkinfoBrportAttrs::TopologyChangeAck({
8815                    let res = parse_u8(next);
8816                    let Some(val) = res else { break };
8817                    val
8818                }),
8819                20u16 => LinkinfoBrportAttrs::ConfigPending({
8820                    let res = parse_u8(next);
8821                    let Some(val) = res else { break };
8822                    val
8823                }),
8824                21u16 => LinkinfoBrportAttrs::MessageAgeTimer({
8825                    let res = parse_u64(next);
8826                    let Some(val) = res else { break };
8827                    val
8828                }),
8829                22u16 => LinkinfoBrportAttrs::ForwardDelayTimer({
8830                    let res = parse_u64(next);
8831                    let Some(val) = res else { break };
8832                    val
8833                }),
8834                23u16 => LinkinfoBrportAttrs::HoldTimer({
8835                    let res = parse_u64(next);
8836                    let Some(val) = res else { break };
8837                    val
8838                }),
8839                24u16 => LinkinfoBrportAttrs::Flush(()),
8840                25u16 => LinkinfoBrportAttrs::MulticastRouter({
8841                    let res = parse_u8(next);
8842                    let Some(val) = res else { break };
8843                    val
8844                }),
8845                26u16 => LinkinfoBrportAttrs::Pad({
8846                    let res = Some(next);
8847                    let Some(val) = res else { break };
8848                    val
8849                }),
8850                27u16 => LinkinfoBrportAttrs::McastFlood(()),
8851                28u16 => LinkinfoBrportAttrs::McastToUcast(()),
8852                29u16 => LinkinfoBrportAttrs::VlanTunnel(()),
8853                30u16 => LinkinfoBrportAttrs::BcastFlood(()),
8854                31u16 => LinkinfoBrportAttrs::GroupFwdMask({
8855                    let res = parse_u16(next);
8856                    let Some(val) = res else { break };
8857                    val
8858                }),
8859                32u16 => LinkinfoBrportAttrs::NeighSuppress(()),
8860                33u16 => LinkinfoBrportAttrs::Isolated(()),
8861                34u16 => LinkinfoBrportAttrs::BackupPort({
8862                    let res = parse_u32(next);
8863                    let Some(val) = res else { break };
8864                    val
8865                }),
8866                35u16 => LinkinfoBrportAttrs::MrpRingOpen(()),
8867                36u16 => LinkinfoBrportAttrs::MrpInOpen(()),
8868                37u16 => LinkinfoBrportAttrs::McastEhtHostsLimit({
8869                    let res = parse_u32(next);
8870                    let Some(val) = res else { break };
8871                    val
8872                }),
8873                38u16 => LinkinfoBrportAttrs::McastEhtHostsCnt({
8874                    let res = parse_u32(next);
8875                    let Some(val) = res else { break };
8876                    val
8877                }),
8878                39u16 => LinkinfoBrportAttrs::Locked(()),
8879                40u16 => LinkinfoBrportAttrs::Mab(()),
8880                41u16 => LinkinfoBrportAttrs::McastNGroups({
8881                    let res = parse_u32(next);
8882                    let Some(val) = res else { break };
8883                    val
8884                }),
8885                42u16 => LinkinfoBrportAttrs::McastMaxGroups({
8886                    let res = parse_u32(next);
8887                    let Some(val) = res else { break };
8888                    val
8889                }),
8890                43u16 => LinkinfoBrportAttrs::NeighVlanSuppress(()),
8891                44u16 => LinkinfoBrportAttrs::BackupNhid({
8892                    let res = parse_u32(next);
8893                    let Some(val) = res else { break };
8894                    val
8895                }),
8896                n => {
8897                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
8898                        break;
8899                    } else {
8900                        continue;
8901                    }
8902                }
8903            };
8904            return Some(Ok(res));
8905        }
8906        Some(Err(ErrorContext::new(
8907            "LinkinfoBrportAttrs",
8908            r#type.and_then(|t| LinkinfoBrportAttrs::attr_from_type(t)),
8909            self.orig_loc,
8910            self.buf.as_ptr().wrapping_add(pos) as usize,
8911        )))
8912    }
8913}
8914impl<'a> std::fmt::Debug for IterableLinkinfoBrportAttrs<'_> {
8915    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8916        let mut fmt = f.debug_struct("LinkinfoBrportAttrs");
8917        for attr in self.clone() {
8918            let attr = match attr {
8919                Ok(a) => a,
8920                Err(err) => {
8921                    fmt.finish()?;
8922                    f.write_str("Err(")?;
8923                    err.fmt(f)?;
8924                    return f.write_str(")");
8925                }
8926            };
8927            match attr {
8928                LinkinfoBrportAttrs::State(val) => fmt.field("State", &val),
8929                LinkinfoBrportAttrs::Priority(val) => fmt.field("Priority", &val),
8930                LinkinfoBrportAttrs::Cost(val) => fmt.field("Cost", &val),
8931                LinkinfoBrportAttrs::Mode(val) => fmt.field("Mode", &val),
8932                LinkinfoBrportAttrs::Guard(val) => fmt.field("Guard", &val),
8933                LinkinfoBrportAttrs::Protect(val) => fmt.field("Protect", &val),
8934                LinkinfoBrportAttrs::FastLeave(val) => fmt.field("FastLeave", &val),
8935                LinkinfoBrportAttrs::Learning(val) => fmt.field("Learning", &val),
8936                LinkinfoBrportAttrs::UnicastFlood(val) => fmt.field("UnicastFlood", &val),
8937                LinkinfoBrportAttrs::Proxyarp(val) => fmt.field("Proxyarp", &val),
8938                LinkinfoBrportAttrs::LearningSync(val) => fmt.field("LearningSync", &val),
8939                LinkinfoBrportAttrs::ProxyarpWifi(val) => fmt.field("ProxyarpWifi", &val),
8940                LinkinfoBrportAttrs::RootId(val) => fmt.field("RootId", &val),
8941                LinkinfoBrportAttrs::BridgeId(val) => fmt.field("BridgeId", &val),
8942                LinkinfoBrportAttrs::DesignatedPort(val) => fmt.field("DesignatedPort", &val),
8943                LinkinfoBrportAttrs::DesignatedCost(val) => fmt.field("DesignatedCost", &val),
8944                LinkinfoBrportAttrs::Id(val) => fmt.field("Id", &val),
8945                LinkinfoBrportAttrs::No(val) => fmt.field("No", &val),
8946                LinkinfoBrportAttrs::TopologyChangeAck(val) => fmt.field("TopologyChangeAck", &val),
8947                LinkinfoBrportAttrs::ConfigPending(val) => fmt.field("ConfigPending", &val),
8948                LinkinfoBrportAttrs::MessageAgeTimer(val) => fmt.field("MessageAgeTimer", &val),
8949                LinkinfoBrportAttrs::ForwardDelayTimer(val) => fmt.field("ForwardDelayTimer", &val),
8950                LinkinfoBrportAttrs::HoldTimer(val) => fmt.field("HoldTimer", &val),
8951                LinkinfoBrportAttrs::Flush(val) => fmt.field("Flush", &val),
8952                LinkinfoBrportAttrs::MulticastRouter(val) => fmt.field("MulticastRouter", &val),
8953                LinkinfoBrportAttrs::Pad(val) => fmt.field("Pad", &val),
8954                LinkinfoBrportAttrs::McastFlood(val) => fmt.field("McastFlood", &val),
8955                LinkinfoBrportAttrs::McastToUcast(val) => fmt.field("McastToUcast", &val),
8956                LinkinfoBrportAttrs::VlanTunnel(val) => fmt.field("VlanTunnel", &val),
8957                LinkinfoBrportAttrs::BcastFlood(val) => fmt.field("BcastFlood", &val),
8958                LinkinfoBrportAttrs::GroupFwdMask(val) => fmt.field("GroupFwdMask", &val),
8959                LinkinfoBrportAttrs::NeighSuppress(val) => fmt.field("NeighSuppress", &val),
8960                LinkinfoBrportAttrs::Isolated(val) => fmt.field("Isolated", &val),
8961                LinkinfoBrportAttrs::BackupPort(val) => fmt.field("BackupPort", &val),
8962                LinkinfoBrportAttrs::MrpRingOpen(val) => fmt.field("MrpRingOpen", &val),
8963                LinkinfoBrportAttrs::MrpInOpen(val) => fmt.field("MrpInOpen", &val),
8964                LinkinfoBrportAttrs::McastEhtHostsLimit(val) => {
8965                    fmt.field("McastEhtHostsLimit", &val)
8966                }
8967                LinkinfoBrportAttrs::McastEhtHostsCnt(val) => fmt.field("McastEhtHostsCnt", &val),
8968                LinkinfoBrportAttrs::Locked(val) => fmt.field("Locked", &val),
8969                LinkinfoBrportAttrs::Mab(val) => fmt.field("Mab", &val),
8970                LinkinfoBrportAttrs::McastNGroups(val) => fmt.field("McastNGroups", &val),
8971                LinkinfoBrportAttrs::McastMaxGroups(val) => fmt.field("McastMaxGroups", &val),
8972                LinkinfoBrportAttrs::NeighVlanSuppress(val) => fmt.field("NeighVlanSuppress", &val),
8973                LinkinfoBrportAttrs::BackupNhid(val) => fmt.field("BackupNhid", &val),
8974            };
8975        }
8976        fmt.finish()
8977    }
8978}
8979impl IterableLinkinfoBrportAttrs<'_> {
8980    pub fn lookup_attr(
8981        &self,
8982        offset: usize,
8983        missing_type: Option<u16>,
8984    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
8985        let mut stack = Vec::new();
8986        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
8987        if cur == offset {
8988            stack.push(("LinkinfoBrportAttrs", offset));
8989            return (
8990                stack,
8991                missing_type.and_then(|t| LinkinfoBrportAttrs::attr_from_type(t)),
8992            );
8993        }
8994        if cur > offset || cur + self.buf.len() < offset {
8995            return (stack, None);
8996        }
8997        let mut attrs = self.clone();
8998        let mut last_off = cur + attrs.pos;
8999        while let Some(attr) = attrs.next() {
9000            let Ok(attr) = attr else { break };
9001            match attr {
9002                LinkinfoBrportAttrs::State(val) => {
9003                    if last_off == offset {
9004                        stack.push(("State", last_off));
9005                        break;
9006                    }
9007                }
9008                LinkinfoBrportAttrs::Priority(val) => {
9009                    if last_off == offset {
9010                        stack.push(("Priority", last_off));
9011                        break;
9012                    }
9013                }
9014                LinkinfoBrportAttrs::Cost(val) => {
9015                    if last_off == offset {
9016                        stack.push(("Cost", last_off));
9017                        break;
9018                    }
9019                }
9020                LinkinfoBrportAttrs::Mode(val) => {
9021                    if last_off == offset {
9022                        stack.push(("Mode", last_off));
9023                        break;
9024                    }
9025                }
9026                LinkinfoBrportAttrs::Guard(val) => {
9027                    if last_off == offset {
9028                        stack.push(("Guard", last_off));
9029                        break;
9030                    }
9031                }
9032                LinkinfoBrportAttrs::Protect(val) => {
9033                    if last_off == offset {
9034                        stack.push(("Protect", last_off));
9035                        break;
9036                    }
9037                }
9038                LinkinfoBrportAttrs::FastLeave(val) => {
9039                    if last_off == offset {
9040                        stack.push(("FastLeave", last_off));
9041                        break;
9042                    }
9043                }
9044                LinkinfoBrportAttrs::Learning(val) => {
9045                    if last_off == offset {
9046                        stack.push(("Learning", last_off));
9047                        break;
9048                    }
9049                }
9050                LinkinfoBrportAttrs::UnicastFlood(val) => {
9051                    if last_off == offset {
9052                        stack.push(("UnicastFlood", last_off));
9053                        break;
9054                    }
9055                }
9056                LinkinfoBrportAttrs::Proxyarp(val) => {
9057                    if last_off == offset {
9058                        stack.push(("Proxyarp", last_off));
9059                        break;
9060                    }
9061                }
9062                LinkinfoBrportAttrs::LearningSync(val) => {
9063                    if last_off == offset {
9064                        stack.push(("LearningSync", last_off));
9065                        break;
9066                    }
9067                }
9068                LinkinfoBrportAttrs::ProxyarpWifi(val) => {
9069                    if last_off == offset {
9070                        stack.push(("ProxyarpWifi", last_off));
9071                        break;
9072                    }
9073                }
9074                LinkinfoBrportAttrs::RootId(val) => {
9075                    if last_off == offset {
9076                        stack.push(("RootId", last_off));
9077                        break;
9078                    }
9079                }
9080                LinkinfoBrportAttrs::BridgeId(val) => {
9081                    if last_off == offset {
9082                        stack.push(("BridgeId", last_off));
9083                        break;
9084                    }
9085                }
9086                LinkinfoBrportAttrs::DesignatedPort(val) => {
9087                    if last_off == offset {
9088                        stack.push(("DesignatedPort", last_off));
9089                        break;
9090                    }
9091                }
9092                LinkinfoBrportAttrs::DesignatedCost(val) => {
9093                    if last_off == offset {
9094                        stack.push(("DesignatedCost", last_off));
9095                        break;
9096                    }
9097                }
9098                LinkinfoBrportAttrs::Id(val) => {
9099                    if last_off == offset {
9100                        stack.push(("Id", last_off));
9101                        break;
9102                    }
9103                }
9104                LinkinfoBrportAttrs::No(val) => {
9105                    if last_off == offset {
9106                        stack.push(("No", last_off));
9107                        break;
9108                    }
9109                }
9110                LinkinfoBrportAttrs::TopologyChangeAck(val) => {
9111                    if last_off == offset {
9112                        stack.push(("TopologyChangeAck", last_off));
9113                        break;
9114                    }
9115                }
9116                LinkinfoBrportAttrs::ConfigPending(val) => {
9117                    if last_off == offset {
9118                        stack.push(("ConfigPending", last_off));
9119                        break;
9120                    }
9121                }
9122                LinkinfoBrportAttrs::MessageAgeTimer(val) => {
9123                    if last_off == offset {
9124                        stack.push(("MessageAgeTimer", last_off));
9125                        break;
9126                    }
9127                }
9128                LinkinfoBrportAttrs::ForwardDelayTimer(val) => {
9129                    if last_off == offset {
9130                        stack.push(("ForwardDelayTimer", last_off));
9131                        break;
9132                    }
9133                }
9134                LinkinfoBrportAttrs::HoldTimer(val) => {
9135                    if last_off == offset {
9136                        stack.push(("HoldTimer", last_off));
9137                        break;
9138                    }
9139                }
9140                LinkinfoBrportAttrs::Flush(val) => {
9141                    if last_off == offset {
9142                        stack.push(("Flush", last_off));
9143                        break;
9144                    }
9145                }
9146                LinkinfoBrportAttrs::MulticastRouter(val) => {
9147                    if last_off == offset {
9148                        stack.push(("MulticastRouter", last_off));
9149                        break;
9150                    }
9151                }
9152                LinkinfoBrportAttrs::Pad(val) => {
9153                    if last_off == offset {
9154                        stack.push(("Pad", last_off));
9155                        break;
9156                    }
9157                }
9158                LinkinfoBrportAttrs::McastFlood(val) => {
9159                    if last_off == offset {
9160                        stack.push(("McastFlood", last_off));
9161                        break;
9162                    }
9163                }
9164                LinkinfoBrportAttrs::McastToUcast(val) => {
9165                    if last_off == offset {
9166                        stack.push(("McastToUcast", last_off));
9167                        break;
9168                    }
9169                }
9170                LinkinfoBrportAttrs::VlanTunnel(val) => {
9171                    if last_off == offset {
9172                        stack.push(("VlanTunnel", last_off));
9173                        break;
9174                    }
9175                }
9176                LinkinfoBrportAttrs::BcastFlood(val) => {
9177                    if last_off == offset {
9178                        stack.push(("BcastFlood", last_off));
9179                        break;
9180                    }
9181                }
9182                LinkinfoBrportAttrs::GroupFwdMask(val) => {
9183                    if last_off == offset {
9184                        stack.push(("GroupFwdMask", last_off));
9185                        break;
9186                    }
9187                }
9188                LinkinfoBrportAttrs::NeighSuppress(val) => {
9189                    if last_off == offset {
9190                        stack.push(("NeighSuppress", last_off));
9191                        break;
9192                    }
9193                }
9194                LinkinfoBrportAttrs::Isolated(val) => {
9195                    if last_off == offset {
9196                        stack.push(("Isolated", last_off));
9197                        break;
9198                    }
9199                }
9200                LinkinfoBrportAttrs::BackupPort(val) => {
9201                    if last_off == offset {
9202                        stack.push(("BackupPort", last_off));
9203                        break;
9204                    }
9205                }
9206                LinkinfoBrportAttrs::MrpRingOpen(val) => {
9207                    if last_off == offset {
9208                        stack.push(("MrpRingOpen", last_off));
9209                        break;
9210                    }
9211                }
9212                LinkinfoBrportAttrs::MrpInOpen(val) => {
9213                    if last_off == offset {
9214                        stack.push(("MrpInOpen", last_off));
9215                        break;
9216                    }
9217                }
9218                LinkinfoBrportAttrs::McastEhtHostsLimit(val) => {
9219                    if last_off == offset {
9220                        stack.push(("McastEhtHostsLimit", last_off));
9221                        break;
9222                    }
9223                }
9224                LinkinfoBrportAttrs::McastEhtHostsCnt(val) => {
9225                    if last_off == offset {
9226                        stack.push(("McastEhtHostsCnt", last_off));
9227                        break;
9228                    }
9229                }
9230                LinkinfoBrportAttrs::Locked(val) => {
9231                    if last_off == offset {
9232                        stack.push(("Locked", last_off));
9233                        break;
9234                    }
9235                }
9236                LinkinfoBrportAttrs::Mab(val) => {
9237                    if last_off == offset {
9238                        stack.push(("Mab", last_off));
9239                        break;
9240                    }
9241                }
9242                LinkinfoBrportAttrs::McastNGroups(val) => {
9243                    if last_off == offset {
9244                        stack.push(("McastNGroups", last_off));
9245                        break;
9246                    }
9247                }
9248                LinkinfoBrportAttrs::McastMaxGroups(val) => {
9249                    if last_off == offset {
9250                        stack.push(("McastMaxGroups", last_off));
9251                        break;
9252                    }
9253                }
9254                LinkinfoBrportAttrs::NeighVlanSuppress(val) => {
9255                    if last_off == offset {
9256                        stack.push(("NeighVlanSuppress", last_off));
9257                        break;
9258                    }
9259                }
9260                LinkinfoBrportAttrs::BackupNhid(val) => {
9261                    if last_off == offset {
9262                        stack.push(("BackupNhid", last_off));
9263                        break;
9264                    }
9265                }
9266                _ => {}
9267            };
9268            last_off = cur + attrs.pos;
9269        }
9270        if !stack.is_empty() {
9271            stack.push(("LinkinfoBrportAttrs", cur));
9272        }
9273        (stack, None)
9274    }
9275}
9276#[derive(Clone)]
9277pub enum LinkinfoGreAttrs<'a> {
9278    Link(u32),
9279    Iflags(u16),
9280    Oflags(u16),
9281    Ikey(u32),
9282    Okey(u32),
9283    Local(&'a [u8]),
9284    Remote(&'a [u8]),
9285    Ttl(u8),
9286    Tos(u8),
9287    Pmtudisc(u8),
9288    EncapLimit(u8),
9289    Flowinfo(u32),
9290    Flags(u32),
9291    EncapType(u16),
9292    EncapFlags(u16),
9293    EncapSport(u16),
9294    EncapDport(u16),
9295    CollectMetadata(()),
9296    IgnoreDf(u8),
9297    Fwmark(u32),
9298    ErspanIndex(u32),
9299    ErspanVer(u8),
9300    ErspanDir(u8),
9301    ErspanHwid(u16),
9302}
9303impl<'a> IterableLinkinfoGreAttrs<'a> {
9304    pub fn get_link(&self) -> Result<u32, ErrorContext> {
9305        let mut iter = self.clone();
9306        iter.pos = 0;
9307        for attr in iter {
9308            if let LinkinfoGreAttrs::Link(val) = attr? {
9309                return Ok(val);
9310            }
9311        }
9312        Err(ErrorContext::new_missing(
9313            "LinkinfoGreAttrs",
9314            "Link",
9315            self.orig_loc,
9316            self.buf.as_ptr() as usize,
9317        ))
9318    }
9319    pub fn get_iflags(&self) -> Result<u16, ErrorContext> {
9320        let mut iter = self.clone();
9321        iter.pos = 0;
9322        for attr in iter {
9323            if let LinkinfoGreAttrs::Iflags(val) = attr? {
9324                return Ok(val);
9325            }
9326        }
9327        Err(ErrorContext::new_missing(
9328            "LinkinfoGreAttrs",
9329            "Iflags",
9330            self.orig_loc,
9331            self.buf.as_ptr() as usize,
9332        ))
9333    }
9334    pub fn get_oflags(&self) -> Result<u16, ErrorContext> {
9335        let mut iter = self.clone();
9336        iter.pos = 0;
9337        for attr in iter {
9338            if let LinkinfoGreAttrs::Oflags(val) = attr? {
9339                return Ok(val);
9340            }
9341        }
9342        Err(ErrorContext::new_missing(
9343            "LinkinfoGreAttrs",
9344            "Oflags",
9345            self.orig_loc,
9346            self.buf.as_ptr() as usize,
9347        ))
9348    }
9349    pub fn get_ikey(&self) -> Result<u32, ErrorContext> {
9350        let mut iter = self.clone();
9351        iter.pos = 0;
9352        for attr in iter {
9353            if let LinkinfoGreAttrs::Ikey(val) = attr? {
9354                return Ok(val);
9355            }
9356        }
9357        Err(ErrorContext::new_missing(
9358            "LinkinfoGreAttrs",
9359            "Ikey",
9360            self.orig_loc,
9361            self.buf.as_ptr() as usize,
9362        ))
9363    }
9364    pub fn get_okey(&self) -> Result<u32, ErrorContext> {
9365        let mut iter = self.clone();
9366        iter.pos = 0;
9367        for attr in iter {
9368            if let LinkinfoGreAttrs::Okey(val) = attr? {
9369                return Ok(val);
9370            }
9371        }
9372        Err(ErrorContext::new_missing(
9373            "LinkinfoGreAttrs",
9374            "Okey",
9375            self.orig_loc,
9376            self.buf.as_ptr() as usize,
9377        ))
9378    }
9379    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
9380        let mut iter = self.clone();
9381        iter.pos = 0;
9382        for attr in iter {
9383            if let LinkinfoGreAttrs::Local(val) = attr? {
9384                return Ok(val);
9385            }
9386        }
9387        Err(ErrorContext::new_missing(
9388            "LinkinfoGreAttrs",
9389            "Local",
9390            self.orig_loc,
9391            self.buf.as_ptr() as usize,
9392        ))
9393    }
9394    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
9395        let mut iter = self.clone();
9396        iter.pos = 0;
9397        for attr in iter {
9398            if let LinkinfoGreAttrs::Remote(val) = attr? {
9399                return Ok(val);
9400            }
9401        }
9402        Err(ErrorContext::new_missing(
9403            "LinkinfoGreAttrs",
9404            "Remote",
9405            self.orig_loc,
9406            self.buf.as_ptr() as usize,
9407        ))
9408    }
9409    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
9410        let mut iter = self.clone();
9411        iter.pos = 0;
9412        for attr in iter {
9413            if let LinkinfoGreAttrs::Ttl(val) = attr? {
9414                return Ok(val);
9415            }
9416        }
9417        Err(ErrorContext::new_missing(
9418            "LinkinfoGreAttrs",
9419            "Ttl",
9420            self.orig_loc,
9421            self.buf.as_ptr() as usize,
9422        ))
9423    }
9424    pub fn get_tos(&self) -> Result<u8, ErrorContext> {
9425        let mut iter = self.clone();
9426        iter.pos = 0;
9427        for attr in iter {
9428            if let LinkinfoGreAttrs::Tos(val) = attr? {
9429                return Ok(val);
9430            }
9431        }
9432        Err(ErrorContext::new_missing(
9433            "LinkinfoGreAttrs",
9434            "Tos",
9435            self.orig_loc,
9436            self.buf.as_ptr() as usize,
9437        ))
9438    }
9439    pub fn get_pmtudisc(&self) -> Result<u8, ErrorContext> {
9440        let mut iter = self.clone();
9441        iter.pos = 0;
9442        for attr in iter {
9443            if let LinkinfoGreAttrs::Pmtudisc(val) = attr? {
9444                return Ok(val);
9445            }
9446        }
9447        Err(ErrorContext::new_missing(
9448            "LinkinfoGreAttrs",
9449            "Pmtudisc",
9450            self.orig_loc,
9451            self.buf.as_ptr() as usize,
9452        ))
9453    }
9454    pub fn get_encap_limit(&self) -> Result<u8, ErrorContext> {
9455        let mut iter = self.clone();
9456        iter.pos = 0;
9457        for attr in iter {
9458            if let LinkinfoGreAttrs::EncapLimit(val) = attr? {
9459                return Ok(val);
9460            }
9461        }
9462        Err(ErrorContext::new_missing(
9463            "LinkinfoGreAttrs",
9464            "EncapLimit",
9465            self.orig_loc,
9466            self.buf.as_ptr() as usize,
9467        ))
9468    }
9469    pub fn get_flowinfo(&self) -> Result<u32, ErrorContext> {
9470        let mut iter = self.clone();
9471        iter.pos = 0;
9472        for attr in iter {
9473            if let LinkinfoGreAttrs::Flowinfo(val) = attr? {
9474                return Ok(val);
9475            }
9476        }
9477        Err(ErrorContext::new_missing(
9478            "LinkinfoGreAttrs",
9479            "Flowinfo",
9480            self.orig_loc,
9481            self.buf.as_ptr() as usize,
9482        ))
9483    }
9484    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
9485        let mut iter = self.clone();
9486        iter.pos = 0;
9487        for attr in iter {
9488            if let LinkinfoGreAttrs::Flags(val) = attr? {
9489                return Ok(val);
9490            }
9491        }
9492        Err(ErrorContext::new_missing(
9493            "LinkinfoGreAttrs",
9494            "Flags",
9495            self.orig_loc,
9496            self.buf.as_ptr() as usize,
9497        ))
9498    }
9499    pub fn get_encap_type(&self) -> Result<u16, ErrorContext> {
9500        let mut iter = self.clone();
9501        iter.pos = 0;
9502        for attr in iter {
9503            if let LinkinfoGreAttrs::EncapType(val) = attr? {
9504                return Ok(val);
9505            }
9506        }
9507        Err(ErrorContext::new_missing(
9508            "LinkinfoGreAttrs",
9509            "EncapType",
9510            self.orig_loc,
9511            self.buf.as_ptr() as usize,
9512        ))
9513    }
9514    pub fn get_encap_flags(&self) -> Result<u16, ErrorContext> {
9515        let mut iter = self.clone();
9516        iter.pos = 0;
9517        for attr in iter {
9518            if let LinkinfoGreAttrs::EncapFlags(val) = attr? {
9519                return Ok(val);
9520            }
9521        }
9522        Err(ErrorContext::new_missing(
9523            "LinkinfoGreAttrs",
9524            "EncapFlags",
9525            self.orig_loc,
9526            self.buf.as_ptr() as usize,
9527        ))
9528    }
9529    pub fn get_encap_sport(&self) -> Result<u16, ErrorContext> {
9530        let mut iter = self.clone();
9531        iter.pos = 0;
9532        for attr in iter {
9533            if let LinkinfoGreAttrs::EncapSport(val) = attr? {
9534                return Ok(val);
9535            }
9536        }
9537        Err(ErrorContext::new_missing(
9538            "LinkinfoGreAttrs",
9539            "EncapSport",
9540            self.orig_loc,
9541            self.buf.as_ptr() as usize,
9542        ))
9543    }
9544    pub fn get_encap_dport(&self) -> Result<u16, ErrorContext> {
9545        let mut iter = self.clone();
9546        iter.pos = 0;
9547        for attr in iter {
9548            if let LinkinfoGreAttrs::EncapDport(val) = attr? {
9549                return Ok(val);
9550            }
9551        }
9552        Err(ErrorContext::new_missing(
9553            "LinkinfoGreAttrs",
9554            "EncapDport",
9555            self.orig_loc,
9556            self.buf.as_ptr() as usize,
9557        ))
9558    }
9559    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
9560        let mut iter = self.clone();
9561        iter.pos = 0;
9562        for attr in iter {
9563            if let LinkinfoGreAttrs::CollectMetadata(val) = attr? {
9564                return Ok(val);
9565            }
9566        }
9567        Err(ErrorContext::new_missing(
9568            "LinkinfoGreAttrs",
9569            "CollectMetadata",
9570            self.orig_loc,
9571            self.buf.as_ptr() as usize,
9572        ))
9573    }
9574    pub fn get_ignore_df(&self) -> Result<u8, ErrorContext> {
9575        let mut iter = self.clone();
9576        iter.pos = 0;
9577        for attr in iter {
9578            if let LinkinfoGreAttrs::IgnoreDf(val) = attr? {
9579                return Ok(val);
9580            }
9581        }
9582        Err(ErrorContext::new_missing(
9583            "LinkinfoGreAttrs",
9584            "IgnoreDf",
9585            self.orig_loc,
9586            self.buf.as_ptr() as usize,
9587        ))
9588    }
9589    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
9590        let mut iter = self.clone();
9591        iter.pos = 0;
9592        for attr in iter {
9593            if let LinkinfoGreAttrs::Fwmark(val) = attr? {
9594                return Ok(val);
9595            }
9596        }
9597        Err(ErrorContext::new_missing(
9598            "LinkinfoGreAttrs",
9599            "Fwmark",
9600            self.orig_loc,
9601            self.buf.as_ptr() as usize,
9602        ))
9603    }
9604    pub fn get_erspan_index(&self) -> Result<u32, ErrorContext> {
9605        let mut iter = self.clone();
9606        iter.pos = 0;
9607        for attr in iter {
9608            if let LinkinfoGreAttrs::ErspanIndex(val) = attr? {
9609                return Ok(val);
9610            }
9611        }
9612        Err(ErrorContext::new_missing(
9613            "LinkinfoGreAttrs",
9614            "ErspanIndex",
9615            self.orig_loc,
9616            self.buf.as_ptr() as usize,
9617        ))
9618    }
9619    pub fn get_erspan_ver(&self) -> Result<u8, ErrorContext> {
9620        let mut iter = self.clone();
9621        iter.pos = 0;
9622        for attr in iter {
9623            if let LinkinfoGreAttrs::ErspanVer(val) = attr? {
9624                return Ok(val);
9625            }
9626        }
9627        Err(ErrorContext::new_missing(
9628            "LinkinfoGreAttrs",
9629            "ErspanVer",
9630            self.orig_loc,
9631            self.buf.as_ptr() as usize,
9632        ))
9633    }
9634    pub fn get_erspan_dir(&self) -> Result<u8, ErrorContext> {
9635        let mut iter = self.clone();
9636        iter.pos = 0;
9637        for attr in iter {
9638            if let LinkinfoGreAttrs::ErspanDir(val) = attr? {
9639                return Ok(val);
9640            }
9641        }
9642        Err(ErrorContext::new_missing(
9643            "LinkinfoGreAttrs",
9644            "ErspanDir",
9645            self.orig_loc,
9646            self.buf.as_ptr() as usize,
9647        ))
9648    }
9649    pub fn get_erspan_hwid(&self) -> Result<u16, ErrorContext> {
9650        let mut iter = self.clone();
9651        iter.pos = 0;
9652        for attr in iter {
9653            if let LinkinfoGreAttrs::ErspanHwid(val) = attr? {
9654                return Ok(val);
9655            }
9656        }
9657        Err(ErrorContext::new_missing(
9658            "LinkinfoGreAttrs",
9659            "ErspanHwid",
9660            self.orig_loc,
9661            self.buf.as_ptr() as usize,
9662        ))
9663    }
9664}
9665impl<'a> LinkinfoGreAttrs<'a> {
9666    pub fn new(buf: &'a [u8]) -> IterableLinkinfoGreAttrs<'a> {
9667        IterableLinkinfoGreAttrs::with_loc(buf, buf.as_ptr() as usize)
9668    }
9669    fn attr_from_type(r#type: u16) -> Option<&'static str> {
9670        let res = match r#type {
9671            1u16 => "Link",
9672            2u16 => "Iflags",
9673            3u16 => "Oflags",
9674            4u16 => "Ikey",
9675            5u16 => "Okey",
9676            6u16 => "Local",
9677            7u16 => "Remote",
9678            8u16 => "Ttl",
9679            9u16 => "Tos",
9680            10u16 => "Pmtudisc",
9681            11u16 => "EncapLimit",
9682            12u16 => "Flowinfo",
9683            13u16 => "Flags",
9684            14u16 => "EncapType",
9685            15u16 => "EncapFlags",
9686            16u16 => "EncapSport",
9687            17u16 => "EncapDport",
9688            18u16 => "CollectMetadata",
9689            19u16 => "IgnoreDf",
9690            20u16 => "Fwmark",
9691            21u16 => "ErspanIndex",
9692            22u16 => "ErspanVer",
9693            23u16 => "ErspanDir",
9694            24u16 => "ErspanHwid",
9695            _ => return None,
9696        };
9697        Some(res)
9698    }
9699}
9700#[derive(Clone, Copy, Default)]
9701pub struct IterableLinkinfoGreAttrs<'a> {
9702    buf: &'a [u8],
9703    pos: usize,
9704    orig_loc: usize,
9705}
9706impl<'a> IterableLinkinfoGreAttrs<'a> {
9707    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
9708        Self {
9709            buf,
9710            pos: 0,
9711            orig_loc,
9712        }
9713    }
9714    pub fn get_buf(&self) -> &'a [u8] {
9715        self.buf
9716    }
9717}
9718impl<'a> Iterator for IterableLinkinfoGreAttrs<'a> {
9719    type Item = Result<LinkinfoGreAttrs<'a>, ErrorContext>;
9720    fn next(&mut self) -> Option<Self::Item> {
9721        if self.buf.len() == self.pos {
9722            return None;
9723        }
9724        let pos = self.pos;
9725        let mut r#type = None;
9726        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
9727            r#type = Some(header.r#type);
9728            let res = match header.r#type {
9729                1u16 => LinkinfoGreAttrs::Link({
9730                    let res = parse_u32(next);
9731                    let Some(val) = res else { break };
9732                    val
9733                }),
9734                2u16 => LinkinfoGreAttrs::Iflags({
9735                    let res = parse_be_u16(next);
9736                    let Some(val) = res else { break };
9737                    val
9738                }),
9739                3u16 => LinkinfoGreAttrs::Oflags({
9740                    let res = parse_be_u16(next);
9741                    let Some(val) = res else { break };
9742                    val
9743                }),
9744                4u16 => LinkinfoGreAttrs::Ikey({
9745                    let res = parse_be_u32(next);
9746                    let Some(val) = res else { break };
9747                    val
9748                }),
9749                5u16 => LinkinfoGreAttrs::Okey({
9750                    let res = parse_be_u32(next);
9751                    let Some(val) = res else { break };
9752                    val
9753                }),
9754                6u16 => LinkinfoGreAttrs::Local({
9755                    let res = Some(next);
9756                    let Some(val) = res else { break };
9757                    val
9758                }),
9759                7u16 => LinkinfoGreAttrs::Remote({
9760                    let res = Some(next);
9761                    let Some(val) = res else { break };
9762                    val
9763                }),
9764                8u16 => LinkinfoGreAttrs::Ttl({
9765                    let res = parse_u8(next);
9766                    let Some(val) = res else { break };
9767                    val
9768                }),
9769                9u16 => LinkinfoGreAttrs::Tos({
9770                    let res = parse_u8(next);
9771                    let Some(val) = res else { break };
9772                    val
9773                }),
9774                10u16 => LinkinfoGreAttrs::Pmtudisc({
9775                    let res = parse_u8(next);
9776                    let Some(val) = res else { break };
9777                    val
9778                }),
9779                11u16 => LinkinfoGreAttrs::EncapLimit({
9780                    let res = parse_u8(next);
9781                    let Some(val) = res else { break };
9782                    val
9783                }),
9784                12u16 => LinkinfoGreAttrs::Flowinfo({
9785                    let res = parse_be_u32(next);
9786                    let Some(val) = res else { break };
9787                    val
9788                }),
9789                13u16 => LinkinfoGreAttrs::Flags({
9790                    let res = parse_u32(next);
9791                    let Some(val) = res else { break };
9792                    val
9793                }),
9794                14u16 => LinkinfoGreAttrs::EncapType({
9795                    let res = parse_u16(next);
9796                    let Some(val) = res else { break };
9797                    val
9798                }),
9799                15u16 => LinkinfoGreAttrs::EncapFlags({
9800                    let res = parse_u16(next);
9801                    let Some(val) = res else { break };
9802                    val
9803                }),
9804                16u16 => LinkinfoGreAttrs::EncapSport({
9805                    let res = parse_be_u16(next);
9806                    let Some(val) = res else { break };
9807                    val
9808                }),
9809                17u16 => LinkinfoGreAttrs::EncapDport({
9810                    let res = parse_be_u16(next);
9811                    let Some(val) = res else { break };
9812                    val
9813                }),
9814                18u16 => LinkinfoGreAttrs::CollectMetadata(()),
9815                19u16 => LinkinfoGreAttrs::IgnoreDf({
9816                    let res = parse_u8(next);
9817                    let Some(val) = res else { break };
9818                    val
9819                }),
9820                20u16 => LinkinfoGreAttrs::Fwmark({
9821                    let res = parse_u32(next);
9822                    let Some(val) = res else { break };
9823                    val
9824                }),
9825                21u16 => LinkinfoGreAttrs::ErspanIndex({
9826                    let res = parse_u32(next);
9827                    let Some(val) = res else { break };
9828                    val
9829                }),
9830                22u16 => LinkinfoGreAttrs::ErspanVer({
9831                    let res = parse_u8(next);
9832                    let Some(val) = res else { break };
9833                    val
9834                }),
9835                23u16 => LinkinfoGreAttrs::ErspanDir({
9836                    let res = parse_u8(next);
9837                    let Some(val) = res else { break };
9838                    val
9839                }),
9840                24u16 => LinkinfoGreAttrs::ErspanHwid({
9841                    let res = parse_u16(next);
9842                    let Some(val) = res else { break };
9843                    val
9844                }),
9845                n => {
9846                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
9847                        break;
9848                    } else {
9849                        continue;
9850                    }
9851                }
9852            };
9853            return Some(Ok(res));
9854        }
9855        Some(Err(ErrorContext::new(
9856            "LinkinfoGreAttrs",
9857            r#type.and_then(|t| LinkinfoGreAttrs::attr_from_type(t)),
9858            self.orig_loc,
9859            self.buf.as_ptr().wrapping_add(pos) as usize,
9860        )))
9861    }
9862}
9863impl<'a> std::fmt::Debug for IterableLinkinfoGreAttrs<'_> {
9864    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9865        let mut fmt = f.debug_struct("LinkinfoGreAttrs");
9866        for attr in self.clone() {
9867            let attr = match attr {
9868                Ok(a) => a,
9869                Err(err) => {
9870                    fmt.finish()?;
9871                    f.write_str("Err(")?;
9872                    err.fmt(f)?;
9873                    return f.write_str(")");
9874                }
9875            };
9876            match attr {
9877                LinkinfoGreAttrs::Link(val) => fmt.field("Link", &val),
9878                LinkinfoGreAttrs::Iflags(val) => fmt.field("Iflags", &val),
9879                LinkinfoGreAttrs::Oflags(val) => fmt.field("Oflags", &val),
9880                LinkinfoGreAttrs::Ikey(val) => fmt.field("Ikey", &val),
9881                LinkinfoGreAttrs::Okey(val) => fmt.field("Okey", &val),
9882                LinkinfoGreAttrs::Local(val) => fmt.field("Local", &val),
9883                LinkinfoGreAttrs::Remote(val) => fmt.field("Remote", &val),
9884                LinkinfoGreAttrs::Ttl(val) => fmt.field("Ttl", &val),
9885                LinkinfoGreAttrs::Tos(val) => fmt.field("Tos", &val),
9886                LinkinfoGreAttrs::Pmtudisc(val) => fmt.field("Pmtudisc", &val),
9887                LinkinfoGreAttrs::EncapLimit(val) => fmt.field("EncapLimit", &val),
9888                LinkinfoGreAttrs::Flowinfo(val) => fmt.field("Flowinfo", &val),
9889                LinkinfoGreAttrs::Flags(val) => fmt.field("Flags", &val),
9890                LinkinfoGreAttrs::EncapType(val) => fmt.field("EncapType", &val),
9891                LinkinfoGreAttrs::EncapFlags(val) => fmt.field("EncapFlags", &val),
9892                LinkinfoGreAttrs::EncapSport(val) => fmt.field("EncapSport", &val),
9893                LinkinfoGreAttrs::EncapDport(val) => fmt.field("EncapDport", &val),
9894                LinkinfoGreAttrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
9895                LinkinfoGreAttrs::IgnoreDf(val) => fmt.field("IgnoreDf", &val),
9896                LinkinfoGreAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
9897                LinkinfoGreAttrs::ErspanIndex(val) => fmt.field("ErspanIndex", &val),
9898                LinkinfoGreAttrs::ErspanVer(val) => fmt.field("ErspanVer", &val),
9899                LinkinfoGreAttrs::ErspanDir(val) => fmt.field("ErspanDir", &val),
9900                LinkinfoGreAttrs::ErspanHwid(val) => fmt.field("ErspanHwid", &val),
9901            };
9902        }
9903        fmt.finish()
9904    }
9905}
9906impl IterableLinkinfoGreAttrs<'_> {
9907    pub fn lookup_attr(
9908        &self,
9909        offset: usize,
9910        missing_type: Option<u16>,
9911    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
9912        let mut stack = Vec::new();
9913        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
9914        if cur == offset {
9915            stack.push(("LinkinfoGreAttrs", offset));
9916            return (
9917                stack,
9918                missing_type.and_then(|t| LinkinfoGreAttrs::attr_from_type(t)),
9919            );
9920        }
9921        if cur > offset || cur + self.buf.len() < offset {
9922            return (stack, None);
9923        }
9924        let mut attrs = self.clone();
9925        let mut last_off = cur + attrs.pos;
9926        while let Some(attr) = attrs.next() {
9927            let Ok(attr) = attr else { break };
9928            match attr {
9929                LinkinfoGreAttrs::Link(val) => {
9930                    if last_off == offset {
9931                        stack.push(("Link", last_off));
9932                        break;
9933                    }
9934                }
9935                LinkinfoGreAttrs::Iflags(val) => {
9936                    if last_off == offset {
9937                        stack.push(("Iflags", last_off));
9938                        break;
9939                    }
9940                }
9941                LinkinfoGreAttrs::Oflags(val) => {
9942                    if last_off == offset {
9943                        stack.push(("Oflags", last_off));
9944                        break;
9945                    }
9946                }
9947                LinkinfoGreAttrs::Ikey(val) => {
9948                    if last_off == offset {
9949                        stack.push(("Ikey", last_off));
9950                        break;
9951                    }
9952                }
9953                LinkinfoGreAttrs::Okey(val) => {
9954                    if last_off == offset {
9955                        stack.push(("Okey", last_off));
9956                        break;
9957                    }
9958                }
9959                LinkinfoGreAttrs::Local(val) => {
9960                    if last_off == offset {
9961                        stack.push(("Local", last_off));
9962                        break;
9963                    }
9964                }
9965                LinkinfoGreAttrs::Remote(val) => {
9966                    if last_off == offset {
9967                        stack.push(("Remote", last_off));
9968                        break;
9969                    }
9970                }
9971                LinkinfoGreAttrs::Ttl(val) => {
9972                    if last_off == offset {
9973                        stack.push(("Ttl", last_off));
9974                        break;
9975                    }
9976                }
9977                LinkinfoGreAttrs::Tos(val) => {
9978                    if last_off == offset {
9979                        stack.push(("Tos", last_off));
9980                        break;
9981                    }
9982                }
9983                LinkinfoGreAttrs::Pmtudisc(val) => {
9984                    if last_off == offset {
9985                        stack.push(("Pmtudisc", last_off));
9986                        break;
9987                    }
9988                }
9989                LinkinfoGreAttrs::EncapLimit(val) => {
9990                    if last_off == offset {
9991                        stack.push(("EncapLimit", last_off));
9992                        break;
9993                    }
9994                }
9995                LinkinfoGreAttrs::Flowinfo(val) => {
9996                    if last_off == offset {
9997                        stack.push(("Flowinfo", last_off));
9998                        break;
9999                    }
10000                }
10001                LinkinfoGreAttrs::Flags(val) => {
10002                    if last_off == offset {
10003                        stack.push(("Flags", last_off));
10004                        break;
10005                    }
10006                }
10007                LinkinfoGreAttrs::EncapType(val) => {
10008                    if last_off == offset {
10009                        stack.push(("EncapType", last_off));
10010                        break;
10011                    }
10012                }
10013                LinkinfoGreAttrs::EncapFlags(val) => {
10014                    if last_off == offset {
10015                        stack.push(("EncapFlags", last_off));
10016                        break;
10017                    }
10018                }
10019                LinkinfoGreAttrs::EncapSport(val) => {
10020                    if last_off == offset {
10021                        stack.push(("EncapSport", last_off));
10022                        break;
10023                    }
10024                }
10025                LinkinfoGreAttrs::EncapDport(val) => {
10026                    if last_off == offset {
10027                        stack.push(("EncapDport", last_off));
10028                        break;
10029                    }
10030                }
10031                LinkinfoGreAttrs::CollectMetadata(val) => {
10032                    if last_off == offset {
10033                        stack.push(("CollectMetadata", last_off));
10034                        break;
10035                    }
10036                }
10037                LinkinfoGreAttrs::IgnoreDf(val) => {
10038                    if last_off == offset {
10039                        stack.push(("IgnoreDf", last_off));
10040                        break;
10041                    }
10042                }
10043                LinkinfoGreAttrs::Fwmark(val) => {
10044                    if last_off == offset {
10045                        stack.push(("Fwmark", last_off));
10046                        break;
10047                    }
10048                }
10049                LinkinfoGreAttrs::ErspanIndex(val) => {
10050                    if last_off == offset {
10051                        stack.push(("ErspanIndex", last_off));
10052                        break;
10053                    }
10054                }
10055                LinkinfoGreAttrs::ErspanVer(val) => {
10056                    if last_off == offset {
10057                        stack.push(("ErspanVer", last_off));
10058                        break;
10059                    }
10060                }
10061                LinkinfoGreAttrs::ErspanDir(val) => {
10062                    if last_off == offset {
10063                        stack.push(("ErspanDir", last_off));
10064                        break;
10065                    }
10066                }
10067                LinkinfoGreAttrs::ErspanHwid(val) => {
10068                    if last_off == offset {
10069                        stack.push(("ErspanHwid", last_off));
10070                        break;
10071                    }
10072                }
10073                _ => {}
10074            };
10075            last_off = cur + attrs.pos;
10076        }
10077        if !stack.is_empty() {
10078            stack.push(("LinkinfoGreAttrs", cur));
10079        }
10080        (stack, None)
10081    }
10082}
10083#[derive(Clone)]
10084pub enum LinkinfoGre6Attrs<'a> {
10085    Link(u32),
10086    Iflags(u16),
10087    Oflags(u16),
10088    Ikey(u32),
10089    Okey(u32),
10090    Local(&'a [u8]),
10091    Remote(&'a [u8]),
10092    Ttl(u8),
10093    EncapLimit(u8),
10094    Flowinfo(u32),
10095    Flags(u32),
10096    EncapType(u16),
10097    EncapFlags(u16),
10098    EncapSport(u16),
10099    EncapDport(u16),
10100    CollectMetadata(()),
10101    Fwmark(u32),
10102    ErspanIndex(u32),
10103    ErspanVer(u8),
10104    ErspanDir(u8),
10105    ErspanHwid(u16),
10106}
10107impl<'a> IterableLinkinfoGre6Attrs<'a> {
10108    pub fn get_link(&self) -> Result<u32, ErrorContext> {
10109        let mut iter = self.clone();
10110        iter.pos = 0;
10111        for attr in iter {
10112            if let LinkinfoGre6Attrs::Link(val) = attr? {
10113                return Ok(val);
10114            }
10115        }
10116        Err(ErrorContext::new_missing(
10117            "LinkinfoGre6Attrs",
10118            "Link",
10119            self.orig_loc,
10120            self.buf.as_ptr() as usize,
10121        ))
10122    }
10123    pub fn get_iflags(&self) -> Result<u16, ErrorContext> {
10124        let mut iter = self.clone();
10125        iter.pos = 0;
10126        for attr in iter {
10127            if let LinkinfoGre6Attrs::Iflags(val) = attr? {
10128                return Ok(val);
10129            }
10130        }
10131        Err(ErrorContext::new_missing(
10132            "LinkinfoGre6Attrs",
10133            "Iflags",
10134            self.orig_loc,
10135            self.buf.as_ptr() as usize,
10136        ))
10137    }
10138    pub fn get_oflags(&self) -> Result<u16, ErrorContext> {
10139        let mut iter = self.clone();
10140        iter.pos = 0;
10141        for attr in iter {
10142            if let LinkinfoGre6Attrs::Oflags(val) = attr? {
10143                return Ok(val);
10144            }
10145        }
10146        Err(ErrorContext::new_missing(
10147            "LinkinfoGre6Attrs",
10148            "Oflags",
10149            self.orig_loc,
10150            self.buf.as_ptr() as usize,
10151        ))
10152    }
10153    pub fn get_ikey(&self) -> Result<u32, ErrorContext> {
10154        let mut iter = self.clone();
10155        iter.pos = 0;
10156        for attr in iter {
10157            if let LinkinfoGre6Attrs::Ikey(val) = attr? {
10158                return Ok(val);
10159            }
10160        }
10161        Err(ErrorContext::new_missing(
10162            "LinkinfoGre6Attrs",
10163            "Ikey",
10164            self.orig_loc,
10165            self.buf.as_ptr() as usize,
10166        ))
10167    }
10168    pub fn get_okey(&self) -> Result<u32, ErrorContext> {
10169        let mut iter = self.clone();
10170        iter.pos = 0;
10171        for attr in iter {
10172            if let LinkinfoGre6Attrs::Okey(val) = attr? {
10173                return Ok(val);
10174            }
10175        }
10176        Err(ErrorContext::new_missing(
10177            "LinkinfoGre6Attrs",
10178            "Okey",
10179            self.orig_loc,
10180            self.buf.as_ptr() as usize,
10181        ))
10182    }
10183    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
10184        let mut iter = self.clone();
10185        iter.pos = 0;
10186        for attr in iter {
10187            if let LinkinfoGre6Attrs::Local(val) = attr? {
10188                return Ok(val);
10189            }
10190        }
10191        Err(ErrorContext::new_missing(
10192            "LinkinfoGre6Attrs",
10193            "Local",
10194            self.orig_loc,
10195            self.buf.as_ptr() as usize,
10196        ))
10197    }
10198    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
10199        let mut iter = self.clone();
10200        iter.pos = 0;
10201        for attr in iter {
10202            if let LinkinfoGre6Attrs::Remote(val) = attr? {
10203                return Ok(val);
10204            }
10205        }
10206        Err(ErrorContext::new_missing(
10207            "LinkinfoGre6Attrs",
10208            "Remote",
10209            self.orig_loc,
10210            self.buf.as_ptr() as usize,
10211        ))
10212    }
10213    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
10214        let mut iter = self.clone();
10215        iter.pos = 0;
10216        for attr in iter {
10217            if let LinkinfoGre6Attrs::Ttl(val) = attr? {
10218                return Ok(val);
10219            }
10220        }
10221        Err(ErrorContext::new_missing(
10222            "LinkinfoGre6Attrs",
10223            "Ttl",
10224            self.orig_loc,
10225            self.buf.as_ptr() as usize,
10226        ))
10227    }
10228    pub fn get_encap_limit(&self) -> Result<u8, ErrorContext> {
10229        let mut iter = self.clone();
10230        iter.pos = 0;
10231        for attr in iter {
10232            if let LinkinfoGre6Attrs::EncapLimit(val) = attr? {
10233                return Ok(val);
10234            }
10235        }
10236        Err(ErrorContext::new_missing(
10237            "LinkinfoGre6Attrs",
10238            "EncapLimit",
10239            self.orig_loc,
10240            self.buf.as_ptr() as usize,
10241        ))
10242    }
10243    pub fn get_flowinfo(&self) -> Result<u32, ErrorContext> {
10244        let mut iter = self.clone();
10245        iter.pos = 0;
10246        for attr in iter {
10247            if let LinkinfoGre6Attrs::Flowinfo(val) = attr? {
10248                return Ok(val);
10249            }
10250        }
10251        Err(ErrorContext::new_missing(
10252            "LinkinfoGre6Attrs",
10253            "Flowinfo",
10254            self.orig_loc,
10255            self.buf.as_ptr() as usize,
10256        ))
10257    }
10258    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
10259        let mut iter = self.clone();
10260        iter.pos = 0;
10261        for attr in iter {
10262            if let LinkinfoGre6Attrs::Flags(val) = attr? {
10263                return Ok(val);
10264            }
10265        }
10266        Err(ErrorContext::new_missing(
10267            "LinkinfoGre6Attrs",
10268            "Flags",
10269            self.orig_loc,
10270            self.buf.as_ptr() as usize,
10271        ))
10272    }
10273    pub fn get_encap_type(&self) -> Result<u16, ErrorContext> {
10274        let mut iter = self.clone();
10275        iter.pos = 0;
10276        for attr in iter {
10277            if let LinkinfoGre6Attrs::EncapType(val) = attr? {
10278                return Ok(val);
10279            }
10280        }
10281        Err(ErrorContext::new_missing(
10282            "LinkinfoGre6Attrs",
10283            "EncapType",
10284            self.orig_loc,
10285            self.buf.as_ptr() as usize,
10286        ))
10287    }
10288    pub fn get_encap_flags(&self) -> Result<u16, ErrorContext> {
10289        let mut iter = self.clone();
10290        iter.pos = 0;
10291        for attr in iter {
10292            if let LinkinfoGre6Attrs::EncapFlags(val) = attr? {
10293                return Ok(val);
10294            }
10295        }
10296        Err(ErrorContext::new_missing(
10297            "LinkinfoGre6Attrs",
10298            "EncapFlags",
10299            self.orig_loc,
10300            self.buf.as_ptr() as usize,
10301        ))
10302    }
10303    pub fn get_encap_sport(&self) -> Result<u16, ErrorContext> {
10304        let mut iter = self.clone();
10305        iter.pos = 0;
10306        for attr in iter {
10307            if let LinkinfoGre6Attrs::EncapSport(val) = attr? {
10308                return Ok(val);
10309            }
10310        }
10311        Err(ErrorContext::new_missing(
10312            "LinkinfoGre6Attrs",
10313            "EncapSport",
10314            self.orig_loc,
10315            self.buf.as_ptr() as usize,
10316        ))
10317    }
10318    pub fn get_encap_dport(&self) -> Result<u16, ErrorContext> {
10319        let mut iter = self.clone();
10320        iter.pos = 0;
10321        for attr in iter {
10322            if let LinkinfoGre6Attrs::EncapDport(val) = attr? {
10323                return Ok(val);
10324            }
10325        }
10326        Err(ErrorContext::new_missing(
10327            "LinkinfoGre6Attrs",
10328            "EncapDport",
10329            self.orig_loc,
10330            self.buf.as_ptr() as usize,
10331        ))
10332    }
10333    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
10334        let mut iter = self.clone();
10335        iter.pos = 0;
10336        for attr in iter {
10337            if let LinkinfoGre6Attrs::CollectMetadata(val) = attr? {
10338                return Ok(val);
10339            }
10340        }
10341        Err(ErrorContext::new_missing(
10342            "LinkinfoGre6Attrs",
10343            "CollectMetadata",
10344            self.orig_loc,
10345            self.buf.as_ptr() as usize,
10346        ))
10347    }
10348    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
10349        let mut iter = self.clone();
10350        iter.pos = 0;
10351        for attr in iter {
10352            if let LinkinfoGre6Attrs::Fwmark(val) = attr? {
10353                return Ok(val);
10354            }
10355        }
10356        Err(ErrorContext::new_missing(
10357            "LinkinfoGre6Attrs",
10358            "Fwmark",
10359            self.orig_loc,
10360            self.buf.as_ptr() as usize,
10361        ))
10362    }
10363    pub fn get_erspan_index(&self) -> Result<u32, ErrorContext> {
10364        let mut iter = self.clone();
10365        iter.pos = 0;
10366        for attr in iter {
10367            if let LinkinfoGre6Attrs::ErspanIndex(val) = attr? {
10368                return Ok(val);
10369            }
10370        }
10371        Err(ErrorContext::new_missing(
10372            "LinkinfoGre6Attrs",
10373            "ErspanIndex",
10374            self.orig_loc,
10375            self.buf.as_ptr() as usize,
10376        ))
10377    }
10378    pub fn get_erspan_ver(&self) -> Result<u8, ErrorContext> {
10379        let mut iter = self.clone();
10380        iter.pos = 0;
10381        for attr in iter {
10382            if let LinkinfoGre6Attrs::ErspanVer(val) = attr? {
10383                return Ok(val);
10384            }
10385        }
10386        Err(ErrorContext::new_missing(
10387            "LinkinfoGre6Attrs",
10388            "ErspanVer",
10389            self.orig_loc,
10390            self.buf.as_ptr() as usize,
10391        ))
10392    }
10393    pub fn get_erspan_dir(&self) -> Result<u8, ErrorContext> {
10394        let mut iter = self.clone();
10395        iter.pos = 0;
10396        for attr in iter {
10397            if let LinkinfoGre6Attrs::ErspanDir(val) = attr? {
10398                return Ok(val);
10399            }
10400        }
10401        Err(ErrorContext::new_missing(
10402            "LinkinfoGre6Attrs",
10403            "ErspanDir",
10404            self.orig_loc,
10405            self.buf.as_ptr() as usize,
10406        ))
10407    }
10408    pub fn get_erspan_hwid(&self) -> Result<u16, ErrorContext> {
10409        let mut iter = self.clone();
10410        iter.pos = 0;
10411        for attr in iter {
10412            if let LinkinfoGre6Attrs::ErspanHwid(val) = attr? {
10413                return Ok(val);
10414            }
10415        }
10416        Err(ErrorContext::new_missing(
10417            "LinkinfoGre6Attrs",
10418            "ErspanHwid",
10419            self.orig_loc,
10420            self.buf.as_ptr() as usize,
10421        ))
10422    }
10423}
10424impl<'a> LinkinfoGre6Attrs<'a> {
10425    pub fn new(buf: &'a [u8]) -> IterableLinkinfoGre6Attrs<'a> {
10426        IterableLinkinfoGre6Attrs::with_loc(buf, buf.as_ptr() as usize)
10427    }
10428    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10429        let res = match r#type {
10430            1u16 => "Link",
10431            2u16 => "Iflags",
10432            3u16 => "Oflags",
10433            4u16 => "Ikey",
10434            5u16 => "Okey",
10435            6u16 => "Local",
10436            7u16 => "Remote",
10437            8u16 => "Ttl",
10438            9u16 => "EncapLimit",
10439            10u16 => "Flowinfo",
10440            11u16 => "Flags",
10441            12u16 => "EncapType",
10442            13u16 => "EncapFlags",
10443            14u16 => "EncapSport",
10444            15u16 => "EncapDport",
10445            16u16 => "CollectMetadata",
10446            17u16 => "Fwmark",
10447            18u16 => "ErspanIndex",
10448            19u16 => "ErspanVer",
10449            20u16 => "ErspanDir",
10450            21u16 => "ErspanHwid",
10451            _ => return None,
10452        };
10453        Some(res)
10454    }
10455}
10456#[derive(Clone, Copy, Default)]
10457pub struct IterableLinkinfoGre6Attrs<'a> {
10458    buf: &'a [u8],
10459    pos: usize,
10460    orig_loc: usize,
10461}
10462impl<'a> IterableLinkinfoGre6Attrs<'a> {
10463    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10464        Self {
10465            buf,
10466            pos: 0,
10467            orig_loc,
10468        }
10469    }
10470    pub fn get_buf(&self) -> &'a [u8] {
10471        self.buf
10472    }
10473}
10474impl<'a> Iterator for IterableLinkinfoGre6Attrs<'a> {
10475    type Item = Result<LinkinfoGre6Attrs<'a>, ErrorContext>;
10476    fn next(&mut self) -> Option<Self::Item> {
10477        if self.buf.len() == self.pos {
10478            return None;
10479        }
10480        let pos = self.pos;
10481        let mut r#type = None;
10482        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
10483            r#type = Some(header.r#type);
10484            let res = match header.r#type {
10485                1u16 => LinkinfoGre6Attrs::Link({
10486                    let res = parse_u32(next);
10487                    let Some(val) = res else { break };
10488                    val
10489                }),
10490                2u16 => LinkinfoGre6Attrs::Iflags({
10491                    let res = parse_be_u16(next);
10492                    let Some(val) = res else { break };
10493                    val
10494                }),
10495                3u16 => LinkinfoGre6Attrs::Oflags({
10496                    let res = parse_be_u16(next);
10497                    let Some(val) = res else { break };
10498                    val
10499                }),
10500                4u16 => LinkinfoGre6Attrs::Ikey({
10501                    let res = parse_be_u32(next);
10502                    let Some(val) = res else { break };
10503                    val
10504                }),
10505                5u16 => LinkinfoGre6Attrs::Okey({
10506                    let res = parse_be_u32(next);
10507                    let Some(val) = res else { break };
10508                    val
10509                }),
10510                6u16 => LinkinfoGre6Attrs::Local({
10511                    let res = Some(next);
10512                    let Some(val) = res else { break };
10513                    val
10514                }),
10515                7u16 => LinkinfoGre6Attrs::Remote({
10516                    let res = Some(next);
10517                    let Some(val) = res else { break };
10518                    val
10519                }),
10520                8u16 => LinkinfoGre6Attrs::Ttl({
10521                    let res = parse_u8(next);
10522                    let Some(val) = res else { break };
10523                    val
10524                }),
10525                9u16 => LinkinfoGre6Attrs::EncapLimit({
10526                    let res = parse_u8(next);
10527                    let Some(val) = res else { break };
10528                    val
10529                }),
10530                10u16 => LinkinfoGre6Attrs::Flowinfo({
10531                    let res = parse_be_u32(next);
10532                    let Some(val) = res else { break };
10533                    val
10534                }),
10535                11u16 => LinkinfoGre6Attrs::Flags({
10536                    let res = parse_u32(next);
10537                    let Some(val) = res else { break };
10538                    val
10539                }),
10540                12u16 => LinkinfoGre6Attrs::EncapType({
10541                    let res = parse_u16(next);
10542                    let Some(val) = res else { break };
10543                    val
10544                }),
10545                13u16 => LinkinfoGre6Attrs::EncapFlags({
10546                    let res = parse_u16(next);
10547                    let Some(val) = res else { break };
10548                    val
10549                }),
10550                14u16 => LinkinfoGre6Attrs::EncapSport({
10551                    let res = parse_be_u16(next);
10552                    let Some(val) = res else { break };
10553                    val
10554                }),
10555                15u16 => LinkinfoGre6Attrs::EncapDport({
10556                    let res = parse_be_u16(next);
10557                    let Some(val) = res else { break };
10558                    val
10559                }),
10560                16u16 => LinkinfoGre6Attrs::CollectMetadata(()),
10561                17u16 => LinkinfoGre6Attrs::Fwmark({
10562                    let res = parse_u32(next);
10563                    let Some(val) = res else { break };
10564                    val
10565                }),
10566                18u16 => LinkinfoGre6Attrs::ErspanIndex({
10567                    let res = parse_u32(next);
10568                    let Some(val) = res else { break };
10569                    val
10570                }),
10571                19u16 => LinkinfoGre6Attrs::ErspanVer({
10572                    let res = parse_u8(next);
10573                    let Some(val) = res else { break };
10574                    val
10575                }),
10576                20u16 => LinkinfoGre6Attrs::ErspanDir({
10577                    let res = parse_u8(next);
10578                    let Some(val) = res else { break };
10579                    val
10580                }),
10581                21u16 => LinkinfoGre6Attrs::ErspanHwid({
10582                    let res = parse_u16(next);
10583                    let Some(val) = res else { break };
10584                    val
10585                }),
10586                n => {
10587                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
10588                        break;
10589                    } else {
10590                        continue;
10591                    }
10592                }
10593            };
10594            return Some(Ok(res));
10595        }
10596        Some(Err(ErrorContext::new(
10597            "LinkinfoGre6Attrs",
10598            r#type.and_then(|t| LinkinfoGre6Attrs::attr_from_type(t)),
10599            self.orig_loc,
10600            self.buf.as_ptr().wrapping_add(pos) as usize,
10601        )))
10602    }
10603}
10604impl<'a> std::fmt::Debug for IterableLinkinfoGre6Attrs<'_> {
10605    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10606        let mut fmt = f.debug_struct("LinkinfoGre6Attrs");
10607        for attr in self.clone() {
10608            let attr = match attr {
10609                Ok(a) => a,
10610                Err(err) => {
10611                    fmt.finish()?;
10612                    f.write_str("Err(")?;
10613                    err.fmt(f)?;
10614                    return f.write_str(")");
10615                }
10616            };
10617            match attr {
10618                LinkinfoGre6Attrs::Link(val) => fmt.field("Link", &val),
10619                LinkinfoGre6Attrs::Iflags(val) => fmt.field("Iflags", &val),
10620                LinkinfoGre6Attrs::Oflags(val) => fmt.field("Oflags", &val),
10621                LinkinfoGre6Attrs::Ikey(val) => fmt.field("Ikey", &val),
10622                LinkinfoGre6Attrs::Okey(val) => fmt.field("Okey", &val),
10623                LinkinfoGre6Attrs::Local(val) => fmt.field("Local", &val),
10624                LinkinfoGre6Attrs::Remote(val) => fmt.field("Remote", &val),
10625                LinkinfoGre6Attrs::Ttl(val) => fmt.field("Ttl", &val),
10626                LinkinfoGre6Attrs::EncapLimit(val) => fmt.field("EncapLimit", &val),
10627                LinkinfoGre6Attrs::Flowinfo(val) => fmt.field("Flowinfo", &val),
10628                LinkinfoGre6Attrs::Flags(val) => fmt.field("Flags", &val),
10629                LinkinfoGre6Attrs::EncapType(val) => fmt.field("EncapType", &val),
10630                LinkinfoGre6Attrs::EncapFlags(val) => fmt.field("EncapFlags", &val),
10631                LinkinfoGre6Attrs::EncapSport(val) => fmt.field("EncapSport", &val),
10632                LinkinfoGre6Attrs::EncapDport(val) => fmt.field("EncapDport", &val),
10633                LinkinfoGre6Attrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
10634                LinkinfoGre6Attrs::Fwmark(val) => fmt.field("Fwmark", &val),
10635                LinkinfoGre6Attrs::ErspanIndex(val) => fmt.field("ErspanIndex", &val),
10636                LinkinfoGre6Attrs::ErspanVer(val) => fmt.field("ErspanVer", &val),
10637                LinkinfoGre6Attrs::ErspanDir(val) => fmt.field("ErspanDir", &val),
10638                LinkinfoGre6Attrs::ErspanHwid(val) => fmt.field("ErspanHwid", &val),
10639            };
10640        }
10641        fmt.finish()
10642    }
10643}
10644impl IterableLinkinfoGre6Attrs<'_> {
10645    pub fn lookup_attr(
10646        &self,
10647        offset: usize,
10648        missing_type: Option<u16>,
10649    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
10650        let mut stack = Vec::new();
10651        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
10652        if cur == offset {
10653            stack.push(("LinkinfoGre6Attrs", offset));
10654            return (
10655                stack,
10656                missing_type.and_then(|t| LinkinfoGre6Attrs::attr_from_type(t)),
10657            );
10658        }
10659        if cur > offset || cur + self.buf.len() < offset {
10660            return (stack, None);
10661        }
10662        let mut attrs = self.clone();
10663        let mut last_off = cur + attrs.pos;
10664        while let Some(attr) = attrs.next() {
10665            let Ok(attr) = attr else { break };
10666            match attr {
10667                LinkinfoGre6Attrs::Link(val) => {
10668                    if last_off == offset {
10669                        stack.push(("Link", last_off));
10670                        break;
10671                    }
10672                }
10673                LinkinfoGre6Attrs::Iflags(val) => {
10674                    if last_off == offset {
10675                        stack.push(("Iflags", last_off));
10676                        break;
10677                    }
10678                }
10679                LinkinfoGre6Attrs::Oflags(val) => {
10680                    if last_off == offset {
10681                        stack.push(("Oflags", last_off));
10682                        break;
10683                    }
10684                }
10685                LinkinfoGre6Attrs::Ikey(val) => {
10686                    if last_off == offset {
10687                        stack.push(("Ikey", last_off));
10688                        break;
10689                    }
10690                }
10691                LinkinfoGre6Attrs::Okey(val) => {
10692                    if last_off == offset {
10693                        stack.push(("Okey", last_off));
10694                        break;
10695                    }
10696                }
10697                LinkinfoGre6Attrs::Local(val) => {
10698                    if last_off == offset {
10699                        stack.push(("Local", last_off));
10700                        break;
10701                    }
10702                }
10703                LinkinfoGre6Attrs::Remote(val) => {
10704                    if last_off == offset {
10705                        stack.push(("Remote", last_off));
10706                        break;
10707                    }
10708                }
10709                LinkinfoGre6Attrs::Ttl(val) => {
10710                    if last_off == offset {
10711                        stack.push(("Ttl", last_off));
10712                        break;
10713                    }
10714                }
10715                LinkinfoGre6Attrs::EncapLimit(val) => {
10716                    if last_off == offset {
10717                        stack.push(("EncapLimit", last_off));
10718                        break;
10719                    }
10720                }
10721                LinkinfoGre6Attrs::Flowinfo(val) => {
10722                    if last_off == offset {
10723                        stack.push(("Flowinfo", last_off));
10724                        break;
10725                    }
10726                }
10727                LinkinfoGre6Attrs::Flags(val) => {
10728                    if last_off == offset {
10729                        stack.push(("Flags", last_off));
10730                        break;
10731                    }
10732                }
10733                LinkinfoGre6Attrs::EncapType(val) => {
10734                    if last_off == offset {
10735                        stack.push(("EncapType", last_off));
10736                        break;
10737                    }
10738                }
10739                LinkinfoGre6Attrs::EncapFlags(val) => {
10740                    if last_off == offset {
10741                        stack.push(("EncapFlags", last_off));
10742                        break;
10743                    }
10744                }
10745                LinkinfoGre6Attrs::EncapSport(val) => {
10746                    if last_off == offset {
10747                        stack.push(("EncapSport", last_off));
10748                        break;
10749                    }
10750                }
10751                LinkinfoGre6Attrs::EncapDport(val) => {
10752                    if last_off == offset {
10753                        stack.push(("EncapDport", last_off));
10754                        break;
10755                    }
10756                }
10757                LinkinfoGre6Attrs::CollectMetadata(val) => {
10758                    if last_off == offset {
10759                        stack.push(("CollectMetadata", last_off));
10760                        break;
10761                    }
10762                }
10763                LinkinfoGre6Attrs::Fwmark(val) => {
10764                    if last_off == offset {
10765                        stack.push(("Fwmark", last_off));
10766                        break;
10767                    }
10768                }
10769                LinkinfoGre6Attrs::ErspanIndex(val) => {
10770                    if last_off == offset {
10771                        stack.push(("ErspanIndex", last_off));
10772                        break;
10773                    }
10774                }
10775                LinkinfoGre6Attrs::ErspanVer(val) => {
10776                    if last_off == offset {
10777                        stack.push(("ErspanVer", last_off));
10778                        break;
10779                    }
10780                }
10781                LinkinfoGre6Attrs::ErspanDir(val) => {
10782                    if last_off == offset {
10783                        stack.push(("ErspanDir", last_off));
10784                        break;
10785                    }
10786                }
10787                LinkinfoGre6Attrs::ErspanHwid(val) => {
10788                    if last_off == offset {
10789                        stack.push(("ErspanHwid", last_off));
10790                        break;
10791                    }
10792                }
10793                _ => {}
10794            };
10795            last_off = cur + attrs.pos;
10796        }
10797        if !stack.is_empty() {
10798            stack.push(("LinkinfoGre6Attrs", cur));
10799        }
10800        (stack, None)
10801    }
10802}
10803#[derive(Clone)]
10804pub enum LinkinfoVtiAttrs<'a> {
10805    Link(u32),
10806    Ikey(u32),
10807    Okey(u32),
10808    Local(&'a [u8]),
10809    Remote(&'a [u8]),
10810    Fwmark(u32),
10811}
10812impl<'a> IterableLinkinfoVtiAttrs<'a> {
10813    pub fn get_link(&self) -> Result<u32, ErrorContext> {
10814        let mut iter = self.clone();
10815        iter.pos = 0;
10816        for attr in iter {
10817            if let LinkinfoVtiAttrs::Link(val) = attr? {
10818                return Ok(val);
10819            }
10820        }
10821        Err(ErrorContext::new_missing(
10822            "LinkinfoVtiAttrs",
10823            "Link",
10824            self.orig_loc,
10825            self.buf.as_ptr() as usize,
10826        ))
10827    }
10828    pub fn get_ikey(&self) -> Result<u32, ErrorContext> {
10829        let mut iter = self.clone();
10830        iter.pos = 0;
10831        for attr in iter {
10832            if let LinkinfoVtiAttrs::Ikey(val) = attr? {
10833                return Ok(val);
10834            }
10835        }
10836        Err(ErrorContext::new_missing(
10837            "LinkinfoVtiAttrs",
10838            "Ikey",
10839            self.orig_loc,
10840            self.buf.as_ptr() as usize,
10841        ))
10842    }
10843    pub fn get_okey(&self) -> Result<u32, ErrorContext> {
10844        let mut iter = self.clone();
10845        iter.pos = 0;
10846        for attr in iter {
10847            if let LinkinfoVtiAttrs::Okey(val) = attr? {
10848                return Ok(val);
10849            }
10850        }
10851        Err(ErrorContext::new_missing(
10852            "LinkinfoVtiAttrs",
10853            "Okey",
10854            self.orig_loc,
10855            self.buf.as_ptr() as usize,
10856        ))
10857    }
10858    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
10859        let mut iter = self.clone();
10860        iter.pos = 0;
10861        for attr in iter {
10862            if let LinkinfoVtiAttrs::Local(val) = attr? {
10863                return Ok(val);
10864            }
10865        }
10866        Err(ErrorContext::new_missing(
10867            "LinkinfoVtiAttrs",
10868            "Local",
10869            self.orig_loc,
10870            self.buf.as_ptr() as usize,
10871        ))
10872    }
10873    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
10874        let mut iter = self.clone();
10875        iter.pos = 0;
10876        for attr in iter {
10877            if let LinkinfoVtiAttrs::Remote(val) = attr? {
10878                return Ok(val);
10879            }
10880        }
10881        Err(ErrorContext::new_missing(
10882            "LinkinfoVtiAttrs",
10883            "Remote",
10884            self.orig_loc,
10885            self.buf.as_ptr() as usize,
10886        ))
10887    }
10888    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
10889        let mut iter = self.clone();
10890        iter.pos = 0;
10891        for attr in iter {
10892            if let LinkinfoVtiAttrs::Fwmark(val) = attr? {
10893                return Ok(val);
10894            }
10895        }
10896        Err(ErrorContext::new_missing(
10897            "LinkinfoVtiAttrs",
10898            "Fwmark",
10899            self.orig_loc,
10900            self.buf.as_ptr() as usize,
10901        ))
10902    }
10903}
10904impl<'a> LinkinfoVtiAttrs<'a> {
10905    pub fn new(buf: &'a [u8]) -> IterableLinkinfoVtiAttrs<'a> {
10906        IterableLinkinfoVtiAttrs::with_loc(buf, buf.as_ptr() as usize)
10907    }
10908    fn attr_from_type(r#type: u16) -> Option<&'static str> {
10909        let res = match r#type {
10910            1u16 => "Link",
10911            2u16 => "Ikey",
10912            3u16 => "Okey",
10913            4u16 => "Local",
10914            5u16 => "Remote",
10915            6u16 => "Fwmark",
10916            _ => return None,
10917        };
10918        Some(res)
10919    }
10920}
10921#[derive(Clone, Copy, Default)]
10922pub struct IterableLinkinfoVtiAttrs<'a> {
10923    buf: &'a [u8],
10924    pos: usize,
10925    orig_loc: usize,
10926}
10927impl<'a> IterableLinkinfoVtiAttrs<'a> {
10928    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
10929        Self {
10930            buf,
10931            pos: 0,
10932            orig_loc,
10933        }
10934    }
10935    pub fn get_buf(&self) -> &'a [u8] {
10936        self.buf
10937    }
10938}
10939impl<'a> Iterator for IterableLinkinfoVtiAttrs<'a> {
10940    type Item = Result<LinkinfoVtiAttrs<'a>, ErrorContext>;
10941    fn next(&mut self) -> Option<Self::Item> {
10942        if self.buf.len() == self.pos {
10943            return None;
10944        }
10945        let pos = self.pos;
10946        let mut r#type = None;
10947        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
10948            r#type = Some(header.r#type);
10949            let res = match header.r#type {
10950                1u16 => LinkinfoVtiAttrs::Link({
10951                    let res = parse_u32(next);
10952                    let Some(val) = res else { break };
10953                    val
10954                }),
10955                2u16 => LinkinfoVtiAttrs::Ikey({
10956                    let res = parse_be_u32(next);
10957                    let Some(val) = res else { break };
10958                    val
10959                }),
10960                3u16 => LinkinfoVtiAttrs::Okey({
10961                    let res = parse_be_u32(next);
10962                    let Some(val) = res else { break };
10963                    val
10964                }),
10965                4u16 => LinkinfoVtiAttrs::Local({
10966                    let res = Some(next);
10967                    let Some(val) = res else { break };
10968                    val
10969                }),
10970                5u16 => LinkinfoVtiAttrs::Remote({
10971                    let res = Some(next);
10972                    let Some(val) = res else { break };
10973                    val
10974                }),
10975                6u16 => LinkinfoVtiAttrs::Fwmark({
10976                    let res = parse_u32(next);
10977                    let Some(val) = res else { break };
10978                    val
10979                }),
10980                n => {
10981                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
10982                        break;
10983                    } else {
10984                        continue;
10985                    }
10986                }
10987            };
10988            return Some(Ok(res));
10989        }
10990        Some(Err(ErrorContext::new(
10991            "LinkinfoVtiAttrs",
10992            r#type.and_then(|t| LinkinfoVtiAttrs::attr_from_type(t)),
10993            self.orig_loc,
10994            self.buf.as_ptr().wrapping_add(pos) as usize,
10995        )))
10996    }
10997}
10998impl<'a> std::fmt::Debug for IterableLinkinfoVtiAttrs<'_> {
10999    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11000        let mut fmt = f.debug_struct("LinkinfoVtiAttrs");
11001        for attr in self.clone() {
11002            let attr = match attr {
11003                Ok(a) => a,
11004                Err(err) => {
11005                    fmt.finish()?;
11006                    f.write_str("Err(")?;
11007                    err.fmt(f)?;
11008                    return f.write_str(")");
11009                }
11010            };
11011            match attr {
11012                LinkinfoVtiAttrs::Link(val) => fmt.field("Link", &val),
11013                LinkinfoVtiAttrs::Ikey(val) => fmt.field("Ikey", &val),
11014                LinkinfoVtiAttrs::Okey(val) => fmt.field("Okey", &val),
11015                LinkinfoVtiAttrs::Local(val) => fmt.field("Local", &val),
11016                LinkinfoVtiAttrs::Remote(val) => fmt.field("Remote", &val),
11017                LinkinfoVtiAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
11018            };
11019        }
11020        fmt.finish()
11021    }
11022}
11023impl IterableLinkinfoVtiAttrs<'_> {
11024    pub fn lookup_attr(
11025        &self,
11026        offset: usize,
11027        missing_type: Option<u16>,
11028    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11029        let mut stack = Vec::new();
11030        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11031        if cur == offset {
11032            stack.push(("LinkinfoVtiAttrs", offset));
11033            return (
11034                stack,
11035                missing_type.and_then(|t| LinkinfoVtiAttrs::attr_from_type(t)),
11036            );
11037        }
11038        if cur > offset || cur + self.buf.len() < offset {
11039            return (stack, None);
11040        }
11041        let mut attrs = self.clone();
11042        let mut last_off = cur + attrs.pos;
11043        while let Some(attr) = attrs.next() {
11044            let Ok(attr) = attr else { break };
11045            match attr {
11046                LinkinfoVtiAttrs::Link(val) => {
11047                    if last_off == offset {
11048                        stack.push(("Link", last_off));
11049                        break;
11050                    }
11051                }
11052                LinkinfoVtiAttrs::Ikey(val) => {
11053                    if last_off == offset {
11054                        stack.push(("Ikey", last_off));
11055                        break;
11056                    }
11057                }
11058                LinkinfoVtiAttrs::Okey(val) => {
11059                    if last_off == offset {
11060                        stack.push(("Okey", last_off));
11061                        break;
11062                    }
11063                }
11064                LinkinfoVtiAttrs::Local(val) => {
11065                    if last_off == offset {
11066                        stack.push(("Local", last_off));
11067                        break;
11068                    }
11069                }
11070                LinkinfoVtiAttrs::Remote(val) => {
11071                    if last_off == offset {
11072                        stack.push(("Remote", last_off));
11073                        break;
11074                    }
11075                }
11076                LinkinfoVtiAttrs::Fwmark(val) => {
11077                    if last_off == offset {
11078                        stack.push(("Fwmark", last_off));
11079                        break;
11080                    }
11081                }
11082                _ => {}
11083            };
11084            last_off = cur + attrs.pos;
11085        }
11086        if !stack.is_empty() {
11087            stack.push(("LinkinfoVtiAttrs", cur));
11088        }
11089        (stack, None)
11090    }
11091}
11092#[derive(Clone)]
11093pub enum LinkinfoVti6Attrs<'a> {
11094    Link(u32),
11095    Ikey(u32),
11096    Okey(u32),
11097    Local(&'a [u8]),
11098    Remote(&'a [u8]),
11099    Fwmark(u32),
11100}
11101impl<'a> IterableLinkinfoVti6Attrs<'a> {
11102    pub fn get_link(&self) -> Result<u32, ErrorContext> {
11103        let mut iter = self.clone();
11104        iter.pos = 0;
11105        for attr in iter {
11106            if let LinkinfoVti6Attrs::Link(val) = attr? {
11107                return Ok(val);
11108            }
11109        }
11110        Err(ErrorContext::new_missing(
11111            "LinkinfoVti6Attrs",
11112            "Link",
11113            self.orig_loc,
11114            self.buf.as_ptr() as usize,
11115        ))
11116    }
11117    pub fn get_ikey(&self) -> Result<u32, ErrorContext> {
11118        let mut iter = self.clone();
11119        iter.pos = 0;
11120        for attr in iter {
11121            if let LinkinfoVti6Attrs::Ikey(val) = attr? {
11122                return Ok(val);
11123            }
11124        }
11125        Err(ErrorContext::new_missing(
11126            "LinkinfoVti6Attrs",
11127            "Ikey",
11128            self.orig_loc,
11129            self.buf.as_ptr() as usize,
11130        ))
11131    }
11132    pub fn get_okey(&self) -> Result<u32, ErrorContext> {
11133        let mut iter = self.clone();
11134        iter.pos = 0;
11135        for attr in iter {
11136            if let LinkinfoVti6Attrs::Okey(val) = attr? {
11137                return Ok(val);
11138            }
11139        }
11140        Err(ErrorContext::new_missing(
11141            "LinkinfoVti6Attrs",
11142            "Okey",
11143            self.orig_loc,
11144            self.buf.as_ptr() as usize,
11145        ))
11146    }
11147    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
11148        let mut iter = self.clone();
11149        iter.pos = 0;
11150        for attr in iter {
11151            if let LinkinfoVti6Attrs::Local(val) = attr? {
11152                return Ok(val);
11153            }
11154        }
11155        Err(ErrorContext::new_missing(
11156            "LinkinfoVti6Attrs",
11157            "Local",
11158            self.orig_loc,
11159            self.buf.as_ptr() as usize,
11160        ))
11161    }
11162    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
11163        let mut iter = self.clone();
11164        iter.pos = 0;
11165        for attr in iter {
11166            if let LinkinfoVti6Attrs::Remote(val) = attr? {
11167                return Ok(val);
11168            }
11169        }
11170        Err(ErrorContext::new_missing(
11171            "LinkinfoVti6Attrs",
11172            "Remote",
11173            self.orig_loc,
11174            self.buf.as_ptr() as usize,
11175        ))
11176    }
11177    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
11178        let mut iter = self.clone();
11179        iter.pos = 0;
11180        for attr in iter {
11181            if let LinkinfoVti6Attrs::Fwmark(val) = attr? {
11182                return Ok(val);
11183            }
11184        }
11185        Err(ErrorContext::new_missing(
11186            "LinkinfoVti6Attrs",
11187            "Fwmark",
11188            self.orig_loc,
11189            self.buf.as_ptr() as usize,
11190        ))
11191    }
11192}
11193impl<'a> LinkinfoVti6Attrs<'a> {
11194    pub fn new(buf: &'a [u8]) -> IterableLinkinfoVti6Attrs<'a> {
11195        IterableLinkinfoVti6Attrs::with_loc(buf, buf.as_ptr() as usize)
11196    }
11197    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11198        let res = match r#type {
11199            1u16 => "Link",
11200            2u16 => "Ikey",
11201            3u16 => "Okey",
11202            4u16 => "Local",
11203            5u16 => "Remote",
11204            6u16 => "Fwmark",
11205            _ => return None,
11206        };
11207        Some(res)
11208    }
11209}
11210#[derive(Clone, Copy, Default)]
11211pub struct IterableLinkinfoVti6Attrs<'a> {
11212    buf: &'a [u8],
11213    pos: usize,
11214    orig_loc: usize,
11215}
11216impl<'a> IterableLinkinfoVti6Attrs<'a> {
11217    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11218        Self {
11219            buf,
11220            pos: 0,
11221            orig_loc,
11222        }
11223    }
11224    pub fn get_buf(&self) -> &'a [u8] {
11225        self.buf
11226    }
11227}
11228impl<'a> Iterator for IterableLinkinfoVti6Attrs<'a> {
11229    type Item = Result<LinkinfoVti6Attrs<'a>, ErrorContext>;
11230    fn next(&mut self) -> Option<Self::Item> {
11231        if self.buf.len() == self.pos {
11232            return None;
11233        }
11234        let pos = self.pos;
11235        let mut r#type = None;
11236        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
11237            r#type = Some(header.r#type);
11238            let res = match header.r#type {
11239                1u16 => LinkinfoVti6Attrs::Link({
11240                    let res = parse_u32(next);
11241                    let Some(val) = res else { break };
11242                    val
11243                }),
11244                2u16 => LinkinfoVti6Attrs::Ikey({
11245                    let res = parse_be_u32(next);
11246                    let Some(val) = res else { break };
11247                    val
11248                }),
11249                3u16 => LinkinfoVti6Attrs::Okey({
11250                    let res = parse_be_u32(next);
11251                    let Some(val) = res else { break };
11252                    val
11253                }),
11254                4u16 => LinkinfoVti6Attrs::Local({
11255                    let res = Some(next);
11256                    let Some(val) = res else { break };
11257                    val
11258                }),
11259                5u16 => LinkinfoVti6Attrs::Remote({
11260                    let res = Some(next);
11261                    let Some(val) = res else { break };
11262                    val
11263                }),
11264                6u16 => LinkinfoVti6Attrs::Fwmark({
11265                    let res = parse_u32(next);
11266                    let Some(val) = res else { break };
11267                    val
11268                }),
11269                n => {
11270                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
11271                        break;
11272                    } else {
11273                        continue;
11274                    }
11275                }
11276            };
11277            return Some(Ok(res));
11278        }
11279        Some(Err(ErrorContext::new(
11280            "LinkinfoVti6Attrs",
11281            r#type.and_then(|t| LinkinfoVti6Attrs::attr_from_type(t)),
11282            self.orig_loc,
11283            self.buf.as_ptr().wrapping_add(pos) as usize,
11284        )))
11285    }
11286}
11287impl<'a> std::fmt::Debug for IterableLinkinfoVti6Attrs<'_> {
11288    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11289        let mut fmt = f.debug_struct("LinkinfoVti6Attrs");
11290        for attr in self.clone() {
11291            let attr = match attr {
11292                Ok(a) => a,
11293                Err(err) => {
11294                    fmt.finish()?;
11295                    f.write_str("Err(")?;
11296                    err.fmt(f)?;
11297                    return f.write_str(")");
11298                }
11299            };
11300            match attr {
11301                LinkinfoVti6Attrs::Link(val) => fmt.field("Link", &val),
11302                LinkinfoVti6Attrs::Ikey(val) => fmt.field("Ikey", &val),
11303                LinkinfoVti6Attrs::Okey(val) => fmt.field("Okey", &val),
11304                LinkinfoVti6Attrs::Local(val) => fmt.field("Local", &val),
11305                LinkinfoVti6Attrs::Remote(val) => fmt.field("Remote", &val),
11306                LinkinfoVti6Attrs::Fwmark(val) => fmt.field("Fwmark", &val),
11307            };
11308        }
11309        fmt.finish()
11310    }
11311}
11312impl IterableLinkinfoVti6Attrs<'_> {
11313    pub fn lookup_attr(
11314        &self,
11315        offset: usize,
11316        missing_type: Option<u16>,
11317    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11318        let mut stack = Vec::new();
11319        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11320        if cur == offset {
11321            stack.push(("LinkinfoVti6Attrs", offset));
11322            return (
11323                stack,
11324                missing_type.and_then(|t| LinkinfoVti6Attrs::attr_from_type(t)),
11325            );
11326        }
11327        if cur > offset || cur + self.buf.len() < offset {
11328            return (stack, None);
11329        }
11330        let mut attrs = self.clone();
11331        let mut last_off = cur + attrs.pos;
11332        while let Some(attr) = attrs.next() {
11333            let Ok(attr) = attr else { break };
11334            match attr {
11335                LinkinfoVti6Attrs::Link(val) => {
11336                    if last_off == offset {
11337                        stack.push(("Link", last_off));
11338                        break;
11339                    }
11340                }
11341                LinkinfoVti6Attrs::Ikey(val) => {
11342                    if last_off == offset {
11343                        stack.push(("Ikey", last_off));
11344                        break;
11345                    }
11346                }
11347                LinkinfoVti6Attrs::Okey(val) => {
11348                    if last_off == offset {
11349                        stack.push(("Okey", last_off));
11350                        break;
11351                    }
11352                }
11353                LinkinfoVti6Attrs::Local(val) => {
11354                    if last_off == offset {
11355                        stack.push(("Local", last_off));
11356                        break;
11357                    }
11358                }
11359                LinkinfoVti6Attrs::Remote(val) => {
11360                    if last_off == offset {
11361                        stack.push(("Remote", last_off));
11362                        break;
11363                    }
11364                }
11365                LinkinfoVti6Attrs::Fwmark(val) => {
11366                    if last_off == offset {
11367                        stack.push(("Fwmark", last_off));
11368                        break;
11369                    }
11370                }
11371                _ => {}
11372            };
11373            last_off = cur + attrs.pos;
11374        }
11375        if !stack.is_empty() {
11376            stack.push(("LinkinfoVti6Attrs", cur));
11377        }
11378        (stack, None)
11379    }
11380}
11381#[derive(Clone)]
11382pub enum LinkinfoGeneveAttrs<'a> {
11383    Id(u32),
11384    Remote(&'a [u8]),
11385    Ttl(u8),
11386    Tos(u8),
11387    Port(u16),
11388    CollectMetadata(()),
11389    Remote6(&'a [u8]),
11390    UdpCsum(u8),
11391    UdpZeroCsum6Tx(u8),
11392    UdpZeroCsum6Rx(u8),
11393    Label(u32),
11394    TtlInherit(u8),
11395    Df(u8),
11396    InnerProtoInherit(()),
11397    PortRange(PushIflaGenevePortRange),
11398}
11399impl<'a> IterableLinkinfoGeneveAttrs<'a> {
11400    pub fn get_id(&self) -> Result<u32, ErrorContext> {
11401        let mut iter = self.clone();
11402        iter.pos = 0;
11403        for attr in iter {
11404            if let LinkinfoGeneveAttrs::Id(val) = attr? {
11405                return Ok(val);
11406            }
11407        }
11408        Err(ErrorContext::new_missing(
11409            "LinkinfoGeneveAttrs",
11410            "Id",
11411            self.orig_loc,
11412            self.buf.as_ptr() as usize,
11413        ))
11414    }
11415    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
11416        let mut iter = self.clone();
11417        iter.pos = 0;
11418        for attr in iter {
11419            if let LinkinfoGeneveAttrs::Remote(val) = attr? {
11420                return Ok(val);
11421            }
11422        }
11423        Err(ErrorContext::new_missing(
11424            "LinkinfoGeneveAttrs",
11425            "Remote",
11426            self.orig_loc,
11427            self.buf.as_ptr() as usize,
11428        ))
11429    }
11430    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
11431        let mut iter = self.clone();
11432        iter.pos = 0;
11433        for attr in iter {
11434            if let LinkinfoGeneveAttrs::Ttl(val) = attr? {
11435                return Ok(val);
11436            }
11437        }
11438        Err(ErrorContext::new_missing(
11439            "LinkinfoGeneveAttrs",
11440            "Ttl",
11441            self.orig_loc,
11442            self.buf.as_ptr() as usize,
11443        ))
11444    }
11445    pub fn get_tos(&self) -> Result<u8, ErrorContext> {
11446        let mut iter = self.clone();
11447        iter.pos = 0;
11448        for attr in iter {
11449            if let LinkinfoGeneveAttrs::Tos(val) = attr? {
11450                return Ok(val);
11451            }
11452        }
11453        Err(ErrorContext::new_missing(
11454            "LinkinfoGeneveAttrs",
11455            "Tos",
11456            self.orig_loc,
11457            self.buf.as_ptr() as usize,
11458        ))
11459    }
11460    pub fn get_port(&self) -> Result<u16, ErrorContext> {
11461        let mut iter = self.clone();
11462        iter.pos = 0;
11463        for attr in iter {
11464            if let LinkinfoGeneveAttrs::Port(val) = attr? {
11465                return Ok(val);
11466            }
11467        }
11468        Err(ErrorContext::new_missing(
11469            "LinkinfoGeneveAttrs",
11470            "Port",
11471            self.orig_loc,
11472            self.buf.as_ptr() as usize,
11473        ))
11474    }
11475    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
11476        let mut iter = self.clone();
11477        iter.pos = 0;
11478        for attr in iter {
11479            if let LinkinfoGeneveAttrs::CollectMetadata(val) = attr? {
11480                return Ok(val);
11481            }
11482        }
11483        Err(ErrorContext::new_missing(
11484            "LinkinfoGeneveAttrs",
11485            "CollectMetadata",
11486            self.orig_loc,
11487            self.buf.as_ptr() as usize,
11488        ))
11489    }
11490    pub fn get_remote6(&self) -> Result<&'a [u8], ErrorContext> {
11491        let mut iter = self.clone();
11492        iter.pos = 0;
11493        for attr in iter {
11494            if let LinkinfoGeneveAttrs::Remote6(val) = attr? {
11495                return Ok(val);
11496            }
11497        }
11498        Err(ErrorContext::new_missing(
11499            "LinkinfoGeneveAttrs",
11500            "Remote6",
11501            self.orig_loc,
11502            self.buf.as_ptr() as usize,
11503        ))
11504    }
11505    pub fn get_udp_csum(&self) -> Result<u8, ErrorContext> {
11506        let mut iter = self.clone();
11507        iter.pos = 0;
11508        for attr in iter {
11509            if let LinkinfoGeneveAttrs::UdpCsum(val) = attr? {
11510                return Ok(val);
11511            }
11512        }
11513        Err(ErrorContext::new_missing(
11514            "LinkinfoGeneveAttrs",
11515            "UdpCsum",
11516            self.orig_loc,
11517            self.buf.as_ptr() as usize,
11518        ))
11519    }
11520    pub fn get_udp_zero_csum6_tx(&self) -> Result<u8, ErrorContext> {
11521        let mut iter = self.clone();
11522        iter.pos = 0;
11523        for attr in iter {
11524            if let LinkinfoGeneveAttrs::UdpZeroCsum6Tx(val) = attr? {
11525                return Ok(val);
11526            }
11527        }
11528        Err(ErrorContext::new_missing(
11529            "LinkinfoGeneveAttrs",
11530            "UdpZeroCsum6Tx",
11531            self.orig_loc,
11532            self.buf.as_ptr() as usize,
11533        ))
11534    }
11535    pub fn get_udp_zero_csum6_rx(&self) -> Result<u8, ErrorContext> {
11536        let mut iter = self.clone();
11537        iter.pos = 0;
11538        for attr in iter {
11539            if let LinkinfoGeneveAttrs::UdpZeroCsum6Rx(val) = attr? {
11540                return Ok(val);
11541            }
11542        }
11543        Err(ErrorContext::new_missing(
11544            "LinkinfoGeneveAttrs",
11545            "UdpZeroCsum6Rx",
11546            self.orig_loc,
11547            self.buf.as_ptr() as usize,
11548        ))
11549    }
11550    pub fn get_label(&self) -> Result<u32, ErrorContext> {
11551        let mut iter = self.clone();
11552        iter.pos = 0;
11553        for attr in iter {
11554            if let LinkinfoGeneveAttrs::Label(val) = attr? {
11555                return Ok(val);
11556            }
11557        }
11558        Err(ErrorContext::new_missing(
11559            "LinkinfoGeneveAttrs",
11560            "Label",
11561            self.orig_loc,
11562            self.buf.as_ptr() as usize,
11563        ))
11564    }
11565    pub fn get_ttl_inherit(&self) -> Result<u8, ErrorContext> {
11566        let mut iter = self.clone();
11567        iter.pos = 0;
11568        for attr in iter {
11569            if let LinkinfoGeneveAttrs::TtlInherit(val) = attr? {
11570                return Ok(val);
11571            }
11572        }
11573        Err(ErrorContext::new_missing(
11574            "LinkinfoGeneveAttrs",
11575            "TtlInherit",
11576            self.orig_loc,
11577            self.buf.as_ptr() as usize,
11578        ))
11579    }
11580    pub fn get_df(&self) -> Result<u8, ErrorContext> {
11581        let mut iter = self.clone();
11582        iter.pos = 0;
11583        for attr in iter {
11584            if let LinkinfoGeneveAttrs::Df(val) = attr? {
11585                return Ok(val);
11586            }
11587        }
11588        Err(ErrorContext::new_missing(
11589            "LinkinfoGeneveAttrs",
11590            "Df",
11591            self.orig_loc,
11592            self.buf.as_ptr() as usize,
11593        ))
11594    }
11595    pub fn get_inner_proto_inherit(&self) -> Result<(), ErrorContext> {
11596        let mut iter = self.clone();
11597        iter.pos = 0;
11598        for attr in iter {
11599            if let LinkinfoGeneveAttrs::InnerProtoInherit(val) = attr? {
11600                return Ok(val);
11601            }
11602        }
11603        Err(ErrorContext::new_missing(
11604            "LinkinfoGeneveAttrs",
11605            "InnerProtoInherit",
11606            self.orig_loc,
11607            self.buf.as_ptr() as usize,
11608        ))
11609    }
11610    pub fn get_port_range(&self) -> Result<PushIflaGenevePortRange, ErrorContext> {
11611        let mut iter = self.clone();
11612        iter.pos = 0;
11613        for attr in iter {
11614            if let LinkinfoGeneveAttrs::PortRange(val) = attr? {
11615                return Ok(val);
11616            }
11617        }
11618        Err(ErrorContext::new_missing(
11619            "LinkinfoGeneveAttrs",
11620            "PortRange",
11621            self.orig_loc,
11622            self.buf.as_ptr() as usize,
11623        ))
11624    }
11625}
11626impl<'a> LinkinfoGeneveAttrs<'a> {
11627    pub fn new(buf: &'a [u8]) -> IterableLinkinfoGeneveAttrs<'a> {
11628        IterableLinkinfoGeneveAttrs::with_loc(buf, buf.as_ptr() as usize)
11629    }
11630    fn attr_from_type(r#type: u16) -> Option<&'static str> {
11631        let res = match r#type {
11632            1u16 => "Id",
11633            2u16 => "Remote",
11634            3u16 => "Ttl",
11635            4u16 => "Tos",
11636            5u16 => "Port",
11637            6u16 => "CollectMetadata",
11638            7u16 => "Remote6",
11639            8u16 => "UdpCsum",
11640            9u16 => "UdpZeroCsum6Tx",
11641            10u16 => "UdpZeroCsum6Rx",
11642            11u16 => "Label",
11643            12u16 => "TtlInherit",
11644            13u16 => "Df",
11645            14u16 => "InnerProtoInherit",
11646            15u16 => "PortRange",
11647            _ => return None,
11648        };
11649        Some(res)
11650    }
11651}
11652#[derive(Clone, Copy, Default)]
11653pub struct IterableLinkinfoGeneveAttrs<'a> {
11654    buf: &'a [u8],
11655    pos: usize,
11656    orig_loc: usize,
11657}
11658impl<'a> IterableLinkinfoGeneveAttrs<'a> {
11659    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
11660        Self {
11661            buf,
11662            pos: 0,
11663            orig_loc,
11664        }
11665    }
11666    pub fn get_buf(&self) -> &'a [u8] {
11667        self.buf
11668    }
11669}
11670impl<'a> Iterator for IterableLinkinfoGeneveAttrs<'a> {
11671    type Item = Result<LinkinfoGeneveAttrs<'a>, ErrorContext>;
11672    fn next(&mut self) -> Option<Self::Item> {
11673        if self.buf.len() == self.pos {
11674            return None;
11675        }
11676        let pos = self.pos;
11677        let mut r#type = None;
11678        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
11679            r#type = Some(header.r#type);
11680            let res = match header.r#type {
11681                1u16 => LinkinfoGeneveAttrs::Id({
11682                    let res = parse_u32(next);
11683                    let Some(val) = res else { break };
11684                    val
11685                }),
11686                2u16 => LinkinfoGeneveAttrs::Remote({
11687                    let res = Some(next);
11688                    let Some(val) = res else { break };
11689                    val
11690                }),
11691                3u16 => LinkinfoGeneveAttrs::Ttl({
11692                    let res = parse_u8(next);
11693                    let Some(val) = res else { break };
11694                    val
11695                }),
11696                4u16 => LinkinfoGeneveAttrs::Tos({
11697                    let res = parse_u8(next);
11698                    let Some(val) = res else { break };
11699                    val
11700                }),
11701                5u16 => LinkinfoGeneveAttrs::Port({
11702                    let res = parse_be_u16(next);
11703                    let Some(val) = res else { break };
11704                    val
11705                }),
11706                6u16 => LinkinfoGeneveAttrs::CollectMetadata(()),
11707                7u16 => LinkinfoGeneveAttrs::Remote6({
11708                    let res = Some(next);
11709                    let Some(val) = res else { break };
11710                    val
11711                }),
11712                8u16 => LinkinfoGeneveAttrs::UdpCsum({
11713                    let res = parse_u8(next);
11714                    let Some(val) = res else { break };
11715                    val
11716                }),
11717                9u16 => LinkinfoGeneveAttrs::UdpZeroCsum6Tx({
11718                    let res = parse_u8(next);
11719                    let Some(val) = res else { break };
11720                    val
11721                }),
11722                10u16 => LinkinfoGeneveAttrs::UdpZeroCsum6Rx({
11723                    let res = parse_u8(next);
11724                    let Some(val) = res else { break };
11725                    val
11726                }),
11727                11u16 => LinkinfoGeneveAttrs::Label({
11728                    let res = parse_be_u32(next);
11729                    let Some(val) = res else { break };
11730                    val
11731                }),
11732                12u16 => LinkinfoGeneveAttrs::TtlInherit({
11733                    let res = parse_u8(next);
11734                    let Some(val) = res else { break };
11735                    val
11736                }),
11737                13u16 => LinkinfoGeneveAttrs::Df({
11738                    let res = parse_u8(next);
11739                    let Some(val) = res else { break };
11740                    val
11741                }),
11742                14u16 => LinkinfoGeneveAttrs::InnerProtoInherit(()),
11743                15u16 => LinkinfoGeneveAttrs::PortRange({
11744                    let res = PushIflaGenevePortRange::new_from_slice(next);
11745                    let Some(val) = res else { break };
11746                    val
11747                }),
11748                n => {
11749                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
11750                        break;
11751                    } else {
11752                        continue;
11753                    }
11754                }
11755            };
11756            return Some(Ok(res));
11757        }
11758        Some(Err(ErrorContext::new(
11759            "LinkinfoGeneveAttrs",
11760            r#type.and_then(|t| LinkinfoGeneveAttrs::attr_from_type(t)),
11761            self.orig_loc,
11762            self.buf.as_ptr().wrapping_add(pos) as usize,
11763        )))
11764    }
11765}
11766impl<'a> std::fmt::Debug for IterableLinkinfoGeneveAttrs<'_> {
11767    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11768        let mut fmt = f.debug_struct("LinkinfoGeneveAttrs");
11769        for attr in self.clone() {
11770            let attr = match attr {
11771                Ok(a) => a,
11772                Err(err) => {
11773                    fmt.finish()?;
11774                    f.write_str("Err(")?;
11775                    err.fmt(f)?;
11776                    return f.write_str(")");
11777                }
11778            };
11779            match attr {
11780                LinkinfoGeneveAttrs::Id(val) => fmt.field("Id", &val),
11781                LinkinfoGeneveAttrs::Remote(val) => fmt.field("Remote", &val),
11782                LinkinfoGeneveAttrs::Ttl(val) => fmt.field("Ttl", &val),
11783                LinkinfoGeneveAttrs::Tos(val) => fmt.field("Tos", &val),
11784                LinkinfoGeneveAttrs::Port(val) => fmt.field("Port", &val),
11785                LinkinfoGeneveAttrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
11786                LinkinfoGeneveAttrs::Remote6(val) => fmt.field("Remote6", &val),
11787                LinkinfoGeneveAttrs::UdpCsum(val) => fmt.field("UdpCsum", &val),
11788                LinkinfoGeneveAttrs::UdpZeroCsum6Tx(val) => fmt.field("UdpZeroCsum6Tx", &val),
11789                LinkinfoGeneveAttrs::UdpZeroCsum6Rx(val) => fmt.field("UdpZeroCsum6Rx", &val),
11790                LinkinfoGeneveAttrs::Label(val) => fmt.field("Label", &val),
11791                LinkinfoGeneveAttrs::TtlInherit(val) => fmt.field("TtlInherit", &val),
11792                LinkinfoGeneveAttrs::Df(val) => fmt.field("Df", &val),
11793                LinkinfoGeneveAttrs::InnerProtoInherit(val) => fmt.field("InnerProtoInherit", &val),
11794                LinkinfoGeneveAttrs::PortRange(val) => fmt.field("PortRange", &val),
11795            };
11796        }
11797        fmt.finish()
11798    }
11799}
11800impl IterableLinkinfoGeneveAttrs<'_> {
11801    pub fn lookup_attr(
11802        &self,
11803        offset: usize,
11804        missing_type: Option<u16>,
11805    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
11806        let mut stack = Vec::new();
11807        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
11808        if cur == offset {
11809            stack.push(("LinkinfoGeneveAttrs", offset));
11810            return (
11811                stack,
11812                missing_type.and_then(|t| LinkinfoGeneveAttrs::attr_from_type(t)),
11813            );
11814        }
11815        if cur > offset || cur + self.buf.len() < offset {
11816            return (stack, None);
11817        }
11818        let mut attrs = self.clone();
11819        let mut last_off = cur + attrs.pos;
11820        while let Some(attr) = attrs.next() {
11821            let Ok(attr) = attr else { break };
11822            match attr {
11823                LinkinfoGeneveAttrs::Id(val) => {
11824                    if last_off == offset {
11825                        stack.push(("Id", last_off));
11826                        break;
11827                    }
11828                }
11829                LinkinfoGeneveAttrs::Remote(val) => {
11830                    if last_off == offset {
11831                        stack.push(("Remote", last_off));
11832                        break;
11833                    }
11834                }
11835                LinkinfoGeneveAttrs::Ttl(val) => {
11836                    if last_off == offset {
11837                        stack.push(("Ttl", last_off));
11838                        break;
11839                    }
11840                }
11841                LinkinfoGeneveAttrs::Tos(val) => {
11842                    if last_off == offset {
11843                        stack.push(("Tos", last_off));
11844                        break;
11845                    }
11846                }
11847                LinkinfoGeneveAttrs::Port(val) => {
11848                    if last_off == offset {
11849                        stack.push(("Port", last_off));
11850                        break;
11851                    }
11852                }
11853                LinkinfoGeneveAttrs::CollectMetadata(val) => {
11854                    if last_off == offset {
11855                        stack.push(("CollectMetadata", last_off));
11856                        break;
11857                    }
11858                }
11859                LinkinfoGeneveAttrs::Remote6(val) => {
11860                    if last_off == offset {
11861                        stack.push(("Remote6", last_off));
11862                        break;
11863                    }
11864                }
11865                LinkinfoGeneveAttrs::UdpCsum(val) => {
11866                    if last_off == offset {
11867                        stack.push(("UdpCsum", last_off));
11868                        break;
11869                    }
11870                }
11871                LinkinfoGeneveAttrs::UdpZeroCsum6Tx(val) => {
11872                    if last_off == offset {
11873                        stack.push(("UdpZeroCsum6Tx", last_off));
11874                        break;
11875                    }
11876                }
11877                LinkinfoGeneveAttrs::UdpZeroCsum6Rx(val) => {
11878                    if last_off == offset {
11879                        stack.push(("UdpZeroCsum6Rx", last_off));
11880                        break;
11881                    }
11882                }
11883                LinkinfoGeneveAttrs::Label(val) => {
11884                    if last_off == offset {
11885                        stack.push(("Label", last_off));
11886                        break;
11887                    }
11888                }
11889                LinkinfoGeneveAttrs::TtlInherit(val) => {
11890                    if last_off == offset {
11891                        stack.push(("TtlInherit", last_off));
11892                        break;
11893                    }
11894                }
11895                LinkinfoGeneveAttrs::Df(val) => {
11896                    if last_off == offset {
11897                        stack.push(("Df", last_off));
11898                        break;
11899                    }
11900                }
11901                LinkinfoGeneveAttrs::InnerProtoInherit(val) => {
11902                    if last_off == offset {
11903                        stack.push(("InnerProtoInherit", last_off));
11904                        break;
11905                    }
11906                }
11907                LinkinfoGeneveAttrs::PortRange(val) => {
11908                    if last_off == offset {
11909                        stack.push(("PortRange", last_off));
11910                        break;
11911                    }
11912                }
11913                _ => {}
11914            };
11915            last_off = cur + attrs.pos;
11916        }
11917        if !stack.is_empty() {
11918            stack.push(("LinkinfoGeneveAttrs", cur));
11919        }
11920        (stack, None)
11921    }
11922}
11923#[derive(Clone)]
11924pub enum LinkinfoIptunAttrs<'a> {
11925    Link(u32),
11926    Local(&'a [u8]),
11927    Remote(&'a [u8]),
11928    Ttl(u8),
11929    Tos(u8),
11930    EncapLimit(u8),
11931    Flowinfo(u32),
11932    Flags(u16),
11933    Proto(u8),
11934    Pmtudisc(u8),
11935    _6rdPrefix(&'a [u8]),
11936    _6rdRelayPrefix(&'a [u8]),
11937    _6rdPrefixlen(u16),
11938    _6rdRelayPrefixlen(u16),
11939    EncapType(u16),
11940    EncapFlags(u16),
11941    EncapSport(u16),
11942    EncapDport(u16),
11943    CollectMetadata(()),
11944    Fwmark(u32),
11945}
11946impl<'a> IterableLinkinfoIptunAttrs<'a> {
11947    pub fn get_link(&self) -> Result<u32, ErrorContext> {
11948        let mut iter = self.clone();
11949        iter.pos = 0;
11950        for attr in iter {
11951            if let LinkinfoIptunAttrs::Link(val) = attr? {
11952                return Ok(val);
11953            }
11954        }
11955        Err(ErrorContext::new_missing(
11956            "LinkinfoIptunAttrs",
11957            "Link",
11958            self.orig_loc,
11959            self.buf.as_ptr() as usize,
11960        ))
11961    }
11962    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
11963        let mut iter = self.clone();
11964        iter.pos = 0;
11965        for attr in iter {
11966            if let LinkinfoIptunAttrs::Local(val) = attr? {
11967                return Ok(val);
11968            }
11969        }
11970        Err(ErrorContext::new_missing(
11971            "LinkinfoIptunAttrs",
11972            "Local",
11973            self.orig_loc,
11974            self.buf.as_ptr() as usize,
11975        ))
11976    }
11977    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
11978        let mut iter = self.clone();
11979        iter.pos = 0;
11980        for attr in iter {
11981            if let LinkinfoIptunAttrs::Remote(val) = attr? {
11982                return Ok(val);
11983            }
11984        }
11985        Err(ErrorContext::new_missing(
11986            "LinkinfoIptunAttrs",
11987            "Remote",
11988            self.orig_loc,
11989            self.buf.as_ptr() as usize,
11990        ))
11991    }
11992    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
11993        let mut iter = self.clone();
11994        iter.pos = 0;
11995        for attr in iter {
11996            if let LinkinfoIptunAttrs::Ttl(val) = attr? {
11997                return Ok(val);
11998            }
11999        }
12000        Err(ErrorContext::new_missing(
12001            "LinkinfoIptunAttrs",
12002            "Ttl",
12003            self.orig_loc,
12004            self.buf.as_ptr() as usize,
12005        ))
12006    }
12007    pub fn get_tos(&self) -> Result<u8, ErrorContext> {
12008        let mut iter = self.clone();
12009        iter.pos = 0;
12010        for attr in iter {
12011            if let LinkinfoIptunAttrs::Tos(val) = attr? {
12012                return Ok(val);
12013            }
12014        }
12015        Err(ErrorContext::new_missing(
12016            "LinkinfoIptunAttrs",
12017            "Tos",
12018            self.orig_loc,
12019            self.buf.as_ptr() as usize,
12020        ))
12021    }
12022    pub fn get_encap_limit(&self) -> Result<u8, ErrorContext> {
12023        let mut iter = self.clone();
12024        iter.pos = 0;
12025        for attr in iter {
12026            if let LinkinfoIptunAttrs::EncapLimit(val) = attr? {
12027                return Ok(val);
12028            }
12029        }
12030        Err(ErrorContext::new_missing(
12031            "LinkinfoIptunAttrs",
12032            "EncapLimit",
12033            self.orig_loc,
12034            self.buf.as_ptr() as usize,
12035        ))
12036    }
12037    pub fn get_flowinfo(&self) -> Result<u32, ErrorContext> {
12038        let mut iter = self.clone();
12039        iter.pos = 0;
12040        for attr in iter {
12041            if let LinkinfoIptunAttrs::Flowinfo(val) = attr? {
12042                return Ok(val);
12043            }
12044        }
12045        Err(ErrorContext::new_missing(
12046            "LinkinfoIptunAttrs",
12047            "Flowinfo",
12048            self.orig_loc,
12049            self.buf.as_ptr() as usize,
12050        ))
12051    }
12052    pub fn get_flags(&self) -> Result<u16, ErrorContext> {
12053        let mut iter = self.clone();
12054        iter.pos = 0;
12055        for attr in iter {
12056            if let LinkinfoIptunAttrs::Flags(val) = attr? {
12057                return Ok(val);
12058            }
12059        }
12060        Err(ErrorContext::new_missing(
12061            "LinkinfoIptunAttrs",
12062            "Flags",
12063            self.orig_loc,
12064            self.buf.as_ptr() as usize,
12065        ))
12066    }
12067    pub fn get_proto(&self) -> Result<u8, ErrorContext> {
12068        let mut iter = self.clone();
12069        iter.pos = 0;
12070        for attr in iter {
12071            if let LinkinfoIptunAttrs::Proto(val) = attr? {
12072                return Ok(val);
12073            }
12074        }
12075        Err(ErrorContext::new_missing(
12076            "LinkinfoIptunAttrs",
12077            "Proto",
12078            self.orig_loc,
12079            self.buf.as_ptr() as usize,
12080        ))
12081    }
12082    pub fn get_pmtudisc(&self) -> Result<u8, ErrorContext> {
12083        let mut iter = self.clone();
12084        iter.pos = 0;
12085        for attr in iter {
12086            if let LinkinfoIptunAttrs::Pmtudisc(val) = attr? {
12087                return Ok(val);
12088            }
12089        }
12090        Err(ErrorContext::new_missing(
12091            "LinkinfoIptunAttrs",
12092            "Pmtudisc",
12093            self.orig_loc,
12094            self.buf.as_ptr() as usize,
12095        ))
12096    }
12097    pub fn get_6rd_prefix(&self) -> Result<&'a [u8], ErrorContext> {
12098        let mut iter = self.clone();
12099        iter.pos = 0;
12100        for attr in iter {
12101            if let LinkinfoIptunAttrs::_6rdPrefix(val) = attr? {
12102                return Ok(val);
12103            }
12104        }
12105        Err(ErrorContext::new_missing(
12106            "LinkinfoIptunAttrs",
12107            "6rdPrefix",
12108            self.orig_loc,
12109            self.buf.as_ptr() as usize,
12110        ))
12111    }
12112    pub fn get_6rd_relay_prefix(&self) -> Result<&'a [u8], ErrorContext> {
12113        let mut iter = self.clone();
12114        iter.pos = 0;
12115        for attr in iter {
12116            if let LinkinfoIptunAttrs::_6rdRelayPrefix(val) = attr? {
12117                return Ok(val);
12118            }
12119        }
12120        Err(ErrorContext::new_missing(
12121            "LinkinfoIptunAttrs",
12122            "6rdRelayPrefix",
12123            self.orig_loc,
12124            self.buf.as_ptr() as usize,
12125        ))
12126    }
12127    pub fn get_6rd_prefixlen(&self) -> Result<u16, ErrorContext> {
12128        let mut iter = self.clone();
12129        iter.pos = 0;
12130        for attr in iter {
12131            if let LinkinfoIptunAttrs::_6rdPrefixlen(val) = attr? {
12132                return Ok(val);
12133            }
12134        }
12135        Err(ErrorContext::new_missing(
12136            "LinkinfoIptunAttrs",
12137            "6rdPrefixlen",
12138            self.orig_loc,
12139            self.buf.as_ptr() as usize,
12140        ))
12141    }
12142    pub fn get_6rd_relay_prefixlen(&self) -> Result<u16, ErrorContext> {
12143        let mut iter = self.clone();
12144        iter.pos = 0;
12145        for attr in iter {
12146            if let LinkinfoIptunAttrs::_6rdRelayPrefixlen(val) = attr? {
12147                return Ok(val);
12148            }
12149        }
12150        Err(ErrorContext::new_missing(
12151            "LinkinfoIptunAttrs",
12152            "6rdRelayPrefixlen",
12153            self.orig_loc,
12154            self.buf.as_ptr() as usize,
12155        ))
12156    }
12157    pub fn get_encap_type(&self) -> Result<u16, ErrorContext> {
12158        let mut iter = self.clone();
12159        iter.pos = 0;
12160        for attr in iter {
12161            if let LinkinfoIptunAttrs::EncapType(val) = attr? {
12162                return Ok(val);
12163            }
12164        }
12165        Err(ErrorContext::new_missing(
12166            "LinkinfoIptunAttrs",
12167            "EncapType",
12168            self.orig_loc,
12169            self.buf.as_ptr() as usize,
12170        ))
12171    }
12172    pub fn get_encap_flags(&self) -> Result<u16, ErrorContext> {
12173        let mut iter = self.clone();
12174        iter.pos = 0;
12175        for attr in iter {
12176            if let LinkinfoIptunAttrs::EncapFlags(val) = attr? {
12177                return Ok(val);
12178            }
12179        }
12180        Err(ErrorContext::new_missing(
12181            "LinkinfoIptunAttrs",
12182            "EncapFlags",
12183            self.orig_loc,
12184            self.buf.as_ptr() as usize,
12185        ))
12186    }
12187    pub fn get_encap_sport(&self) -> Result<u16, ErrorContext> {
12188        let mut iter = self.clone();
12189        iter.pos = 0;
12190        for attr in iter {
12191            if let LinkinfoIptunAttrs::EncapSport(val) = attr? {
12192                return Ok(val);
12193            }
12194        }
12195        Err(ErrorContext::new_missing(
12196            "LinkinfoIptunAttrs",
12197            "EncapSport",
12198            self.orig_loc,
12199            self.buf.as_ptr() as usize,
12200        ))
12201    }
12202    pub fn get_encap_dport(&self) -> Result<u16, ErrorContext> {
12203        let mut iter = self.clone();
12204        iter.pos = 0;
12205        for attr in iter {
12206            if let LinkinfoIptunAttrs::EncapDport(val) = attr? {
12207                return Ok(val);
12208            }
12209        }
12210        Err(ErrorContext::new_missing(
12211            "LinkinfoIptunAttrs",
12212            "EncapDport",
12213            self.orig_loc,
12214            self.buf.as_ptr() as usize,
12215        ))
12216    }
12217    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
12218        let mut iter = self.clone();
12219        iter.pos = 0;
12220        for attr in iter {
12221            if let LinkinfoIptunAttrs::CollectMetadata(val) = attr? {
12222                return Ok(val);
12223            }
12224        }
12225        Err(ErrorContext::new_missing(
12226            "LinkinfoIptunAttrs",
12227            "CollectMetadata",
12228            self.orig_loc,
12229            self.buf.as_ptr() as usize,
12230        ))
12231    }
12232    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
12233        let mut iter = self.clone();
12234        iter.pos = 0;
12235        for attr in iter {
12236            if let LinkinfoIptunAttrs::Fwmark(val) = attr? {
12237                return Ok(val);
12238            }
12239        }
12240        Err(ErrorContext::new_missing(
12241            "LinkinfoIptunAttrs",
12242            "Fwmark",
12243            self.orig_loc,
12244            self.buf.as_ptr() as usize,
12245        ))
12246    }
12247}
12248impl<'a> LinkinfoIptunAttrs<'a> {
12249    pub fn new(buf: &'a [u8]) -> IterableLinkinfoIptunAttrs<'a> {
12250        IterableLinkinfoIptunAttrs::with_loc(buf, buf.as_ptr() as usize)
12251    }
12252    fn attr_from_type(r#type: u16) -> Option<&'static str> {
12253        let res = match r#type {
12254            1u16 => "Link",
12255            2u16 => "Local",
12256            3u16 => "Remote",
12257            4u16 => "Ttl",
12258            5u16 => "Tos",
12259            6u16 => "EncapLimit",
12260            7u16 => "Flowinfo",
12261            8u16 => "Flags",
12262            9u16 => "Proto",
12263            10u16 => "Pmtudisc",
12264            11u16 => "6rdPrefix",
12265            12u16 => "6rdRelayPrefix",
12266            13u16 => "6rdPrefixlen",
12267            14u16 => "6rdRelayPrefixlen",
12268            15u16 => "EncapType",
12269            16u16 => "EncapFlags",
12270            17u16 => "EncapSport",
12271            18u16 => "EncapDport",
12272            19u16 => "CollectMetadata",
12273            20u16 => "Fwmark",
12274            _ => return None,
12275        };
12276        Some(res)
12277    }
12278}
12279#[derive(Clone, Copy, Default)]
12280pub struct IterableLinkinfoIptunAttrs<'a> {
12281    buf: &'a [u8],
12282    pos: usize,
12283    orig_loc: usize,
12284}
12285impl<'a> IterableLinkinfoIptunAttrs<'a> {
12286    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
12287        Self {
12288            buf,
12289            pos: 0,
12290            orig_loc,
12291        }
12292    }
12293    pub fn get_buf(&self) -> &'a [u8] {
12294        self.buf
12295    }
12296}
12297impl<'a> Iterator for IterableLinkinfoIptunAttrs<'a> {
12298    type Item = Result<LinkinfoIptunAttrs<'a>, ErrorContext>;
12299    fn next(&mut self) -> Option<Self::Item> {
12300        if self.buf.len() == self.pos {
12301            return None;
12302        }
12303        let pos = self.pos;
12304        let mut r#type = None;
12305        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
12306            r#type = Some(header.r#type);
12307            let res = match header.r#type {
12308                1u16 => LinkinfoIptunAttrs::Link({
12309                    let res = parse_u32(next);
12310                    let Some(val) = res else { break };
12311                    val
12312                }),
12313                2u16 => LinkinfoIptunAttrs::Local({
12314                    let res = Some(next);
12315                    let Some(val) = res else { break };
12316                    val
12317                }),
12318                3u16 => LinkinfoIptunAttrs::Remote({
12319                    let res = Some(next);
12320                    let Some(val) = res else { break };
12321                    val
12322                }),
12323                4u16 => LinkinfoIptunAttrs::Ttl({
12324                    let res = parse_u8(next);
12325                    let Some(val) = res else { break };
12326                    val
12327                }),
12328                5u16 => LinkinfoIptunAttrs::Tos({
12329                    let res = parse_u8(next);
12330                    let Some(val) = res else { break };
12331                    val
12332                }),
12333                6u16 => LinkinfoIptunAttrs::EncapLimit({
12334                    let res = parse_u8(next);
12335                    let Some(val) = res else { break };
12336                    val
12337                }),
12338                7u16 => LinkinfoIptunAttrs::Flowinfo({
12339                    let res = parse_be_u32(next);
12340                    let Some(val) = res else { break };
12341                    val
12342                }),
12343                8u16 => LinkinfoIptunAttrs::Flags({
12344                    let res = parse_be_u16(next);
12345                    let Some(val) = res else { break };
12346                    val
12347                }),
12348                9u16 => LinkinfoIptunAttrs::Proto({
12349                    let res = parse_u8(next);
12350                    let Some(val) = res else { break };
12351                    val
12352                }),
12353                10u16 => LinkinfoIptunAttrs::Pmtudisc({
12354                    let res = parse_u8(next);
12355                    let Some(val) = res else { break };
12356                    val
12357                }),
12358                11u16 => LinkinfoIptunAttrs::_6rdPrefix({
12359                    let res = Some(next);
12360                    let Some(val) = res else { break };
12361                    val
12362                }),
12363                12u16 => LinkinfoIptunAttrs::_6rdRelayPrefix({
12364                    let res = Some(next);
12365                    let Some(val) = res else { break };
12366                    val
12367                }),
12368                13u16 => LinkinfoIptunAttrs::_6rdPrefixlen({
12369                    let res = parse_u16(next);
12370                    let Some(val) = res else { break };
12371                    val
12372                }),
12373                14u16 => LinkinfoIptunAttrs::_6rdRelayPrefixlen({
12374                    let res = parse_u16(next);
12375                    let Some(val) = res else { break };
12376                    val
12377                }),
12378                15u16 => LinkinfoIptunAttrs::EncapType({
12379                    let res = parse_u16(next);
12380                    let Some(val) = res else { break };
12381                    val
12382                }),
12383                16u16 => LinkinfoIptunAttrs::EncapFlags({
12384                    let res = parse_u16(next);
12385                    let Some(val) = res else { break };
12386                    val
12387                }),
12388                17u16 => LinkinfoIptunAttrs::EncapSport({
12389                    let res = parse_be_u16(next);
12390                    let Some(val) = res else { break };
12391                    val
12392                }),
12393                18u16 => LinkinfoIptunAttrs::EncapDport({
12394                    let res = parse_be_u16(next);
12395                    let Some(val) = res else { break };
12396                    val
12397                }),
12398                19u16 => LinkinfoIptunAttrs::CollectMetadata(()),
12399                20u16 => LinkinfoIptunAttrs::Fwmark({
12400                    let res = parse_u32(next);
12401                    let Some(val) = res else { break };
12402                    val
12403                }),
12404                n => {
12405                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
12406                        break;
12407                    } else {
12408                        continue;
12409                    }
12410                }
12411            };
12412            return Some(Ok(res));
12413        }
12414        Some(Err(ErrorContext::new(
12415            "LinkinfoIptunAttrs",
12416            r#type.and_then(|t| LinkinfoIptunAttrs::attr_from_type(t)),
12417            self.orig_loc,
12418            self.buf.as_ptr().wrapping_add(pos) as usize,
12419        )))
12420    }
12421}
12422impl<'a> std::fmt::Debug for IterableLinkinfoIptunAttrs<'_> {
12423    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12424        let mut fmt = f.debug_struct("LinkinfoIptunAttrs");
12425        for attr in self.clone() {
12426            let attr = match attr {
12427                Ok(a) => a,
12428                Err(err) => {
12429                    fmt.finish()?;
12430                    f.write_str("Err(")?;
12431                    err.fmt(f)?;
12432                    return f.write_str(")");
12433                }
12434            };
12435            match attr {
12436                LinkinfoIptunAttrs::Link(val) => fmt.field("Link", &val),
12437                LinkinfoIptunAttrs::Local(val) => fmt.field("Local", &val),
12438                LinkinfoIptunAttrs::Remote(val) => fmt.field("Remote", &val),
12439                LinkinfoIptunAttrs::Ttl(val) => fmt.field("Ttl", &val),
12440                LinkinfoIptunAttrs::Tos(val) => fmt.field("Tos", &val),
12441                LinkinfoIptunAttrs::EncapLimit(val) => fmt.field("EncapLimit", &val),
12442                LinkinfoIptunAttrs::Flowinfo(val) => fmt.field("Flowinfo", &val),
12443                LinkinfoIptunAttrs::Flags(val) => fmt.field("Flags", &val),
12444                LinkinfoIptunAttrs::Proto(val) => fmt.field("Proto", &val),
12445                LinkinfoIptunAttrs::Pmtudisc(val) => fmt.field("Pmtudisc", &val),
12446                LinkinfoIptunAttrs::_6rdPrefix(val) => fmt.field("_6rdPrefix", &val),
12447                LinkinfoIptunAttrs::_6rdRelayPrefix(val) => fmt.field("_6rdRelayPrefix", &val),
12448                LinkinfoIptunAttrs::_6rdPrefixlen(val) => fmt.field("_6rdPrefixlen", &val),
12449                LinkinfoIptunAttrs::_6rdRelayPrefixlen(val) => {
12450                    fmt.field("_6rdRelayPrefixlen", &val)
12451                }
12452                LinkinfoIptunAttrs::EncapType(val) => fmt.field("EncapType", &val),
12453                LinkinfoIptunAttrs::EncapFlags(val) => fmt.field("EncapFlags", &val),
12454                LinkinfoIptunAttrs::EncapSport(val) => fmt.field("EncapSport", &val),
12455                LinkinfoIptunAttrs::EncapDport(val) => fmt.field("EncapDport", &val),
12456                LinkinfoIptunAttrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
12457                LinkinfoIptunAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
12458            };
12459        }
12460        fmt.finish()
12461    }
12462}
12463impl IterableLinkinfoIptunAttrs<'_> {
12464    pub fn lookup_attr(
12465        &self,
12466        offset: usize,
12467        missing_type: Option<u16>,
12468    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
12469        let mut stack = Vec::new();
12470        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
12471        if cur == offset {
12472            stack.push(("LinkinfoIptunAttrs", offset));
12473            return (
12474                stack,
12475                missing_type.and_then(|t| LinkinfoIptunAttrs::attr_from_type(t)),
12476            );
12477        }
12478        if cur > offset || cur + self.buf.len() < offset {
12479            return (stack, None);
12480        }
12481        let mut attrs = self.clone();
12482        let mut last_off = cur + attrs.pos;
12483        while let Some(attr) = attrs.next() {
12484            let Ok(attr) = attr else { break };
12485            match attr {
12486                LinkinfoIptunAttrs::Link(val) => {
12487                    if last_off == offset {
12488                        stack.push(("Link", last_off));
12489                        break;
12490                    }
12491                }
12492                LinkinfoIptunAttrs::Local(val) => {
12493                    if last_off == offset {
12494                        stack.push(("Local", last_off));
12495                        break;
12496                    }
12497                }
12498                LinkinfoIptunAttrs::Remote(val) => {
12499                    if last_off == offset {
12500                        stack.push(("Remote", last_off));
12501                        break;
12502                    }
12503                }
12504                LinkinfoIptunAttrs::Ttl(val) => {
12505                    if last_off == offset {
12506                        stack.push(("Ttl", last_off));
12507                        break;
12508                    }
12509                }
12510                LinkinfoIptunAttrs::Tos(val) => {
12511                    if last_off == offset {
12512                        stack.push(("Tos", last_off));
12513                        break;
12514                    }
12515                }
12516                LinkinfoIptunAttrs::EncapLimit(val) => {
12517                    if last_off == offset {
12518                        stack.push(("EncapLimit", last_off));
12519                        break;
12520                    }
12521                }
12522                LinkinfoIptunAttrs::Flowinfo(val) => {
12523                    if last_off == offset {
12524                        stack.push(("Flowinfo", last_off));
12525                        break;
12526                    }
12527                }
12528                LinkinfoIptunAttrs::Flags(val) => {
12529                    if last_off == offset {
12530                        stack.push(("Flags", last_off));
12531                        break;
12532                    }
12533                }
12534                LinkinfoIptunAttrs::Proto(val) => {
12535                    if last_off == offset {
12536                        stack.push(("Proto", last_off));
12537                        break;
12538                    }
12539                }
12540                LinkinfoIptunAttrs::Pmtudisc(val) => {
12541                    if last_off == offset {
12542                        stack.push(("Pmtudisc", last_off));
12543                        break;
12544                    }
12545                }
12546                LinkinfoIptunAttrs::_6rdPrefix(val) => {
12547                    if last_off == offset {
12548                        stack.push(("6rdPrefix", last_off));
12549                        break;
12550                    }
12551                }
12552                LinkinfoIptunAttrs::_6rdRelayPrefix(val) => {
12553                    if last_off == offset {
12554                        stack.push(("6rdRelayPrefix", last_off));
12555                        break;
12556                    }
12557                }
12558                LinkinfoIptunAttrs::_6rdPrefixlen(val) => {
12559                    if last_off == offset {
12560                        stack.push(("6rdPrefixlen", last_off));
12561                        break;
12562                    }
12563                }
12564                LinkinfoIptunAttrs::_6rdRelayPrefixlen(val) => {
12565                    if last_off == offset {
12566                        stack.push(("6rdRelayPrefixlen", last_off));
12567                        break;
12568                    }
12569                }
12570                LinkinfoIptunAttrs::EncapType(val) => {
12571                    if last_off == offset {
12572                        stack.push(("EncapType", last_off));
12573                        break;
12574                    }
12575                }
12576                LinkinfoIptunAttrs::EncapFlags(val) => {
12577                    if last_off == offset {
12578                        stack.push(("EncapFlags", last_off));
12579                        break;
12580                    }
12581                }
12582                LinkinfoIptunAttrs::EncapSport(val) => {
12583                    if last_off == offset {
12584                        stack.push(("EncapSport", last_off));
12585                        break;
12586                    }
12587                }
12588                LinkinfoIptunAttrs::EncapDport(val) => {
12589                    if last_off == offset {
12590                        stack.push(("EncapDport", last_off));
12591                        break;
12592                    }
12593                }
12594                LinkinfoIptunAttrs::CollectMetadata(val) => {
12595                    if last_off == offset {
12596                        stack.push(("CollectMetadata", last_off));
12597                        break;
12598                    }
12599                }
12600                LinkinfoIptunAttrs::Fwmark(val) => {
12601                    if last_off == offset {
12602                        stack.push(("Fwmark", last_off));
12603                        break;
12604                    }
12605                }
12606                _ => {}
12607            };
12608            last_off = cur + attrs.pos;
12609        }
12610        if !stack.is_empty() {
12611            stack.push(("LinkinfoIptunAttrs", cur));
12612        }
12613        (stack, None)
12614    }
12615}
12616#[derive(Clone)]
12617pub enum LinkinfoIp6tnlAttrs<'a> {
12618    Link(u32),
12619    Local(&'a [u8]),
12620    Remote(&'a [u8]),
12621    Ttl(u8),
12622    EncapLimit(u8),
12623    Flowinfo(u32),
12624    Flags(u32),
12625    Proto(u8),
12626    EncapType(u16),
12627    EncapFlags(u16),
12628    EncapSport(u16),
12629    EncapDport(u16),
12630    CollectMetadata(()),
12631    Fwmark(u32),
12632}
12633impl<'a> IterableLinkinfoIp6tnlAttrs<'a> {
12634    pub fn get_link(&self) -> Result<u32, ErrorContext> {
12635        let mut iter = self.clone();
12636        iter.pos = 0;
12637        for attr in iter {
12638            if let LinkinfoIp6tnlAttrs::Link(val) = attr? {
12639                return Ok(val);
12640            }
12641        }
12642        Err(ErrorContext::new_missing(
12643            "LinkinfoIp6tnlAttrs",
12644            "Link",
12645            self.orig_loc,
12646            self.buf.as_ptr() as usize,
12647        ))
12648    }
12649    pub fn get_local(&self) -> Result<&'a [u8], ErrorContext> {
12650        let mut iter = self.clone();
12651        iter.pos = 0;
12652        for attr in iter {
12653            if let LinkinfoIp6tnlAttrs::Local(val) = attr? {
12654                return Ok(val);
12655            }
12656        }
12657        Err(ErrorContext::new_missing(
12658            "LinkinfoIp6tnlAttrs",
12659            "Local",
12660            self.orig_loc,
12661            self.buf.as_ptr() as usize,
12662        ))
12663    }
12664    pub fn get_remote(&self) -> Result<&'a [u8], ErrorContext> {
12665        let mut iter = self.clone();
12666        iter.pos = 0;
12667        for attr in iter {
12668            if let LinkinfoIp6tnlAttrs::Remote(val) = attr? {
12669                return Ok(val);
12670            }
12671        }
12672        Err(ErrorContext::new_missing(
12673            "LinkinfoIp6tnlAttrs",
12674            "Remote",
12675            self.orig_loc,
12676            self.buf.as_ptr() as usize,
12677        ))
12678    }
12679    pub fn get_ttl(&self) -> Result<u8, ErrorContext> {
12680        let mut iter = self.clone();
12681        iter.pos = 0;
12682        for attr in iter {
12683            if let LinkinfoIp6tnlAttrs::Ttl(val) = attr? {
12684                return Ok(val);
12685            }
12686        }
12687        Err(ErrorContext::new_missing(
12688            "LinkinfoIp6tnlAttrs",
12689            "Ttl",
12690            self.orig_loc,
12691            self.buf.as_ptr() as usize,
12692        ))
12693    }
12694    pub fn get_encap_limit(&self) -> Result<u8, ErrorContext> {
12695        let mut iter = self.clone();
12696        iter.pos = 0;
12697        for attr in iter {
12698            if let LinkinfoIp6tnlAttrs::EncapLimit(val) = attr? {
12699                return Ok(val);
12700            }
12701        }
12702        Err(ErrorContext::new_missing(
12703            "LinkinfoIp6tnlAttrs",
12704            "EncapLimit",
12705            self.orig_loc,
12706            self.buf.as_ptr() as usize,
12707        ))
12708    }
12709    pub fn get_flowinfo(&self) -> Result<u32, ErrorContext> {
12710        let mut iter = self.clone();
12711        iter.pos = 0;
12712        for attr in iter {
12713            if let LinkinfoIp6tnlAttrs::Flowinfo(val) = attr? {
12714                return Ok(val);
12715            }
12716        }
12717        Err(ErrorContext::new_missing(
12718            "LinkinfoIp6tnlAttrs",
12719            "Flowinfo",
12720            self.orig_loc,
12721            self.buf.as_ptr() as usize,
12722        ))
12723    }
12724    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
12725        let mut iter = self.clone();
12726        iter.pos = 0;
12727        for attr in iter {
12728            if let LinkinfoIp6tnlAttrs::Flags(val) = attr? {
12729                return Ok(val);
12730            }
12731        }
12732        Err(ErrorContext::new_missing(
12733            "LinkinfoIp6tnlAttrs",
12734            "Flags",
12735            self.orig_loc,
12736            self.buf.as_ptr() as usize,
12737        ))
12738    }
12739    pub fn get_proto(&self) -> Result<u8, ErrorContext> {
12740        let mut iter = self.clone();
12741        iter.pos = 0;
12742        for attr in iter {
12743            if let LinkinfoIp6tnlAttrs::Proto(val) = attr? {
12744                return Ok(val);
12745            }
12746        }
12747        Err(ErrorContext::new_missing(
12748            "LinkinfoIp6tnlAttrs",
12749            "Proto",
12750            self.orig_loc,
12751            self.buf.as_ptr() as usize,
12752        ))
12753    }
12754    pub fn get_encap_type(&self) -> Result<u16, ErrorContext> {
12755        let mut iter = self.clone();
12756        iter.pos = 0;
12757        for attr in iter {
12758            if let LinkinfoIp6tnlAttrs::EncapType(val) = attr? {
12759                return Ok(val);
12760            }
12761        }
12762        Err(ErrorContext::new_missing(
12763            "LinkinfoIp6tnlAttrs",
12764            "EncapType",
12765            self.orig_loc,
12766            self.buf.as_ptr() as usize,
12767        ))
12768    }
12769    pub fn get_encap_flags(&self) -> Result<u16, ErrorContext> {
12770        let mut iter = self.clone();
12771        iter.pos = 0;
12772        for attr in iter {
12773            if let LinkinfoIp6tnlAttrs::EncapFlags(val) = attr? {
12774                return Ok(val);
12775            }
12776        }
12777        Err(ErrorContext::new_missing(
12778            "LinkinfoIp6tnlAttrs",
12779            "EncapFlags",
12780            self.orig_loc,
12781            self.buf.as_ptr() as usize,
12782        ))
12783    }
12784    pub fn get_encap_sport(&self) -> Result<u16, ErrorContext> {
12785        let mut iter = self.clone();
12786        iter.pos = 0;
12787        for attr in iter {
12788            if let LinkinfoIp6tnlAttrs::EncapSport(val) = attr? {
12789                return Ok(val);
12790            }
12791        }
12792        Err(ErrorContext::new_missing(
12793            "LinkinfoIp6tnlAttrs",
12794            "EncapSport",
12795            self.orig_loc,
12796            self.buf.as_ptr() as usize,
12797        ))
12798    }
12799    pub fn get_encap_dport(&self) -> Result<u16, ErrorContext> {
12800        let mut iter = self.clone();
12801        iter.pos = 0;
12802        for attr in iter {
12803            if let LinkinfoIp6tnlAttrs::EncapDport(val) = attr? {
12804                return Ok(val);
12805            }
12806        }
12807        Err(ErrorContext::new_missing(
12808            "LinkinfoIp6tnlAttrs",
12809            "EncapDport",
12810            self.orig_loc,
12811            self.buf.as_ptr() as usize,
12812        ))
12813    }
12814    pub fn get_collect_metadata(&self) -> Result<(), ErrorContext> {
12815        let mut iter = self.clone();
12816        iter.pos = 0;
12817        for attr in iter {
12818            if let LinkinfoIp6tnlAttrs::CollectMetadata(val) = attr? {
12819                return Ok(val);
12820            }
12821        }
12822        Err(ErrorContext::new_missing(
12823            "LinkinfoIp6tnlAttrs",
12824            "CollectMetadata",
12825            self.orig_loc,
12826            self.buf.as_ptr() as usize,
12827        ))
12828    }
12829    pub fn get_fwmark(&self) -> Result<u32, ErrorContext> {
12830        let mut iter = self.clone();
12831        iter.pos = 0;
12832        for attr in iter {
12833            if let LinkinfoIp6tnlAttrs::Fwmark(val) = attr? {
12834                return Ok(val);
12835            }
12836        }
12837        Err(ErrorContext::new_missing(
12838            "LinkinfoIp6tnlAttrs",
12839            "Fwmark",
12840            self.orig_loc,
12841            self.buf.as_ptr() as usize,
12842        ))
12843    }
12844}
12845impl<'a> LinkinfoIp6tnlAttrs<'a> {
12846    pub fn new(buf: &'a [u8]) -> IterableLinkinfoIp6tnlAttrs<'a> {
12847        IterableLinkinfoIp6tnlAttrs::with_loc(buf, buf.as_ptr() as usize)
12848    }
12849    fn attr_from_type(r#type: u16) -> Option<&'static str> {
12850        let res = match r#type {
12851            1u16 => "Link",
12852            2u16 => "Local",
12853            3u16 => "Remote",
12854            4u16 => "Ttl",
12855            5u16 => "EncapLimit",
12856            6u16 => "Flowinfo",
12857            7u16 => "Flags",
12858            8u16 => "Proto",
12859            9u16 => "EncapType",
12860            10u16 => "EncapFlags",
12861            11u16 => "EncapSport",
12862            12u16 => "EncapDport",
12863            13u16 => "CollectMetadata",
12864            14u16 => "Fwmark",
12865            _ => return None,
12866        };
12867        Some(res)
12868    }
12869}
12870#[derive(Clone, Copy, Default)]
12871pub struct IterableLinkinfoIp6tnlAttrs<'a> {
12872    buf: &'a [u8],
12873    pos: usize,
12874    orig_loc: usize,
12875}
12876impl<'a> IterableLinkinfoIp6tnlAttrs<'a> {
12877    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
12878        Self {
12879            buf,
12880            pos: 0,
12881            orig_loc,
12882        }
12883    }
12884    pub fn get_buf(&self) -> &'a [u8] {
12885        self.buf
12886    }
12887}
12888impl<'a> Iterator for IterableLinkinfoIp6tnlAttrs<'a> {
12889    type Item = Result<LinkinfoIp6tnlAttrs<'a>, ErrorContext>;
12890    fn next(&mut self) -> Option<Self::Item> {
12891        if self.buf.len() == self.pos {
12892            return None;
12893        }
12894        let pos = self.pos;
12895        let mut r#type = None;
12896        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
12897            r#type = Some(header.r#type);
12898            let res = match header.r#type {
12899                1u16 => LinkinfoIp6tnlAttrs::Link({
12900                    let res = parse_u32(next);
12901                    let Some(val) = res else { break };
12902                    val
12903                }),
12904                2u16 => LinkinfoIp6tnlAttrs::Local({
12905                    let res = Some(next);
12906                    let Some(val) = res else { break };
12907                    val
12908                }),
12909                3u16 => LinkinfoIp6tnlAttrs::Remote({
12910                    let res = Some(next);
12911                    let Some(val) = res else { break };
12912                    val
12913                }),
12914                4u16 => LinkinfoIp6tnlAttrs::Ttl({
12915                    let res = parse_u8(next);
12916                    let Some(val) = res else { break };
12917                    val
12918                }),
12919                5u16 => LinkinfoIp6tnlAttrs::EncapLimit({
12920                    let res = parse_u8(next);
12921                    let Some(val) = res else { break };
12922                    val
12923                }),
12924                6u16 => LinkinfoIp6tnlAttrs::Flowinfo({
12925                    let res = parse_be_u32(next);
12926                    let Some(val) = res else { break };
12927                    val
12928                }),
12929                7u16 => LinkinfoIp6tnlAttrs::Flags({
12930                    let res = parse_u32(next);
12931                    let Some(val) = res else { break };
12932                    val
12933                }),
12934                8u16 => LinkinfoIp6tnlAttrs::Proto({
12935                    let res = parse_u8(next);
12936                    let Some(val) = res else { break };
12937                    val
12938                }),
12939                9u16 => LinkinfoIp6tnlAttrs::EncapType({
12940                    let res = parse_u16(next);
12941                    let Some(val) = res else { break };
12942                    val
12943                }),
12944                10u16 => LinkinfoIp6tnlAttrs::EncapFlags({
12945                    let res = parse_u16(next);
12946                    let Some(val) = res else { break };
12947                    val
12948                }),
12949                11u16 => LinkinfoIp6tnlAttrs::EncapSport({
12950                    let res = parse_be_u16(next);
12951                    let Some(val) = res else { break };
12952                    val
12953                }),
12954                12u16 => LinkinfoIp6tnlAttrs::EncapDport({
12955                    let res = parse_be_u16(next);
12956                    let Some(val) = res else { break };
12957                    val
12958                }),
12959                13u16 => LinkinfoIp6tnlAttrs::CollectMetadata(()),
12960                14u16 => LinkinfoIp6tnlAttrs::Fwmark({
12961                    let res = parse_u32(next);
12962                    let Some(val) = res else { break };
12963                    val
12964                }),
12965                n => {
12966                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
12967                        break;
12968                    } else {
12969                        continue;
12970                    }
12971                }
12972            };
12973            return Some(Ok(res));
12974        }
12975        Some(Err(ErrorContext::new(
12976            "LinkinfoIp6tnlAttrs",
12977            r#type.and_then(|t| LinkinfoIp6tnlAttrs::attr_from_type(t)),
12978            self.orig_loc,
12979            self.buf.as_ptr().wrapping_add(pos) as usize,
12980        )))
12981    }
12982}
12983impl<'a> std::fmt::Debug for IterableLinkinfoIp6tnlAttrs<'_> {
12984    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12985        let mut fmt = f.debug_struct("LinkinfoIp6tnlAttrs");
12986        for attr in self.clone() {
12987            let attr = match attr {
12988                Ok(a) => a,
12989                Err(err) => {
12990                    fmt.finish()?;
12991                    f.write_str("Err(")?;
12992                    err.fmt(f)?;
12993                    return f.write_str(")");
12994                }
12995            };
12996            match attr {
12997                LinkinfoIp6tnlAttrs::Link(val) => fmt.field("Link", &val),
12998                LinkinfoIp6tnlAttrs::Local(val) => fmt.field("Local", &val),
12999                LinkinfoIp6tnlAttrs::Remote(val) => fmt.field("Remote", &val),
13000                LinkinfoIp6tnlAttrs::Ttl(val) => fmt.field("Ttl", &val),
13001                LinkinfoIp6tnlAttrs::EncapLimit(val) => fmt.field("EncapLimit", &val),
13002                LinkinfoIp6tnlAttrs::Flowinfo(val) => fmt.field("Flowinfo", &val),
13003                LinkinfoIp6tnlAttrs::Flags(val) => fmt.field("Flags", &val),
13004                LinkinfoIp6tnlAttrs::Proto(val) => fmt.field("Proto", &val),
13005                LinkinfoIp6tnlAttrs::EncapType(val) => fmt.field("EncapType", &val),
13006                LinkinfoIp6tnlAttrs::EncapFlags(val) => fmt.field("EncapFlags", &val),
13007                LinkinfoIp6tnlAttrs::EncapSport(val) => fmt.field("EncapSport", &val),
13008                LinkinfoIp6tnlAttrs::EncapDport(val) => fmt.field("EncapDport", &val),
13009                LinkinfoIp6tnlAttrs::CollectMetadata(val) => fmt.field("CollectMetadata", &val),
13010                LinkinfoIp6tnlAttrs::Fwmark(val) => fmt.field("Fwmark", &val),
13011            };
13012        }
13013        fmt.finish()
13014    }
13015}
13016impl IterableLinkinfoIp6tnlAttrs<'_> {
13017    pub fn lookup_attr(
13018        &self,
13019        offset: usize,
13020        missing_type: Option<u16>,
13021    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13022        let mut stack = Vec::new();
13023        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13024        if cur == offset {
13025            stack.push(("LinkinfoIp6tnlAttrs", offset));
13026            return (
13027                stack,
13028                missing_type.and_then(|t| LinkinfoIp6tnlAttrs::attr_from_type(t)),
13029            );
13030        }
13031        if cur > offset || cur + self.buf.len() < offset {
13032            return (stack, None);
13033        }
13034        let mut attrs = self.clone();
13035        let mut last_off = cur + attrs.pos;
13036        while let Some(attr) = attrs.next() {
13037            let Ok(attr) = attr else { break };
13038            match attr {
13039                LinkinfoIp6tnlAttrs::Link(val) => {
13040                    if last_off == offset {
13041                        stack.push(("Link", last_off));
13042                        break;
13043                    }
13044                }
13045                LinkinfoIp6tnlAttrs::Local(val) => {
13046                    if last_off == offset {
13047                        stack.push(("Local", last_off));
13048                        break;
13049                    }
13050                }
13051                LinkinfoIp6tnlAttrs::Remote(val) => {
13052                    if last_off == offset {
13053                        stack.push(("Remote", last_off));
13054                        break;
13055                    }
13056                }
13057                LinkinfoIp6tnlAttrs::Ttl(val) => {
13058                    if last_off == offset {
13059                        stack.push(("Ttl", last_off));
13060                        break;
13061                    }
13062                }
13063                LinkinfoIp6tnlAttrs::EncapLimit(val) => {
13064                    if last_off == offset {
13065                        stack.push(("EncapLimit", last_off));
13066                        break;
13067                    }
13068                }
13069                LinkinfoIp6tnlAttrs::Flowinfo(val) => {
13070                    if last_off == offset {
13071                        stack.push(("Flowinfo", last_off));
13072                        break;
13073                    }
13074                }
13075                LinkinfoIp6tnlAttrs::Flags(val) => {
13076                    if last_off == offset {
13077                        stack.push(("Flags", last_off));
13078                        break;
13079                    }
13080                }
13081                LinkinfoIp6tnlAttrs::Proto(val) => {
13082                    if last_off == offset {
13083                        stack.push(("Proto", last_off));
13084                        break;
13085                    }
13086                }
13087                LinkinfoIp6tnlAttrs::EncapType(val) => {
13088                    if last_off == offset {
13089                        stack.push(("EncapType", last_off));
13090                        break;
13091                    }
13092                }
13093                LinkinfoIp6tnlAttrs::EncapFlags(val) => {
13094                    if last_off == offset {
13095                        stack.push(("EncapFlags", last_off));
13096                        break;
13097                    }
13098                }
13099                LinkinfoIp6tnlAttrs::EncapSport(val) => {
13100                    if last_off == offset {
13101                        stack.push(("EncapSport", last_off));
13102                        break;
13103                    }
13104                }
13105                LinkinfoIp6tnlAttrs::EncapDport(val) => {
13106                    if last_off == offset {
13107                        stack.push(("EncapDport", last_off));
13108                        break;
13109                    }
13110                }
13111                LinkinfoIp6tnlAttrs::CollectMetadata(val) => {
13112                    if last_off == offset {
13113                        stack.push(("CollectMetadata", last_off));
13114                        break;
13115                    }
13116                }
13117                LinkinfoIp6tnlAttrs::Fwmark(val) => {
13118                    if last_off == offset {
13119                        stack.push(("Fwmark", last_off));
13120                        break;
13121                    }
13122                }
13123                _ => {}
13124            };
13125            last_off = cur + attrs.pos;
13126        }
13127        if !stack.is_empty() {
13128            stack.push(("LinkinfoIp6tnlAttrs", cur));
13129        }
13130        (stack, None)
13131    }
13132}
13133#[derive(Clone)]
13134pub enum LinkinfoTunAttrs {
13135    Owner(u32),
13136    Group(u32),
13137    Type(u8),
13138    Pi(u8),
13139    VnetHdr(u8),
13140    Persist(u8),
13141    MultiQueue(u8),
13142    NumQueues(u32),
13143    NumDisabledQueues(u32),
13144}
13145impl<'a> IterableLinkinfoTunAttrs<'a> {
13146    pub fn get_owner(&self) -> Result<u32, ErrorContext> {
13147        let mut iter = self.clone();
13148        iter.pos = 0;
13149        for attr in iter {
13150            if let LinkinfoTunAttrs::Owner(val) = attr? {
13151                return Ok(val);
13152            }
13153        }
13154        Err(ErrorContext::new_missing(
13155            "LinkinfoTunAttrs",
13156            "Owner",
13157            self.orig_loc,
13158            self.buf.as_ptr() as usize,
13159        ))
13160    }
13161    pub fn get_group(&self) -> Result<u32, ErrorContext> {
13162        let mut iter = self.clone();
13163        iter.pos = 0;
13164        for attr in iter {
13165            if let LinkinfoTunAttrs::Group(val) = attr? {
13166                return Ok(val);
13167            }
13168        }
13169        Err(ErrorContext::new_missing(
13170            "LinkinfoTunAttrs",
13171            "Group",
13172            self.orig_loc,
13173            self.buf.as_ptr() as usize,
13174        ))
13175    }
13176    pub fn get_type(&self) -> Result<u8, ErrorContext> {
13177        let mut iter = self.clone();
13178        iter.pos = 0;
13179        for attr in iter {
13180            if let LinkinfoTunAttrs::Type(val) = attr? {
13181                return Ok(val);
13182            }
13183        }
13184        Err(ErrorContext::new_missing(
13185            "LinkinfoTunAttrs",
13186            "Type",
13187            self.orig_loc,
13188            self.buf.as_ptr() as usize,
13189        ))
13190    }
13191    pub fn get_pi(&self) -> Result<u8, ErrorContext> {
13192        let mut iter = self.clone();
13193        iter.pos = 0;
13194        for attr in iter {
13195            if let LinkinfoTunAttrs::Pi(val) = attr? {
13196                return Ok(val);
13197            }
13198        }
13199        Err(ErrorContext::new_missing(
13200            "LinkinfoTunAttrs",
13201            "Pi",
13202            self.orig_loc,
13203            self.buf.as_ptr() as usize,
13204        ))
13205    }
13206    pub fn get_vnet_hdr(&self) -> Result<u8, ErrorContext> {
13207        let mut iter = self.clone();
13208        iter.pos = 0;
13209        for attr in iter {
13210            if let LinkinfoTunAttrs::VnetHdr(val) = attr? {
13211                return Ok(val);
13212            }
13213        }
13214        Err(ErrorContext::new_missing(
13215            "LinkinfoTunAttrs",
13216            "VnetHdr",
13217            self.orig_loc,
13218            self.buf.as_ptr() as usize,
13219        ))
13220    }
13221    pub fn get_persist(&self) -> Result<u8, ErrorContext> {
13222        let mut iter = self.clone();
13223        iter.pos = 0;
13224        for attr in iter {
13225            if let LinkinfoTunAttrs::Persist(val) = attr? {
13226                return Ok(val);
13227            }
13228        }
13229        Err(ErrorContext::new_missing(
13230            "LinkinfoTunAttrs",
13231            "Persist",
13232            self.orig_loc,
13233            self.buf.as_ptr() as usize,
13234        ))
13235    }
13236    pub fn get_multi_queue(&self) -> Result<u8, ErrorContext> {
13237        let mut iter = self.clone();
13238        iter.pos = 0;
13239        for attr in iter {
13240            if let LinkinfoTunAttrs::MultiQueue(val) = attr? {
13241                return Ok(val);
13242            }
13243        }
13244        Err(ErrorContext::new_missing(
13245            "LinkinfoTunAttrs",
13246            "MultiQueue",
13247            self.orig_loc,
13248            self.buf.as_ptr() as usize,
13249        ))
13250    }
13251    pub fn get_num_queues(&self) -> Result<u32, ErrorContext> {
13252        let mut iter = self.clone();
13253        iter.pos = 0;
13254        for attr in iter {
13255            if let LinkinfoTunAttrs::NumQueues(val) = attr? {
13256                return Ok(val);
13257            }
13258        }
13259        Err(ErrorContext::new_missing(
13260            "LinkinfoTunAttrs",
13261            "NumQueues",
13262            self.orig_loc,
13263            self.buf.as_ptr() as usize,
13264        ))
13265    }
13266    pub fn get_num_disabled_queues(&self) -> Result<u32, ErrorContext> {
13267        let mut iter = self.clone();
13268        iter.pos = 0;
13269        for attr in iter {
13270            if let LinkinfoTunAttrs::NumDisabledQueues(val) = attr? {
13271                return Ok(val);
13272            }
13273        }
13274        Err(ErrorContext::new_missing(
13275            "LinkinfoTunAttrs",
13276            "NumDisabledQueues",
13277            self.orig_loc,
13278            self.buf.as_ptr() as usize,
13279        ))
13280    }
13281}
13282impl LinkinfoTunAttrs {
13283    pub fn new(buf: &'_ [u8]) -> IterableLinkinfoTunAttrs<'_> {
13284        IterableLinkinfoTunAttrs::with_loc(buf, buf.as_ptr() as usize)
13285    }
13286    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13287        let res = match r#type {
13288            1u16 => "Owner",
13289            2u16 => "Group",
13290            3u16 => "Type",
13291            4u16 => "Pi",
13292            5u16 => "VnetHdr",
13293            6u16 => "Persist",
13294            7u16 => "MultiQueue",
13295            8u16 => "NumQueues",
13296            9u16 => "NumDisabledQueues",
13297            _ => return None,
13298        };
13299        Some(res)
13300    }
13301}
13302#[derive(Clone, Copy, Default)]
13303pub struct IterableLinkinfoTunAttrs<'a> {
13304    buf: &'a [u8],
13305    pos: usize,
13306    orig_loc: usize,
13307}
13308impl<'a> IterableLinkinfoTunAttrs<'a> {
13309    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13310        Self {
13311            buf,
13312            pos: 0,
13313            orig_loc,
13314        }
13315    }
13316    pub fn get_buf(&self) -> &'a [u8] {
13317        self.buf
13318    }
13319}
13320impl<'a> Iterator for IterableLinkinfoTunAttrs<'a> {
13321    type Item = Result<LinkinfoTunAttrs, ErrorContext>;
13322    fn next(&mut self) -> Option<Self::Item> {
13323        if self.buf.len() == self.pos {
13324            return None;
13325        }
13326        let pos = self.pos;
13327        let mut r#type = None;
13328        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
13329            r#type = Some(header.r#type);
13330            let res = match header.r#type {
13331                1u16 => LinkinfoTunAttrs::Owner({
13332                    let res = parse_u32(next);
13333                    let Some(val) = res else { break };
13334                    val
13335                }),
13336                2u16 => LinkinfoTunAttrs::Group({
13337                    let res = parse_u32(next);
13338                    let Some(val) = res else { break };
13339                    val
13340                }),
13341                3u16 => LinkinfoTunAttrs::Type({
13342                    let res = parse_u8(next);
13343                    let Some(val) = res else { break };
13344                    val
13345                }),
13346                4u16 => LinkinfoTunAttrs::Pi({
13347                    let res = parse_u8(next);
13348                    let Some(val) = res else { break };
13349                    val
13350                }),
13351                5u16 => LinkinfoTunAttrs::VnetHdr({
13352                    let res = parse_u8(next);
13353                    let Some(val) = res else { break };
13354                    val
13355                }),
13356                6u16 => LinkinfoTunAttrs::Persist({
13357                    let res = parse_u8(next);
13358                    let Some(val) = res else { break };
13359                    val
13360                }),
13361                7u16 => LinkinfoTunAttrs::MultiQueue({
13362                    let res = parse_u8(next);
13363                    let Some(val) = res else { break };
13364                    val
13365                }),
13366                8u16 => LinkinfoTunAttrs::NumQueues({
13367                    let res = parse_u32(next);
13368                    let Some(val) = res else { break };
13369                    val
13370                }),
13371                9u16 => LinkinfoTunAttrs::NumDisabledQueues({
13372                    let res = parse_u32(next);
13373                    let Some(val) = res else { break };
13374                    val
13375                }),
13376                n => {
13377                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
13378                        break;
13379                    } else {
13380                        continue;
13381                    }
13382                }
13383            };
13384            return Some(Ok(res));
13385        }
13386        Some(Err(ErrorContext::new(
13387            "LinkinfoTunAttrs",
13388            r#type.and_then(|t| LinkinfoTunAttrs::attr_from_type(t)),
13389            self.orig_loc,
13390            self.buf.as_ptr().wrapping_add(pos) as usize,
13391        )))
13392    }
13393}
13394impl std::fmt::Debug for IterableLinkinfoTunAttrs<'_> {
13395    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13396        let mut fmt = f.debug_struct("LinkinfoTunAttrs");
13397        for attr in self.clone() {
13398            let attr = match attr {
13399                Ok(a) => a,
13400                Err(err) => {
13401                    fmt.finish()?;
13402                    f.write_str("Err(")?;
13403                    err.fmt(f)?;
13404                    return f.write_str(")");
13405                }
13406            };
13407            match attr {
13408                LinkinfoTunAttrs::Owner(val) => fmt.field("Owner", &val),
13409                LinkinfoTunAttrs::Group(val) => fmt.field("Group", &val),
13410                LinkinfoTunAttrs::Type(val) => fmt.field("Type", &val),
13411                LinkinfoTunAttrs::Pi(val) => fmt.field("Pi", &val),
13412                LinkinfoTunAttrs::VnetHdr(val) => fmt.field("VnetHdr", &val),
13413                LinkinfoTunAttrs::Persist(val) => fmt.field("Persist", &val),
13414                LinkinfoTunAttrs::MultiQueue(val) => fmt.field("MultiQueue", &val),
13415                LinkinfoTunAttrs::NumQueues(val) => fmt.field("NumQueues", &val),
13416                LinkinfoTunAttrs::NumDisabledQueues(val) => fmt.field("NumDisabledQueues", &val),
13417            };
13418        }
13419        fmt.finish()
13420    }
13421}
13422impl IterableLinkinfoTunAttrs<'_> {
13423    pub fn lookup_attr(
13424        &self,
13425        offset: usize,
13426        missing_type: Option<u16>,
13427    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13428        let mut stack = Vec::new();
13429        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13430        if cur == offset {
13431            stack.push(("LinkinfoTunAttrs", offset));
13432            return (
13433                stack,
13434                missing_type.and_then(|t| LinkinfoTunAttrs::attr_from_type(t)),
13435            );
13436        }
13437        if cur > offset || cur + self.buf.len() < offset {
13438            return (stack, None);
13439        }
13440        let mut attrs = self.clone();
13441        let mut last_off = cur + attrs.pos;
13442        while let Some(attr) = attrs.next() {
13443            let Ok(attr) = attr else { break };
13444            match attr {
13445                LinkinfoTunAttrs::Owner(val) => {
13446                    if last_off == offset {
13447                        stack.push(("Owner", last_off));
13448                        break;
13449                    }
13450                }
13451                LinkinfoTunAttrs::Group(val) => {
13452                    if last_off == offset {
13453                        stack.push(("Group", last_off));
13454                        break;
13455                    }
13456                }
13457                LinkinfoTunAttrs::Type(val) => {
13458                    if last_off == offset {
13459                        stack.push(("Type", last_off));
13460                        break;
13461                    }
13462                }
13463                LinkinfoTunAttrs::Pi(val) => {
13464                    if last_off == offset {
13465                        stack.push(("Pi", last_off));
13466                        break;
13467                    }
13468                }
13469                LinkinfoTunAttrs::VnetHdr(val) => {
13470                    if last_off == offset {
13471                        stack.push(("VnetHdr", last_off));
13472                        break;
13473                    }
13474                }
13475                LinkinfoTunAttrs::Persist(val) => {
13476                    if last_off == offset {
13477                        stack.push(("Persist", last_off));
13478                        break;
13479                    }
13480                }
13481                LinkinfoTunAttrs::MultiQueue(val) => {
13482                    if last_off == offset {
13483                        stack.push(("MultiQueue", last_off));
13484                        break;
13485                    }
13486                }
13487                LinkinfoTunAttrs::NumQueues(val) => {
13488                    if last_off == offset {
13489                        stack.push(("NumQueues", last_off));
13490                        break;
13491                    }
13492                }
13493                LinkinfoTunAttrs::NumDisabledQueues(val) => {
13494                    if last_off == offset {
13495                        stack.push(("NumDisabledQueues", last_off));
13496                        break;
13497                    }
13498                }
13499                _ => {}
13500            };
13501            last_off = cur + attrs.pos;
13502        }
13503        if !stack.is_empty() {
13504            stack.push(("LinkinfoTunAttrs", cur));
13505        }
13506        (stack, None)
13507    }
13508}
13509#[derive(Clone)]
13510pub enum LinkinfoVlanAttrs<'a> {
13511    Id(u16),
13512    Flags(PushIflaVlanFlags),
13513    EgressQos(IterableIflaVlanQos<'a>),
13514    IngressQos(IterableIflaVlanQos<'a>),
13515    #[doc = "Associated type: \"VlanProtocols\" (enum)"]
13516    Protocol(u16),
13517}
13518impl<'a> IterableLinkinfoVlanAttrs<'a> {
13519    pub fn get_id(&self) -> Result<u16, ErrorContext> {
13520        let mut iter = self.clone();
13521        iter.pos = 0;
13522        for attr in iter {
13523            if let LinkinfoVlanAttrs::Id(val) = attr? {
13524                return Ok(val);
13525            }
13526        }
13527        Err(ErrorContext::new_missing(
13528            "LinkinfoVlanAttrs",
13529            "Id",
13530            self.orig_loc,
13531            self.buf.as_ptr() as usize,
13532        ))
13533    }
13534    pub fn get_flags(&self) -> Result<PushIflaVlanFlags, ErrorContext> {
13535        let mut iter = self.clone();
13536        iter.pos = 0;
13537        for attr in iter {
13538            if let LinkinfoVlanAttrs::Flags(val) = attr? {
13539                return Ok(val);
13540            }
13541        }
13542        Err(ErrorContext::new_missing(
13543            "LinkinfoVlanAttrs",
13544            "Flags",
13545            self.orig_loc,
13546            self.buf.as_ptr() as usize,
13547        ))
13548    }
13549    pub fn get_egress_qos(&self) -> Result<IterableIflaVlanQos<'a>, ErrorContext> {
13550        let mut iter = self.clone();
13551        iter.pos = 0;
13552        for attr in iter {
13553            if let LinkinfoVlanAttrs::EgressQos(val) = attr? {
13554                return Ok(val);
13555            }
13556        }
13557        Err(ErrorContext::new_missing(
13558            "LinkinfoVlanAttrs",
13559            "EgressQos",
13560            self.orig_loc,
13561            self.buf.as_ptr() as usize,
13562        ))
13563    }
13564    pub fn get_ingress_qos(&self) -> Result<IterableIflaVlanQos<'a>, ErrorContext> {
13565        let mut iter = self.clone();
13566        iter.pos = 0;
13567        for attr in iter {
13568            if let LinkinfoVlanAttrs::IngressQos(val) = attr? {
13569                return Ok(val);
13570            }
13571        }
13572        Err(ErrorContext::new_missing(
13573            "LinkinfoVlanAttrs",
13574            "IngressQos",
13575            self.orig_loc,
13576            self.buf.as_ptr() as usize,
13577        ))
13578    }
13579    #[doc = "Associated type: \"VlanProtocols\" (enum)"]
13580    pub fn get_protocol(&self) -> Result<u16, ErrorContext> {
13581        let mut iter = self.clone();
13582        iter.pos = 0;
13583        for attr in iter {
13584            if let LinkinfoVlanAttrs::Protocol(val) = attr? {
13585                return Ok(val);
13586            }
13587        }
13588        Err(ErrorContext::new_missing(
13589            "LinkinfoVlanAttrs",
13590            "Protocol",
13591            self.orig_loc,
13592            self.buf.as_ptr() as usize,
13593        ))
13594    }
13595}
13596impl<'a> LinkinfoVlanAttrs<'a> {
13597    pub fn new(buf: &'a [u8]) -> IterableLinkinfoVlanAttrs<'a> {
13598        IterableLinkinfoVlanAttrs::with_loc(buf, buf.as_ptr() as usize)
13599    }
13600    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13601        let res = match r#type {
13602            1u16 => "Id",
13603            2u16 => "Flags",
13604            3u16 => "EgressQos",
13605            4u16 => "IngressQos",
13606            5u16 => "Protocol",
13607            _ => return None,
13608        };
13609        Some(res)
13610    }
13611}
13612#[derive(Clone, Copy, Default)]
13613pub struct IterableLinkinfoVlanAttrs<'a> {
13614    buf: &'a [u8],
13615    pos: usize,
13616    orig_loc: usize,
13617}
13618impl<'a> IterableLinkinfoVlanAttrs<'a> {
13619    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13620        Self {
13621            buf,
13622            pos: 0,
13623            orig_loc,
13624        }
13625    }
13626    pub fn get_buf(&self) -> &'a [u8] {
13627        self.buf
13628    }
13629}
13630impl<'a> Iterator for IterableLinkinfoVlanAttrs<'a> {
13631    type Item = Result<LinkinfoVlanAttrs<'a>, ErrorContext>;
13632    fn next(&mut self) -> Option<Self::Item> {
13633        if self.buf.len() == self.pos {
13634            return None;
13635        }
13636        let pos = self.pos;
13637        let mut r#type = None;
13638        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
13639            r#type = Some(header.r#type);
13640            let res = match header.r#type {
13641                1u16 => LinkinfoVlanAttrs::Id({
13642                    let res = parse_u16(next);
13643                    let Some(val) = res else { break };
13644                    val
13645                }),
13646                2u16 => LinkinfoVlanAttrs::Flags({
13647                    let res = PushIflaVlanFlags::new_from_slice(next);
13648                    let Some(val) = res else { break };
13649                    val
13650                }),
13651                3u16 => LinkinfoVlanAttrs::EgressQos({
13652                    let res = Some(IterableIflaVlanQos::with_loc(next, self.orig_loc));
13653                    let Some(val) = res else { break };
13654                    val
13655                }),
13656                4u16 => LinkinfoVlanAttrs::IngressQos({
13657                    let res = Some(IterableIflaVlanQos::with_loc(next, self.orig_loc));
13658                    let Some(val) = res else { break };
13659                    val
13660                }),
13661                5u16 => LinkinfoVlanAttrs::Protocol({
13662                    let res = parse_be_u16(next);
13663                    let Some(val) = res else { break };
13664                    val
13665                }),
13666                n => {
13667                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
13668                        break;
13669                    } else {
13670                        continue;
13671                    }
13672                }
13673            };
13674            return Some(Ok(res));
13675        }
13676        Some(Err(ErrorContext::new(
13677            "LinkinfoVlanAttrs",
13678            r#type.and_then(|t| LinkinfoVlanAttrs::attr_from_type(t)),
13679            self.orig_loc,
13680            self.buf.as_ptr().wrapping_add(pos) as usize,
13681        )))
13682    }
13683}
13684impl<'a> std::fmt::Debug for IterableLinkinfoVlanAttrs<'_> {
13685    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13686        let mut fmt = f.debug_struct("LinkinfoVlanAttrs");
13687        for attr in self.clone() {
13688            let attr = match attr {
13689                Ok(a) => a,
13690                Err(err) => {
13691                    fmt.finish()?;
13692                    f.write_str("Err(")?;
13693                    err.fmt(f)?;
13694                    return f.write_str(")");
13695                }
13696            };
13697            match attr {
13698                LinkinfoVlanAttrs::Id(val) => fmt.field("Id", &val),
13699                LinkinfoVlanAttrs::Flags(val) => fmt.field("Flags", &val),
13700                LinkinfoVlanAttrs::EgressQos(val) => fmt.field("EgressQos", &val),
13701                LinkinfoVlanAttrs::IngressQos(val) => fmt.field("IngressQos", &val),
13702                LinkinfoVlanAttrs::Protocol(val) => fmt.field(
13703                    "Protocol",
13704                    &FormatEnum(val.into(), VlanProtocols::from_value),
13705                ),
13706            };
13707        }
13708        fmt.finish()
13709    }
13710}
13711impl IterableLinkinfoVlanAttrs<'_> {
13712    pub fn lookup_attr(
13713        &self,
13714        offset: usize,
13715        missing_type: Option<u16>,
13716    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13717        let mut stack = Vec::new();
13718        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13719        if cur == offset {
13720            stack.push(("LinkinfoVlanAttrs", offset));
13721            return (
13722                stack,
13723                missing_type.and_then(|t| LinkinfoVlanAttrs::attr_from_type(t)),
13724            );
13725        }
13726        if cur > offset || cur + self.buf.len() < offset {
13727            return (stack, None);
13728        }
13729        let mut attrs = self.clone();
13730        let mut last_off = cur + attrs.pos;
13731        let mut missing = None;
13732        while let Some(attr) = attrs.next() {
13733            let Ok(attr) = attr else { break };
13734            match attr {
13735                LinkinfoVlanAttrs::Id(val) => {
13736                    if last_off == offset {
13737                        stack.push(("Id", last_off));
13738                        break;
13739                    }
13740                }
13741                LinkinfoVlanAttrs::Flags(val) => {
13742                    if last_off == offset {
13743                        stack.push(("Flags", last_off));
13744                        break;
13745                    }
13746                }
13747                LinkinfoVlanAttrs::EgressQos(val) => {
13748                    (stack, missing) = val.lookup_attr(offset, missing_type);
13749                    if !stack.is_empty() {
13750                        break;
13751                    }
13752                }
13753                LinkinfoVlanAttrs::IngressQos(val) => {
13754                    (stack, missing) = val.lookup_attr(offset, missing_type);
13755                    if !stack.is_empty() {
13756                        break;
13757                    }
13758                }
13759                LinkinfoVlanAttrs::Protocol(val) => {
13760                    if last_off == offset {
13761                        stack.push(("Protocol", last_off));
13762                        break;
13763                    }
13764                }
13765                _ => {}
13766            };
13767            last_off = cur + attrs.pos;
13768        }
13769        if !stack.is_empty() {
13770            stack.push(("LinkinfoVlanAttrs", cur));
13771        }
13772        (stack, missing)
13773    }
13774}
13775#[derive(Clone)]
13776pub enum IflaVlanQos {
13777    #[doc = "Attribute may repeat multiple times (treat it as array)"]
13778    Mapping(PushIflaVlanQosMapping),
13779}
13780impl<'a> IterableIflaVlanQos<'a> {
13781    #[doc = "Attribute may repeat multiple times (treat it as array)"]
13782    pub fn get_mapping(&self) -> MultiAttrIterable<Self, IflaVlanQos, PushIflaVlanQosMapping> {
13783        MultiAttrIterable::new(self.clone(), |variant| {
13784            if let IflaVlanQos::Mapping(val) = variant {
13785                Some(val)
13786            } else {
13787                None
13788            }
13789        })
13790    }
13791}
13792impl IflaVlanQos {
13793    pub fn new(buf: &'_ [u8]) -> IterableIflaVlanQos<'_> {
13794        IterableIflaVlanQos::with_loc(buf, buf.as_ptr() as usize)
13795    }
13796    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13797        let res = match r#type {
13798            1u16 => "Mapping",
13799            _ => return None,
13800        };
13801        Some(res)
13802    }
13803}
13804#[derive(Clone, Copy, Default)]
13805pub struct IterableIflaVlanQos<'a> {
13806    buf: &'a [u8],
13807    pos: usize,
13808    orig_loc: usize,
13809}
13810impl<'a> IterableIflaVlanQos<'a> {
13811    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13812        Self {
13813            buf,
13814            pos: 0,
13815            orig_loc,
13816        }
13817    }
13818    pub fn get_buf(&self) -> &'a [u8] {
13819        self.buf
13820    }
13821}
13822impl<'a> Iterator for IterableIflaVlanQos<'a> {
13823    type Item = Result<IflaVlanQos, ErrorContext>;
13824    fn next(&mut self) -> Option<Self::Item> {
13825        if self.buf.len() == self.pos {
13826            return None;
13827        }
13828        let pos = self.pos;
13829        let mut r#type = None;
13830        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
13831            r#type = Some(header.r#type);
13832            let res = match header.r#type {
13833                1u16 => IflaVlanQos::Mapping({
13834                    let res = PushIflaVlanQosMapping::new_from_slice(next);
13835                    let Some(val) = res else { break };
13836                    val
13837                }),
13838                n => {
13839                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
13840                        break;
13841                    } else {
13842                        continue;
13843                    }
13844                }
13845            };
13846            return Some(Ok(res));
13847        }
13848        Some(Err(ErrorContext::new(
13849            "IflaVlanQos",
13850            r#type.and_then(|t| IflaVlanQos::attr_from_type(t)),
13851            self.orig_loc,
13852            self.buf.as_ptr().wrapping_add(pos) as usize,
13853        )))
13854    }
13855}
13856impl std::fmt::Debug for IterableIflaVlanQos<'_> {
13857    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13858        let mut fmt = f.debug_struct("IflaVlanQos");
13859        for attr in self.clone() {
13860            let attr = match attr {
13861                Ok(a) => a,
13862                Err(err) => {
13863                    fmt.finish()?;
13864                    f.write_str("Err(")?;
13865                    err.fmt(f)?;
13866                    return f.write_str(")");
13867                }
13868            };
13869            match attr {
13870                IflaVlanQos::Mapping(val) => fmt.field("Mapping", &val),
13871            };
13872        }
13873        fmt.finish()
13874    }
13875}
13876impl IterableIflaVlanQos<'_> {
13877    pub fn lookup_attr(
13878        &self,
13879        offset: usize,
13880        missing_type: Option<u16>,
13881    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
13882        let mut stack = Vec::new();
13883        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
13884        if cur == offset {
13885            stack.push(("IflaVlanQos", offset));
13886            return (
13887                stack,
13888                missing_type.and_then(|t| IflaVlanQos::attr_from_type(t)),
13889            );
13890        }
13891        if cur > offset || cur + self.buf.len() < offset {
13892            return (stack, None);
13893        }
13894        let mut attrs = self.clone();
13895        let mut last_off = cur + attrs.pos;
13896        while let Some(attr) = attrs.next() {
13897            let Ok(attr) = attr else { break };
13898            match attr {
13899                IflaVlanQos::Mapping(val) => {
13900                    if last_off == offset {
13901                        stack.push(("Mapping", last_off));
13902                        break;
13903                    }
13904                }
13905                _ => {}
13906            };
13907            last_off = cur + attrs.pos;
13908        }
13909        if !stack.is_empty() {
13910            stack.push(("IflaVlanQos", cur));
13911        }
13912        (stack, None)
13913    }
13914}
13915#[derive(Clone)]
13916pub enum LinkinfoVrfAttrs {
13917    Table(u32),
13918}
13919impl<'a> IterableLinkinfoVrfAttrs<'a> {
13920    pub fn get_table(&self) -> Result<u32, ErrorContext> {
13921        let mut iter = self.clone();
13922        iter.pos = 0;
13923        for attr in iter {
13924            if let LinkinfoVrfAttrs::Table(val) = attr? {
13925                return Ok(val);
13926            }
13927        }
13928        Err(ErrorContext::new_missing(
13929            "LinkinfoVrfAttrs",
13930            "Table",
13931            self.orig_loc,
13932            self.buf.as_ptr() as usize,
13933        ))
13934    }
13935}
13936impl LinkinfoVrfAttrs {
13937    pub fn new(buf: &'_ [u8]) -> IterableLinkinfoVrfAttrs<'_> {
13938        IterableLinkinfoVrfAttrs::with_loc(buf, buf.as_ptr() as usize)
13939    }
13940    fn attr_from_type(r#type: u16) -> Option<&'static str> {
13941        let res = match r#type {
13942            1u16 => "Table",
13943            _ => return None,
13944        };
13945        Some(res)
13946    }
13947}
13948#[derive(Clone, Copy, Default)]
13949pub struct IterableLinkinfoVrfAttrs<'a> {
13950    buf: &'a [u8],
13951    pos: usize,
13952    orig_loc: usize,
13953}
13954impl<'a> IterableLinkinfoVrfAttrs<'a> {
13955    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
13956        Self {
13957            buf,
13958            pos: 0,
13959            orig_loc,
13960        }
13961    }
13962    pub fn get_buf(&self) -> &'a [u8] {
13963        self.buf
13964    }
13965}
13966impl<'a> Iterator for IterableLinkinfoVrfAttrs<'a> {
13967    type Item = Result<LinkinfoVrfAttrs, ErrorContext>;
13968    fn next(&mut self) -> Option<Self::Item> {
13969        if self.buf.len() == self.pos {
13970            return None;
13971        }
13972        let pos = self.pos;
13973        let mut r#type = None;
13974        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
13975            r#type = Some(header.r#type);
13976            let res = match header.r#type {
13977                1u16 => LinkinfoVrfAttrs::Table({
13978                    let res = parse_u32(next);
13979                    let Some(val) = res else { break };
13980                    val
13981                }),
13982                n => {
13983                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
13984                        break;
13985                    } else {
13986                        continue;
13987                    }
13988                }
13989            };
13990            return Some(Ok(res));
13991        }
13992        Some(Err(ErrorContext::new(
13993            "LinkinfoVrfAttrs",
13994            r#type.and_then(|t| LinkinfoVrfAttrs::attr_from_type(t)),
13995            self.orig_loc,
13996            self.buf.as_ptr().wrapping_add(pos) as usize,
13997        )))
13998    }
13999}
14000impl std::fmt::Debug for IterableLinkinfoVrfAttrs<'_> {
14001    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14002        let mut fmt = f.debug_struct("LinkinfoVrfAttrs");
14003        for attr in self.clone() {
14004            let attr = match attr {
14005                Ok(a) => a,
14006                Err(err) => {
14007                    fmt.finish()?;
14008                    f.write_str("Err(")?;
14009                    err.fmt(f)?;
14010                    return f.write_str(")");
14011                }
14012            };
14013            match attr {
14014                LinkinfoVrfAttrs::Table(val) => fmt.field("Table", &val),
14015            };
14016        }
14017        fmt.finish()
14018    }
14019}
14020impl IterableLinkinfoVrfAttrs<'_> {
14021    pub fn lookup_attr(
14022        &self,
14023        offset: usize,
14024        missing_type: Option<u16>,
14025    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14026        let mut stack = Vec::new();
14027        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14028        if cur == offset {
14029            stack.push(("LinkinfoVrfAttrs", offset));
14030            return (
14031                stack,
14032                missing_type.and_then(|t| LinkinfoVrfAttrs::attr_from_type(t)),
14033            );
14034        }
14035        if cur > offset || cur + self.buf.len() < offset {
14036            return (stack, None);
14037        }
14038        let mut attrs = self.clone();
14039        let mut last_off = cur + attrs.pos;
14040        while let Some(attr) = attrs.next() {
14041            let Ok(attr) = attr else { break };
14042            match attr {
14043                LinkinfoVrfAttrs::Table(val) => {
14044                    if last_off == offset {
14045                        stack.push(("Table", last_off));
14046                        break;
14047                    }
14048                }
14049                _ => {}
14050            };
14051            last_off = cur + attrs.pos;
14052        }
14053        if !stack.is_empty() {
14054            stack.push(("LinkinfoVrfAttrs", cur));
14055        }
14056        (stack, None)
14057    }
14058}
14059#[derive(Clone)]
14060pub enum XdpAttrs {
14061    Fd(i32),
14062    Attached(u8),
14063    Flags(u32),
14064    ProgId(u32),
14065    DrvProgId(u32),
14066    SkbProgId(u32),
14067    HwProgId(u32),
14068    ExpectedFd(i32),
14069}
14070impl<'a> IterableXdpAttrs<'a> {
14071    pub fn get_fd(&self) -> Result<i32, ErrorContext> {
14072        let mut iter = self.clone();
14073        iter.pos = 0;
14074        for attr in iter {
14075            if let XdpAttrs::Fd(val) = attr? {
14076                return Ok(val);
14077            }
14078        }
14079        Err(ErrorContext::new_missing(
14080            "XdpAttrs",
14081            "Fd",
14082            self.orig_loc,
14083            self.buf.as_ptr() as usize,
14084        ))
14085    }
14086    pub fn get_attached(&self) -> Result<u8, ErrorContext> {
14087        let mut iter = self.clone();
14088        iter.pos = 0;
14089        for attr in iter {
14090            if let XdpAttrs::Attached(val) = attr? {
14091                return Ok(val);
14092            }
14093        }
14094        Err(ErrorContext::new_missing(
14095            "XdpAttrs",
14096            "Attached",
14097            self.orig_loc,
14098            self.buf.as_ptr() as usize,
14099        ))
14100    }
14101    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
14102        let mut iter = self.clone();
14103        iter.pos = 0;
14104        for attr in iter {
14105            if let XdpAttrs::Flags(val) = attr? {
14106                return Ok(val);
14107            }
14108        }
14109        Err(ErrorContext::new_missing(
14110            "XdpAttrs",
14111            "Flags",
14112            self.orig_loc,
14113            self.buf.as_ptr() as usize,
14114        ))
14115    }
14116    pub fn get_prog_id(&self) -> Result<u32, ErrorContext> {
14117        let mut iter = self.clone();
14118        iter.pos = 0;
14119        for attr in iter {
14120            if let XdpAttrs::ProgId(val) = attr? {
14121                return Ok(val);
14122            }
14123        }
14124        Err(ErrorContext::new_missing(
14125            "XdpAttrs",
14126            "ProgId",
14127            self.orig_loc,
14128            self.buf.as_ptr() as usize,
14129        ))
14130    }
14131    pub fn get_drv_prog_id(&self) -> Result<u32, ErrorContext> {
14132        let mut iter = self.clone();
14133        iter.pos = 0;
14134        for attr in iter {
14135            if let XdpAttrs::DrvProgId(val) = attr? {
14136                return Ok(val);
14137            }
14138        }
14139        Err(ErrorContext::new_missing(
14140            "XdpAttrs",
14141            "DrvProgId",
14142            self.orig_loc,
14143            self.buf.as_ptr() as usize,
14144        ))
14145    }
14146    pub fn get_skb_prog_id(&self) -> Result<u32, ErrorContext> {
14147        let mut iter = self.clone();
14148        iter.pos = 0;
14149        for attr in iter {
14150            if let XdpAttrs::SkbProgId(val) = attr? {
14151                return Ok(val);
14152            }
14153        }
14154        Err(ErrorContext::new_missing(
14155            "XdpAttrs",
14156            "SkbProgId",
14157            self.orig_loc,
14158            self.buf.as_ptr() as usize,
14159        ))
14160    }
14161    pub fn get_hw_prog_id(&self) -> Result<u32, ErrorContext> {
14162        let mut iter = self.clone();
14163        iter.pos = 0;
14164        for attr in iter {
14165            if let XdpAttrs::HwProgId(val) = attr? {
14166                return Ok(val);
14167            }
14168        }
14169        Err(ErrorContext::new_missing(
14170            "XdpAttrs",
14171            "HwProgId",
14172            self.orig_loc,
14173            self.buf.as_ptr() as usize,
14174        ))
14175    }
14176    pub fn get_expected_fd(&self) -> Result<i32, ErrorContext> {
14177        let mut iter = self.clone();
14178        iter.pos = 0;
14179        for attr in iter {
14180            if let XdpAttrs::ExpectedFd(val) = attr? {
14181                return Ok(val);
14182            }
14183        }
14184        Err(ErrorContext::new_missing(
14185            "XdpAttrs",
14186            "ExpectedFd",
14187            self.orig_loc,
14188            self.buf.as_ptr() as usize,
14189        ))
14190    }
14191}
14192impl XdpAttrs {
14193    pub fn new(buf: &'_ [u8]) -> IterableXdpAttrs<'_> {
14194        IterableXdpAttrs::with_loc(buf, buf.as_ptr() as usize)
14195    }
14196    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14197        let res = match r#type {
14198            1u16 => "Fd",
14199            2u16 => "Attached",
14200            3u16 => "Flags",
14201            4u16 => "ProgId",
14202            5u16 => "DrvProgId",
14203            6u16 => "SkbProgId",
14204            7u16 => "HwProgId",
14205            8u16 => "ExpectedFd",
14206            _ => return None,
14207        };
14208        Some(res)
14209    }
14210}
14211#[derive(Clone, Copy, Default)]
14212pub struct IterableXdpAttrs<'a> {
14213    buf: &'a [u8],
14214    pos: usize,
14215    orig_loc: usize,
14216}
14217impl<'a> IterableXdpAttrs<'a> {
14218    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14219        Self {
14220            buf,
14221            pos: 0,
14222            orig_loc,
14223        }
14224    }
14225    pub fn get_buf(&self) -> &'a [u8] {
14226        self.buf
14227    }
14228}
14229impl<'a> Iterator for IterableXdpAttrs<'a> {
14230    type Item = Result<XdpAttrs, ErrorContext>;
14231    fn next(&mut self) -> Option<Self::Item> {
14232        if self.buf.len() == self.pos {
14233            return None;
14234        }
14235        let pos = self.pos;
14236        let mut r#type = None;
14237        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
14238            r#type = Some(header.r#type);
14239            let res = match header.r#type {
14240                1u16 => XdpAttrs::Fd({
14241                    let res = parse_i32(next);
14242                    let Some(val) = res else { break };
14243                    val
14244                }),
14245                2u16 => XdpAttrs::Attached({
14246                    let res = parse_u8(next);
14247                    let Some(val) = res else { break };
14248                    val
14249                }),
14250                3u16 => XdpAttrs::Flags({
14251                    let res = parse_u32(next);
14252                    let Some(val) = res else { break };
14253                    val
14254                }),
14255                4u16 => XdpAttrs::ProgId({
14256                    let res = parse_u32(next);
14257                    let Some(val) = res else { break };
14258                    val
14259                }),
14260                5u16 => XdpAttrs::DrvProgId({
14261                    let res = parse_u32(next);
14262                    let Some(val) = res else { break };
14263                    val
14264                }),
14265                6u16 => XdpAttrs::SkbProgId({
14266                    let res = parse_u32(next);
14267                    let Some(val) = res else { break };
14268                    val
14269                }),
14270                7u16 => XdpAttrs::HwProgId({
14271                    let res = parse_u32(next);
14272                    let Some(val) = res else { break };
14273                    val
14274                }),
14275                8u16 => XdpAttrs::ExpectedFd({
14276                    let res = parse_i32(next);
14277                    let Some(val) = res else { break };
14278                    val
14279                }),
14280                n => {
14281                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
14282                        break;
14283                    } else {
14284                        continue;
14285                    }
14286                }
14287            };
14288            return Some(Ok(res));
14289        }
14290        Some(Err(ErrorContext::new(
14291            "XdpAttrs",
14292            r#type.and_then(|t| XdpAttrs::attr_from_type(t)),
14293            self.orig_loc,
14294            self.buf.as_ptr().wrapping_add(pos) as usize,
14295        )))
14296    }
14297}
14298impl std::fmt::Debug for IterableXdpAttrs<'_> {
14299    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14300        let mut fmt = f.debug_struct("XdpAttrs");
14301        for attr in self.clone() {
14302            let attr = match attr {
14303                Ok(a) => a,
14304                Err(err) => {
14305                    fmt.finish()?;
14306                    f.write_str("Err(")?;
14307                    err.fmt(f)?;
14308                    return f.write_str(")");
14309                }
14310            };
14311            match attr {
14312                XdpAttrs::Fd(val) => fmt.field("Fd", &val),
14313                XdpAttrs::Attached(val) => fmt.field("Attached", &val),
14314                XdpAttrs::Flags(val) => fmt.field("Flags", &val),
14315                XdpAttrs::ProgId(val) => fmt.field("ProgId", &val),
14316                XdpAttrs::DrvProgId(val) => fmt.field("DrvProgId", &val),
14317                XdpAttrs::SkbProgId(val) => fmt.field("SkbProgId", &val),
14318                XdpAttrs::HwProgId(val) => fmt.field("HwProgId", &val),
14319                XdpAttrs::ExpectedFd(val) => fmt.field("ExpectedFd", &val),
14320            };
14321        }
14322        fmt.finish()
14323    }
14324}
14325impl IterableXdpAttrs<'_> {
14326    pub fn lookup_attr(
14327        &self,
14328        offset: usize,
14329        missing_type: Option<u16>,
14330    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14331        let mut stack = Vec::new();
14332        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14333        if cur == offset {
14334            stack.push(("XdpAttrs", offset));
14335            return (
14336                stack,
14337                missing_type.and_then(|t| XdpAttrs::attr_from_type(t)),
14338            );
14339        }
14340        if cur > offset || cur + self.buf.len() < offset {
14341            return (stack, None);
14342        }
14343        let mut attrs = self.clone();
14344        let mut last_off = cur + attrs.pos;
14345        while let Some(attr) = attrs.next() {
14346            let Ok(attr) = attr else { break };
14347            match attr {
14348                XdpAttrs::Fd(val) => {
14349                    if last_off == offset {
14350                        stack.push(("Fd", last_off));
14351                        break;
14352                    }
14353                }
14354                XdpAttrs::Attached(val) => {
14355                    if last_off == offset {
14356                        stack.push(("Attached", last_off));
14357                        break;
14358                    }
14359                }
14360                XdpAttrs::Flags(val) => {
14361                    if last_off == offset {
14362                        stack.push(("Flags", last_off));
14363                        break;
14364                    }
14365                }
14366                XdpAttrs::ProgId(val) => {
14367                    if last_off == offset {
14368                        stack.push(("ProgId", last_off));
14369                        break;
14370                    }
14371                }
14372                XdpAttrs::DrvProgId(val) => {
14373                    if last_off == offset {
14374                        stack.push(("DrvProgId", last_off));
14375                        break;
14376                    }
14377                }
14378                XdpAttrs::SkbProgId(val) => {
14379                    if last_off == offset {
14380                        stack.push(("SkbProgId", last_off));
14381                        break;
14382                    }
14383                }
14384                XdpAttrs::HwProgId(val) => {
14385                    if last_off == offset {
14386                        stack.push(("HwProgId", last_off));
14387                        break;
14388                    }
14389                }
14390                XdpAttrs::ExpectedFd(val) => {
14391                    if last_off == offset {
14392                        stack.push(("ExpectedFd", last_off));
14393                        break;
14394                    }
14395                }
14396                _ => {}
14397            };
14398            last_off = cur + attrs.pos;
14399        }
14400        if !stack.is_empty() {
14401            stack.push(("XdpAttrs", cur));
14402        }
14403        (stack, None)
14404    }
14405}
14406#[derive(Clone)]
14407pub enum IflaAttrs<'a> {
14408    #[doc = "u32 indexed by ipv4-devconf - 1 on output, on input it's a nest"]
14409    Conf(&'a [u8]),
14410}
14411impl<'a> IterableIflaAttrs<'a> {
14412    #[doc = "u32 indexed by ipv4-devconf - 1 on output, on input it's a nest"]
14413    pub fn get_conf(&self) -> Result<&'a [u8], ErrorContext> {
14414        let mut iter = self.clone();
14415        iter.pos = 0;
14416        for attr in iter {
14417            if let IflaAttrs::Conf(val) = attr? {
14418                return Ok(val);
14419            }
14420        }
14421        Err(ErrorContext::new_missing(
14422            "IflaAttrs",
14423            "Conf",
14424            self.orig_loc,
14425            self.buf.as_ptr() as usize,
14426        ))
14427    }
14428}
14429impl<'a> IflaAttrs<'a> {
14430    pub fn new(buf: &'a [u8]) -> IterableIflaAttrs<'a> {
14431        IterableIflaAttrs::with_loc(buf, buf.as_ptr() as usize)
14432    }
14433    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14434        let res = match r#type {
14435            1u16 => "Conf",
14436            _ => return None,
14437        };
14438        Some(res)
14439    }
14440}
14441#[derive(Clone, Copy, Default)]
14442pub struct IterableIflaAttrs<'a> {
14443    buf: &'a [u8],
14444    pos: usize,
14445    orig_loc: usize,
14446}
14447impl<'a> IterableIflaAttrs<'a> {
14448    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14449        Self {
14450            buf,
14451            pos: 0,
14452            orig_loc,
14453        }
14454    }
14455    pub fn get_buf(&self) -> &'a [u8] {
14456        self.buf
14457    }
14458}
14459impl<'a> Iterator for IterableIflaAttrs<'a> {
14460    type Item = Result<IflaAttrs<'a>, ErrorContext>;
14461    fn next(&mut self) -> Option<Self::Item> {
14462        if self.buf.len() == self.pos {
14463            return None;
14464        }
14465        let pos = self.pos;
14466        let mut r#type = None;
14467        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
14468            r#type = Some(header.r#type);
14469            let res = match header.r#type {
14470                1u16 => IflaAttrs::Conf({
14471                    let res = Some(next);
14472                    let Some(val) = res else { break };
14473                    val
14474                }),
14475                n => {
14476                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
14477                        break;
14478                    } else {
14479                        continue;
14480                    }
14481                }
14482            };
14483            return Some(Ok(res));
14484        }
14485        Some(Err(ErrorContext::new(
14486            "IflaAttrs",
14487            r#type.and_then(|t| IflaAttrs::attr_from_type(t)),
14488            self.orig_loc,
14489            self.buf.as_ptr().wrapping_add(pos) as usize,
14490        )))
14491    }
14492}
14493impl<'a> std::fmt::Debug for IterableIflaAttrs<'_> {
14494    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14495        let mut fmt = f.debug_struct("IflaAttrs");
14496        for attr in self.clone() {
14497            let attr = match attr {
14498                Ok(a) => a,
14499                Err(err) => {
14500                    fmt.finish()?;
14501                    f.write_str("Err(")?;
14502                    err.fmt(f)?;
14503                    return f.write_str(")");
14504                }
14505            };
14506            match attr {
14507                IflaAttrs::Conf(val) => fmt.field("Conf", &val),
14508            };
14509        }
14510        fmt.finish()
14511    }
14512}
14513impl IterableIflaAttrs<'_> {
14514    pub fn lookup_attr(
14515        &self,
14516        offset: usize,
14517        missing_type: Option<u16>,
14518    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14519        let mut stack = Vec::new();
14520        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14521        if cur == offset {
14522            stack.push(("IflaAttrs", offset));
14523            return (
14524                stack,
14525                missing_type.and_then(|t| IflaAttrs::attr_from_type(t)),
14526            );
14527        }
14528        if cur > offset || cur + self.buf.len() < offset {
14529            return (stack, None);
14530        }
14531        let mut attrs = self.clone();
14532        let mut last_off = cur + attrs.pos;
14533        while let Some(attr) = attrs.next() {
14534            let Ok(attr) = attr else { break };
14535            match attr {
14536                IflaAttrs::Conf(val) => {
14537                    if last_off == offset {
14538                        stack.push(("Conf", last_off));
14539                        break;
14540                    }
14541                }
14542                _ => {}
14543            };
14544            last_off = cur + attrs.pos;
14545        }
14546        if !stack.is_empty() {
14547            stack.push(("IflaAttrs", cur));
14548        }
14549        (stack, None)
14550    }
14551}
14552#[derive(Clone)]
14553pub enum Ifla6Attrs<'a> {
14554    Flags(u32),
14555    #[doc = "u32 indexed by ipv6-devconf - 1 on output, on input it's a nest"]
14556    Conf(&'a [u8]),
14557    Stats(&'a [u8]),
14558    Mcast(&'a [u8]),
14559    Cacheinfo(PushIflaCacheinfo),
14560    Icmp6stats(&'a [u8]),
14561    Token(&'a [u8]),
14562    AddrGenMode(u8),
14563    RaMtu(u32),
14564}
14565impl<'a> IterableIfla6Attrs<'a> {
14566    pub fn get_flags(&self) -> Result<u32, ErrorContext> {
14567        let mut iter = self.clone();
14568        iter.pos = 0;
14569        for attr in iter {
14570            if let Ifla6Attrs::Flags(val) = attr? {
14571                return Ok(val);
14572            }
14573        }
14574        Err(ErrorContext::new_missing(
14575            "Ifla6Attrs",
14576            "Flags",
14577            self.orig_loc,
14578            self.buf.as_ptr() as usize,
14579        ))
14580    }
14581    #[doc = "u32 indexed by ipv6-devconf - 1 on output, on input it's a nest"]
14582    pub fn get_conf(&self) -> Result<&'a [u8], ErrorContext> {
14583        let mut iter = self.clone();
14584        iter.pos = 0;
14585        for attr in iter {
14586            if let Ifla6Attrs::Conf(val) = attr? {
14587                return Ok(val);
14588            }
14589        }
14590        Err(ErrorContext::new_missing(
14591            "Ifla6Attrs",
14592            "Conf",
14593            self.orig_loc,
14594            self.buf.as_ptr() as usize,
14595        ))
14596    }
14597    pub fn get_stats(&self) -> Result<&'a [u8], ErrorContext> {
14598        let mut iter = self.clone();
14599        iter.pos = 0;
14600        for attr in iter {
14601            if let Ifla6Attrs::Stats(val) = attr? {
14602                return Ok(val);
14603            }
14604        }
14605        Err(ErrorContext::new_missing(
14606            "Ifla6Attrs",
14607            "Stats",
14608            self.orig_loc,
14609            self.buf.as_ptr() as usize,
14610        ))
14611    }
14612    pub fn get_mcast(&self) -> Result<&'a [u8], ErrorContext> {
14613        let mut iter = self.clone();
14614        iter.pos = 0;
14615        for attr in iter {
14616            if let Ifla6Attrs::Mcast(val) = attr? {
14617                return Ok(val);
14618            }
14619        }
14620        Err(ErrorContext::new_missing(
14621            "Ifla6Attrs",
14622            "Mcast",
14623            self.orig_loc,
14624            self.buf.as_ptr() as usize,
14625        ))
14626    }
14627    pub fn get_cacheinfo(&self) -> Result<PushIflaCacheinfo, ErrorContext> {
14628        let mut iter = self.clone();
14629        iter.pos = 0;
14630        for attr in iter {
14631            if let Ifla6Attrs::Cacheinfo(val) = attr? {
14632                return Ok(val);
14633            }
14634        }
14635        Err(ErrorContext::new_missing(
14636            "Ifla6Attrs",
14637            "Cacheinfo",
14638            self.orig_loc,
14639            self.buf.as_ptr() as usize,
14640        ))
14641    }
14642    pub fn get_icmp6stats(&self) -> Result<&'a [u8], ErrorContext> {
14643        let mut iter = self.clone();
14644        iter.pos = 0;
14645        for attr in iter {
14646            if let Ifla6Attrs::Icmp6stats(val) = attr? {
14647                return Ok(val);
14648            }
14649        }
14650        Err(ErrorContext::new_missing(
14651            "Ifla6Attrs",
14652            "Icmp6stats",
14653            self.orig_loc,
14654            self.buf.as_ptr() as usize,
14655        ))
14656    }
14657    pub fn get_token(&self) -> Result<&'a [u8], ErrorContext> {
14658        let mut iter = self.clone();
14659        iter.pos = 0;
14660        for attr in iter {
14661            if let Ifla6Attrs::Token(val) = attr? {
14662                return Ok(val);
14663            }
14664        }
14665        Err(ErrorContext::new_missing(
14666            "Ifla6Attrs",
14667            "Token",
14668            self.orig_loc,
14669            self.buf.as_ptr() as usize,
14670        ))
14671    }
14672    pub fn get_addr_gen_mode(&self) -> Result<u8, ErrorContext> {
14673        let mut iter = self.clone();
14674        iter.pos = 0;
14675        for attr in iter {
14676            if let Ifla6Attrs::AddrGenMode(val) = attr? {
14677                return Ok(val);
14678            }
14679        }
14680        Err(ErrorContext::new_missing(
14681            "Ifla6Attrs",
14682            "AddrGenMode",
14683            self.orig_loc,
14684            self.buf.as_ptr() as usize,
14685        ))
14686    }
14687    pub fn get_ra_mtu(&self) -> Result<u32, ErrorContext> {
14688        let mut iter = self.clone();
14689        iter.pos = 0;
14690        for attr in iter {
14691            if let Ifla6Attrs::RaMtu(val) = attr? {
14692                return Ok(val);
14693            }
14694        }
14695        Err(ErrorContext::new_missing(
14696            "Ifla6Attrs",
14697            "RaMtu",
14698            self.orig_loc,
14699            self.buf.as_ptr() as usize,
14700        ))
14701    }
14702}
14703impl<'a> Ifla6Attrs<'a> {
14704    pub fn new(buf: &'a [u8]) -> IterableIfla6Attrs<'a> {
14705        IterableIfla6Attrs::with_loc(buf, buf.as_ptr() as usize)
14706    }
14707    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14708        let res = match r#type {
14709            1u16 => "Flags",
14710            2u16 => "Conf",
14711            3u16 => "Stats",
14712            4u16 => "Mcast",
14713            5u16 => "Cacheinfo",
14714            6u16 => "Icmp6stats",
14715            7u16 => "Token",
14716            8u16 => "AddrGenMode",
14717            9u16 => "RaMtu",
14718            _ => return None,
14719        };
14720        Some(res)
14721    }
14722}
14723#[derive(Clone, Copy, Default)]
14724pub struct IterableIfla6Attrs<'a> {
14725    buf: &'a [u8],
14726    pos: usize,
14727    orig_loc: usize,
14728}
14729impl<'a> IterableIfla6Attrs<'a> {
14730    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14731        Self {
14732            buf,
14733            pos: 0,
14734            orig_loc,
14735        }
14736    }
14737    pub fn get_buf(&self) -> &'a [u8] {
14738        self.buf
14739    }
14740}
14741impl<'a> Iterator for IterableIfla6Attrs<'a> {
14742    type Item = Result<Ifla6Attrs<'a>, ErrorContext>;
14743    fn next(&mut self) -> Option<Self::Item> {
14744        if self.buf.len() == self.pos {
14745            return None;
14746        }
14747        let pos = self.pos;
14748        let mut r#type = None;
14749        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
14750            r#type = Some(header.r#type);
14751            let res = match header.r#type {
14752                1u16 => Ifla6Attrs::Flags({
14753                    let res = parse_u32(next);
14754                    let Some(val) = res else { break };
14755                    val
14756                }),
14757                2u16 => Ifla6Attrs::Conf({
14758                    let res = Some(next);
14759                    let Some(val) = res else { break };
14760                    val
14761                }),
14762                3u16 => Ifla6Attrs::Stats({
14763                    let res = Some(next);
14764                    let Some(val) = res else { break };
14765                    val
14766                }),
14767                4u16 => Ifla6Attrs::Mcast({
14768                    let res = Some(next);
14769                    let Some(val) = res else { break };
14770                    val
14771                }),
14772                5u16 => Ifla6Attrs::Cacheinfo({
14773                    let res = PushIflaCacheinfo::new_from_slice(next);
14774                    let Some(val) = res else { break };
14775                    val
14776                }),
14777                6u16 => Ifla6Attrs::Icmp6stats({
14778                    let res = Some(next);
14779                    let Some(val) = res else { break };
14780                    val
14781                }),
14782                7u16 => Ifla6Attrs::Token({
14783                    let res = Some(next);
14784                    let Some(val) = res else { break };
14785                    val
14786                }),
14787                8u16 => Ifla6Attrs::AddrGenMode({
14788                    let res = parse_u8(next);
14789                    let Some(val) = res else { break };
14790                    val
14791                }),
14792                9u16 => Ifla6Attrs::RaMtu({
14793                    let res = parse_u32(next);
14794                    let Some(val) = res else { break };
14795                    val
14796                }),
14797                n => {
14798                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
14799                        break;
14800                    } else {
14801                        continue;
14802                    }
14803                }
14804            };
14805            return Some(Ok(res));
14806        }
14807        Some(Err(ErrorContext::new(
14808            "Ifla6Attrs",
14809            r#type.and_then(|t| Ifla6Attrs::attr_from_type(t)),
14810            self.orig_loc,
14811            self.buf.as_ptr().wrapping_add(pos) as usize,
14812        )))
14813    }
14814}
14815impl<'a> std::fmt::Debug for IterableIfla6Attrs<'_> {
14816    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14817        let mut fmt = f.debug_struct("Ifla6Attrs");
14818        for attr in self.clone() {
14819            let attr = match attr {
14820                Ok(a) => a,
14821                Err(err) => {
14822                    fmt.finish()?;
14823                    f.write_str("Err(")?;
14824                    err.fmt(f)?;
14825                    return f.write_str(")");
14826                }
14827            };
14828            match attr {
14829                Ifla6Attrs::Flags(val) => fmt.field("Flags", &val),
14830                Ifla6Attrs::Conf(val) => fmt.field("Conf", &val),
14831                Ifla6Attrs::Stats(val) => fmt.field("Stats", &val),
14832                Ifla6Attrs::Mcast(val) => fmt.field("Mcast", &val),
14833                Ifla6Attrs::Cacheinfo(val) => fmt.field("Cacheinfo", &val),
14834                Ifla6Attrs::Icmp6stats(val) => fmt.field("Icmp6stats", &val),
14835                Ifla6Attrs::Token(val) => fmt.field("Token", &val),
14836                Ifla6Attrs::AddrGenMode(val) => fmt.field("AddrGenMode", &val),
14837                Ifla6Attrs::RaMtu(val) => fmt.field("RaMtu", &val),
14838            };
14839        }
14840        fmt.finish()
14841    }
14842}
14843impl IterableIfla6Attrs<'_> {
14844    pub fn lookup_attr(
14845        &self,
14846        offset: usize,
14847        missing_type: Option<u16>,
14848    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
14849        let mut stack = Vec::new();
14850        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
14851        if cur == offset {
14852            stack.push(("Ifla6Attrs", offset));
14853            return (
14854                stack,
14855                missing_type.and_then(|t| Ifla6Attrs::attr_from_type(t)),
14856            );
14857        }
14858        if cur > offset || cur + self.buf.len() < offset {
14859            return (stack, None);
14860        }
14861        let mut attrs = self.clone();
14862        let mut last_off = cur + attrs.pos;
14863        while let Some(attr) = attrs.next() {
14864            let Ok(attr) = attr else { break };
14865            match attr {
14866                Ifla6Attrs::Flags(val) => {
14867                    if last_off == offset {
14868                        stack.push(("Flags", last_off));
14869                        break;
14870                    }
14871                }
14872                Ifla6Attrs::Conf(val) => {
14873                    if last_off == offset {
14874                        stack.push(("Conf", last_off));
14875                        break;
14876                    }
14877                }
14878                Ifla6Attrs::Stats(val) => {
14879                    if last_off == offset {
14880                        stack.push(("Stats", last_off));
14881                        break;
14882                    }
14883                }
14884                Ifla6Attrs::Mcast(val) => {
14885                    if last_off == offset {
14886                        stack.push(("Mcast", last_off));
14887                        break;
14888                    }
14889                }
14890                Ifla6Attrs::Cacheinfo(val) => {
14891                    if last_off == offset {
14892                        stack.push(("Cacheinfo", last_off));
14893                        break;
14894                    }
14895                }
14896                Ifla6Attrs::Icmp6stats(val) => {
14897                    if last_off == offset {
14898                        stack.push(("Icmp6stats", last_off));
14899                        break;
14900                    }
14901                }
14902                Ifla6Attrs::Token(val) => {
14903                    if last_off == offset {
14904                        stack.push(("Token", last_off));
14905                        break;
14906                    }
14907                }
14908                Ifla6Attrs::AddrGenMode(val) => {
14909                    if last_off == offset {
14910                        stack.push(("AddrGenMode", last_off));
14911                        break;
14912                    }
14913                }
14914                Ifla6Attrs::RaMtu(val) => {
14915                    if last_off == offset {
14916                        stack.push(("RaMtu", last_off));
14917                        break;
14918                    }
14919                }
14920                _ => {}
14921            };
14922            last_off = cur + attrs.pos;
14923        }
14924        if !stack.is_empty() {
14925            stack.push(("Ifla6Attrs", cur));
14926        }
14927        (stack, None)
14928    }
14929}
14930#[derive(Clone)]
14931pub enum MctpAttrs {
14932    Net(u32),
14933    PhysBinding(u8),
14934}
14935impl<'a> IterableMctpAttrs<'a> {
14936    pub fn get_net(&self) -> Result<u32, ErrorContext> {
14937        let mut iter = self.clone();
14938        iter.pos = 0;
14939        for attr in iter {
14940            if let MctpAttrs::Net(val) = attr? {
14941                return Ok(val);
14942            }
14943        }
14944        Err(ErrorContext::new_missing(
14945            "MctpAttrs",
14946            "Net",
14947            self.orig_loc,
14948            self.buf.as_ptr() as usize,
14949        ))
14950    }
14951    pub fn get_phys_binding(&self) -> Result<u8, ErrorContext> {
14952        let mut iter = self.clone();
14953        iter.pos = 0;
14954        for attr in iter {
14955            if let MctpAttrs::PhysBinding(val) = attr? {
14956                return Ok(val);
14957            }
14958        }
14959        Err(ErrorContext::new_missing(
14960            "MctpAttrs",
14961            "PhysBinding",
14962            self.orig_loc,
14963            self.buf.as_ptr() as usize,
14964        ))
14965    }
14966}
14967impl MctpAttrs {
14968    pub fn new(buf: &'_ [u8]) -> IterableMctpAttrs<'_> {
14969        IterableMctpAttrs::with_loc(buf, buf.as_ptr() as usize)
14970    }
14971    fn attr_from_type(r#type: u16) -> Option<&'static str> {
14972        let res = match r#type {
14973            1u16 => "Net",
14974            2u16 => "PhysBinding",
14975            _ => return None,
14976        };
14977        Some(res)
14978    }
14979}
14980#[derive(Clone, Copy, Default)]
14981pub struct IterableMctpAttrs<'a> {
14982    buf: &'a [u8],
14983    pos: usize,
14984    orig_loc: usize,
14985}
14986impl<'a> IterableMctpAttrs<'a> {
14987    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
14988        Self {
14989            buf,
14990            pos: 0,
14991            orig_loc,
14992        }
14993    }
14994    pub fn get_buf(&self) -> &'a [u8] {
14995        self.buf
14996    }
14997}
14998impl<'a> Iterator for IterableMctpAttrs<'a> {
14999    type Item = Result<MctpAttrs, ErrorContext>;
15000    fn next(&mut self) -> Option<Self::Item> {
15001        if self.buf.len() == self.pos {
15002            return None;
15003        }
15004        let pos = self.pos;
15005        let mut r#type = None;
15006        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
15007            r#type = Some(header.r#type);
15008            let res = match header.r#type {
15009                1u16 => MctpAttrs::Net({
15010                    let res = parse_u32(next);
15011                    let Some(val) = res else { break };
15012                    val
15013                }),
15014                2u16 => MctpAttrs::PhysBinding({
15015                    let res = parse_u8(next);
15016                    let Some(val) = res else { break };
15017                    val
15018                }),
15019                n => {
15020                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
15021                        break;
15022                    } else {
15023                        continue;
15024                    }
15025                }
15026            };
15027            return Some(Ok(res));
15028        }
15029        Some(Err(ErrorContext::new(
15030            "MctpAttrs",
15031            r#type.and_then(|t| MctpAttrs::attr_from_type(t)),
15032            self.orig_loc,
15033            self.buf.as_ptr().wrapping_add(pos) as usize,
15034        )))
15035    }
15036}
15037impl std::fmt::Debug for IterableMctpAttrs<'_> {
15038    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15039        let mut fmt = f.debug_struct("MctpAttrs");
15040        for attr in self.clone() {
15041            let attr = match attr {
15042                Ok(a) => a,
15043                Err(err) => {
15044                    fmt.finish()?;
15045                    f.write_str("Err(")?;
15046                    err.fmt(f)?;
15047                    return f.write_str(")");
15048                }
15049            };
15050            match attr {
15051                MctpAttrs::Net(val) => fmt.field("Net", &val),
15052                MctpAttrs::PhysBinding(val) => fmt.field("PhysBinding", &val),
15053            };
15054        }
15055        fmt.finish()
15056    }
15057}
15058impl IterableMctpAttrs<'_> {
15059    pub fn lookup_attr(
15060        &self,
15061        offset: usize,
15062        missing_type: Option<u16>,
15063    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15064        let mut stack = Vec::new();
15065        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15066        if cur == offset {
15067            stack.push(("MctpAttrs", offset));
15068            return (
15069                stack,
15070                missing_type.and_then(|t| MctpAttrs::attr_from_type(t)),
15071            );
15072        }
15073        if cur > offset || cur + self.buf.len() < offset {
15074            return (stack, None);
15075        }
15076        let mut attrs = self.clone();
15077        let mut last_off = cur + attrs.pos;
15078        while let Some(attr) = attrs.next() {
15079            let Ok(attr) = attr else { break };
15080            match attr {
15081                MctpAttrs::Net(val) => {
15082                    if last_off == offset {
15083                        stack.push(("Net", last_off));
15084                        break;
15085                    }
15086                }
15087                MctpAttrs::PhysBinding(val) => {
15088                    if last_off == offset {
15089                        stack.push(("PhysBinding", last_off));
15090                        break;
15091                    }
15092                }
15093                _ => {}
15094            };
15095            last_off = cur + attrs.pos;
15096        }
15097        if !stack.is_empty() {
15098            stack.push(("MctpAttrs", cur));
15099        }
15100        (stack, None)
15101    }
15102}
15103#[derive(Clone)]
15104pub enum StatsAttrs<'a> {
15105    Link64(PushRtnlLinkStats64),
15106    LinkXstats(&'a [u8]),
15107    LinkXstatsSlave(&'a [u8]),
15108    LinkOffloadXstats(IterableLinkOffloadXstats<'a>),
15109    AfSpec(&'a [u8]),
15110}
15111impl<'a> IterableStatsAttrs<'a> {
15112    pub fn get_link_64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
15113        let mut iter = self.clone();
15114        iter.pos = 0;
15115        for attr in iter {
15116            if let StatsAttrs::Link64(val) = attr? {
15117                return Ok(val);
15118            }
15119        }
15120        Err(ErrorContext::new_missing(
15121            "StatsAttrs",
15122            "Link64",
15123            self.orig_loc,
15124            self.buf.as_ptr() as usize,
15125        ))
15126    }
15127    pub fn get_link_xstats(&self) -> Result<&'a [u8], ErrorContext> {
15128        let mut iter = self.clone();
15129        iter.pos = 0;
15130        for attr in iter {
15131            if let StatsAttrs::LinkXstats(val) = attr? {
15132                return Ok(val);
15133            }
15134        }
15135        Err(ErrorContext::new_missing(
15136            "StatsAttrs",
15137            "LinkXstats",
15138            self.orig_loc,
15139            self.buf.as_ptr() as usize,
15140        ))
15141    }
15142    pub fn get_link_xstats_slave(&self) -> Result<&'a [u8], ErrorContext> {
15143        let mut iter = self.clone();
15144        iter.pos = 0;
15145        for attr in iter {
15146            if let StatsAttrs::LinkXstatsSlave(val) = attr? {
15147                return Ok(val);
15148            }
15149        }
15150        Err(ErrorContext::new_missing(
15151            "StatsAttrs",
15152            "LinkXstatsSlave",
15153            self.orig_loc,
15154            self.buf.as_ptr() as usize,
15155        ))
15156    }
15157    pub fn get_link_offload_xstats(&self) -> Result<IterableLinkOffloadXstats<'a>, ErrorContext> {
15158        let mut iter = self.clone();
15159        iter.pos = 0;
15160        for attr in iter {
15161            if let StatsAttrs::LinkOffloadXstats(val) = attr? {
15162                return Ok(val);
15163            }
15164        }
15165        Err(ErrorContext::new_missing(
15166            "StatsAttrs",
15167            "LinkOffloadXstats",
15168            self.orig_loc,
15169            self.buf.as_ptr() as usize,
15170        ))
15171    }
15172    pub fn get_af_spec(&self) -> Result<&'a [u8], ErrorContext> {
15173        let mut iter = self.clone();
15174        iter.pos = 0;
15175        for attr in iter {
15176            if let StatsAttrs::AfSpec(val) = attr? {
15177                return Ok(val);
15178            }
15179        }
15180        Err(ErrorContext::new_missing(
15181            "StatsAttrs",
15182            "AfSpec",
15183            self.orig_loc,
15184            self.buf.as_ptr() as usize,
15185        ))
15186    }
15187}
15188impl<'a> StatsAttrs<'a> {
15189    pub fn new(buf: &'a [u8]) -> IterableStatsAttrs<'a> {
15190        IterableStatsAttrs::with_loc(buf, buf.as_ptr() as usize)
15191    }
15192    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15193        let res = match r#type {
15194            1u16 => "Link64",
15195            2u16 => "LinkXstats",
15196            3u16 => "LinkXstatsSlave",
15197            4u16 => "LinkOffloadXstats",
15198            5u16 => "AfSpec",
15199            _ => return None,
15200        };
15201        Some(res)
15202    }
15203}
15204#[derive(Clone, Copy, Default)]
15205pub struct IterableStatsAttrs<'a> {
15206    buf: &'a [u8],
15207    pos: usize,
15208    orig_loc: usize,
15209}
15210impl<'a> IterableStatsAttrs<'a> {
15211    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15212        Self {
15213            buf,
15214            pos: 0,
15215            orig_loc,
15216        }
15217    }
15218    pub fn get_buf(&self) -> &'a [u8] {
15219        self.buf
15220    }
15221}
15222impl<'a> Iterator for IterableStatsAttrs<'a> {
15223    type Item = Result<StatsAttrs<'a>, ErrorContext>;
15224    fn next(&mut self) -> Option<Self::Item> {
15225        if self.buf.len() == self.pos {
15226            return None;
15227        }
15228        let pos = self.pos;
15229        let mut r#type = None;
15230        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
15231            r#type = Some(header.r#type);
15232            let res = match header.r#type {
15233                1u16 => StatsAttrs::Link64({
15234                    let res = PushRtnlLinkStats64::new_from_slice(next);
15235                    let Some(val) = res else { break };
15236                    val
15237                }),
15238                2u16 => StatsAttrs::LinkXstats({
15239                    let res = Some(next);
15240                    let Some(val) = res else { break };
15241                    val
15242                }),
15243                3u16 => StatsAttrs::LinkXstatsSlave({
15244                    let res = Some(next);
15245                    let Some(val) = res else { break };
15246                    val
15247                }),
15248                4u16 => StatsAttrs::LinkOffloadXstats({
15249                    let res = Some(IterableLinkOffloadXstats::with_loc(next, self.orig_loc));
15250                    let Some(val) = res else { break };
15251                    val
15252                }),
15253                5u16 => StatsAttrs::AfSpec({
15254                    let res = Some(next);
15255                    let Some(val) = res else { break };
15256                    val
15257                }),
15258                n => {
15259                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
15260                        break;
15261                    } else {
15262                        continue;
15263                    }
15264                }
15265            };
15266            return Some(Ok(res));
15267        }
15268        Some(Err(ErrorContext::new(
15269            "StatsAttrs",
15270            r#type.and_then(|t| StatsAttrs::attr_from_type(t)),
15271            self.orig_loc,
15272            self.buf.as_ptr().wrapping_add(pos) as usize,
15273        )))
15274    }
15275}
15276impl<'a> std::fmt::Debug for IterableStatsAttrs<'_> {
15277    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15278        let mut fmt = f.debug_struct("StatsAttrs");
15279        for attr in self.clone() {
15280            let attr = match attr {
15281                Ok(a) => a,
15282                Err(err) => {
15283                    fmt.finish()?;
15284                    f.write_str("Err(")?;
15285                    err.fmt(f)?;
15286                    return f.write_str(")");
15287                }
15288            };
15289            match attr {
15290                StatsAttrs::Link64(val) => fmt.field("Link64", &val),
15291                StatsAttrs::LinkXstats(val) => fmt.field("LinkXstats", &val),
15292                StatsAttrs::LinkXstatsSlave(val) => fmt.field("LinkXstatsSlave", &val),
15293                StatsAttrs::LinkOffloadXstats(val) => fmt.field("LinkOffloadXstats", &val),
15294                StatsAttrs::AfSpec(val) => fmt.field("AfSpec", &val),
15295            };
15296        }
15297        fmt.finish()
15298    }
15299}
15300impl IterableStatsAttrs<'_> {
15301    pub fn lookup_attr(
15302        &self,
15303        offset: usize,
15304        missing_type: Option<u16>,
15305    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15306        let mut stack = Vec::new();
15307        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15308        if cur == offset {
15309            stack.push(("StatsAttrs", offset));
15310            return (
15311                stack,
15312                missing_type.and_then(|t| StatsAttrs::attr_from_type(t)),
15313            );
15314        }
15315        if cur > offset || cur + self.buf.len() < offset {
15316            return (stack, None);
15317        }
15318        let mut attrs = self.clone();
15319        let mut last_off = cur + attrs.pos;
15320        let mut missing = None;
15321        while let Some(attr) = attrs.next() {
15322            let Ok(attr) = attr else { break };
15323            match attr {
15324                StatsAttrs::Link64(val) => {
15325                    if last_off == offset {
15326                        stack.push(("Link64", last_off));
15327                        break;
15328                    }
15329                }
15330                StatsAttrs::LinkXstats(val) => {
15331                    if last_off == offset {
15332                        stack.push(("LinkXstats", last_off));
15333                        break;
15334                    }
15335                }
15336                StatsAttrs::LinkXstatsSlave(val) => {
15337                    if last_off == offset {
15338                        stack.push(("LinkXstatsSlave", last_off));
15339                        break;
15340                    }
15341                }
15342                StatsAttrs::LinkOffloadXstats(val) => {
15343                    (stack, missing) = val.lookup_attr(offset, missing_type);
15344                    if !stack.is_empty() {
15345                        break;
15346                    }
15347                }
15348                StatsAttrs::AfSpec(val) => {
15349                    if last_off == offset {
15350                        stack.push(("AfSpec", last_off));
15351                        break;
15352                    }
15353                }
15354                _ => {}
15355            };
15356            last_off = cur + attrs.pos;
15357        }
15358        if !stack.is_empty() {
15359            stack.push(("StatsAttrs", cur));
15360        }
15361        (stack, missing)
15362    }
15363}
15364#[derive(Clone)]
15365pub enum LinkOffloadXstats<'a> {
15366    CpuHit(&'a [u8]),
15367    HwSInfo(IterableArrayHwSInfoOne<'a>),
15368    L3Stats(&'a [u8]),
15369}
15370impl<'a> IterableLinkOffloadXstats<'a> {
15371    pub fn get_cpu_hit(&self) -> Result<&'a [u8], ErrorContext> {
15372        let mut iter = self.clone();
15373        iter.pos = 0;
15374        for attr in iter {
15375            if let LinkOffloadXstats::CpuHit(val) = attr? {
15376                return Ok(val);
15377            }
15378        }
15379        Err(ErrorContext::new_missing(
15380            "LinkOffloadXstats",
15381            "CpuHit",
15382            self.orig_loc,
15383            self.buf.as_ptr() as usize,
15384        ))
15385    }
15386    pub fn get_hw_s_info(
15387        &self,
15388    ) -> Result<ArrayIterable<IterableArrayHwSInfoOne<'a>, IterableHwSInfoOne<'a>>, ErrorContext>
15389    {
15390        for attr in self.clone() {
15391            if let LinkOffloadXstats::HwSInfo(val) = attr? {
15392                return Ok(ArrayIterable::new(val));
15393            }
15394        }
15395        Err(ErrorContext::new_missing(
15396            "LinkOffloadXstats",
15397            "HwSInfo",
15398            self.orig_loc,
15399            self.buf.as_ptr() as usize,
15400        ))
15401    }
15402    pub fn get_l3_stats(&self) -> Result<&'a [u8], ErrorContext> {
15403        let mut iter = self.clone();
15404        iter.pos = 0;
15405        for attr in iter {
15406            if let LinkOffloadXstats::L3Stats(val) = attr? {
15407                return Ok(val);
15408            }
15409        }
15410        Err(ErrorContext::new_missing(
15411            "LinkOffloadXstats",
15412            "L3Stats",
15413            self.orig_loc,
15414            self.buf.as_ptr() as usize,
15415        ))
15416    }
15417}
15418impl HwSInfoOne {
15419    pub fn new_array(buf: &[u8]) -> IterableArrayHwSInfoOne<'_> {
15420        IterableArrayHwSInfoOne::with_loc(buf, buf.as_ptr() as usize)
15421    }
15422}
15423#[derive(Clone, Copy, Default)]
15424pub struct IterableArrayHwSInfoOne<'a> {
15425    buf: &'a [u8],
15426    pos: usize,
15427    orig_loc: usize,
15428}
15429impl<'a> IterableArrayHwSInfoOne<'a> {
15430    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15431        Self {
15432            buf,
15433            pos: 0,
15434            orig_loc,
15435        }
15436    }
15437    pub fn get_buf(&self) -> &'a [u8] {
15438        self.buf
15439    }
15440}
15441impl<'a> Iterator for IterableArrayHwSInfoOne<'a> {
15442    type Item = Result<IterableHwSInfoOne<'a>, ErrorContext>;
15443    fn next(&mut self) -> Option<Self::Item> {
15444        if self.buf.len() == self.pos {
15445            return None;
15446        }
15447        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
15448            {
15449                return Some(Ok(IterableHwSInfoOne::with_loc(next, self.orig_loc)));
15450            }
15451        }
15452        Some(Err(ErrorContext::new(
15453            "HwSInfoOne",
15454            None,
15455            self.orig_loc,
15456            self.buf.as_ptr().wrapping_add(self.pos) as usize,
15457        )))
15458    }
15459}
15460impl<'a> LinkOffloadXstats<'a> {
15461    pub fn new(buf: &'a [u8]) -> IterableLinkOffloadXstats<'a> {
15462        IterableLinkOffloadXstats::with_loc(buf, buf.as_ptr() as usize)
15463    }
15464    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15465        let res = match r#type {
15466            1u16 => "CpuHit",
15467            2u16 => "HwSInfo",
15468            3u16 => "L3Stats",
15469            _ => return None,
15470        };
15471        Some(res)
15472    }
15473}
15474#[derive(Clone, Copy, Default)]
15475pub struct IterableLinkOffloadXstats<'a> {
15476    buf: &'a [u8],
15477    pos: usize,
15478    orig_loc: usize,
15479}
15480impl<'a> IterableLinkOffloadXstats<'a> {
15481    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15482        Self {
15483            buf,
15484            pos: 0,
15485            orig_loc,
15486        }
15487    }
15488    pub fn get_buf(&self) -> &'a [u8] {
15489        self.buf
15490    }
15491}
15492impl<'a> Iterator for IterableLinkOffloadXstats<'a> {
15493    type Item = Result<LinkOffloadXstats<'a>, ErrorContext>;
15494    fn next(&mut self) -> Option<Self::Item> {
15495        if self.buf.len() == self.pos {
15496            return None;
15497        }
15498        let pos = self.pos;
15499        let mut r#type = None;
15500        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
15501            r#type = Some(header.r#type);
15502            let res = match header.r#type {
15503                1u16 => LinkOffloadXstats::CpuHit({
15504                    let res = Some(next);
15505                    let Some(val) = res else { break };
15506                    val
15507                }),
15508                2u16 => LinkOffloadXstats::HwSInfo({
15509                    let res = Some(IterableArrayHwSInfoOne::with_loc(next, self.orig_loc));
15510                    let Some(val) = res else { break };
15511                    val
15512                }),
15513                3u16 => LinkOffloadXstats::L3Stats({
15514                    let res = Some(next);
15515                    let Some(val) = res else { break };
15516                    val
15517                }),
15518                n => {
15519                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
15520                        break;
15521                    } else {
15522                        continue;
15523                    }
15524                }
15525            };
15526            return Some(Ok(res));
15527        }
15528        Some(Err(ErrorContext::new(
15529            "LinkOffloadXstats",
15530            r#type.and_then(|t| LinkOffloadXstats::attr_from_type(t)),
15531            self.orig_loc,
15532            self.buf.as_ptr().wrapping_add(pos) as usize,
15533        )))
15534    }
15535}
15536impl std::fmt::Debug for IterableArrayHwSInfoOne<'_> {
15537    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15538        fmt.debug_list()
15539            .entries(self.clone().map(FlattenErrorContext))
15540            .finish()
15541    }
15542}
15543impl<'a> std::fmt::Debug for IterableLinkOffloadXstats<'_> {
15544    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15545        let mut fmt = f.debug_struct("LinkOffloadXstats");
15546        for attr in self.clone() {
15547            let attr = match attr {
15548                Ok(a) => a,
15549                Err(err) => {
15550                    fmt.finish()?;
15551                    f.write_str("Err(")?;
15552                    err.fmt(f)?;
15553                    return f.write_str(")");
15554                }
15555            };
15556            match attr {
15557                LinkOffloadXstats::CpuHit(val) => fmt.field("CpuHit", &val),
15558                LinkOffloadXstats::HwSInfo(val) => fmt.field("HwSInfo", &val),
15559                LinkOffloadXstats::L3Stats(val) => fmt.field("L3Stats", &val),
15560            };
15561        }
15562        fmt.finish()
15563    }
15564}
15565impl IterableLinkOffloadXstats<'_> {
15566    pub fn lookup_attr(
15567        &self,
15568        offset: usize,
15569        missing_type: Option<u16>,
15570    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15571        let mut stack = Vec::new();
15572        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15573        if cur == offset {
15574            stack.push(("LinkOffloadXstats", offset));
15575            return (
15576                stack,
15577                missing_type.and_then(|t| LinkOffloadXstats::attr_from_type(t)),
15578            );
15579        }
15580        if cur > offset || cur + self.buf.len() < offset {
15581            return (stack, None);
15582        }
15583        let mut attrs = self.clone();
15584        let mut last_off = cur + attrs.pos;
15585        let mut missing = None;
15586        while let Some(attr) = attrs.next() {
15587            let Ok(attr) = attr else { break };
15588            match attr {
15589                LinkOffloadXstats::CpuHit(val) => {
15590                    if last_off == offset {
15591                        stack.push(("CpuHit", last_off));
15592                        break;
15593                    }
15594                }
15595                LinkOffloadXstats::HwSInfo(val) => {
15596                    for entry in val {
15597                        let Ok(attr) = entry else { break };
15598                        (stack, missing) = attr.lookup_attr(offset, missing_type);
15599                        if !stack.is_empty() {
15600                            break;
15601                        }
15602                    }
15603                    if !stack.is_empty() {
15604                        stack.push(("HwSInfo", last_off));
15605                        break;
15606                    }
15607                }
15608                LinkOffloadXstats::L3Stats(val) => {
15609                    if last_off == offset {
15610                        stack.push(("L3Stats", last_off));
15611                        break;
15612                    }
15613                }
15614                _ => {}
15615            };
15616            last_off = cur + attrs.pos;
15617        }
15618        if !stack.is_empty() {
15619            stack.push(("LinkOffloadXstats", cur));
15620        }
15621        (stack, missing)
15622    }
15623}
15624#[derive(Clone)]
15625pub enum HwSInfoOne {
15626    Request(u8),
15627    Used(u8),
15628}
15629impl<'a> IterableHwSInfoOne<'a> {
15630    pub fn get_request(&self) -> Result<u8, ErrorContext> {
15631        let mut iter = self.clone();
15632        iter.pos = 0;
15633        for attr in iter {
15634            if let HwSInfoOne::Request(val) = attr? {
15635                return Ok(val);
15636            }
15637        }
15638        Err(ErrorContext::new_missing(
15639            "HwSInfoOne",
15640            "Request",
15641            self.orig_loc,
15642            self.buf.as_ptr() as usize,
15643        ))
15644    }
15645    pub fn get_used(&self) -> Result<u8, ErrorContext> {
15646        let mut iter = self.clone();
15647        iter.pos = 0;
15648        for attr in iter {
15649            if let HwSInfoOne::Used(val) = attr? {
15650                return Ok(val);
15651            }
15652        }
15653        Err(ErrorContext::new_missing(
15654            "HwSInfoOne",
15655            "Used",
15656            self.orig_loc,
15657            self.buf.as_ptr() as usize,
15658        ))
15659    }
15660}
15661impl HwSInfoOne {
15662    pub fn new(buf: &'_ [u8]) -> IterableHwSInfoOne<'_> {
15663        IterableHwSInfoOne::with_loc(buf, buf.as_ptr() as usize)
15664    }
15665    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15666        let res = match r#type {
15667            1u16 => "Request",
15668            2u16 => "Used",
15669            _ => return None,
15670        };
15671        Some(res)
15672    }
15673}
15674#[derive(Clone, Copy, Default)]
15675pub struct IterableHwSInfoOne<'a> {
15676    buf: &'a [u8],
15677    pos: usize,
15678    orig_loc: usize,
15679}
15680impl<'a> IterableHwSInfoOne<'a> {
15681    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15682        Self {
15683            buf,
15684            pos: 0,
15685            orig_loc,
15686        }
15687    }
15688    pub fn get_buf(&self) -> &'a [u8] {
15689        self.buf
15690    }
15691}
15692impl<'a> Iterator for IterableHwSInfoOne<'a> {
15693    type Item = Result<HwSInfoOne, ErrorContext>;
15694    fn next(&mut self) -> Option<Self::Item> {
15695        if self.buf.len() == self.pos {
15696            return None;
15697        }
15698        let pos = self.pos;
15699        let mut r#type = None;
15700        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
15701            r#type = Some(header.r#type);
15702            let res = match header.r#type {
15703                1u16 => HwSInfoOne::Request({
15704                    let res = parse_u8(next);
15705                    let Some(val) = res else { break };
15706                    val
15707                }),
15708                2u16 => HwSInfoOne::Used({
15709                    let res = parse_u8(next);
15710                    let Some(val) = res else { break };
15711                    val
15712                }),
15713                n => {
15714                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
15715                        break;
15716                    } else {
15717                        continue;
15718                    }
15719                }
15720            };
15721            return Some(Ok(res));
15722        }
15723        Some(Err(ErrorContext::new(
15724            "HwSInfoOne",
15725            r#type.and_then(|t| HwSInfoOne::attr_from_type(t)),
15726            self.orig_loc,
15727            self.buf.as_ptr().wrapping_add(pos) as usize,
15728        )))
15729    }
15730}
15731impl std::fmt::Debug for IterableHwSInfoOne<'_> {
15732    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15733        let mut fmt = f.debug_struct("HwSInfoOne");
15734        for attr in self.clone() {
15735            let attr = match attr {
15736                Ok(a) => a,
15737                Err(err) => {
15738                    fmt.finish()?;
15739                    f.write_str("Err(")?;
15740                    err.fmt(f)?;
15741                    return f.write_str(")");
15742                }
15743            };
15744            match attr {
15745                HwSInfoOne::Request(val) => fmt.field("Request", &val),
15746                HwSInfoOne::Used(val) => fmt.field("Used", &val),
15747            };
15748        }
15749        fmt.finish()
15750    }
15751}
15752impl IterableHwSInfoOne<'_> {
15753    pub fn lookup_attr(
15754        &self,
15755        offset: usize,
15756        missing_type: Option<u16>,
15757    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15758        let mut stack = Vec::new();
15759        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15760        if cur == offset {
15761            stack.push(("HwSInfoOne", offset));
15762            return (
15763                stack,
15764                missing_type.and_then(|t| HwSInfoOne::attr_from_type(t)),
15765            );
15766        }
15767        if cur > offset || cur + self.buf.len() < offset {
15768            return (stack, None);
15769        }
15770        let mut attrs = self.clone();
15771        let mut last_off = cur + attrs.pos;
15772        while let Some(attr) = attrs.next() {
15773            let Ok(attr) = attr else { break };
15774            match attr {
15775                HwSInfoOne::Request(val) => {
15776                    if last_off == offset {
15777                        stack.push(("Request", last_off));
15778                        break;
15779                    }
15780                }
15781                HwSInfoOne::Used(val) => {
15782                    if last_off == offset {
15783                        stack.push(("Used", last_off));
15784                        break;
15785                    }
15786                }
15787                _ => {}
15788            };
15789            last_off = cur + attrs.pos;
15790        }
15791        if !stack.is_empty() {
15792            stack.push(("HwSInfoOne", cur));
15793        }
15794        (stack, None)
15795    }
15796}
15797#[derive(Clone)]
15798pub enum LinkDpllPinAttrs {
15799    Id(u32),
15800}
15801impl<'a> IterableLinkDpllPinAttrs<'a> {
15802    pub fn get_id(&self) -> Result<u32, ErrorContext> {
15803        let mut iter = self.clone();
15804        iter.pos = 0;
15805        for attr in iter {
15806            if let LinkDpllPinAttrs::Id(val) = attr? {
15807                return Ok(val);
15808            }
15809        }
15810        Err(ErrorContext::new_missing(
15811            "LinkDpllPinAttrs",
15812            "Id",
15813            self.orig_loc,
15814            self.buf.as_ptr() as usize,
15815        ))
15816    }
15817}
15818impl LinkDpllPinAttrs {
15819    pub fn new(buf: &'_ [u8]) -> IterableLinkDpllPinAttrs<'_> {
15820        IterableLinkDpllPinAttrs::with_loc(buf, buf.as_ptr() as usize)
15821    }
15822    fn attr_from_type(r#type: u16) -> Option<&'static str> {
15823        let res = match r#type {
15824            1u16 => "Id",
15825            _ => return None,
15826        };
15827        Some(res)
15828    }
15829}
15830#[derive(Clone, Copy, Default)]
15831pub struct IterableLinkDpllPinAttrs<'a> {
15832    buf: &'a [u8],
15833    pos: usize,
15834    orig_loc: usize,
15835}
15836impl<'a> IterableLinkDpllPinAttrs<'a> {
15837    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
15838        Self {
15839            buf,
15840            pos: 0,
15841            orig_loc,
15842        }
15843    }
15844    pub fn get_buf(&self) -> &'a [u8] {
15845        self.buf
15846    }
15847}
15848impl<'a> Iterator for IterableLinkDpllPinAttrs<'a> {
15849    type Item = Result<LinkDpllPinAttrs, ErrorContext>;
15850    fn next(&mut self) -> Option<Self::Item> {
15851        if self.buf.len() == self.pos {
15852            return None;
15853        }
15854        let pos = self.pos;
15855        let mut r#type = None;
15856        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
15857            r#type = Some(header.r#type);
15858            let res = match header.r#type {
15859                1u16 => LinkDpllPinAttrs::Id({
15860                    let res = parse_u32(next);
15861                    let Some(val) = res else { break };
15862                    val
15863                }),
15864                n => {
15865                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
15866                        break;
15867                    } else {
15868                        continue;
15869                    }
15870                }
15871            };
15872            return Some(Ok(res));
15873        }
15874        Some(Err(ErrorContext::new(
15875            "LinkDpllPinAttrs",
15876            r#type.and_then(|t| LinkDpllPinAttrs::attr_from_type(t)),
15877            self.orig_loc,
15878            self.buf.as_ptr().wrapping_add(pos) as usize,
15879        )))
15880    }
15881}
15882impl std::fmt::Debug for IterableLinkDpllPinAttrs<'_> {
15883    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15884        let mut fmt = f.debug_struct("LinkDpllPinAttrs");
15885        for attr in self.clone() {
15886            let attr = match attr {
15887                Ok(a) => a,
15888                Err(err) => {
15889                    fmt.finish()?;
15890                    f.write_str("Err(")?;
15891                    err.fmt(f)?;
15892                    return f.write_str(")");
15893                }
15894            };
15895            match attr {
15896                LinkDpllPinAttrs::Id(val) => fmt.field("Id", &val),
15897            };
15898        }
15899        fmt.finish()
15900    }
15901}
15902impl IterableLinkDpllPinAttrs<'_> {
15903    pub fn lookup_attr(
15904        &self,
15905        offset: usize,
15906        missing_type: Option<u16>,
15907    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
15908        let mut stack = Vec::new();
15909        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
15910        if cur == offset {
15911            stack.push(("LinkDpllPinAttrs", offset));
15912            return (
15913                stack,
15914                missing_type.and_then(|t| LinkDpllPinAttrs::attr_from_type(t)),
15915            );
15916        }
15917        if cur > offset || cur + self.buf.len() < offset {
15918            return (stack, None);
15919        }
15920        let mut attrs = self.clone();
15921        let mut last_off = cur + attrs.pos;
15922        while let Some(attr) = attrs.next() {
15923            let Ok(attr) = attr else { break };
15924            match attr {
15925                LinkDpllPinAttrs::Id(val) => {
15926                    if last_off == offset {
15927                        stack.push(("Id", last_off));
15928                        break;
15929                    }
15930                }
15931                _ => {}
15932            };
15933            last_off = cur + attrs.pos;
15934        }
15935        if !stack.is_empty() {
15936            stack.push(("LinkDpllPinAttrs", cur));
15937        }
15938        (stack, None)
15939    }
15940}
15941#[derive(Clone)]
15942pub enum LinkinfoNetkitAttrs<'a> {
15943    PeerInfo(&'a [u8]),
15944    Primary(u8),
15945    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
15946    Policy(u32),
15947    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
15948    PeerPolicy(u32),
15949    #[doc = "Associated type: \"NetkitMode\" (enum)"]
15950    Mode(u32),
15951    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
15952    Scrub(u32),
15953    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
15954    PeerScrub(u32),
15955    Headroom(u16),
15956    Tailroom(u16),
15957}
15958impl<'a> IterableLinkinfoNetkitAttrs<'a> {
15959    pub fn get_peer_info(&self) -> Result<&'a [u8], ErrorContext> {
15960        let mut iter = self.clone();
15961        iter.pos = 0;
15962        for attr in iter {
15963            if let LinkinfoNetkitAttrs::PeerInfo(val) = attr? {
15964                return Ok(val);
15965            }
15966        }
15967        Err(ErrorContext::new_missing(
15968            "LinkinfoNetkitAttrs",
15969            "PeerInfo",
15970            self.orig_loc,
15971            self.buf.as_ptr() as usize,
15972        ))
15973    }
15974    pub fn get_primary(&self) -> Result<u8, ErrorContext> {
15975        let mut iter = self.clone();
15976        iter.pos = 0;
15977        for attr in iter {
15978            if let LinkinfoNetkitAttrs::Primary(val) = attr? {
15979                return Ok(val);
15980            }
15981        }
15982        Err(ErrorContext::new_missing(
15983            "LinkinfoNetkitAttrs",
15984            "Primary",
15985            self.orig_loc,
15986            self.buf.as_ptr() as usize,
15987        ))
15988    }
15989    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
15990    pub fn get_policy(&self) -> Result<u32, ErrorContext> {
15991        let mut iter = self.clone();
15992        iter.pos = 0;
15993        for attr in iter {
15994            if let LinkinfoNetkitAttrs::Policy(val) = attr? {
15995                return Ok(val);
15996            }
15997        }
15998        Err(ErrorContext::new_missing(
15999            "LinkinfoNetkitAttrs",
16000            "Policy",
16001            self.orig_loc,
16002            self.buf.as_ptr() as usize,
16003        ))
16004    }
16005    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
16006    pub fn get_peer_policy(&self) -> Result<u32, ErrorContext> {
16007        let mut iter = self.clone();
16008        iter.pos = 0;
16009        for attr in iter {
16010            if let LinkinfoNetkitAttrs::PeerPolicy(val) = attr? {
16011                return Ok(val);
16012            }
16013        }
16014        Err(ErrorContext::new_missing(
16015            "LinkinfoNetkitAttrs",
16016            "PeerPolicy",
16017            self.orig_loc,
16018            self.buf.as_ptr() as usize,
16019        ))
16020    }
16021    #[doc = "Associated type: \"NetkitMode\" (enum)"]
16022    pub fn get_mode(&self) -> Result<u32, ErrorContext> {
16023        let mut iter = self.clone();
16024        iter.pos = 0;
16025        for attr in iter {
16026            if let LinkinfoNetkitAttrs::Mode(val) = attr? {
16027                return Ok(val);
16028            }
16029        }
16030        Err(ErrorContext::new_missing(
16031            "LinkinfoNetkitAttrs",
16032            "Mode",
16033            self.orig_loc,
16034            self.buf.as_ptr() as usize,
16035        ))
16036    }
16037    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
16038    pub fn get_scrub(&self) -> Result<u32, ErrorContext> {
16039        let mut iter = self.clone();
16040        iter.pos = 0;
16041        for attr in iter {
16042            if let LinkinfoNetkitAttrs::Scrub(val) = attr? {
16043                return Ok(val);
16044            }
16045        }
16046        Err(ErrorContext::new_missing(
16047            "LinkinfoNetkitAttrs",
16048            "Scrub",
16049            self.orig_loc,
16050            self.buf.as_ptr() as usize,
16051        ))
16052    }
16053    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
16054    pub fn get_peer_scrub(&self) -> Result<u32, ErrorContext> {
16055        let mut iter = self.clone();
16056        iter.pos = 0;
16057        for attr in iter {
16058            if let LinkinfoNetkitAttrs::PeerScrub(val) = attr? {
16059                return Ok(val);
16060            }
16061        }
16062        Err(ErrorContext::new_missing(
16063            "LinkinfoNetkitAttrs",
16064            "PeerScrub",
16065            self.orig_loc,
16066            self.buf.as_ptr() as usize,
16067        ))
16068    }
16069    pub fn get_headroom(&self) -> Result<u16, ErrorContext> {
16070        let mut iter = self.clone();
16071        iter.pos = 0;
16072        for attr in iter {
16073            if let LinkinfoNetkitAttrs::Headroom(val) = attr? {
16074                return Ok(val);
16075            }
16076        }
16077        Err(ErrorContext::new_missing(
16078            "LinkinfoNetkitAttrs",
16079            "Headroom",
16080            self.orig_loc,
16081            self.buf.as_ptr() as usize,
16082        ))
16083    }
16084    pub fn get_tailroom(&self) -> Result<u16, ErrorContext> {
16085        let mut iter = self.clone();
16086        iter.pos = 0;
16087        for attr in iter {
16088            if let LinkinfoNetkitAttrs::Tailroom(val) = attr? {
16089                return Ok(val);
16090            }
16091        }
16092        Err(ErrorContext::new_missing(
16093            "LinkinfoNetkitAttrs",
16094            "Tailroom",
16095            self.orig_loc,
16096            self.buf.as_ptr() as usize,
16097        ))
16098    }
16099}
16100impl<'a> LinkinfoNetkitAttrs<'a> {
16101    pub fn new(buf: &'a [u8]) -> IterableLinkinfoNetkitAttrs<'a> {
16102        IterableLinkinfoNetkitAttrs::with_loc(buf, buf.as_ptr() as usize)
16103    }
16104    fn attr_from_type(r#type: u16) -> Option<&'static str> {
16105        let res = match r#type {
16106            1u16 => "PeerInfo",
16107            2u16 => "Primary",
16108            3u16 => "Policy",
16109            4u16 => "PeerPolicy",
16110            5u16 => "Mode",
16111            6u16 => "Scrub",
16112            7u16 => "PeerScrub",
16113            8u16 => "Headroom",
16114            9u16 => "Tailroom",
16115            _ => return None,
16116        };
16117        Some(res)
16118    }
16119}
16120#[derive(Clone, Copy, Default)]
16121pub struct IterableLinkinfoNetkitAttrs<'a> {
16122    buf: &'a [u8],
16123    pos: usize,
16124    orig_loc: usize,
16125}
16126impl<'a> IterableLinkinfoNetkitAttrs<'a> {
16127    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
16128        Self {
16129            buf,
16130            pos: 0,
16131            orig_loc,
16132        }
16133    }
16134    pub fn get_buf(&self) -> &'a [u8] {
16135        self.buf
16136    }
16137}
16138impl<'a> Iterator for IterableLinkinfoNetkitAttrs<'a> {
16139    type Item = Result<LinkinfoNetkitAttrs<'a>, ErrorContext>;
16140    fn next(&mut self) -> Option<Self::Item> {
16141        if self.buf.len() == self.pos {
16142            return None;
16143        }
16144        let pos = self.pos;
16145        let mut r#type = None;
16146        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
16147            r#type = Some(header.r#type);
16148            let res = match header.r#type {
16149                1u16 => LinkinfoNetkitAttrs::PeerInfo({
16150                    let res = Some(next);
16151                    let Some(val) = res else { break };
16152                    val
16153                }),
16154                2u16 => LinkinfoNetkitAttrs::Primary({
16155                    let res = parse_u8(next);
16156                    let Some(val) = res else { break };
16157                    val
16158                }),
16159                3u16 => LinkinfoNetkitAttrs::Policy({
16160                    let res = parse_u32(next);
16161                    let Some(val) = res else { break };
16162                    val
16163                }),
16164                4u16 => LinkinfoNetkitAttrs::PeerPolicy({
16165                    let res = parse_u32(next);
16166                    let Some(val) = res else { break };
16167                    val
16168                }),
16169                5u16 => LinkinfoNetkitAttrs::Mode({
16170                    let res = parse_u32(next);
16171                    let Some(val) = res else { break };
16172                    val
16173                }),
16174                6u16 => LinkinfoNetkitAttrs::Scrub({
16175                    let res = parse_u32(next);
16176                    let Some(val) = res else { break };
16177                    val
16178                }),
16179                7u16 => LinkinfoNetkitAttrs::PeerScrub({
16180                    let res = parse_u32(next);
16181                    let Some(val) = res else { break };
16182                    val
16183                }),
16184                8u16 => LinkinfoNetkitAttrs::Headroom({
16185                    let res = parse_u16(next);
16186                    let Some(val) = res else { break };
16187                    val
16188                }),
16189                9u16 => LinkinfoNetkitAttrs::Tailroom({
16190                    let res = parse_u16(next);
16191                    let Some(val) = res else { break };
16192                    val
16193                }),
16194                n => {
16195                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
16196                        break;
16197                    } else {
16198                        continue;
16199                    }
16200                }
16201            };
16202            return Some(Ok(res));
16203        }
16204        Some(Err(ErrorContext::new(
16205            "LinkinfoNetkitAttrs",
16206            r#type.and_then(|t| LinkinfoNetkitAttrs::attr_from_type(t)),
16207            self.orig_loc,
16208            self.buf.as_ptr().wrapping_add(pos) as usize,
16209        )))
16210    }
16211}
16212impl<'a> std::fmt::Debug for IterableLinkinfoNetkitAttrs<'_> {
16213    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16214        let mut fmt = f.debug_struct("LinkinfoNetkitAttrs");
16215        for attr in self.clone() {
16216            let attr = match attr {
16217                Ok(a) => a,
16218                Err(err) => {
16219                    fmt.finish()?;
16220                    f.write_str("Err(")?;
16221                    err.fmt(f)?;
16222                    return f.write_str(")");
16223                }
16224            };
16225            match attr {
16226                LinkinfoNetkitAttrs::PeerInfo(val) => fmt.field("PeerInfo", &val),
16227                LinkinfoNetkitAttrs::Primary(val) => fmt.field("Primary", &val),
16228                LinkinfoNetkitAttrs::Policy(val) => {
16229                    fmt.field("Policy", &FormatEnum(val.into(), NetkitPolicy::from_value))
16230                }
16231                LinkinfoNetkitAttrs::PeerPolicy(val) => fmt.field(
16232                    "PeerPolicy",
16233                    &FormatEnum(val.into(), NetkitPolicy::from_value),
16234                ),
16235                LinkinfoNetkitAttrs::Mode(val) => {
16236                    fmt.field("Mode", &FormatEnum(val.into(), NetkitMode::from_value))
16237                }
16238                LinkinfoNetkitAttrs::Scrub(val) => {
16239                    fmt.field("Scrub", &FormatEnum(val.into(), NetkitScrub::from_value))
16240                }
16241                LinkinfoNetkitAttrs::PeerScrub(val) => fmt.field(
16242                    "PeerScrub",
16243                    &FormatEnum(val.into(), NetkitScrub::from_value),
16244                ),
16245                LinkinfoNetkitAttrs::Headroom(val) => fmt.field("Headroom", &val),
16246                LinkinfoNetkitAttrs::Tailroom(val) => fmt.field("Tailroom", &val),
16247            };
16248        }
16249        fmt.finish()
16250    }
16251}
16252impl IterableLinkinfoNetkitAttrs<'_> {
16253    pub fn lookup_attr(
16254        &self,
16255        offset: usize,
16256        missing_type: Option<u16>,
16257    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16258        let mut stack = Vec::new();
16259        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
16260        if cur == offset {
16261            stack.push(("LinkinfoNetkitAttrs", offset));
16262            return (
16263                stack,
16264                missing_type.and_then(|t| LinkinfoNetkitAttrs::attr_from_type(t)),
16265            );
16266        }
16267        if cur > offset || cur + self.buf.len() < offset {
16268            return (stack, None);
16269        }
16270        let mut attrs = self.clone();
16271        let mut last_off = cur + attrs.pos;
16272        while let Some(attr) = attrs.next() {
16273            let Ok(attr) = attr else { break };
16274            match attr {
16275                LinkinfoNetkitAttrs::PeerInfo(val) => {
16276                    if last_off == offset {
16277                        stack.push(("PeerInfo", last_off));
16278                        break;
16279                    }
16280                }
16281                LinkinfoNetkitAttrs::Primary(val) => {
16282                    if last_off == offset {
16283                        stack.push(("Primary", last_off));
16284                        break;
16285                    }
16286                }
16287                LinkinfoNetkitAttrs::Policy(val) => {
16288                    if last_off == offset {
16289                        stack.push(("Policy", last_off));
16290                        break;
16291                    }
16292                }
16293                LinkinfoNetkitAttrs::PeerPolicy(val) => {
16294                    if last_off == offset {
16295                        stack.push(("PeerPolicy", last_off));
16296                        break;
16297                    }
16298                }
16299                LinkinfoNetkitAttrs::Mode(val) => {
16300                    if last_off == offset {
16301                        stack.push(("Mode", last_off));
16302                        break;
16303                    }
16304                }
16305                LinkinfoNetkitAttrs::Scrub(val) => {
16306                    if last_off == offset {
16307                        stack.push(("Scrub", last_off));
16308                        break;
16309                    }
16310                }
16311                LinkinfoNetkitAttrs::PeerScrub(val) => {
16312                    if last_off == offset {
16313                        stack.push(("PeerScrub", last_off));
16314                        break;
16315                    }
16316                }
16317                LinkinfoNetkitAttrs::Headroom(val) => {
16318                    if last_off == offset {
16319                        stack.push(("Headroom", last_off));
16320                        break;
16321                    }
16322                }
16323                LinkinfoNetkitAttrs::Tailroom(val) => {
16324                    if last_off == offset {
16325                        stack.push(("Tailroom", last_off));
16326                        break;
16327                    }
16328                }
16329                _ => {}
16330            };
16331            last_off = cur + attrs.pos;
16332        }
16333        if !stack.is_empty() {
16334            stack.push(("LinkinfoNetkitAttrs", cur));
16335        }
16336        (stack, None)
16337    }
16338}
16339#[derive(Clone)]
16340pub enum LinkinfoOvpnAttrs {
16341    #[doc = "Associated type: \"OvpnMode\" (enum)"]
16342    Mode(u8),
16343}
16344impl<'a> IterableLinkinfoOvpnAttrs<'a> {
16345    #[doc = "Associated type: \"OvpnMode\" (enum)"]
16346    pub fn get_mode(&self) -> Result<u8, ErrorContext> {
16347        let mut iter = self.clone();
16348        iter.pos = 0;
16349        for attr in iter {
16350            if let LinkinfoOvpnAttrs::Mode(val) = attr? {
16351                return Ok(val);
16352            }
16353        }
16354        Err(ErrorContext::new_missing(
16355            "LinkinfoOvpnAttrs",
16356            "Mode",
16357            self.orig_loc,
16358            self.buf.as_ptr() as usize,
16359        ))
16360    }
16361}
16362impl LinkinfoOvpnAttrs {
16363    pub fn new(buf: &'_ [u8]) -> IterableLinkinfoOvpnAttrs<'_> {
16364        IterableLinkinfoOvpnAttrs::with_loc(buf, buf.as_ptr() as usize)
16365    }
16366    fn attr_from_type(r#type: u16) -> Option<&'static str> {
16367        let res = match r#type {
16368            1u16 => "Mode",
16369            _ => return None,
16370        };
16371        Some(res)
16372    }
16373}
16374#[derive(Clone, Copy, Default)]
16375pub struct IterableLinkinfoOvpnAttrs<'a> {
16376    buf: &'a [u8],
16377    pos: usize,
16378    orig_loc: usize,
16379}
16380impl<'a> IterableLinkinfoOvpnAttrs<'a> {
16381    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
16382        Self {
16383            buf,
16384            pos: 0,
16385            orig_loc,
16386        }
16387    }
16388    pub fn get_buf(&self) -> &'a [u8] {
16389        self.buf
16390    }
16391}
16392impl<'a> Iterator for IterableLinkinfoOvpnAttrs<'a> {
16393    type Item = Result<LinkinfoOvpnAttrs, ErrorContext>;
16394    fn next(&mut self) -> Option<Self::Item> {
16395        if self.buf.len() == self.pos {
16396            return None;
16397        }
16398        let pos = self.pos;
16399        let mut r#type = None;
16400        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
16401            r#type = Some(header.r#type);
16402            let res = match header.r#type {
16403                1u16 => LinkinfoOvpnAttrs::Mode({
16404                    let res = parse_u8(next);
16405                    let Some(val) = res else { break };
16406                    val
16407                }),
16408                n => {
16409                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
16410                        break;
16411                    } else {
16412                        continue;
16413                    }
16414                }
16415            };
16416            return Some(Ok(res));
16417        }
16418        Some(Err(ErrorContext::new(
16419            "LinkinfoOvpnAttrs",
16420            r#type.and_then(|t| LinkinfoOvpnAttrs::attr_from_type(t)),
16421            self.orig_loc,
16422            self.buf.as_ptr().wrapping_add(pos) as usize,
16423        )))
16424    }
16425}
16426impl std::fmt::Debug for IterableLinkinfoOvpnAttrs<'_> {
16427    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16428        let mut fmt = f.debug_struct("LinkinfoOvpnAttrs");
16429        for attr in self.clone() {
16430            let attr = match attr {
16431                Ok(a) => a,
16432                Err(err) => {
16433                    fmt.finish()?;
16434                    f.write_str("Err(")?;
16435                    err.fmt(f)?;
16436                    return f.write_str(")");
16437                }
16438            };
16439            match attr {
16440                LinkinfoOvpnAttrs::Mode(val) => {
16441                    fmt.field("Mode", &FormatEnum(val.into(), OvpnMode::from_value))
16442                }
16443            };
16444        }
16445        fmt.finish()
16446    }
16447}
16448impl IterableLinkinfoOvpnAttrs<'_> {
16449    pub fn lookup_attr(
16450        &self,
16451        offset: usize,
16452        missing_type: Option<u16>,
16453    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
16454        let mut stack = Vec::new();
16455        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
16456        if cur == offset {
16457            stack.push(("LinkinfoOvpnAttrs", offset));
16458            return (
16459                stack,
16460                missing_type.and_then(|t| LinkinfoOvpnAttrs::attr_from_type(t)),
16461            );
16462        }
16463        if cur > offset || cur + self.buf.len() < offset {
16464            return (stack, None);
16465        }
16466        let mut attrs = self.clone();
16467        let mut last_off = cur + attrs.pos;
16468        while let Some(attr) = attrs.next() {
16469            let Ok(attr) = attr else { break };
16470            match attr {
16471                LinkinfoOvpnAttrs::Mode(val) => {
16472                    if last_off == offset {
16473                        stack.push(("Mode", last_off));
16474                        break;
16475                    }
16476                }
16477                _ => {}
16478            };
16479            last_off = cur + attrs.pos;
16480        }
16481        if !stack.is_empty() {
16482            stack.push(("LinkinfoOvpnAttrs", cur));
16483        }
16484        (stack, None)
16485    }
16486}
16487pub struct PushLinkAttrs<Prev: Rec> {
16488    pub(crate) prev: Option<Prev>,
16489    pub(crate) header_offset: Option<usize>,
16490}
16491impl<Prev: Rec> Rec for PushLinkAttrs<Prev> {
16492    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
16493        self.prev.as_mut().unwrap().as_rec_mut()
16494    }
16495}
16496impl<Prev: Rec> PushLinkAttrs<Prev> {
16497    pub fn new(prev: Prev) -> Self {
16498        Self {
16499            prev: Some(prev),
16500            header_offset: None,
16501        }
16502    }
16503    pub fn end_nested(mut self) -> Prev {
16504        let mut prev = self.prev.take().unwrap();
16505        if let Some(header_offset) = &self.header_offset {
16506            finalize_nested_header(prev.as_rec_mut(), *header_offset);
16507        }
16508        prev
16509    }
16510    pub fn push_address(mut self, value: &[u8]) -> Self {
16511        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
16512        self.as_rec_mut().extend(value);
16513        self
16514    }
16515    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
16516        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
16517        self.as_rec_mut().extend(value);
16518        self
16519    }
16520    pub fn push_ifname(mut self, value: &CStr) -> Self {
16521        push_header(
16522            self.as_rec_mut(),
16523            3u16,
16524            value.to_bytes_with_nul().len() as u16,
16525        );
16526        self.as_rec_mut().extend(value.to_bytes_with_nul());
16527        self
16528    }
16529    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
16530        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
16531        self.as_rec_mut().extend(value);
16532        self.as_rec_mut().push(0);
16533        self
16534    }
16535    pub fn push_mtu(mut self, value: u32) -> Self {
16536        push_header(self.as_rec_mut(), 4u16, 4 as u16);
16537        self.as_rec_mut().extend(value.to_ne_bytes());
16538        self
16539    }
16540    pub fn push_link(mut self, value: u32) -> Self {
16541        push_header(self.as_rec_mut(), 5u16, 4 as u16);
16542        self.as_rec_mut().extend(value.to_ne_bytes());
16543        self
16544    }
16545    pub fn push_qdisc(mut self, value: &CStr) -> Self {
16546        push_header(
16547            self.as_rec_mut(),
16548            6u16,
16549            value.to_bytes_with_nul().len() as u16,
16550        );
16551        self.as_rec_mut().extend(value.to_bytes_with_nul());
16552        self
16553    }
16554    pub fn push_qdisc_bytes(mut self, value: &[u8]) -> Self {
16555        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
16556        self.as_rec_mut().extend(value);
16557        self.as_rec_mut().push(0);
16558        self
16559    }
16560    pub fn push_stats(mut self, value: PushRtnlLinkStats) -> Self {
16561        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
16562        self.as_rec_mut().extend(value.as_slice());
16563        self
16564    }
16565    pub fn push_cost(mut self, value: &CStr) -> Self {
16566        push_header(
16567            self.as_rec_mut(),
16568            8u16,
16569            value.to_bytes_with_nul().len() as u16,
16570        );
16571        self.as_rec_mut().extend(value.to_bytes_with_nul());
16572        self
16573    }
16574    pub fn push_cost_bytes(mut self, value: &[u8]) -> Self {
16575        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
16576        self.as_rec_mut().extend(value);
16577        self.as_rec_mut().push(0);
16578        self
16579    }
16580    pub fn push_priority(mut self, value: &CStr) -> Self {
16581        push_header(
16582            self.as_rec_mut(),
16583            9u16,
16584            value.to_bytes_with_nul().len() as u16,
16585        );
16586        self.as_rec_mut().extend(value.to_bytes_with_nul());
16587        self
16588    }
16589    pub fn push_priority_bytes(mut self, value: &[u8]) -> Self {
16590        push_header(self.as_rec_mut(), 9u16, (value.len() + 1) as u16);
16591        self.as_rec_mut().extend(value);
16592        self.as_rec_mut().push(0);
16593        self
16594    }
16595    pub fn push_master(mut self, value: u32) -> Self {
16596        push_header(self.as_rec_mut(), 10u16, 4 as u16);
16597        self.as_rec_mut().extend(value.to_ne_bytes());
16598        self
16599    }
16600    pub fn push_wireless(mut self, value: &CStr) -> Self {
16601        push_header(
16602            self.as_rec_mut(),
16603            11u16,
16604            value.to_bytes_with_nul().len() as u16,
16605        );
16606        self.as_rec_mut().extend(value.to_bytes_with_nul());
16607        self
16608    }
16609    pub fn push_wireless_bytes(mut self, value: &[u8]) -> Self {
16610        push_header(self.as_rec_mut(), 11u16, (value.len() + 1) as u16);
16611        self.as_rec_mut().extend(value);
16612        self.as_rec_mut().push(0);
16613        self
16614    }
16615    pub fn push_protinfo(mut self, value: &CStr) -> Self {
16616        push_header(
16617            self.as_rec_mut(),
16618            12u16,
16619            value.to_bytes_with_nul().len() as u16,
16620        );
16621        self.as_rec_mut().extend(value.to_bytes_with_nul());
16622        self
16623    }
16624    pub fn push_protinfo_bytes(mut self, value: &[u8]) -> Self {
16625        push_header(self.as_rec_mut(), 12u16, (value.len() + 1) as u16);
16626        self.as_rec_mut().extend(value);
16627        self.as_rec_mut().push(0);
16628        self
16629    }
16630    pub fn push_txqlen(mut self, value: u32) -> Self {
16631        push_header(self.as_rec_mut(), 13u16, 4 as u16);
16632        self.as_rec_mut().extend(value.to_ne_bytes());
16633        self
16634    }
16635    pub fn push_map(mut self, value: PushRtnlLinkIfmap) -> Self {
16636        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
16637        self.as_rec_mut().extend(value.as_slice());
16638        self
16639    }
16640    pub fn push_weight(mut self, value: u32) -> Self {
16641        push_header(self.as_rec_mut(), 15u16, 4 as u16);
16642        self.as_rec_mut().extend(value.to_ne_bytes());
16643        self
16644    }
16645    pub fn push_operstate(mut self, value: u8) -> Self {
16646        push_header(self.as_rec_mut(), 16u16, 1 as u16);
16647        self.as_rec_mut().extend(value.to_ne_bytes());
16648        self
16649    }
16650    pub fn push_linkmode(mut self, value: u8) -> Self {
16651        push_header(self.as_rec_mut(), 17u16, 1 as u16);
16652        self.as_rec_mut().extend(value.to_ne_bytes());
16653        self
16654    }
16655    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
16656        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
16657        PushLinkinfoAttrs {
16658            prev: Some(self),
16659            header_offset: Some(header_offset),
16660        }
16661    }
16662    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
16663        push_header(self.as_rec_mut(), 19u16, 4 as u16);
16664        self.as_rec_mut().extend(value.to_ne_bytes());
16665        self
16666    }
16667    pub fn push_ifalias(mut self, value: &CStr) -> Self {
16668        push_header(
16669            self.as_rec_mut(),
16670            20u16,
16671            value.to_bytes_with_nul().len() as u16,
16672        );
16673        self.as_rec_mut().extend(value.to_bytes_with_nul());
16674        self
16675    }
16676    pub fn push_ifalias_bytes(mut self, value: &[u8]) -> Self {
16677        push_header(self.as_rec_mut(), 20u16, (value.len() + 1) as u16);
16678        self.as_rec_mut().extend(value);
16679        self.as_rec_mut().push(0);
16680        self
16681    }
16682    pub fn push_num_vf(mut self, value: u32) -> Self {
16683        push_header(self.as_rec_mut(), 21u16, 4 as u16);
16684        self.as_rec_mut().extend(value.to_ne_bytes());
16685        self
16686    }
16687    pub fn nested_vfinfo_list(mut self) -> PushVfinfoListAttrs<Self> {
16688        let header_offset = push_nested_header(self.as_rec_mut(), 22u16);
16689        PushVfinfoListAttrs {
16690            prev: Some(self),
16691            header_offset: Some(header_offset),
16692        }
16693    }
16694    pub fn push_stats64(mut self, value: PushRtnlLinkStats64) -> Self {
16695        push_header(self.as_rec_mut(), 23u16, value.as_slice().len() as u16);
16696        self.as_rec_mut().extend(value.as_slice());
16697        self
16698    }
16699    pub fn nested_vf_ports(mut self) -> PushVfPortsAttrs<Self> {
16700        let header_offset = push_nested_header(self.as_rec_mut(), 24u16);
16701        PushVfPortsAttrs {
16702            prev: Some(self),
16703            header_offset: Some(header_offset),
16704        }
16705    }
16706    pub fn nested_port_self(mut self) -> PushPortSelfAttrs<Self> {
16707        let header_offset = push_nested_header(self.as_rec_mut(), 25u16);
16708        PushPortSelfAttrs {
16709            prev: Some(self),
16710            header_offset: Some(header_offset),
16711        }
16712    }
16713    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
16714        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
16715        PushAfSpecAttrs {
16716            prev: Some(self),
16717            header_offset: Some(header_offset),
16718        }
16719    }
16720    pub fn push_group(mut self, value: u32) -> Self {
16721        push_header(self.as_rec_mut(), 27u16, 4 as u16);
16722        self.as_rec_mut().extend(value.to_ne_bytes());
16723        self
16724    }
16725    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
16726        push_header(self.as_rec_mut(), 28u16, 4 as u16);
16727        self.as_rec_mut().extend(value.to_ne_bytes());
16728        self
16729    }
16730    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
16731    pub fn push_ext_mask(mut self, value: u32) -> Self {
16732        push_header(self.as_rec_mut(), 29u16, 4 as u16);
16733        self.as_rec_mut().extend(value.to_ne_bytes());
16734        self
16735    }
16736    pub fn push_promiscuity(mut self, value: u32) -> Self {
16737        push_header(self.as_rec_mut(), 30u16, 4 as u16);
16738        self.as_rec_mut().extend(value.to_ne_bytes());
16739        self
16740    }
16741    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
16742        push_header(self.as_rec_mut(), 31u16, 4 as u16);
16743        self.as_rec_mut().extend(value.to_ne_bytes());
16744        self
16745    }
16746    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
16747        push_header(self.as_rec_mut(), 32u16, 4 as u16);
16748        self.as_rec_mut().extend(value.to_ne_bytes());
16749        self
16750    }
16751    pub fn push_carrier(mut self, value: u8) -> Self {
16752        push_header(self.as_rec_mut(), 33u16, 1 as u16);
16753        self.as_rec_mut().extend(value.to_ne_bytes());
16754        self
16755    }
16756    pub fn push_phys_port_id(mut self, value: &[u8]) -> Self {
16757        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
16758        self.as_rec_mut().extend(value);
16759        self
16760    }
16761    pub fn push_carrier_changes(mut self, value: u32) -> Self {
16762        push_header(self.as_rec_mut(), 35u16, 4 as u16);
16763        self.as_rec_mut().extend(value.to_ne_bytes());
16764        self
16765    }
16766    pub fn push_phys_switch_id(mut self, value: &[u8]) -> Self {
16767        push_header(self.as_rec_mut(), 36u16, value.len() as u16);
16768        self.as_rec_mut().extend(value);
16769        self
16770    }
16771    pub fn push_link_netnsid(mut self, value: i32) -> Self {
16772        push_header(self.as_rec_mut(), 37u16, 4 as u16);
16773        self.as_rec_mut().extend(value.to_ne_bytes());
16774        self
16775    }
16776    pub fn push_phys_port_name(mut self, value: &CStr) -> Self {
16777        push_header(
16778            self.as_rec_mut(),
16779            38u16,
16780            value.to_bytes_with_nul().len() as u16,
16781        );
16782        self.as_rec_mut().extend(value.to_bytes_with_nul());
16783        self
16784    }
16785    pub fn push_phys_port_name_bytes(mut self, value: &[u8]) -> Self {
16786        push_header(self.as_rec_mut(), 38u16, (value.len() + 1) as u16);
16787        self.as_rec_mut().extend(value);
16788        self.as_rec_mut().push(0);
16789        self
16790    }
16791    pub fn push_proto_down(mut self, value: u8) -> Self {
16792        push_header(self.as_rec_mut(), 39u16, 1 as u16);
16793        self.as_rec_mut().extend(value.to_ne_bytes());
16794        self
16795    }
16796    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
16797        push_header(self.as_rec_mut(), 40u16, 4 as u16);
16798        self.as_rec_mut().extend(value.to_ne_bytes());
16799        self
16800    }
16801    pub fn push_gso_max_size(mut self, value: u32) -> Self {
16802        push_header(self.as_rec_mut(), 41u16, 4 as u16);
16803        self.as_rec_mut().extend(value.to_ne_bytes());
16804        self
16805    }
16806    pub fn push_pad(mut self, value: &[u8]) -> Self {
16807        push_header(self.as_rec_mut(), 42u16, value.len() as u16);
16808        self.as_rec_mut().extend(value);
16809        self
16810    }
16811    pub fn nested_xdp(mut self) -> PushXdpAttrs<Self> {
16812        let header_offset = push_nested_header(self.as_rec_mut(), 43u16);
16813        PushXdpAttrs {
16814            prev: Some(self),
16815            header_offset: Some(header_offset),
16816        }
16817    }
16818    pub fn push_event(mut self, value: u32) -> Self {
16819        push_header(self.as_rec_mut(), 44u16, 4 as u16);
16820        self.as_rec_mut().extend(value.to_ne_bytes());
16821        self
16822    }
16823    pub fn push_new_netnsid(mut self, value: i32) -> Self {
16824        push_header(self.as_rec_mut(), 45u16, 4 as u16);
16825        self.as_rec_mut().extend(value.to_ne_bytes());
16826        self
16827    }
16828    pub fn push_target_netnsid(mut self, value: i32) -> Self {
16829        push_header(self.as_rec_mut(), 46u16, 4 as u16);
16830        self.as_rec_mut().extend(value.to_ne_bytes());
16831        self
16832    }
16833    pub fn push_carrier_up_count(mut self, value: u32) -> Self {
16834        push_header(self.as_rec_mut(), 47u16, 4 as u16);
16835        self.as_rec_mut().extend(value.to_ne_bytes());
16836        self
16837    }
16838    pub fn push_carrier_down_count(mut self, value: u32) -> Self {
16839        push_header(self.as_rec_mut(), 48u16, 4 as u16);
16840        self.as_rec_mut().extend(value.to_ne_bytes());
16841        self
16842    }
16843    pub fn push_new_ifindex(mut self, value: i32) -> Self {
16844        push_header(self.as_rec_mut(), 49u16, 4 as u16);
16845        self.as_rec_mut().extend(value.to_ne_bytes());
16846        self
16847    }
16848    pub fn push_min_mtu(mut self, value: u32) -> Self {
16849        push_header(self.as_rec_mut(), 50u16, 4 as u16);
16850        self.as_rec_mut().extend(value.to_ne_bytes());
16851        self
16852    }
16853    pub fn push_max_mtu(mut self, value: u32) -> Self {
16854        push_header(self.as_rec_mut(), 51u16, 4 as u16);
16855        self.as_rec_mut().extend(value.to_ne_bytes());
16856        self
16857    }
16858    pub fn nested_prop_list(mut self) -> PushPropListLinkAttrs<Self> {
16859        let header_offset = push_nested_header(self.as_rec_mut(), 52u16);
16860        PushPropListLinkAttrs {
16861            prev: Some(self),
16862            header_offset: Some(header_offset),
16863        }
16864    }
16865    pub fn push_alt_ifname(mut self, value: &CStr) -> Self {
16866        push_header(
16867            self.as_rec_mut(),
16868            53u16,
16869            value.to_bytes_with_nul().len() as u16,
16870        );
16871        self.as_rec_mut().extend(value.to_bytes_with_nul());
16872        self
16873    }
16874    pub fn push_alt_ifname_bytes(mut self, value: &[u8]) -> Self {
16875        push_header(self.as_rec_mut(), 53u16, (value.len() + 1) as u16);
16876        self.as_rec_mut().extend(value);
16877        self.as_rec_mut().push(0);
16878        self
16879    }
16880    pub fn push_perm_address(mut self, value: &[u8]) -> Self {
16881        push_header(self.as_rec_mut(), 54u16, value.len() as u16);
16882        self.as_rec_mut().extend(value);
16883        self
16884    }
16885    pub fn push_proto_down_reason(mut self, value: &CStr) -> Self {
16886        push_header(
16887            self.as_rec_mut(),
16888            55u16,
16889            value.to_bytes_with_nul().len() as u16,
16890        );
16891        self.as_rec_mut().extend(value.to_bytes_with_nul());
16892        self
16893    }
16894    pub fn push_proto_down_reason_bytes(mut self, value: &[u8]) -> Self {
16895        push_header(self.as_rec_mut(), 55u16, (value.len() + 1) as u16);
16896        self.as_rec_mut().extend(value);
16897        self.as_rec_mut().push(0);
16898        self
16899    }
16900    pub fn push_parent_dev_name(mut self, value: &CStr) -> Self {
16901        push_header(
16902            self.as_rec_mut(),
16903            56u16,
16904            value.to_bytes_with_nul().len() as u16,
16905        );
16906        self.as_rec_mut().extend(value.to_bytes_with_nul());
16907        self
16908    }
16909    pub fn push_parent_dev_name_bytes(mut self, value: &[u8]) -> Self {
16910        push_header(self.as_rec_mut(), 56u16, (value.len() + 1) as u16);
16911        self.as_rec_mut().extend(value);
16912        self.as_rec_mut().push(0);
16913        self
16914    }
16915    pub fn push_parent_dev_bus_name(mut self, value: &CStr) -> Self {
16916        push_header(
16917            self.as_rec_mut(),
16918            57u16,
16919            value.to_bytes_with_nul().len() as u16,
16920        );
16921        self.as_rec_mut().extend(value.to_bytes_with_nul());
16922        self
16923    }
16924    pub fn push_parent_dev_bus_name_bytes(mut self, value: &[u8]) -> Self {
16925        push_header(self.as_rec_mut(), 57u16, (value.len() + 1) as u16);
16926        self.as_rec_mut().extend(value);
16927        self.as_rec_mut().push(0);
16928        self
16929    }
16930    pub fn push_gro_max_size(mut self, value: u32) -> Self {
16931        push_header(self.as_rec_mut(), 58u16, 4 as u16);
16932        self.as_rec_mut().extend(value.to_ne_bytes());
16933        self
16934    }
16935    pub fn push_tso_max_size(mut self, value: u32) -> Self {
16936        push_header(self.as_rec_mut(), 59u16, 4 as u16);
16937        self.as_rec_mut().extend(value.to_ne_bytes());
16938        self
16939    }
16940    pub fn push_tso_max_segs(mut self, value: u32) -> Self {
16941        push_header(self.as_rec_mut(), 60u16, 4 as u16);
16942        self.as_rec_mut().extend(value.to_ne_bytes());
16943        self
16944    }
16945    pub fn push_allmulti(mut self, value: u32) -> Self {
16946        push_header(self.as_rec_mut(), 61u16, 4 as u16);
16947        self.as_rec_mut().extend(value.to_ne_bytes());
16948        self
16949    }
16950    pub fn push_devlink_port(mut self, value: &[u8]) -> Self {
16951        push_header(self.as_rec_mut(), 62u16, value.len() as u16);
16952        self.as_rec_mut().extend(value);
16953        self
16954    }
16955    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
16956        push_header(self.as_rec_mut(), 63u16, 4 as u16);
16957        self.as_rec_mut().extend(value.to_ne_bytes());
16958        self
16959    }
16960    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
16961        push_header(self.as_rec_mut(), 64u16, 4 as u16);
16962        self.as_rec_mut().extend(value.to_ne_bytes());
16963        self
16964    }
16965    pub fn nested_dpll_pin(mut self) -> PushLinkDpllPinAttrs<Self> {
16966        let header_offset = push_nested_header(self.as_rec_mut(), 65u16);
16967        PushLinkDpllPinAttrs {
16968            prev: Some(self),
16969            header_offset: Some(header_offset),
16970        }
16971    }
16972    #[doc = "EDT offload horizon supported by the device (in nsec)."]
16973    pub fn push_max_pacing_offload_horizon(mut self, value: u32) -> Self {
16974        push_header(self.as_rec_mut(), 66u16, 4 as u16);
16975        self.as_rec_mut().extend(value.to_ne_bytes());
16976        self
16977    }
16978    pub fn push_netns_immutable(mut self, value: u8) -> Self {
16979        push_header(self.as_rec_mut(), 67u16, 1 as u16);
16980        self.as_rec_mut().extend(value.to_ne_bytes());
16981        self
16982    }
16983}
16984impl<Prev: Rec> Drop for PushLinkAttrs<Prev> {
16985    fn drop(&mut self) {
16986        if let Some(prev) = &mut self.prev {
16987            if let Some(header_offset) = &self.header_offset {
16988                finalize_nested_header(prev.as_rec_mut(), *header_offset);
16989            }
16990        }
16991    }
16992}
16993pub struct PushPropListLinkAttrs<Prev: Rec> {
16994    pub(crate) prev: Option<Prev>,
16995    pub(crate) header_offset: Option<usize>,
16996}
16997impl<Prev: Rec> Rec for PushPropListLinkAttrs<Prev> {
16998    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
16999        self.prev.as_mut().unwrap().as_rec_mut()
17000    }
17001}
17002impl<Prev: Rec> PushPropListLinkAttrs<Prev> {
17003    pub fn new(prev: Prev) -> Self {
17004        Self {
17005            prev: Some(prev),
17006            header_offset: None,
17007        }
17008    }
17009    pub fn end_nested(mut self) -> Prev {
17010        let mut prev = self.prev.take().unwrap();
17011        if let Some(header_offset) = &self.header_offset {
17012            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17013        }
17014        prev
17015    }
17016    pub fn push_alt_ifname(mut self, value: &CStr) -> Self {
17017        push_header(
17018            self.as_rec_mut(),
17019            1u16,
17020            value.to_bytes_with_nul().len() as u16,
17021        );
17022        self.as_rec_mut().extend(value.to_bytes_with_nul());
17023        self
17024    }
17025    pub fn push_alt_ifname_bytes(mut self, value: &[u8]) -> Self {
17026        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
17027        self.as_rec_mut().extend(value);
17028        self.as_rec_mut().push(0);
17029        self
17030    }
17031}
17032impl<Prev: Rec> Drop for PushPropListLinkAttrs<Prev> {
17033    fn drop(&mut self) {
17034        if let Some(prev) = &mut self.prev {
17035            if let Some(header_offset) = &self.header_offset {
17036                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17037            }
17038        }
17039    }
17040}
17041pub struct PushAfSpecAttrs<Prev: Rec> {
17042    pub(crate) prev: Option<Prev>,
17043    pub(crate) header_offset: Option<usize>,
17044}
17045impl<Prev: Rec> Rec for PushAfSpecAttrs<Prev> {
17046    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17047        self.prev.as_mut().unwrap().as_rec_mut()
17048    }
17049}
17050impl<Prev: Rec> PushAfSpecAttrs<Prev> {
17051    pub fn new(prev: Prev) -> Self {
17052        Self {
17053            prev: Some(prev),
17054            header_offset: None,
17055        }
17056    }
17057    pub fn end_nested(mut self) -> Prev {
17058        let mut prev = self.prev.take().unwrap();
17059        if let Some(header_offset) = &self.header_offset {
17060            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17061        }
17062        prev
17063    }
17064    pub fn nested_inet(mut self) -> PushIflaAttrs<Self> {
17065        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17066        PushIflaAttrs {
17067            prev: Some(self),
17068            header_offset: Some(header_offset),
17069        }
17070    }
17071    pub fn nested_inet6(mut self) -> PushIfla6Attrs<Self> {
17072        let header_offset = push_nested_header(self.as_rec_mut(), 10u16);
17073        PushIfla6Attrs {
17074            prev: Some(self),
17075            header_offset: Some(header_offset),
17076        }
17077    }
17078    pub fn nested_mctp(mut self) -> PushMctpAttrs<Self> {
17079        let header_offset = push_nested_header(self.as_rec_mut(), 45u16);
17080        PushMctpAttrs {
17081            prev: Some(self),
17082            header_offset: Some(header_offset),
17083        }
17084    }
17085}
17086impl<Prev: Rec> Drop for PushAfSpecAttrs<Prev> {
17087    fn drop(&mut self) {
17088        if let Some(prev) = &mut self.prev {
17089            if let Some(header_offset) = &self.header_offset {
17090                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17091            }
17092        }
17093    }
17094}
17095pub struct PushVfinfoListAttrs<Prev: Rec> {
17096    pub(crate) prev: Option<Prev>,
17097    pub(crate) header_offset: Option<usize>,
17098}
17099impl<Prev: Rec> Rec for PushVfinfoListAttrs<Prev> {
17100    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17101        self.prev.as_mut().unwrap().as_rec_mut()
17102    }
17103}
17104impl<Prev: Rec> PushVfinfoListAttrs<Prev> {
17105    pub fn new(prev: Prev) -> Self {
17106        Self {
17107            prev: Some(prev),
17108            header_offset: None,
17109        }
17110    }
17111    pub fn end_nested(mut self) -> Prev {
17112        let mut prev = self.prev.take().unwrap();
17113        if let Some(header_offset) = &self.header_offset {
17114            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17115        }
17116        prev
17117    }
17118    #[doc = "Attribute may repeat multiple times (treat it as array)"]
17119    pub fn nested_info(mut self) -> PushVfinfoAttrs<Self> {
17120        let header_offset = push_nested_header(self.as_rec_mut(), 1u16);
17121        PushVfinfoAttrs {
17122            prev: Some(self),
17123            header_offset: Some(header_offset),
17124        }
17125    }
17126}
17127impl<Prev: Rec> Drop for PushVfinfoListAttrs<Prev> {
17128    fn drop(&mut self) {
17129        if let Some(prev) = &mut self.prev {
17130            if let Some(header_offset) = &self.header_offset {
17131                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17132            }
17133        }
17134    }
17135}
17136pub struct PushVfinfoAttrs<Prev: Rec> {
17137    pub(crate) prev: Option<Prev>,
17138    pub(crate) header_offset: Option<usize>,
17139}
17140impl<Prev: Rec> Rec for PushVfinfoAttrs<Prev> {
17141    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17142        self.prev.as_mut().unwrap().as_rec_mut()
17143    }
17144}
17145impl<Prev: Rec> PushVfinfoAttrs<Prev> {
17146    pub fn new(prev: Prev) -> Self {
17147        Self {
17148            prev: Some(prev),
17149            header_offset: None,
17150        }
17151    }
17152    pub fn end_nested(mut self) -> Prev {
17153        let mut prev = self.prev.take().unwrap();
17154        if let Some(header_offset) = &self.header_offset {
17155            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17156        }
17157        prev
17158    }
17159    pub fn push_mac(mut self, value: PushIflaVfMac) -> Self {
17160        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
17161        self.as_rec_mut().extend(value.as_slice());
17162        self
17163    }
17164    pub fn push_vlan(mut self, value: PushIflaVfVlan) -> Self {
17165        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
17166        self.as_rec_mut().extend(value.as_slice());
17167        self
17168    }
17169    pub fn push_tx_rate(mut self, value: PushIflaVfTxRate) -> Self {
17170        push_header(self.as_rec_mut(), 3u16, value.as_slice().len() as u16);
17171        self.as_rec_mut().extend(value.as_slice());
17172        self
17173    }
17174    pub fn push_spoofchk(mut self, value: PushIflaVfSpoofchk) -> Self {
17175        push_header(self.as_rec_mut(), 4u16, value.as_slice().len() as u16);
17176        self.as_rec_mut().extend(value.as_slice());
17177        self
17178    }
17179    pub fn push_link_state(mut self, value: PushIflaVfLinkState) -> Self {
17180        push_header(self.as_rec_mut(), 5u16, value.as_slice().len() as u16);
17181        self.as_rec_mut().extend(value.as_slice());
17182        self
17183    }
17184    pub fn push_rate(mut self, value: PushIflaVfRate) -> Self {
17185        push_header(self.as_rec_mut(), 6u16, value.as_slice().len() as u16);
17186        self.as_rec_mut().extend(value.as_slice());
17187        self
17188    }
17189    pub fn push_rss_query_en(mut self, value: PushIflaVfRssQueryEn) -> Self {
17190        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
17191        self.as_rec_mut().extend(value.as_slice());
17192        self
17193    }
17194    pub fn nested_stats(mut self) -> PushVfStatsAttrs<Self> {
17195        let header_offset = push_nested_header(self.as_rec_mut(), 8u16);
17196        PushVfStatsAttrs {
17197            prev: Some(self),
17198            header_offset: Some(header_offset),
17199        }
17200    }
17201    pub fn push_trust(mut self, value: PushIflaVfTrust) -> Self {
17202        push_header(self.as_rec_mut(), 9u16, value.as_slice().len() as u16);
17203        self.as_rec_mut().extend(value.as_slice());
17204        self
17205    }
17206    pub fn push_ib_node_guid(mut self, value: PushIflaVfGuid) -> Self {
17207        push_header(self.as_rec_mut(), 10u16, value.as_slice().len() as u16);
17208        self.as_rec_mut().extend(value.as_slice());
17209        self
17210    }
17211    pub fn push_ib_port_guid(mut self, value: PushIflaVfGuid) -> Self {
17212        push_header(self.as_rec_mut(), 11u16, value.as_slice().len() as u16);
17213        self.as_rec_mut().extend(value.as_slice());
17214        self
17215    }
17216    pub fn nested_vlan_list(mut self) -> PushVfVlanAttrs<Self> {
17217        let header_offset = push_nested_header(self.as_rec_mut(), 12u16);
17218        PushVfVlanAttrs {
17219            prev: Some(self),
17220            header_offset: Some(header_offset),
17221        }
17222    }
17223    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
17224        push_header(self.as_rec_mut(), 13u16, value.len() as u16);
17225        self.as_rec_mut().extend(value);
17226        self
17227    }
17228}
17229impl<Prev: Rec> Drop for PushVfinfoAttrs<Prev> {
17230    fn drop(&mut self) {
17231        if let Some(prev) = &mut self.prev {
17232            if let Some(header_offset) = &self.header_offset {
17233                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17234            }
17235        }
17236    }
17237}
17238pub struct PushVfStatsAttrs<Prev: Rec> {
17239    pub(crate) prev: Option<Prev>,
17240    pub(crate) header_offset: Option<usize>,
17241}
17242impl<Prev: Rec> Rec for PushVfStatsAttrs<Prev> {
17243    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17244        self.prev.as_mut().unwrap().as_rec_mut()
17245    }
17246}
17247impl<Prev: Rec> PushVfStatsAttrs<Prev> {
17248    pub fn new(prev: Prev) -> Self {
17249        Self {
17250            prev: Some(prev),
17251            header_offset: None,
17252        }
17253    }
17254    pub fn end_nested(mut self) -> Prev {
17255        let mut prev = self.prev.take().unwrap();
17256        if let Some(header_offset) = &self.header_offset {
17257            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17258        }
17259        prev
17260    }
17261    pub fn push_rx_packets(mut self, value: u64) -> Self {
17262        push_header(self.as_rec_mut(), 0u16, 8 as u16);
17263        self.as_rec_mut().extend(value.to_ne_bytes());
17264        self
17265    }
17266    pub fn push_tx_packets(mut self, value: u64) -> Self {
17267        push_header(self.as_rec_mut(), 1u16, 8 as u16);
17268        self.as_rec_mut().extend(value.to_ne_bytes());
17269        self
17270    }
17271    pub fn push_rx_bytes(mut self, value: u64) -> Self {
17272        push_header(self.as_rec_mut(), 2u16, 8 as u16);
17273        self.as_rec_mut().extend(value.to_ne_bytes());
17274        self
17275    }
17276    pub fn push_tx_bytes(mut self, value: u64) -> Self {
17277        push_header(self.as_rec_mut(), 3u16, 8 as u16);
17278        self.as_rec_mut().extend(value.to_ne_bytes());
17279        self
17280    }
17281    pub fn push_broadcast(mut self, value: u64) -> Self {
17282        push_header(self.as_rec_mut(), 4u16, 8 as u16);
17283        self.as_rec_mut().extend(value.to_ne_bytes());
17284        self
17285    }
17286    pub fn push_multicast(mut self, value: u64) -> Self {
17287        push_header(self.as_rec_mut(), 5u16, 8 as u16);
17288        self.as_rec_mut().extend(value.to_ne_bytes());
17289        self
17290    }
17291    pub fn push_pad(mut self, value: &[u8]) -> Self {
17292        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
17293        self.as_rec_mut().extend(value);
17294        self
17295    }
17296    pub fn push_rx_dropped(mut self, value: u64) -> Self {
17297        push_header(self.as_rec_mut(), 7u16, 8 as u16);
17298        self.as_rec_mut().extend(value.to_ne_bytes());
17299        self
17300    }
17301    pub fn push_tx_dropped(mut self, value: u64) -> Self {
17302        push_header(self.as_rec_mut(), 8u16, 8 as u16);
17303        self.as_rec_mut().extend(value.to_ne_bytes());
17304        self
17305    }
17306}
17307impl<Prev: Rec> Drop for PushVfStatsAttrs<Prev> {
17308    fn drop(&mut self) {
17309        if let Some(prev) = &mut self.prev {
17310            if let Some(header_offset) = &self.header_offset {
17311                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17312            }
17313        }
17314    }
17315}
17316pub struct PushVfVlanAttrs<Prev: Rec> {
17317    pub(crate) prev: Option<Prev>,
17318    pub(crate) header_offset: Option<usize>,
17319}
17320impl<Prev: Rec> Rec for PushVfVlanAttrs<Prev> {
17321    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17322        self.prev.as_mut().unwrap().as_rec_mut()
17323    }
17324}
17325impl<Prev: Rec> PushVfVlanAttrs<Prev> {
17326    pub fn new(prev: Prev) -> Self {
17327        Self {
17328            prev: Some(prev),
17329            header_offset: None,
17330        }
17331    }
17332    pub fn end_nested(mut self) -> Prev {
17333        let mut prev = self.prev.take().unwrap();
17334        if let Some(header_offset) = &self.header_offset {
17335            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17336        }
17337        prev
17338    }
17339    #[doc = "Attribute may repeat multiple times (treat it as array)"]
17340    pub fn push_info(mut self, value: PushIflaVfVlanInfo) -> Self {
17341        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
17342        self.as_rec_mut().extend(value.as_slice());
17343        self
17344    }
17345}
17346impl<Prev: Rec> Drop for PushVfVlanAttrs<Prev> {
17347    fn drop(&mut self) {
17348        if let Some(prev) = &mut self.prev {
17349            if let Some(header_offset) = &self.header_offset {
17350                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17351            }
17352        }
17353    }
17354}
17355pub struct PushVfPortsAttrs<Prev: Rec> {
17356    pub(crate) prev: Option<Prev>,
17357    pub(crate) header_offset: Option<usize>,
17358}
17359impl<Prev: Rec> Rec for PushVfPortsAttrs<Prev> {
17360    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17361        self.prev.as_mut().unwrap().as_rec_mut()
17362    }
17363}
17364impl<Prev: Rec> PushVfPortsAttrs<Prev> {
17365    pub fn new(prev: Prev) -> Self {
17366        Self {
17367            prev: Some(prev),
17368            header_offset: None,
17369        }
17370    }
17371    pub fn end_nested(mut self) -> Prev {
17372        let mut prev = self.prev.take().unwrap();
17373        if let Some(header_offset) = &self.header_offset {
17374            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17375        }
17376        prev
17377    }
17378}
17379impl<Prev: Rec> Drop for PushVfPortsAttrs<Prev> {
17380    fn drop(&mut self) {
17381        if let Some(prev) = &mut self.prev {
17382            if let Some(header_offset) = &self.header_offset {
17383                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17384            }
17385        }
17386    }
17387}
17388pub struct PushPortSelfAttrs<Prev: Rec> {
17389    pub(crate) prev: Option<Prev>,
17390    pub(crate) header_offset: Option<usize>,
17391}
17392impl<Prev: Rec> Rec for PushPortSelfAttrs<Prev> {
17393    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17394        self.prev.as_mut().unwrap().as_rec_mut()
17395    }
17396}
17397impl<Prev: Rec> PushPortSelfAttrs<Prev> {
17398    pub fn new(prev: Prev) -> Self {
17399        Self {
17400            prev: Some(prev),
17401            header_offset: None,
17402        }
17403    }
17404    pub fn end_nested(mut self) -> Prev {
17405        let mut prev = self.prev.take().unwrap();
17406        if let Some(header_offset) = &self.header_offset {
17407            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17408        }
17409        prev
17410    }
17411}
17412impl<Prev: Rec> Drop for PushPortSelfAttrs<Prev> {
17413    fn drop(&mut self) {
17414        if let Some(prev) = &mut self.prev {
17415            if let Some(header_offset) = &self.header_offset {
17416                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17417            }
17418        }
17419    }
17420}
17421pub struct PushLinkinfoAttrs<Prev: Rec> {
17422    pub(crate) prev: Option<Prev>,
17423    pub(crate) header_offset: Option<usize>,
17424}
17425impl<Prev: Rec> Rec for PushLinkinfoAttrs<Prev> {
17426    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17427        self.prev.as_mut().unwrap().as_rec_mut()
17428    }
17429}
17430impl<Prev: Rec> PushLinkinfoAttrs<Prev> {
17431    pub fn new(prev: Prev) -> Self {
17432        Self {
17433            prev: Some(prev),
17434            header_offset: None,
17435        }
17436    }
17437    pub fn end_nested(mut self) -> Prev {
17438        let mut prev = self.prev.take().unwrap();
17439        if let Some(header_offset) = &self.header_offset {
17440            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17441        }
17442        prev
17443    }
17444    pub fn push_kind(mut self, value: &CStr) -> Self {
17445        push_header(
17446            self.as_rec_mut(),
17447            1u16,
17448            value.to_bytes_with_nul().len() as u16,
17449        );
17450        self.as_rec_mut().extend(value.to_bytes_with_nul());
17451        self
17452    }
17453    pub fn push_kind_bytes(mut self, value: &[u8]) -> Self {
17454        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
17455        self.as_rec_mut().extend(value);
17456        self.as_rec_mut().push(0);
17457        self
17458    }
17459    #[doc = "Selector attribute is inserted automatically."]
17460    #[doc = "At most one sub-message attribute is expected per attribute set."]
17461    pub fn nested_data_bond(mut self) -> PushLinkinfoBondAttrs<PushDummy<Prev>> {
17462        self = self.push_kind(c"bond");
17463        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17464        let dummy = PushDummy {
17465            prev: self.prev.take(),
17466            header_offset: self.header_offset.take(),
17467        };
17468        PushLinkinfoBondAttrs {
17469            prev: Some(dummy),
17470            header_offset: Some(new_header_offset),
17471        }
17472    }
17473    #[doc = "Selector attribute is inserted automatically."]
17474    #[doc = "At most one sub-message attribute is expected per attribute set."]
17475    pub fn nested_data_bridge(mut self) -> PushLinkinfoBridgeAttrs<PushDummy<Prev>> {
17476        self = self.push_kind(c"bridge");
17477        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17478        let dummy = PushDummy {
17479            prev: self.prev.take(),
17480            header_offset: self.header_offset.take(),
17481        };
17482        PushLinkinfoBridgeAttrs {
17483            prev: Some(dummy),
17484            header_offset: Some(new_header_offset),
17485        }
17486    }
17487    #[doc = "Selector attribute is inserted automatically."]
17488    #[doc = "At most one sub-message attribute is expected per attribute set."]
17489    pub fn nested_data_erspan(mut self) -> PushLinkinfoGreAttrs<PushDummy<Prev>> {
17490        self = self.push_kind(c"erspan");
17491        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17492        let dummy = PushDummy {
17493            prev: self.prev.take(),
17494            header_offset: self.header_offset.take(),
17495        };
17496        PushLinkinfoGreAttrs {
17497            prev: Some(dummy),
17498            header_offset: Some(new_header_offset),
17499        }
17500    }
17501    #[doc = "Selector attribute is inserted automatically."]
17502    #[doc = "At most one sub-message attribute is expected per attribute set."]
17503    pub fn nested_data_gre(mut self) -> PushLinkinfoGreAttrs<PushDummy<Prev>> {
17504        self = self.push_kind(c"gre");
17505        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17506        let dummy = PushDummy {
17507            prev: self.prev.take(),
17508            header_offset: self.header_offset.take(),
17509        };
17510        PushLinkinfoGreAttrs {
17511            prev: Some(dummy),
17512            header_offset: Some(new_header_offset),
17513        }
17514    }
17515    #[doc = "Selector attribute is inserted automatically."]
17516    #[doc = "At most one sub-message attribute is expected per attribute set."]
17517    pub fn nested_data_gretap(mut self) -> PushLinkinfoGreAttrs<PushDummy<Prev>> {
17518        self = self.push_kind(c"gretap");
17519        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17520        let dummy = PushDummy {
17521            prev: self.prev.take(),
17522            header_offset: self.header_offset.take(),
17523        };
17524        PushLinkinfoGreAttrs {
17525            prev: Some(dummy),
17526            header_offset: Some(new_header_offset),
17527        }
17528    }
17529    #[doc = "Selector attribute is inserted automatically."]
17530    #[doc = "At most one sub-message attribute is expected per attribute set."]
17531    pub fn nested_data_ip6gre(mut self) -> PushLinkinfoGre6Attrs<PushDummy<Prev>> {
17532        self = self.push_kind(c"ip6gre");
17533        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17534        let dummy = PushDummy {
17535            prev: self.prev.take(),
17536            header_offset: self.header_offset.take(),
17537        };
17538        PushLinkinfoGre6Attrs {
17539            prev: Some(dummy),
17540            header_offset: Some(new_header_offset),
17541        }
17542    }
17543    #[doc = "Selector attribute is inserted automatically."]
17544    #[doc = "At most one sub-message attribute is expected per attribute set."]
17545    pub fn nested_data_geneve(mut self) -> PushLinkinfoGeneveAttrs<PushDummy<Prev>> {
17546        self = self.push_kind(c"geneve");
17547        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17548        let dummy = PushDummy {
17549            prev: self.prev.take(),
17550            header_offset: self.header_offset.take(),
17551        };
17552        PushLinkinfoGeneveAttrs {
17553            prev: Some(dummy),
17554            header_offset: Some(new_header_offset),
17555        }
17556    }
17557    #[doc = "Selector attribute is inserted automatically."]
17558    #[doc = "At most one sub-message attribute is expected per attribute set."]
17559    pub fn nested_data_ipip(mut self) -> PushLinkinfoIptunAttrs<PushDummy<Prev>> {
17560        self = self.push_kind(c"ipip");
17561        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17562        let dummy = PushDummy {
17563            prev: self.prev.take(),
17564            header_offset: self.header_offset.take(),
17565        };
17566        PushLinkinfoIptunAttrs {
17567            prev: Some(dummy),
17568            header_offset: Some(new_header_offset),
17569        }
17570    }
17571    #[doc = "Selector attribute is inserted automatically."]
17572    #[doc = "At most one sub-message attribute is expected per attribute set."]
17573    pub fn nested_data_ip6tnl(mut self) -> PushLinkinfoIp6tnlAttrs<PushDummy<Prev>> {
17574        self = self.push_kind(c"ip6tnl");
17575        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17576        let dummy = PushDummy {
17577            prev: self.prev.take(),
17578            header_offset: self.header_offset.take(),
17579        };
17580        PushLinkinfoIp6tnlAttrs {
17581            prev: Some(dummy),
17582            header_offset: Some(new_header_offset),
17583        }
17584    }
17585    #[doc = "Selector attribute is inserted automatically."]
17586    #[doc = "At most one sub-message attribute is expected per attribute set."]
17587    pub fn nested_data_sit(mut self) -> PushLinkinfoIptunAttrs<PushDummy<Prev>> {
17588        self = self.push_kind(c"sit");
17589        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17590        let dummy = PushDummy {
17591            prev: self.prev.take(),
17592            header_offset: self.header_offset.take(),
17593        };
17594        PushLinkinfoIptunAttrs {
17595            prev: Some(dummy),
17596            header_offset: Some(new_header_offset),
17597        }
17598    }
17599    #[doc = "Selector attribute is inserted automatically."]
17600    #[doc = "At most one sub-message attribute is expected per attribute set."]
17601    pub fn nested_data_tun(mut self) -> PushLinkinfoTunAttrs<PushDummy<Prev>> {
17602        self = self.push_kind(c"tun");
17603        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17604        let dummy = PushDummy {
17605            prev: self.prev.take(),
17606            header_offset: self.header_offset.take(),
17607        };
17608        PushLinkinfoTunAttrs {
17609            prev: Some(dummy),
17610            header_offset: Some(new_header_offset),
17611        }
17612    }
17613    #[doc = "Selector attribute is inserted automatically."]
17614    #[doc = "At most one sub-message attribute is expected per attribute set."]
17615    pub fn nested_data_vlan(mut self) -> PushLinkinfoVlanAttrs<PushDummy<Prev>> {
17616        self = self.push_kind(c"vlan");
17617        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17618        let dummy = PushDummy {
17619            prev: self.prev.take(),
17620            header_offset: self.header_offset.take(),
17621        };
17622        PushLinkinfoVlanAttrs {
17623            prev: Some(dummy),
17624            header_offset: Some(new_header_offset),
17625        }
17626    }
17627    #[doc = "Selector attribute is inserted automatically."]
17628    #[doc = "At most one sub-message attribute is expected per attribute set."]
17629    pub fn nested_data_vrf(mut self) -> PushLinkinfoVrfAttrs<PushDummy<Prev>> {
17630        self = self.push_kind(c"vrf");
17631        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17632        let dummy = PushDummy {
17633            prev: self.prev.take(),
17634            header_offset: self.header_offset.take(),
17635        };
17636        PushLinkinfoVrfAttrs {
17637            prev: Some(dummy),
17638            header_offset: Some(new_header_offset),
17639        }
17640    }
17641    #[doc = "Selector attribute is inserted automatically."]
17642    #[doc = "At most one sub-message attribute is expected per attribute set."]
17643    pub fn nested_data_vti(mut self) -> PushLinkinfoVtiAttrs<PushDummy<Prev>> {
17644        self = self.push_kind(c"vti");
17645        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17646        let dummy = PushDummy {
17647            prev: self.prev.take(),
17648            header_offset: self.header_offset.take(),
17649        };
17650        PushLinkinfoVtiAttrs {
17651            prev: Some(dummy),
17652            header_offset: Some(new_header_offset),
17653        }
17654    }
17655    #[doc = "Selector attribute is inserted automatically."]
17656    #[doc = "At most one sub-message attribute is expected per attribute set."]
17657    pub fn nested_data_vti6(mut self) -> PushLinkinfoVti6Attrs<PushDummy<Prev>> {
17658        self = self.push_kind(c"vti6");
17659        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17660        let dummy = PushDummy {
17661            prev: self.prev.take(),
17662            header_offset: self.header_offset.take(),
17663        };
17664        PushLinkinfoVti6Attrs {
17665            prev: Some(dummy),
17666            header_offset: Some(new_header_offset),
17667        }
17668    }
17669    #[doc = "Selector attribute is inserted automatically."]
17670    #[doc = "At most one sub-message attribute is expected per attribute set."]
17671    pub fn nested_data_netkit(mut self) -> PushLinkinfoNetkitAttrs<PushDummy<Prev>> {
17672        self = self.push_kind(c"netkit");
17673        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17674        let dummy = PushDummy {
17675            prev: self.prev.take(),
17676            header_offset: self.header_offset.take(),
17677        };
17678        PushLinkinfoNetkitAttrs {
17679            prev: Some(dummy),
17680            header_offset: Some(new_header_offset),
17681        }
17682    }
17683    #[doc = "Selector attribute is inserted automatically."]
17684    #[doc = "At most one sub-message attribute is expected per attribute set."]
17685    pub fn nested_data_ovpn(mut self) -> PushLinkinfoOvpnAttrs<PushDummy<Prev>> {
17686        self = self.push_kind(c"ovpn");
17687        let new_header_offset = push_nested_header(self.as_rec_mut(), 2u16);
17688        let dummy = PushDummy {
17689            prev: self.prev.take(),
17690            header_offset: self.header_offset.take(),
17691        };
17692        PushLinkinfoOvpnAttrs {
17693            prev: Some(dummy),
17694            header_offset: Some(new_header_offset),
17695        }
17696    }
17697    pub fn push_xstats(mut self, value: &[u8]) -> Self {
17698        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
17699        self.as_rec_mut().extend(value);
17700        self
17701    }
17702    pub fn push_slave_kind(mut self, value: &CStr) -> Self {
17703        push_header(
17704            self.as_rec_mut(),
17705            4u16,
17706            value.to_bytes_with_nul().len() as u16,
17707        );
17708        self.as_rec_mut().extend(value.to_bytes_with_nul());
17709        self
17710    }
17711    pub fn push_slave_kind_bytes(mut self, value: &[u8]) -> Self {
17712        push_header(self.as_rec_mut(), 4u16, (value.len() + 1) as u16);
17713        self.as_rec_mut().extend(value);
17714        self.as_rec_mut().push(0);
17715        self
17716    }
17717    #[doc = "Selector attribute is inserted automatically."]
17718    #[doc = "At most one sub-message attribute is expected per attribute set."]
17719    pub fn nested_slave_data_bridge(mut self) -> PushLinkinfoBrportAttrs<PushDummy<Prev>> {
17720        self = self.push_slave_kind(c"bridge");
17721        let new_header_offset = push_nested_header(self.as_rec_mut(), 5u16);
17722        let dummy = PushDummy {
17723            prev: self.prev.take(),
17724            header_offset: self.header_offset.take(),
17725        };
17726        PushLinkinfoBrportAttrs {
17727            prev: Some(dummy),
17728            header_offset: Some(new_header_offset),
17729        }
17730    }
17731    #[doc = "Selector attribute is inserted automatically."]
17732    #[doc = "At most one sub-message attribute is expected per attribute set."]
17733    pub fn nested_slave_data_bond(mut self) -> PushBondSlaveAttrs<PushDummy<Prev>> {
17734        self = self.push_slave_kind(c"bond");
17735        let new_header_offset = push_nested_header(self.as_rec_mut(), 5u16);
17736        let dummy = PushDummy {
17737            prev: self.prev.take(),
17738            header_offset: self.header_offset.take(),
17739        };
17740        PushBondSlaveAttrs {
17741            prev: Some(dummy),
17742            header_offset: Some(new_header_offset),
17743        }
17744    }
17745}
17746impl<Prev: Rec> Drop for PushLinkinfoAttrs<Prev> {
17747    fn drop(&mut self) {
17748        if let Some(prev) = &mut self.prev {
17749            if let Some(header_offset) = &self.header_offset {
17750                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17751            }
17752        }
17753    }
17754}
17755pub struct PushLinkinfoBondAttrs<Prev: Rec> {
17756    pub(crate) prev: Option<Prev>,
17757    pub(crate) header_offset: Option<usize>,
17758}
17759impl<Prev: Rec> Rec for PushLinkinfoBondAttrs<Prev> {
17760    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17761        self.prev.as_mut().unwrap().as_rec_mut()
17762    }
17763}
17764pub struct PushArrayU32<Prev: Rec> {
17765    pub(crate) prev: Option<Prev>,
17766    pub(crate) header_offset: Option<usize>,
17767    pub(crate) counter: u16,
17768}
17769impl<Prev: Rec> Rec for PushArrayU32<Prev> {
17770    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17771        self.prev.as_mut().unwrap().as_rec_mut()
17772    }
17773}
17774impl<Prev: Rec> PushArrayU32<Prev> {
17775    pub fn new(prev: Prev) -> Self {
17776        Self {
17777            prev: Some(prev),
17778            header_offset: None,
17779            counter: 0,
17780        }
17781    }
17782    pub fn end_array(mut self) -> Prev {
17783        let mut prev = self.prev.take().unwrap();
17784        if let Some(header_offset) = &self.header_offset {
17785            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17786        }
17787        prev
17788    }
17789    pub fn entry(mut self, value: std::net::Ipv4Addr) -> Self {
17790        let index = self.counter;
17791        self.counter += 1;
17792        push_header(self.as_rec_mut(), index, 4 as u16);
17793        self.as_rec_mut().extend(&value.to_bits().to_be_bytes());
17794        self
17795    }
17796}
17797impl<Prev: Rec> Drop for PushArrayU32<Prev> {
17798    fn drop(&mut self) {
17799        if let Some(prev) = &mut self.prev {
17800            if let Some(header_offset) = &self.header_offset {
17801                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17802            }
17803        }
17804    }
17805}
17806pub struct PushArrayBinary<Prev: Rec> {
17807    pub(crate) prev: Option<Prev>,
17808    pub(crate) header_offset: Option<usize>,
17809    pub(crate) counter: u16,
17810}
17811impl<Prev: Rec> Rec for PushArrayBinary<Prev> {
17812    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
17813        self.prev.as_mut().unwrap().as_rec_mut()
17814    }
17815}
17816impl<Prev: Rec> PushArrayBinary<Prev> {
17817    pub fn new(prev: Prev) -> Self {
17818        Self {
17819            prev: Some(prev),
17820            header_offset: None,
17821            counter: 0,
17822        }
17823    }
17824    pub fn end_array(mut self) -> Prev {
17825        let mut prev = self.prev.take().unwrap();
17826        if let Some(header_offset) = &self.header_offset {
17827            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17828        }
17829        prev
17830    }
17831    pub fn entry(mut self, value: &[u8]) -> Self {
17832        let index = self.counter;
17833        self.counter += 1;
17834        push_header(self.as_rec_mut(), index, value.len() as u16);
17835        self.as_rec_mut().extend(value);
17836        self
17837    }
17838}
17839impl<Prev: Rec> Drop for PushArrayBinary<Prev> {
17840    fn drop(&mut self) {
17841        if let Some(prev) = &mut self.prev {
17842            if let Some(header_offset) = &self.header_offset {
17843                finalize_nested_header(prev.as_rec_mut(), *header_offset);
17844            }
17845        }
17846    }
17847}
17848impl<Prev: Rec> PushLinkinfoBondAttrs<Prev> {
17849    pub fn new(prev: Prev) -> Self {
17850        Self {
17851            prev: Some(prev),
17852            header_offset: None,
17853        }
17854    }
17855    pub fn end_nested(mut self) -> Prev {
17856        let mut prev = self.prev.take().unwrap();
17857        if let Some(header_offset) = &self.header_offset {
17858            finalize_nested_header(prev.as_rec_mut(), *header_offset);
17859        }
17860        prev
17861    }
17862    pub fn push_mode(mut self, value: u8) -> Self {
17863        push_header(self.as_rec_mut(), 1u16, 1 as u16);
17864        self.as_rec_mut().extend(value.to_ne_bytes());
17865        self
17866    }
17867    pub fn push_active_slave(mut self, value: u32) -> Self {
17868        push_header(self.as_rec_mut(), 2u16, 4 as u16);
17869        self.as_rec_mut().extend(value.to_ne_bytes());
17870        self
17871    }
17872    pub fn push_miimon(mut self, value: u32) -> Self {
17873        push_header(self.as_rec_mut(), 3u16, 4 as u16);
17874        self.as_rec_mut().extend(value.to_ne_bytes());
17875        self
17876    }
17877    pub fn push_updelay(mut self, value: u32) -> Self {
17878        push_header(self.as_rec_mut(), 4u16, 4 as u16);
17879        self.as_rec_mut().extend(value.to_ne_bytes());
17880        self
17881    }
17882    pub fn push_downdelay(mut self, value: u32) -> Self {
17883        push_header(self.as_rec_mut(), 5u16, 4 as u16);
17884        self.as_rec_mut().extend(value.to_ne_bytes());
17885        self
17886    }
17887    pub fn push_use_carrier(mut self, value: u8) -> Self {
17888        push_header(self.as_rec_mut(), 6u16, 1 as u16);
17889        self.as_rec_mut().extend(value.to_ne_bytes());
17890        self
17891    }
17892    pub fn push_arp_interval(mut self, value: u32) -> Self {
17893        push_header(self.as_rec_mut(), 7u16, 4 as u16);
17894        self.as_rec_mut().extend(value.to_ne_bytes());
17895        self
17896    }
17897    pub fn array_arp_ip_target(mut self) -> PushArrayU32<Self> {
17898        let header_offset = push_nested_header(self.as_rec_mut(), 8u16);
17899        PushArrayU32 {
17900            prev: Some(self),
17901            header_offset: Some(header_offset),
17902            counter: 0,
17903        }
17904    }
17905    pub fn push_arp_validate(mut self, value: u32) -> Self {
17906        push_header(self.as_rec_mut(), 9u16, 4 as u16);
17907        self.as_rec_mut().extend(value.to_ne_bytes());
17908        self
17909    }
17910    pub fn push_arp_all_targets(mut self, value: u32) -> Self {
17911        push_header(self.as_rec_mut(), 10u16, 4 as u16);
17912        self.as_rec_mut().extend(value.to_ne_bytes());
17913        self
17914    }
17915    pub fn push_primary(mut self, value: u32) -> Self {
17916        push_header(self.as_rec_mut(), 11u16, 4 as u16);
17917        self.as_rec_mut().extend(value.to_ne_bytes());
17918        self
17919    }
17920    pub fn push_primary_reselect(mut self, value: u8) -> Self {
17921        push_header(self.as_rec_mut(), 12u16, 1 as u16);
17922        self.as_rec_mut().extend(value.to_ne_bytes());
17923        self
17924    }
17925    pub fn push_fail_over_mac(mut self, value: u8) -> Self {
17926        push_header(self.as_rec_mut(), 13u16, 1 as u16);
17927        self.as_rec_mut().extend(value.to_ne_bytes());
17928        self
17929    }
17930    pub fn push_xmit_hash_policy(mut self, value: u8) -> Self {
17931        push_header(self.as_rec_mut(), 14u16, 1 as u16);
17932        self.as_rec_mut().extend(value.to_ne_bytes());
17933        self
17934    }
17935    pub fn push_resend_igmp(mut self, value: u32) -> Self {
17936        push_header(self.as_rec_mut(), 15u16, 4 as u16);
17937        self.as_rec_mut().extend(value.to_ne_bytes());
17938        self
17939    }
17940    pub fn push_num_peer_notif(mut self, value: u8) -> Self {
17941        push_header(self.as_rec_mut(), 16u16, 1 as u16);
17942        self.as_rec_mut().extend(value.to_ne_bytes());
17943        self
17944    }
17945    pub fn push_all_slaves_active(mut self, value: u8) -> Self {
17946        push_header(self.as_rec_mut(), 17u16, 1 as u16);
17947        self.as_rec_mut().extend(value.to_ne_bytes());
17948        self
17949    }
17950    pub fn push_min_links(mut self, value: u32) -> Self {
17951        push_header(self.as_rec_mut(), 18u16, 4 as u16);
17952        self.as_rec_mut().extend(value.to_ne_bytes());
17953        self
17954    }
17955    pub fn push_lp_interval(mut self, value: u32) -> Self {
17956        push_header(self.as_rec_mut(), 19u16, 4 as u16);
17957        self.as_rec_mut().extend(value.to_ne_bytes());
17958        self
17959    }
17960    pub fn push_packets_per_slave(mut self, value: u32) -> Self {
17961        push_header(self.as_rec_mut(), 20u16, 4 as u16);
17962        self.as_rec_mut().extend(value.to_ne_bytes());
17963        self
17964    }
17965    pub fn push_ad_lacp_rate(mut self, value: u8) -> Self {
17966        push_header(self.as_rec_mut(), 21u16, 1 as u16);
17967        self.as_rec_mut().extend(value.to_ne_bytes());
17968        self
17969    }
17970    pub fn push_ad_select(mut self, value: u8) -> Self {
17971        push_header(self.as_rec_mut(), 22u16, 1 as u16);
17972        self.as_rec_mut().extend(value.to_ne_bytes());
17973        self
17974    }
17975    pub fn nested_ad_info(mut self) -> PushBondAdInfoAttrs<Self> {
17976        let header_offset = push_nested_header(self.as_rec_mut(), 23u16);
17977        PushBondAdInfoAttrs {
17978            prev: Some(self),
17979            header_offset: Some(header_offset),
17980        }
17981    }
17982    pub fn push_ad_actor_sys_prio(mut self, value: u16) -> Self {
17983        push_header(self.as_rec_mut(), 24u16, 2 as u16);
17984        self.as_rec_mut().extend(value.to_ne_bytes());
17985        self
17986    }
17987    pub fn push_ad_user_port_key(mut self, value: u16) -> Self {
17988        push_header(self.as_rec_mut(), 25u16, 2 as u16);
17989        self.as_rec_mut().extend(value.to_ne_bytes());
17990        self
17991    }
17992    pub fn push_ad_actor_system(mut self, value: &[u8]) -> Self {
17993        push_header(self.as_rec_mut(), 26u16, value.len() as u16);
17994        self.as_rec_mut().extend(value);
17995        self
17996    }
17997    pub fn push_tlb_dynamic_lb(mut self, value: u8) -> Self {
17998        push_header(self.as_rec_mut(), 27u16, 1 as u16);
17999        self.as_rec_mut().extend(value.to_ne_bytes());
18000        self
18001    }
18002    pub fn push_peer_notif_delay(mut self, value: u32) -> Self {
18003        push_header(self.as_rec_mut(), 28u16, 4 as u16);
18004        self.as_rec_mut().extend(value.to_ne_bytes());
18005        self
18006    }
18007    pub fn push_ad_lacp_active(mut self, value: u8) -> Self {
18008        push_header(self.as_rec_mut(), 29u16, 1 as u16);
18009        self.as_rec_mut().extend(value.to_ne_bytes());
18010        self
18011    }
18012    pub fn push_missed_max(mut self, value: u8) -> Self {
18013        push_header(self.as_rec_mut(), 30u16, 1 as u16);
18014        self.as_rec_mut().extend(value.to_ne_bytes());
18015        self
18016    }
18017    pub fn array_ns_ip6_target(mut self) -> PushArrayBinary<Self> {
18018        let header_offset = push_nested_header(self.as_rec_mut(), 31u16);
18019        PushArrayBinary {
18020            prev: Some(self),
18021            header_offset: Some(header_offset),
18022            counter: 0,
18023        }
18024    }
18025    pub fn push_coupled_control(mut self, value: u8) -> Self {
18026        push_header(self.as_rec_mut(), 32u16, 1 as u16);
18027        self.as_rec_mut().extend(value.to_ne_bytes());
18028        self
18029    }
18030}
18031impl<Prev: Rec> Drop for PushLinkinfoBondAttrs<Prev> {
18032    fn drop(&mut self) {
18033        if let Some(prev) = &mut self.prev {
18034            if let Some(header_offset) = &self.header_offset {
18035                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18036            }
18037        }
18038    }
18039}
18040pub struct PushBondAdInfoAttrs<Prev: Rec> {
18041    pub(crate) prev: Option<Prev>,
18042    pub(crate) header_offset: Option<usize>,
18043}
18044impl<Prev: Rec> Rec for PushBondAdInfoAttrs<Prev> {
18045    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18046        self.prev.as_mut().unwrap().as_rec_mut()
18047    }
18048}
18049impl<Prev: Rec> PushBondAdInfoAttrs<Prev> {
18050    pub fn new(prev: Prev) -> Self {
18051        Self {
18052            prev: Some(prev),
18053            header_offset: None,
18054        }
18055    }
18056    pub fn end_nested(mut self) -> Prev {
18057        let mut prev = self.prev.take().unwrap();
18058        if let Some(header_offset) = &self.header_offset {
18059            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18060        }
18061        prev
18062    }
18063    pub fn push_aggregator(mut self, value: u16) -> Self {
18064        push_header(self.as_rec_mut(), 1u16, 2 as u16);
18065        self.as_rec_mut().extend(value.to_ne_bytes());
18066        self
18067    }
18068    pub fn push_num_ports(mut self, value: u16) -> Self {
18069        push_header(self.as_rec_mut(), 2u16, 2 as u16);
18070        self.as_rec_mut().extend(value.to_ne_bytes());
18071        self
18072    }
18073    pub fn push_actor_key(mut self, value: u16) -> Self {
18074        push_header(self.as_rec_mut(), 3u16, 2 as u16);
18075        self.as_rec_mut().extend(value.to_ne_bytes());
18076        self
18077    }
18078    pub fn push_partner_key(mut self, value: u16) -> Self {
18079        push_header(self.as_rec_mut(), 4u16, 2 as u16);
18080        self.as_rec_mut().extend(value.to_ne_bytes());
18081        self
18082    }
18083    pub fn push_partner_mac(mut self, value: &[u8]) -> Self {
18084        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
18085        self.as_rec_mut().extend(value);
18086        self
18087    }
18088}
18089impl<Prev: Rec> Drop for PushBondAdInfoAttrs<Prev> {
18090    fn drop(&mut self) {
18091        if let Some(prev) = &mut self.prev {
18092            if let Some(header_offset) = &self.header_offset {
18093                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18094            }
18095        }
18096    }
18097}
18098pub struct PushBondSlaveAttrs<Prev: Rec> {
18099    pub(crate) prev: Option<Prev>,
18100    pub(crate) header_offset: Option<usize>,
18101}
18102impl<Prev: Rec> Rec for PushBondSlaveAttrs<Prev> {
18103    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18104        self.prev.as_mut().unwrap().as_rec_mut()
18105    }
18106}
18107impl<Prev: Rec> PushBondSlaveAttrs<Prev> {
18108    pub fn new(prev: Prev) -> Self {
18109        Self {
18110            prev: Some(prev),
18111            header_offset: None,
18112        }
18113    }
18114    pub fn end_nested(mut self) -> Prev {
18115        let mut prev = self.prev.take().unwrap();
18116        if let Some(header_offset) = &self.header_offset {
18117            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18118        }
18119        prev
18120    }
18121    pub fn push_state(mut self, value: u8) -> Self {
18122        push_header(self.as_rec_mut(), 1u16, 1 as u16);
18123        self.as_rec_mut().extend(value.to_ne_bytes());
18124        self
18125    }
18126    pub fn push_mii_status(mut self, value: u8) -> Self {
18127        push_header(self.as_rec_mut(), 2u16, 1 as u16);
18128        self.as_rec_mut().extend(value.to_ne_bytes());
18129        self
18130    }
18131    pub fn push_link_failure_count(mut self, value: u32) -> Self {
18132        push_header(self.as_rec_mut(), 3u16, 4 as u16);
18133        self.as_rec_mut().extend(value.to_ne_bytes());
18134        self
18135    }
18136    pub fn push_perm_hwaddr(mut self, value: &[u8]) -> Self {
18137        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
18138        self.as_rec_mut().extend(value);
18139        self
18140    }
18141    pub fn push_queue_id(mut self, value: u16) -> Self {
18142        push_header(self.as_rec_mut(), 5u16, 2 as u16);
18143        self.as_rec_mut().extend(value.to_ne_bytes());
18144        self
18145    }
18146    pub fn push_ad_aggregator_id(mut self, value: u16) -> Self {
18147        push_header(self.as_rec_mut(), 6u16, 2 as u16);
18148        self.as_rec_mut().extend(value.to_ne_bytes());
18149        self
18150    }
18151    pub fn push_ad_actor_oper_port_state(mut self, value: u8) -> Self {
18152        push_header(self.as_rec_mut(), 7u16, 1 as u16);
18153        self.as_rec_mut().extend(value.to_ne_bytes());
18154        self
18155    }
18156    pub fn push_ad_partner_oper_port_state(mut self, value: u16) -> Self {
18157        push_header(self.as_rec_mut(), 8u16, 2 as u16);
18158        self.as_rec_mut().extend(value.to_ne_bytes());
18159        self
18160    }
18161    pub fn push_prio(mut self, value: u32) -> Self {
18162        push_header(self.as_rec_mut(), 9u16, 4 as u16);
18163        self.as_rec_mut().extend(value.to_ne_bytes());
18164        self
18165    }
18166}
18167impl<Prev: Rec> Drop for PushBondSlaveAttrs<Prev> {
18168    fn drop(&mut self) {
18169        if let Some(prev) = &mut self.prev {
18170            if let Some(header_offset) = &self.header_offset {
18171                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18172            }
18173        }
18174    }
18175}
18176pub struct PushLinkinfoBridgeAttrs<Prev: Rec> {
18177    pub(crate) prev: Option<Prev>,
18178    pub(crate) header_offset: Option<usize>,
18179}
18180impl<Prev: Rec> Rec for PushLinkinfoBridgeAttrs<Prev> {
18181    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18182        self.prev.as_mut().unwrap().as_rec_mut()
18183    }
18184}
18185impl<Prev: Rec> PushLinkinfoBridgeAttrs<Prev> {
18186    pub fn new(prev: Prev) -> Self {
18187        Self {
18188            prev: Some(prev),
18189            header_offset: None,
18190        }
18191    }
18192    pub fn end_nested(mut self) -> Prev {
18193        let mut prev = self.prev.take().unwrap();
18194        if let Some(header_offset) = &self.header_offset {
18195            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18196        }
18197        prev
18198    }
18199    pub fn push_forward_delay(mut self, value: u32) -> Self {
18200        push_header(self.as_rec_mut(), 1u16, 4 as u16);
18201        self.as_rec_mut().extend(value.to_ne_bytes());
18202        self
18203    }
18204    pub fn push_hello_time(mut self, value: u32) -> Self {
18205        push_header(self.as_rec_mut(), 2u16, 4 as u16);
18206        self.as_rec_mut().extend(value.to_ne_bytes());
18207        self
18208    }
18209    pub fn push_max_age(mut self, value: u32) -> Self {
18210        push_header(self.as_rec_mut(), 3u16, 4 as u16);
18211        self.as_rec_mut().extend(value.to_ne_bytes());
18212        self
18213    }
18214    pub fn push_ageing_time(mut self, value: u32) -> Self {
18215        push_header(self.as_rec_mut(), 4u16, 4 as u16);
18216        self.as_rec_mut().extend(value.to_ne_bytes());
18217        self
18218    }
18219    pub fn push_stp_state(mut self, value: u32) -> Self {
18220        push_header(self.as_rec_mut(), 5u16, 4 as u16);
18221        self.as_rec_mut().extend(value.to_ne_bytes());
18222        self
18223    }
18224    pub fn push_priority(mut self, value: u16) -> Self {
18225        push_header(self.as_rec_mut(), 6u16, 2 as u16);
18226        self.as_rec_mut().extend(value.to_ne_bytes());
18227        self
18228    }
18229    pub fn push_vlan_filtering(mut self, value: u8) -> Self {
18230        push_header(self.as_rec_mut(), 7u16, 1 as u16);
18231        self.as_rec_mut().extend(value.to_ne_bytes());
18232        self
18233    }
18234    pub fn push_vlan_protocol(mut self, value: u16) -> Self {
18235        push_header(self.as_rec_mut(), 8u16, 2 as u16);
18236        self.as_rec_mut().extend(value.to_ne_bytes());
18237        self
18238    }
18239    pub fn push_group_fwd_mask(mut self, value: u16) -> Self {
18240        push_header(self.as_rec_mut(), 9u16, 2 as u16);
18241        self.as_rec_mut().extend(value.to_ne_bytes());
18242        self
18243    }
18244    pub fn push_root_id(mut self, value: PushIflaBridgeId) -> Self {
18245        push_header(self.as_rec_mut(), 10u16, value.as_slice().len() as u16);
18246        self.as_rec_mut().extend(value.as_slice());
18247        self
18248    }
18249    pub fn push_bridge_id(mut self, value: PushIflaBridgeId) -> Self {
18250        push_header(self.as_rec_mut(), 11u16, value.as_slice().len() as u16);
18251        self.as_rec_mut().extend(value.as_slice());
18252        self
18253    }
18254    pub fn push_root_port(mut self, value: u16) -> Self {
18255        push_header(self.as_rec_mut(), 12u16, 2 as u16);
18256        self.as_rec_mut().extend(value.to_ne_bytes());
18257        self
18258    }
18259    pub fn push_root_path_cost(mut self, value: u32) -> Self {
18260        push_header(self.as_rec_mut(), 13u16, 4 as u16);
18261        self.as_rec_mut().extend(value.to_ne_bytes());
18262        self
18263    }
18264    pub fn push_topology_change(mut self, value: u8) -> Self {
18265        push_header(self.as_rec_mut(), 14u16, 1 as u16);
18266        self.as_rec_mut().extend(value.to_ne_bytes());
18267        self
18268    }
18269    pub fn push_topology_change_detected(mut self, value: u8) -> Self {
18270        push_header(self.as_rec_mut(), 15u16, 1 as u16);
18271        self.as_rec_mut().extend(value.to_ne_bytes());
18272        self
18273    }
18274    pub fn push_hello_timer(mut self, value: u64) -> Self {
18275        push_header(self.as_rec_mut(), 16u16, 8 as u16);
18276        self.as_rec_mut().extend(value.to_ne_bytes());
18277        self
18278    }
18279    pub fn push_tcn_timer(mut self, value: u64) -> Self {
18280        push_header(self.as_rec_mut(), 17u16, 8 as u16);
18281        self.as_rec_mut().extend(value.to_ne_bytes());
18282        self
18283    }
18284    pub fn push_topology_change_timer(mut self, value: u64) -> Self {
18285        push_header(self.as_rec_mut(), 18u16, 8 as u16);
18286        self.as_rec_mut().extend(value.to_ne_bytes());
18287        self
18288    }
18289    pub fn push_gc_timer(mut self, value: u64) -> Self {
18290        push_header(self.as_rec_mut(), 19u16, 8 as u16);
18291        self.as_rec_mut().extend(value.to_ne_bytes());
18292        self
18293    }
18294    pub fn push_group_addr(mut self, value: &[u8]) -> Self {
18295        push_header(self.as_rec_mut(), 20u16, value.len() as u16);
18296        self.as_rec_mut().extend(value);
18297        self
18298    }
18299    pub fn push_fdb_flush(mut self, value: &[u8]) -> Self {
18300        push_header(self.as_rec_mut(), 21u16, value.len() as u16);
18301        self.as_rec_mut().extend(value);
18302        self
18303    }
18304    pub fn push_mcast_router(mut self, value: u8) -> Self {
18305        push_header(self.as_rec_mut(), 22u16, 1 as u16);
18306        self.as_rec_mut().extend(value.to_ne_bytes());
18307        self
18308    }
18309    pub fn push_mcast_snooping(mut self, value: u8) -> Self {
18310        push_header(self.as_rec_mut(), 23u16, 1 as u16);
18311        self.as_rec_mut().extend(value.to_ne_bytes());
18312        self
18313    }
18314    pub fn push_mcast_query_use_ifaddr(mut self, value: u8) -> Self {
18315        push_header(self.as_rec_mut(), 24u16, 1 as u16);
18316        self.as_rec_mut().extend(value.to_ne_bytes());
18317        self
18318    }
18319    pub fn push_mcast_querier(mut self, value: u8) -> Self {
18320        push_header(self.as_rec_mut(), 25u16, 1 as u16);
18321        self.as_rec_mut().extend(value.to_ne_bytes());
18322        self
18323    }
18324    pub fn push_mcast_hash_elasticity(mut self, value: u32) -> Self {
18325        push_header(self.as_rec_mut(), 26u16, 4 as u16);
18326        self.as_rec_mut().extend(value.to_ne_bytes());
18327        self
18328    }
18329    pub fn push_mcast_hash_max(mut self, value: u32) -> Self {
18330        push_header(self.as_rec_mut(), 27u16, 4 as u16);
18331        self.as_rec_mut().extend(value.to_ne_bytes());
18332        self
18333    }
18334    pub fn push_mcast_last_member_cnt(mut self, value: u32) -> Self {
18335        push_header(self.as_rec_mut(), 28u16, 4 as u16);
18336        self.as_rec_mut().extend(value.to_ne_bytes());
18337        self
18338    }
18339    pub fn push_mcast_startup_query_cnt(mut self, value: u32) -> Self {
18340        push_header(self.as_rec_mut(), 29u16, 4 as u16);
18341        self.as_rec_mut().extend(value.to_ne_bytes());
18342        self
18343    }
18344    pub fn push_mcast_last_member_intvl(mut self, value: u64) -> Self {
18345        push_header(self.as_rec_mut(), 30u16, 8 as u16);
18346        self.as_rec_mut().extend(value.to_ne_bytes());
18347        self
18348    }
18349    pub fn push_mcast_membership_intvl(mut self, value: u64) -> Self {
18350        push_header(self.as_rec_mut(), 31u16, 8 as u16);
18351        self.as_rec_mut().extend(value.to_ne_bytes());
18352        self
18353    }
18354    pub fn push_mcast_querier_intvl(mut self, value: u64) -> Self {
18355        push_header(self.as_rec_mut(), 32u16, 8 as u16);
18356        self.as_rec_mut().extend(value.to_ne_bytes());
18357        self
18358    }
18359    pub fn push_mcast_query_intvl(mut self, value: u64) -> Self {
18360        push_header(self.as_rec_mut(), 33u16, 8 as u16);
18361        self.as_rec_mut().extend(value.to_ne_bytes());
18362        self
18363    }
18364    pub fn push_mcast_query_response_intvl(mut self, value: u64) -> Self {
18365        push_header(self.as_rec_mut(), 34u16, 8 as u16);
18366        self.as_rec_mut().extend(value.to_ne_bytes());
18367        self
18368    }
18369    pub fn push_mcast_startup_query_intvl(mut self, value: u64) -> Self {
18370        push_header(self.as_rec_mut(), 35u16, 8 as u16);
18371        self.as_rec_mut().extend(value.to_ne_bytes());
18372        self
18373    }
18374    pub fn push_nf_call_iptables(mut self, value: u8) -> Self {
18375        push_header(self.as_rec_mut(), 36u16, 1 as u16);
18376        self.as_rec_mut().extend(value.to_ne_bytes());
18377        self
18378    }
18379    pub fn push_nf_call_ip6tables(mut self, value: u8) -> Self {
18380        push_header(self.as_rec_mut(), 37u16, 1 as u16);
18381        self.as_rec_mut().extend(value.to_ne_bytes());
18382        self
18383    }
18384    pub fn push_nf_call_arptables(mut self, value: u8) -> Self {
18385        push_header(self.as_rec_mut(), 38u16, 1 as u16);
18386        self.as_rec_mut().extend(value.to_ne_bytes());
18387        self
18388    }
18389    pub fn push_vlan_default_pvid(mut self, value: u16) -> Self {
18390        push_header(self.as_rec_mut(), 39u16, 2 as u16);
18391        self.as_rec_mut().extend(value.to_ne_bytes());
18392        self
18393    }
18394    pub fn push_pad(mut self, value: &[u8]) -> Self {
18395        push_header(self.as_rec_mut(), 40u16, value.len() as u16);
18396        self.as_rec_mut().extend(value);
18397        self
18398    }
18399    pub fn push_vlan_stats_enabled(mut self, value: u8) -> Self {
18400        push_header(self.as_rec_mut(), 41u16, 1 as u16);
18401        self.as_rec_mut().extend(value.to_ne_bytes());
18402        self
18403    }
18404    pub fn push_mcast_stats_enabled(mut self, value: u8) -> Self {
18405        push_header(self.as_rec_mut(), 42u16, 1 as u16);
18406        self.as_rec_mut().extend(value.to_ne_bytes());
18407        self
18408    }
18409    pub fn push_mcast_igmp_version(mut self, value: u8) -> Self {
18410        push_header(self.as_rec_mut(), 43u16, 1 as u16);
18411        self.as_rec_mut().extend(value.to_ne_bytes());
18412        self
18413    }
18414    pub fn push_mcast_mld_version(mut self, value: u8) -> Self {
18415        push_header(self.as_rec_mut(), 44u16, 1 as u16);
18416        self.as_rec_mut().extend(value.to_ne_bytes());
18417        self
18418    }
18419    pub fn push_vlan_stats_per_port(mut self, value: u8) -> Self {
18420        push_header(self.as_rec_mut(), 45u16, 1 as u16);
18421        self.as_rec_mut().extend(value.to_ne_bytes());
18422        self
18423    }
18424    pub fn push_multi_boolopt(mut self, value: PushBrBooloptMulti) -> Self {
18425        push_header(self.as_rec_mut(), 46u16, value.as_slice().len() as u16);
18426        self.as_rec_mut().extend(value.as_slice());
18427        self
18428    }
18429    pub fn push_mcast_querier_state(mut self, value: &[u8]) -> Self {
18430        push_header(self.as_rec_mut(), 47u16, value.len() as u16);
18431        self.as_rec_mut().extend(value);
18432        self
18433    }
18434    pub fn push_fdb_n_learned(mut self, value: u32) -> Self {
18435        push_header(self.as_rec_mut(), 48u16, 4 as u16);
18436        self.as_rec_mut().extend(value.to_ne_bytes());
18437        self
18438    }
18439    pub fn push_fdb_max_learned(mut self, value: u32) -> Self {
18440        push_header(self.as_rec_mut(), 49u16, 4 as u16);
18441        self.as_rec_mut().extend(value.to_ne_bytes());
18442        self
18443    }
18444}
18445impl<Prev: Rec> Drop for PushLinkinfoBridgeAttrs<Prev> {
18446    fn drop(&mut self) {
18447        if let Some(prev) = &mut self.prev {
18448            if let Some(header_offset) = &self.header_offset {
18449                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18450            }
18451        }
18452    }
18453}
18454pub struct PushLinkinfoBrportAttrs<Prev: Rec> {
18455    pub(crate) prev: Option<Prev>,
18456    pub(crate) header_offset: Option<usize>,
18457}
18458impl<Prev: Rec> Rec for PushLinkinfoBrportAttrs<Prev> {
18459    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18460        self.prev.as_mut().unwrap().as_rec_mut()
18461    }
18462}
18463impl<Prev: Rec> PushLinkinfoBrportAttrs<Prev> {
18464    pub fn new(prev: Prev) -> Self {
18465        Self {
18466            prev: Some(prev),
18467            header_offset: None,
18468        }
18469    }
18470    pub fn end_nested(mut self) -> Prev {
18471        let mut prev = self.prev.take().unwrap();
18472        if let Some(header_offset) = &self.header_offset {
18473            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18474        }
18475        prev
18476    }
18477    pub fn push_state(mut self, value: u8) -> Self {
18478        push_header(self.as_rec_mut(), 1u16, 1 as u16);
18479        self.as_rec_mut().extend(value.to_ne_bytes());
18480        self
18481    }
18482    pub fn push_priority(mut self, value: u16) -> Self {
18483        push_header(self.as_rec_mut(), 2u16, 2 as u16);
18484        self.as_rec_mut().extend(value.to_ne_bytes());
18485        self
18486    }
18487    pub fn push_cost(mut self, value: u32) -> Self {
18488        push_header(self.as_rec_mut(), 3u16, 4 as u16);
18489        self.as_rec_mut().extend(value.to_ne_bytes());
18490        self
18491    }
18492    pub fn push_mode(mut self, value: ()) -> Self {
18493        push_header(self.as_rec_mut(), 4u16, 0 as u16);
18494        self
18495    }
18496    pub fn push_guard(mut self, value: ()) -> Self {
18497        push_header(self.as_rec_mut(), 5u16, 0 as u16);
18498        self
18499    }
18500    pub fn push_protect(mut self, value: ()) -> Self {
18501        push_header(self.as_rec_mut(), 6u16, 0 as u16);
18502        self
18503    }
18504    pub fn push_fast_leave(mut self, value: ()) -> Self {
18505        push_header(self.as_rec_mut(), 7u16, 0 as u16);
18506        self
18507    }
18508    pub fn push_learning(mut self, value: ()) -> Self {
18509        push_header(self.as_rec_mut(), 8u16, 0 as u16);
18510        self
18511    }
18512    pub fn push_unicast_flood(mut self, value: ()) -> Self {
18513        push_header(self.as_rec_mut(), 9u16, 0 as u16);
18514        self
18515    }
18516    pub fn push_proxyarp(mut self, value: ()) -> Self {
18517        push_header(self.as_rec_mut(), 10u16, 0 as u16);
18518        self
18519    }
18520    pub fn push_learning_sync(mut self, value: ()) -> Self {
18521        push_header(self.as_rec_mut(), 11u16, 0 as u16);
18522        self
18523    }
18524    pub fn push_proxyarp_wifi(mut self, value: ()) -> Self {
18525        push_header(self.as_rec_mut(), 12u16, 0 as u16);
18526        self
18527    }
18528    pub fn push_root_id(mut self, value: PushIflaBridgeId) -> Self {
18529        push_header(self.as_rec_mut(), 13u16, value.as_slice().len() as u16);
18530        self.as_rec_mut().extend(value.as_slice());
18531        self
18532    }
18533    pub fn push_bridge_id(mut self, value: PushIflaBridgeId) -> Self {
18534        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
18535        self.as_rec_mut().extend(value.as_slice());
18536        self
18537    }
18538    pub fn push_designated_port(mut self, value: u16) -> Self {
18539        push_header(self.as_rec_mut(), 15u16, 2 as u16);
18540        self.as_rec_mut().extend(value.to_ne_bytes());
18541        self
18542    }
18543    pub fn push_designated_cost(mut self, value: u16) -> Self {
18544        push_header(self.as_rec_mut(), 16u16, 2 as u16);
18545        self.as_rec_mut().extend(value.to_ne_bytes());
18546        self
18547    }
18548    pub fn push_id(mut self, value: u16) -> Self {
18549        push_header(self.as_rec_mut(), 17u16, 2 as u16);
18550        self.as_rec_mut().extend(value.to_ne_bytes());
18551        self
18552    }
18553    pub fn push_no(mut self, value: u16) -> Self {
18554        push_header(self.as_rec_mut(), 18u16, 2 as u16);
18555        self.as_rec_mut().extend(value.to_ne_bytes());
18556        self
18557    }
18558    pub fn push_topology_change_ack(mut self, value: u8) -> Self {
18559        push_header(self.as_rec_mut(), 19u16, 1 as u16);
18560        self.as_rec_mut().extend(value.to_ne_bytes());
18561        self
18562    }
18563    pub fn push_config_pending(mut self, value: u8) -> Self {
18564        push_header(self.as_rec_mut(), 20u16, 1 as u16);
18565        self.as_rec_mut().extend(value.to_ne_bytes());
18566        self
18567    }
18568    pub fn push_message_age_timer(mut self, value: u64) -> Self {
18569        push_header(self.as_rec_mut(), 21u16, 8 as u16);
18570        self.as_rec_mut().extend(value.to_ne_bytes());
18571        self
18572    }
18573    pub fn push_forward_delay_timer(mut self, value: u64) -> Self {
18574        push_header(self.as_rec_mut(), 22u16, 8 as u16);
18575        self.as_rec_mut().extend(value.to_ne_bytes());
18576        self
18577    }
18578    pub fn push_hold_timer(mut self, value: u64) -> Self {
18579        push_header(self.as_rec_mut(), 23u16, 8 as u16);
18580        self.as_rec_mut().extend(value.to_ne_bytes());
18581        self
18582    }
18583    pub fn push_flush(mut self, value: ()) -> Self {
18584        push_header(self.as_rec_mut(), 24u16, 0 as u16);
18585        self
18586    }
18587    pub fn push_multicast_router(mut self, value: u8) -> Self {
18588        push_header(self.as_rec_mut(), 25u16, 1 as u16);
18589        self.as_rec_mut().extend(value.to_ne_bytes());
18590        self
18591    }
18592    pub fn push_pad(mut self, value: &[u8]) -> Self {
18593        push_header(self.as_rec_mut(), 26u16, value.len() as u16);
18594        self.as_rec_mut().extend(value);
18595        self
18596    }
18597    pub fn push_mcast_flood(mut self, value: ()) -> Self {
18598        push_header(self.as_rec_mut(), 27u16, 0 as u16);
18599        self
18600    }
18601    pub fn push_mcast_to_ucast(mut self, value: ()) -> Self {
18602        push_header(self.as_rec_mut(), 28u16, 0 as u16);
18603        self
18604    }
18605    pub fn push_vlan_tunnel(mut self, value: ()) -> Self {
18606        push_header(self.as_rec_mut(), 29u16, 0 as u16);
18607        self
18608    }
18609    pub fn push_bcast_flood(mut self, value: ()) -> Self {
18610        push_header(self.as_rec_mut(), 30u16, 0 as u16);
18611        self
18612    }
18613    pub fn push_group_fwd_mask(mut self, value: u16) -> Self {
18614        push_header(self.as_rec_mut(), 31u16, 2 as u16);
18615        self.as_rec_mut().extend(value.to_ne_bytes());
18616        self
18617    }
18618    pub fn push_neigh_suppress(mut self, value: ()) -> Self {
18619        push_header(self.as_rec_mut(), 32u16, 0 as u16);
18620        self
18621    }
18622    pub fn push_isolated(mut self, value: ()) -> Self {
18623        push_header(self.as_rec_mut(), 33u16, 0 as u16);
18624        self
18625    }
18626    pub fn push_backup_port(mut self, value: u32) -> Self {
18627        push_header(self.as_rec_mut(), 34u16, 4 as u16);
18628        self.as_rec_mut().extend(value.to_ne_bytes());
18629        self
18630    }
18631    pub fn push_mrp_ring_open(mut self, value: ()) -> Self {
18632        push_header(self.as_rec_mut(), 35u16, 0 as u16);
18633        self
18634    }
18635    pub fn push_mrp_in_open(mut self, value: ()) -> Self {
18636        push_header(self.as_rec_mut(), 36u16, 0 as u16);
18637        self
18638    }
18639    pub fn push_mcast_eht_hosts_limit(mut self, value: u32) -> Self {
18640        push_header(self.as_rec_mut(), 37u16, 4 as u16);
18641        self.as_rec_mut().extend(value.to_ne_bytes());
18642        self
18643    }
18644    pub fn push_mcast_eht_hosts_cnt(mut self, value: u32) -> Self {
18645        push_header(self.as_rec_mut(), 38u16, 4 as u16);
18646        self.as_rec_mut().extend(value.to_ne_bytes());
18647        self
18648    }
18649    pub fn push_locked(mut self, value: ()) -> Self {
18650        push_header(self.as_rec_mut(), 39u16, 0 as u16);
18651        self
18652    }
18653    pub fn push_mab(mut self, value: ()) -> Self {
18654        push_header(self.as_rec_mut(), 40u16, 0 as u16);
18655        self
18656    }
18657    pub fn push_mcast_n_groups(mut self, value: u32) -> Self {
18658        push_header(self.as_rec_mut(), 41u16, 4 as u16);
18659        self.as_rec_mut().extend(value.to_ne_bytes());
18660        self
18661    }
18662    pub fn push_mcast_max_groups(mut self, value: u32) -> Self {
18663        push_header(self.as_rec_mut(), 42u16, 4 as u16);
18664        self.as_rec_mut().extend(value.to_ne_bytes());
18665        self
18666    }
18667    pub fn push_neigh_vlan_suppress(mut self, value: ()) -> Self {
18668        push_header(self.as_rec_mut(), 43u16, 0 as u16);
18669        self
18670    }
18671    pub fn push_backup_nhid(mut self, value: u32) -> Self {
18672        push_header(self.as_rec_mut(), 44u16, 4 as u16);
18673        self.as_rec_mut().extend(value.to_ne_bytes());
18674        self
18675    }
18676}
18677impl<Prev: Rec> Drop for PushLinkinfoBrportAttrs<Prev> {
18678    fn drop(&mut self) {
18679        if let Some(prev) = &mut self.prev {
18680            if let Some(header_offset) = &self.header_offset {
18681                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18682            }
18683        }
18684    }
18685}
18686pub struct PushLinkinfoGreAttrs<Prev: Rec> {
18687    pub(crate) prev: Option<Prev>,
18688    pub(crate) header_offset: Option<usize>,
18689}
18690impl<Prev: Rec> Rec for PushLinkinfoGreAttrs<Prev> {
18691    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18692        self.prev.as_mut().unwrap().as_rec_mut()
18693    }
18694}
18695impl<Prev: Rec> PushLinkinfoGreAttrs<Prev> {
18696    pub fn new(prev: Prev) -> Self {
18697        Self {
18698            prev: Some(prev),
18699            header_offset: None,
18700        }
18701    }
18702    pub fn end_nested(mut self) -> Prev {
18703        let mut prev = self.prev.take().unwrap();
18704        if let Some(header_offset) = &self.header_offset {
18705            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18706        }
18707        prev
18708    }
18709    pub fn push_link(mut self, value: u32) -> Self {
18710        push_header(self.as_rec_mut(), 1u16, 4 as u16);
18711        self.as_rec_mut().extend(value.to_ne_bytes());
18712        self
18713    }
18714    pub fn push_iflags(mut self, value: u16) -> Self {
18715        push_header(self.as_rec_mut(), 2u16, 2 as u16);
18716        self.as_rec_mut().extend(value.to_be_bytes());
18717        self
18718    }
18719    pub fn push_oflags(mut self, value: u16) -> Self {
18720        push_header(self.as_rec_mut(), 3u16, 2 as u16);
18721        self.as_rec_mut().extend(value.to_be_bytes());
18722        self
18723    }
18724    pub fn push_ikey(mut self, value: u32) -> Self {
18725        push_header(self.as_rec_mut(), 4u16, 4 as u16);
18726        self.as_rec_mut().extend(value.to_be_bytes());
18727        self
18728    }
18729    pub fn push_okey(mut self, value: u32) -> Self {
18730        push_header(self.as_rec_mut(), 5u16, 4 as u16);
18731        self.as_rec_mut().extend(value.to_be_bytes());
18732        self
18733    }
18734    pub fn push_local(mut self, value: &[u8]) -> Self {
18735        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
18736        self.as_rec_mut().extend(value);
18737        self
18738    }
18739    pub fn push_remote(mut self, value: &[u8]) -> Self {
18740        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
18741        self.as_rec_mut().extend(value);
18742        self
18743    }
18744    pub fn push_ttl(mut self, value: u8) -> Self {
18745        push_header(self.as_rec_mut(), 8u16, 1 as u16);
18746        self.as_rec_mut().extend(value.to_ne_bytes());
18747        self
18748    }
18749    pub fn push_tos(mut self, value: u8) -> Self {
18750        push_header(self.as_rec_mut(), 9u16, 1 as u16);
18751        self.as_rec_mut().extend(value.to_ne_bytes());
18752        self
18753    }
18754    pub fn push_pmtudisc(mut self, value: u8) -> Self {
18755        push_header(self.as_rec_mut(), 10u16, 1 as u16);
18756        self.as_rec_mut().extend(value.to_ne_bytes());
18757        self
18758    }
18759    pub fn push_encap_limit(mut self, value: u8) -> Self {
18760        push_header(self.as_rec_mut(), 11u16, 1 as u16);
18761        self.as_rec_mut().extend(value.to_ne_bytes());
18762        self
18763    }
18764    pub fn push_flowinfo(mut self, value: u32) -> Self {
18765        push_header(self.as_rec_mut(), 12u16, 4 as u16);
18766        self.as_rec_mut().extend(value.to_be_bytes());
18767        self
18768    }
18769    pub fn push_flags(mut self, value: u32) -> Self {
18770        push_header(self.as_rec_mut(), 13u16, 4 as u16);
18771        self.as_rec_mut().extend(value.to_ne_bytes());
18772        self
18773    }
18774    pub fn push_encap_type(mut self, value: u16) -> Self {
18775        push_header(self.as_rec_mut(), 14u16, 2 as u16);
18776        self.as_rec_mut().extend(value.to_ne_bytes());
18777        self
18778    }
18779    pub fn push_encap_flags(mut self, value: u16) -> Self {
18780        push_header(self.as_rec_mut(), 15u16, 2 as u16);
18781        self.as_rec_mut().extend(value.to_ne_bytes());
18782        self
18783    }
18784    pub fn push_encap_sport(mut self, value: u16) -> Self {
18785        push_header(self.as_rec_mut(), 16u16, 2 as u16);
18786        self.as_rec_mut().extend(value.to_be_bytes());
18787        self
18788    }
18789    pub fn push_encap_dport(mut self, value: u16) -> Self {
18790        push_header(self.as_rec_mut(), 17u16, 2 as u16);
18791        self.as_rec_mut().extend(value.to_be_bytes());
18792        self
18793    }
18794    pub fn push_collect_metadata(mut self, value: ()) -> Self {
18795        push_header(self.as_rec_mut(), 18u16, 0 as u16);
18796        self
18797    }
18798    pub fn push_ignore_df(mut self, value: u8) -> Self {
18799        push_header(self.as_rec_mut(), 19u16, 1 as u16);
18800        self.as_rec_mut().extend(value.to_ne_bytes());
18801        self
18802    }
18803    pub fn push_fwmark(mut self, value: u32) -> Self {
18804        push_header(self.as_rec_mut(), 20u16, 4 as u16);
18805        self.as_rec_mut().extend(value.to_ne_bytes());
18806        self
18807    }
18808    pub fn push_erspan_index(mut self, value: u32) -> Self {
18809        push_header(self.as_rec_mut(), 21u16, 4 as u16);
18810        self.as_rec_mut().extend(value.to_ne_bytes());
18811        self
18812    }
18813    pub fn push_erspan_ver(mut self, value: u8) -> Self {
18814        push_header(self.as_rec_mut(), 22u16, 1 as u16);
18815        self.as_rec_mut().extend(value.to_ne_bytes());
18816        self
18817    }
18818    pub fn push_erspan_dir(mut self, value: u8) -> Self {
18819        push_header(self.as_rec_mut(), 23u16, 1 as u16);
18820        self.as_rec_mut().extend(value.to_ne_bytes());
18821        self
18822    }
18823    pub fn push_erspan_hwid(mut self, value: u16) -> Self {
18824        push_header(self.as_rec_mut(), 24u16, 2 as u16);
18825        self.as_rec_mut().extend(value.to_ne_bytes());
18826        self
18827    }
18828}
18829impl<Prev: Rec> Drop for PushLinkinfoGreAttrs<Prev> {
18830    fn drop(&mut self) {
18831        if let Some(prev) = &mut self.prev {
18832            if let Some(header_offset) = &self.header_offset {
18833                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18834            }
18835        }
18836    }
18837}
18838pub struct PushLinkinfoGre6Attrs<Prev: Rec> {
18839    pub(crate) prev: Option<Prev>,
18840    pub(crate) header_offset: Option<usize>,
18841}
18842impl<Prev: Rec> Rec for PushLinkinfoGre6Attrs<Prev> {
18843    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18844        self.prev.as_mut().unwrap().as_rec_mut()
18845    }
18846}
18847impl<Prev: Rec> PushLinkinfoGre6Attrs<Prev> {
18848    pub fn new(prev: Prev) -> Self {
18849        Self {
18850            prev: Some(prev),
18851            header_offset: None,
18852        }
18853    }
18854    pub fn end_nested(mut self) -> Prev {
18855        let mut prev = self.prev.take().unwrap();
18856        if let Some(header_offset) = &self.header_offset {
18857            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18858        }
18859        prev
18860    }
18861    pub fn push_link(mut self, value: u32) -> Self {
18862        push_header(self.as_rec_mut(), 1u16, 4 as u16);
18863        self.as_rec_mut().extend(value.to_ne_bytes());
18864        self
18865    }
18866    pub fn push_iflags(mut self, value: u16) -> Self {
18867        push_header(self.as_rec_mut(), 2u16, 2 as u16);
18868        self.as_rec_mut().extend(value.to_be_bytes());
18869        self
18870    }
18871    pub fn push_oflags(mut self, value: u16) -> Self {
18872        push_header(self.as_rec_mut(), 3u16, 2 as u16);
18873        self.as_rec_mut().extend(value.to_be_bytes());
18874        self
18875    }
18876    pub fn push_ikey(mut self, value: u32) -> Self {
18877        push_header(self.as_rec_mut(), 4u16, 4 as u16);
18878        self.as_rec_mut().extend(value.to_be_bytes());
18879        self
18880    }
18881    pub fn push_okey(mut self, value: u32) -> Self {
18882        push_header(self.as_rec_mut(), 5u16, 4 as u16);
18883        self.as_rec_mut().extend(value.to_be_bytes());
18884        self
18885    }
18886    pub fn push_local(mut self, value: &[u8]) -> Self {
18887        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
18888        self.as_rec_mut().extend(value);
18889        self
18890    }
18891    pub fn push_remote(mut self, value: &[u8]) -> Self {
18892        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
18893        self.as_rec_mut().extend(value);
18894        self
18895    }
18896    pub fn push_ttl(mut self, value: u8) -> Self {
18897        push_header(self.as_rec_mut(), 8u16, 1 as u16);
18898        self.as_rec_mut().extend(value.to_ne_bytes());
18899        self
18900    }
18901    pub fn push_encap_limit(mut self, value: u8) -> Self {
18902        push_header(self.as_rec_mut(), 9u16, 1 as u16);
18903        self.as_rec_mut().extend(value.to_ne_bytes());
18904        self
18905    }
18906    pub fn push_flowinfo(mut self, value: u32) -> Self {
18907        push_header(self.as_rec_mut(), 10u16, 4 as u16);
18908        self.as_rec_mut().extend(value.to_be_bytes());
18909        self
18910    }
18911    pub fn push_flags(mut self, value: u32) -> Self {
18912        push_header(self.as_rec_mut(), 11u16, 4 as u16);
18913        self.as_rec_mut().extend(value.to_ne_bytes());
18914        self
18915    }
18916    pub fn push_encap_type(mut self, value: u16) -> Self {
18917        push_header(self.as_rec_mut(), 12u16, 2 as u16);
18918        self.as_rec_mut().extend(value.to_ne_bytes());
18919        self
18920    }
18921    pub fn push_encap_flags(mut self, value: u16) -> Self {
18922        push_header(self.as_rec_mut(), 13u16, 2 as u16);
18923        self.as_rec_mut().extend(value.to_ne_bytes());
18924        self
18925    }
18926    pub fn push_encap_sport(mut self, value: u16) -> Self {
18927        push_header(self.as_rec_mut(), 14u16, 2 as u16);
18928        self.as_rec_mut().extend(value.to_be_bytes());
18929        self
18930    }
18931    pub fn push_encap_dport(mut self, value: u16) -> Self {
18932        push_header(self.as_rec_mut(), 15u16, 2 as u16);
18933        self.as_rec_mut().extend(value.to_be_bytes());
18934        self
18935    }
18936    pub fn push_collect_metadata(mut self, value: ()) -> Self {
18937        push_header(self.as_rec_mut(), 16u16, 0 as u16);
18938        self
18939    }
18940    pub fn push_fwmark(mut self, value: u32) -> Self {
18941        push_header(self.as_rec_mut(), 17u16, 4 as u16);
18942        self.as_rec_mut().extend(value.to_ne_bytes());
18943        self
18944    }
18945    pub fn push_erspan_index(mut self, value: u32) -> Self {
18946        push_header(self.as_rec_mut(), 18u16, 4 as u16);
18947        self.as_rec_mut().extend(value.to_ne_bytes());
18948        self
18949    }
18950    pub fn push_erspan_ver(mut self, value: u8) -> Self {
18951        push_header(self.as_rec_mut(), 19u16, 1 as u16);
18952        self.as_rec_mut().extend(value.to_ne_bytes());
18953        self
18954    }
18955    pub fn push_erspan_dir(mut self, value: u8) -> Self {
18956        push_header(self.as_rec_mut(), 20u16, 1 as u16);
18957        self.as_rec_mut().extend(value.to_ne_bytes());
18958        self
18959    }
18960    pub fn push_erspan_hwid(mut self, value: u16) -> Self {
18961        push_header(self.as_rec_mut(), 21u16, 2 as u16);
18962        self.as_rec_mut().extend(value.to_ne_bytes());
18963        self
18964    }
18965}
18966impl<Prev: Rec> Drop for PushLinkinfoGre6Attrs<Prev> {
18967    fn drop(&mut self) {
18968        if let Some(prev) = &mut self.prev {
18969            if let Some(header_offset) = &self.header_offset {
18970                finalize_nested_header(prev.as_rec_mut(), *header_offset);
18971            }
18972        }
18973    }
18974}
18975pub struct PushLinkinfoVtiAttrs<Prev: Rec> {
18976    pub(crate) prev: Option<Prev>,
18977    pub(crate) header_offset: Option<usize>,
18978}
18979impl<Prev: Rec> Rec for PushLinkinfoVtiAttrs<Prev> {
18980    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
18981        self.prev.as_mut().unwrap().as_rec_mut()
18982    }
18983}
18984impl<Prev: Rec> PushLinkinfoVtiAttrs<Prev> {
18985    pub fn new(prev: Prev) -> Self {
18986        Self {
18987            prev: Some(prev),
18988            header_offset: None,
18989        }
18990    }
18991    pub fn end_nested(mut self) -> Prev {
18992        let mut prev = self.prev.take().unwrap();
18993        if let Some(header_offset) = &self.header_offset {
18994            finalize_nested_header(prev.as_rec_mut(), *header_offset);
18995        }
18996        prev
18997    }
18998    pub fn push_link(mut self, value: u32) -> Self {
18999        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19000        self.as_rec_mut().extend(value.to_ne_bytes());
19001        self
19002    }
19003    pub fn push_ikey(mut self, value: u32) -> Self {
19004        push_header(self.as_rec_mut(), 2u16, 4 as u16);
19005        self.as_rec_mut().extend(value.to_be_bytes());
19006        self
19007    }
19008    pub fn push_okey(mut self, value: u32) -> Self {
19009        push_header(self.as_rec_mut(), 3u16, 4 as u16);
19010        self.as_rec_mut().extend(value.to_be_bytes());
19011        self
19012    }
19013    pub fn push_local(mut self, value: &[u8]) -> Self {
19014        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
19015        self.as_rec_mut().extend(value);
19016        self
19017    }
19018    pub fn push_remote(mut self, value: &[u8]) -> Self {
19019        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
19020        self.as_rec_mut().extend(value);
19021        self
19022    }
19023    pub fn push_fwmark(mut self, value: u32) -> Self {
19024        push_header(self.as_rec_mut(), 6u16, 4 as u16);
19025        self.as_rec_mut().extend(value.to_ne_bytes());
19026        self
19027    }
19028}
19029impl<Prev: Rec> Drop for PushLinkinfoVtiAttrs<Prev> {
19030    fn drop(&mut self) {
19031        if let Some(prev) = &mut self.prev {
19032            if let Some(header_offset) = &self.header_offset {
19033                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19034            }
19035        }
19036    }
19037}
19038pub struct PushLinkinfoVti6Attrs<Prev: Rec> {
19039    pub(crate) prev: Option<Prev>,
19040    pub(crate) header_offset: Option<usize>,
19041}
19042impl<Prev: Rec> Rec for PushLinkinfoVti6Attrs<Prev> {
19043    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19044        self.prev.as_mut().unwrap().as_rec_mut()
19045    }
19046}
19047impl<Prev: Rec> PushLinkinfoVti6Attrs<Prev> {
19048    pub fn new(prev: Prev) -> Self {
19049        Self {
19050            prev: Some(prev),
19051            header_offset: None,
19052        }
19053    }
19054    pub fn end_nested(mut self) -> Prev {
19055        let mut prev = self.prev.take().unwrap();
19056        if let Some(header_offset) = &self.header_offset {
19057            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19058        }
19059        prev
19060    }
19061    pub fn push_link(mut self, value: u32) -> Self {
19062        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19063        self.as_rec_mut().extend(value.to_ne_bytes());
19064        self
19065    }
19066    pub fn push_ikey(mut self, value: u32) -> Self {
19067        push_header(self.as_rec_mut(), 2u16, 4 as u16);
19068        self.as_rec_mut().extend(value.to_be_bytes());
19069        self
19070    }
19071    pub fn push_okey(mut self, value: u32) -> Self {
19072        push_header(self.as_rec_mut(), 3u16, 4 as u16);
19073        self.as_rec_mut().extend(value.to_be_bytes());
19074        self
19075    }
19076    pub fn push_local(mut self, value: &[u8]) -> Self {
19077        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
19078        self.as_rec_mut().extend(value);
19079        self
19080    }
19081    pub fn push_remote(mut self, value: &[u8]) -> Self {
19082        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
19083        self.as_rec_mut().extend(value);
19084        self
19085    }
19086    pub fn push_fwmark(mut self, value: u32) -> Self {
19087        push_header(self.as_rec_mut(), 6u16, 4 as u16);
19088        self.as_rec_mut().extend(value.to_ne_bytes());
19089        self
19090    }
19091}
19092impl<Prev: Rec> Drop for PushLinkinfoVti6Attrs<Prev> {
19093    fn drop(&mut self) {
19094        if let Some(prev) = &mut self.prev {
19095            if let Some(header_offset) = &self.header_offset {
19096                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19097            }
19098        }
19099    }
19100}
19101pub struct PushLinkinfoGeneveAttrs<Prev: Rec> {
19102    pub(crate) prev: Option<Prev>,
19103    pub(crate) header_offset: Option<usize>,
19104}
19105impl<Prev: Rec> Rec for PushLinkinfoGeneveAttrs<Prev> {
19106    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19107        self.prev.as_mut().unwrap().as_rec_mut()
19108    }
19109}
19110impl<Prev: Rec> PushLinkinfoGeneveAttrs<Prev> {
19111    pub fn new(prev: Prev) -> Self {
19112        Self {
19113            prev: Some(prev),
19114            header_offset: None,
19115        }
19116    }
19117    pub fn end_nested(mut self) -> Prev {
19118        let mut prev = self.prev.take().unwrap();
19119        if let Some(header_offset) = &self.header_offset {
19120            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19121        }
19122        prev
19123    }
19124    pub fn push_id(mut self, value: u32) -> Self {
19125        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19126        self.as_rec_mut().extend(value.to_ne_bytes());
19127        self
19128    }
19129    pub fn push_remote(mut self, value: &[u8]) -> Self {
19130        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19131        self.as_rec_mut().extend(value);
19132        self
19133    }
19134    pub fn push_ttl(mut self, value: u8) -> Self {
19135        push_header(self.as_rec_mut(), 3u16, 1 as u16);
19136        self.as_rec_mut().extend(value.to_ne_bytes());
19137        self
19138    }
19139    pub fn push_tos(mut self, value: u8) -> Self {
19140        push_header(self.as_rec_mut(), 4u16, 1 as u16);
19141        self.as_rec_mut().extend(value.to_ne_bytes());
19142        self
19143    }
19144    pub fn push_port(mut self, value: u16) -> Self {
19145        push_header(self.as_rec_mut(), 5u16, 2 as u16);
19146        self.as_rec_mut().extend(value.to_be_bytes());
19147        self
19148    }
19149    pub fn push_collect_metadata(mut self, value: ()) -> Self {
19150        push_header(self.as_rec_mut(), 6u16, 0 as u16);
19151        self
19152    }
19153    pub fn push_remote6(mut self, value: &[u8]) -> Self {
19154        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
19155        self.as_rec_mut().extend(value);
19156        self
19157    }
19158    pub fn push_udp_csum(mut self, value: u8) -> Self {
19159        push_header(self.as_rec_mut(), 8u16, 1 as u16);
19160        self.as_rec_mut().extend(value.to_ne_bytes());
19161        self
19162    }
19163    pub fn push_udp_zero_csum6_tx(mut self, value: u8) -> Self {
19164        push_header(self.as_rec_mut(), 9u16, 1 as u16);
19165        self.as_rec_mut().extend(value.to_ne_bytes());
19166        self
19167    }
19168    pub fn push_udp_zero_csum6_rx(mut self, value: u8) -> Self {
19169        push_header(self.as_rec_mut(), 10u16, 1 as u16);
19170        self.as_rec_mut().extend(value.to_ne_bytes());
19171        self
19172    }
19173    pub fn push_label(mut self, value: u32) -> Self {
19174        push_header(self.as_rec_mut(), 11u16, 4 as u16);
19175        self.as_rec_mut().extend(value.to_be_bytes());
19176        self
19177    }
19178    pub fn push_ttl_inherit(mut self, value: u8) -> Self {
19179        push_header(self.as_rec_mut(), 12u16, 1 as u16);
19180        self.as_rec_mut().extend(value.to_ne_bytes());
19181        self
19182    }
19183    pub fn push_df(mut self, value: u8) -> Self {
19184        push_header(self.as_rec_mut(), 13u16, 1 as u16);
19185        self.as_rec_mut().extend(value.to_ne_bytes());
19186        self
19187    }
19188    pub fn push_inner_proto_inherit(mut self, value: ()) -> Self {
19189        push_header(self.as_rec_mut(), 14u16, 0 as u16);
19190        self
19191    }
19192    pub fn push_port_range(mut self, value: PushIflaGenevePortRange) -> Self {
19193        push_header(self.as_rec_mut(), 15u16, value.as_slice().len() as u16);
19194        self.as_rec_mut().extend(value.as_slice());
19195        self
19196    }
19197}
19198impl<Prev: Rec> Drop for PushLinkinfoGeneveAttrs<Prev> {
19199    fn drop(&mut self) {
19200        if let Some(prev) = &mut self.prev {
19201            if let Some(header_offset) = &self.header_offset {
19202                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19203            }
19204        }
19205    }
19206}
19207pub struct PushLinkinfoIptunAttrs<Prev: Rec> {
19208    pub(crate) prev: Option<Prev>,
19209    pub(crate) header_offset: Option<usize>,
19210}
19211impl<Prev: Rec> Rec for PushLinkinfoIptunAttrs<Prev> {
19212    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19213        self.prev.as_mut().unwrap().as_rec_mut()
19214    }
19215}
19216impl<Prev: Rec> PushLinkinfoIptunAttrs<Prev> {
19217    pub fn new(prev: Prev) -> Self {
19218        Self {
19219            prev: Some(prev),
19220            header_offset: None,
19221        }
19222    }
19223    pub fn end_nested(mut self) -> Prev {
19224        let mut prev = self.prev.take().unwrap();
19225        if let Some(header_offset) = &self.header_offset {
19226            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19227        }
19228        prev
19229    }
19230    pub fn push_link(mut self, value: u32) -> Self {
19231        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19232        self.as_rec_mut().extend(value.to_ne_bytes());
19233        self
19234    }
19235    pub fn push_local(mut self, value: &[u8]) -> Self {
19236        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19237        self.as_rec_mut().extend(value);
19238        self
19239    }
19240    pub fn push_remote(mut self, value: &[u8]) -> Self {
19241        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
19242        self.as_rec_mut().extend(value);
19243        self
19244    }
19245    pub fn push_ttl(mut self, value: u8) -> Self {
19246        push_header(self.as_rec_mut(), 4u16, 1 as u16);
19247        self.as_rec_mut().extend(value.to_ne_bytes());
19248        self
19249    }
19250    pub fn push_tos(mut self, value: u8) -> Self {
19251        push_header(self.as_rec_mut(), 5u16, 1 as u16);
19252        self.as_rec_mut().extend(value.to_ne_bytes());
19253        self
19254    }
19255    pub fn push_encap_limit(mut self, value: u8) -> Self {
19256        push_header(self.as_rec_mut(), 6u16, 1 as u16);
19257        self.as_rec_mut().extend(value.to_ne_bytes());
19258        self
19259    }
19260    pub fn push_flowinfo(mut self, value: u32) -> Self {
19261        push_header(self.as_rec_mut(), 7u16, 4 as u16);
19262        self.as_rec_mut().extend(value.to_be_bytes());
19263        self
19264    }
19265    pub fn push_flags(mut self, value: u16) -> Self {
19266        push_header(self.as_rec_mut(), 8u16, 2 as u16);
19267        self.as_rec_mut().extend(value.to_be_bytes());
19268        self
19269    }
19270    pub fn push_proto(mut self, value: u8) -> Self {
19271        push_header(self.as_rec_mut(), 9u16, 1 as u16);
19272        self.as_rec_mut().extend(value.to_ne_bytes());
19273        self
19274    }
19275    pub fn push_pmtudisc(mut self, value: u8) -> Self {
19276        push_header(self.as_rec_mut(), 10u16, 1 as u16);
19277        self.as_rec_mut().extend(value.to_ne_bytes());
19278        self
19279    }
19280    pub fn push_6rd_prefix(mut self, value: &[u8]) -> Self {
19281        push_header(self.as_rec_mut(), 11u16, value.len() as u16);
19282        self.as_rec_mut().extend(value);
19283        self
19284    }
19285    pub fn push_6rd_relay_prefix(mut self, value: &[u8]) -> Self {
19286        push_header(self.as_rec_mut(), 12u16, value.len() as u16);
19287        self.as_rec_mut().extend(value);
19288        self
19289    }
19290    pub fn push_6rd_prefixlen(mut self, value: u16) -> Self {
19291        push_header(self.as_rec_mut(), 13u16, 2 as u16);
19292        self.as_rec_mut().extend(value.to_ne_bytes());
19293        self
19294    }
19295    pub fn push_6rd_relay_prefixlen(mut self, value: u16) -> Self {
19296        push_header(self.as_rec_mut(), 14u16, 2 as u16);
19297        self.as_rec_mut().extend(value.to_ne_bytes());
19298        self
19299    }
19300    pub fn push_encap_type(mut self, value: u16) -> Self {
19301        push_header(self.as_rec_mut(), 15u16, 2 as u16);
19302        self.as_rec_mut().extend(value.to_ne_bytes());
19303        self
19304    }
19305    pub fn push_encap_flags(mut self, value: u16) -> Self {
19306        push_header(self.as_rec_mut(), 16u16, 2 as u16);
19307        self.as_rec_mut().extend(value.to_ne_bytes());
19308        self
19309    }
19310    pub fn push_encap_sport(mut self, value: u16) -> Self {
19311        push_header(self.as_rec_mut(), 17u16, 2 as u16);
19312        self.as_rec_mut().extend(value.to_be_bytes());
19313        self
19314    }
19315    pub fn push_encap_dport(mut self, value: u16) -> Self {
19316        push_header(self.as_rec_mut(), 18u16, 2 as u16);
19317        self.as_rec_mut().extend(value.to_be_bytes());
19318        self
19319    }
19320    pub fn push_collect_metadata(mut self, value: ()) -> Self {
19321        push_header(self.as_rec_mut(), 19u16, 0 as u16);
19322        self
19323    }
19324    pub fn push_fwmark(mut self, value: u32) -> Self {
19325        push_header(self.as_rec_mut(), 20u16, 4 as u16);
19326        self.as_rec_mut().extend(value.to_ne_bytes());
19327        self
19328    }
19329}
19330impl<Prev: Rec> Drop for PushLinkinfoIptunAttrs<Prev> {
19331    fn drop(&mut self) {
19332        if let Some(prev) = &mut self.prev {
19333            if let Some(header_offset) = &self.header_offset {
19334                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19335            }
19336        }
19337    }
19338}
19339pub struct PushLinkinfoIp6tnlAttrs<Prev: Rec> {
19340    pub(crate) prev: Option<Prev>,
19341    pub(crate) header_offset: Option<usize>,
19342}
19343impl<Prev: Rec> Rec for PushLinkinfoIp6tnlAttrs<Prev> {
19344    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19345        self.prev.as_mut().unwrap().as_rec_mut()
19346    }
19347}
19348impl<Prev: Rec> PushLinkinfoIp6tnlAttrs<Prev> {
19349    pub fn new(prev: Prev) -> Self {
19350        Self {
19351            prev: Some(prev),
19352            header_offset: None,
19353        }
19354    }
19355    pub fn end_nested(mut self) -> Prev {
19356        let mut prev = self.prev.take().unwrap();
19357        if let Some(header_offset) = &self.header_offset {
19358            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19359        }
19360        prev
19361    }
19362    pub fn push_link(mut self, value: u32) -> Self {
19363        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19364        self.as_rec_mut().extend(value.to_ne_bytes());
19365        self
19366    }
19367    pub fn push_local(mut self, value: &[u8]) -> Self {
19368        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19369        self.as_rec_mut().extend(value);
19370        self
19371    }
19372    pub fn push_remote(mut self, value: &[u8]) -> Self {
19373        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
19374        self.as_rec_mut().extend(value);
19375        self
19376    }
19377    pub fn push_ttl(mut self, value: u8) -> Self {
19378        push_header(self.as_rec_mut(), 4u16, 1 as u16);
19379        self.as_rec_mut().extend(value.to_ne_bytes());
19380        self
19381    }
19382    pub fn push_encap_limit(mut self, value: u8) -> Self {
19383        push_header(self.as_rec_mut(), 5u16, 1 as u16);
19384        self.as_rec_mut().extend(value.to_ne_bytes());
19385        self
19386    }
19387    pub fn push_flowinfo(mut self, value: u32) -> Self {
19388        push_header(self.as_rec_mut(), 6u16, 4 as u16);
19389        self.as_rec_mut().extend(value.to_be_bytes());
19390        self
19391    }
19392    pub fn push_flags(mut self, value: u32) -> Self {
19393        push_header(self.as_rec_mut(), 7u16, 4 as u16);
19394        self.as_rec_mut().extend(value.to_ne_bytes());
19395        self
19396    }
19397    pub fn push_proto(mut self, value: u8) -> Self {
19398        push_header(self.as_rec_mut(), 8u16, 1 as u16);
19399        self.as_rec_mut().extend(value.to_ne_bytes());
19400        self
19401    }
19402    pub fn push_encap_type(mut self, value: u16) -> Self {
19403        push_header(self.as_rec_mut(), 9u16, 2 as u16);
19404        self.as_rec_mut().extend(value.to_ne_bytes());
19405        self
19406    }
19407    pub fn push_encap_flags(mut self, value: u16) -> Self {
19408        push_header(self.as_rec_mut(), 10u16, 2 as u16);
19409        self.as_rec_mut().extend(value.to_ne_bytes());
19410        self
19411    }
19412    pub fn push_encap_sport(mut self, value: u16) -> Self {
19413        push_header(self.as_rec_mut(), 11u16, 2 as u16);
19414        self.as_rec_mut().extend(value.to_be_bytes());
19415        self
19416    }
19417    pub fn push_encap_dport(mut self, value: u16) -> Self {
19418        push_header(self.as_rec_mut(), 12u16, 2 as u16);
19419        self.as_rec_mut().extend(value.to_be_bytes());
19420        self
19421    }
19422    pub fn push_collect_metadata(mut self, value: ()) -> Self {
19423        push_header(self.as_rec_mut(), 13u16, 0 as u16);
19424        self
19425    }
19426    pub fn push_fwmark(mut self, value: u32) -> Self {
19427        push_header(self.as_rec_mut(), 14u16, 4 as u16);
19428        self.as_rec_mut().extend(value.to_ne_bytes());
19429        self
19430    }
19431}
19432impl<Prev: Rec> Drop for PushLinkinfoIp6tnlAttrs<Prev> {
19433    fn drop(&mut self) {
19434        if let Some(prev) = &mut self.prev {
19435            if let Some(header_offset) = &self.header_offset {
19436                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19437            }
19438        }
19439    }
19440}
19441pub struct PushLinkinfoTunAttrs<Prev: Rec> {
19442    pub(crate) prev: Option<Prev>,
19443    pub(crate) header_offset: Option<usize>,
19444}
19445impl<Prev: Rec> Rec for PushLinkinfoTunAttrs<Prev> {
19446    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19447        self.prev.as_mut().unwrap().as_rec_mut()
19448    }
19449}
19450impl<Prev: Rec> PushLinkinfoTunAttrs<Prev> {
19451    pub fn new(prev: Prev) -> Self {
19452        Self {
19453            prev: Some(prev),
19454            header_offset: None,
19455        }
19456    }
19457    pub fn end_nested(mut self) -> Prev {
19458        let mut prev = self.prev.take().unwrap();
19459        if let Some(header_offset) = &self.header_offset {
19460            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19461        }
19462        prev
19463    }
19464    pub fn push_owner(mut self, value: u32) -> Self {
19465        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19466        self.as_rec_mut().extend(value.to_ne_bytes());
19467        self
19468    }
19469    pub fn push_group(mut self, value: u32) -> Self {
19470        push_header(self.as_rec_mut(), 2u16, 4 as u16);
19471        self.as_rec_mut().extend(value.to_ne_bytes());
19472        self
19473    }
19474    pub fn push_type(mut self, value: u8) -> Self {
19475        push_header(self.as_rec_mut(), 3u16, 1 as u16);
19476        self.as_rec_mut().extend(value.to_ne_bytes());
19477        self
19478    }
19479    pub fn push_pi(mut self, value: u8) -> Self {
19480        push_header(self.as_rec_mut(), 4u16, 1 as u16);
19481        self.as_rec_mut().extend(value.to_ne_bytes());
19482        self
19483    }
19484    pub fn push_vnet_hdr(mut self, value: u8) -> Self {
19485        push_header(self.as_rec_mut(), 5u16, 1 as u16);
19486        self.as_rec_mut().extend(value.to_ne_bytes());
19487        self
19488    }
19489    pub fn push_persist(mut self, value: u8) -> Self {
19490        push_header(self.as_rec_mut(), 6u16, 1 as u16);
19491        self.as_rec_mut().extend(value.to_ne_bytes());
19492        self
19493    }
19494    pub fn push_multi_queue(mut self, value: u8) -> Self {
19495        push_header(self.as_rec_mut(), 7u16, 1 as u16);
19496        self.as_rec_mut().extend(value.to_ne_bytes());
19497        self
19498    }
19499    pub fn push_num_queues(mut self, value: u32) -> Self {
19500        push_header(self.as_rec_mut(), 8u16, 4 as u16);
19501        self.as_rec_mut().extend(value.to_ne_bytes());
19502        self
19503    }
19504    pub fn push_num_disabled_queues(mut self, value: u32) -> Self {
19505        push_header(self.as_rec_mut(), 9u16, 4 as u16);
19506        self.as_rec_mut().extend(value.to_ne_bytes());
19507        self
19508    }
19509}
19510impl<Prev: Rec> Drop for PushLinkinfoTunAttrs<Prev> {
19511    fn drop(&mut self) {
19512        if let Some(prev) = &mut self.prev {
19513            if let Some(header_offset) = &self.header_offset {
19514                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19515            }
19516        }
19517    }
19518}
19519pub struct PushLinkinfoVlanAttrs<Prev: Rec> {
19520    pub(crate) prev: Option<Prev>,
19521    pub(crate) header_offset: Option<usize>,
19522}
19523impl<Prev: Rec> Rec for PushLinkinfoVlanAttrs<Prev> {
19524    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19525        self.prev.as_mut().unwrap().as_rec_mut()
19526    }
19527}
19528impl<Prev: Rec> PushLinkinfoVlanAttrs<Prev> {
19529    pub fn new(prev: Prev) -> Self {
19530        Self {
19531            prev: Some(prev),
19532            header_offset: None,
19533        }
19534    }
19535    pub fn end_nested(mut self) -> Prev {
19536        let mut prev = self.prev.take().unwrap();
19537        if let Some(header_offset) = &self.header_offset {
19538            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19539        }
19540        prev
19541    }
19542    pub fn push_id(mut self, value: u16) -> Self {
19543        push_header(self.as_rec_mut(), 1u16, 2 as u16);
19544        self.as_rec_mut().extend(value.to_ne_bytes());
19545        self
19546    }
19547    pub fn push_flags(mut self, value: PushIflaVlanFlags) -> Self {
19548        push_header(self.as_rec_mut(), 2u16, value.as_slice().len() as u16);
19549        self.as_rec_mut().extend(value.as_slice());
19550        self
19551    }
19552    pub fn nested_egress_qos(mut self) -> PushIflaVlanQos<Self> {
19553        let header_offset = push_nested_header(self.as_rec_mut(), 3u16);
19554        PushIflaVlanQos {
19555            prev: Some(self),
19556            header_offset: Some(header_offset),
19557        }
19558    }
19559    pub fn nested_ingress_qos(mut self) -> PushIflaVlanQos<Self> {
19560        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
19561        PushIflaVlanQos {
19562            prev: Some(self),
19563            header_offset: Some(header_offset),
19564        }
19565    }
19566    #[doc = "Associated type: \"VlanProtocols\" (enum)"]
19567    pub fn push_protocol(mut self, value: u16) -> Self {
19568        push_header(self.as_rec_mut(), 5u16, 2 as u16);
19569        self.as_rec_mut().extend(value.to_be_bytes());
19570        self
19571    }
19572}
19573impl<Prev: Rec> Drop for PushLinkinfoVlanAttrs<Prev> {
19574    fn drop(&mut self) {
19575        if let Some(prev) = &mut self.prev {
19576            if let Some(header_offset) = &self.header_offset {
19577                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19578            }
19579        }
19580    }
19581}
19582pub struct PushIflaVlanQos<Prev: Rec> {
19583    pub(crate) prev: Option<Prev>,
19584    pub(crate) header_offset: Option<usize>,
19585}
19586impl<Prev: Rec> Rec for PushIflaVlanQos<Prev> {
19587    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19588        self.prev.as_mut().unwrap().as_rec_mut()
19589    }
19590}
19591impl<Prev: Rec> PushIflaVlanQos<Prev> {
19592    pub fn new(prev: Prev) -> Self {
19593        Self {
19594            prev: Some(prev),
19595            header_offset: None,
19596        }
19597    }
19598    pub fn end_nested(mut self) -> Prev {
19599        let mut prev = self.prev.take().unwrap();
19600        if let Some(header_offset) = &self.header_offset {
19601            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19602        }
19603        prev
19604    }
19605    #[doc = "Attribute may repeat multiple times (treat it as array)"]
19606    pub fn push_mapping(mut self, value: PushIflaVlanQosMapping) -> Self {
19607        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
19608        self.as_rec_mut().extend(value.as_slice());
19609        self
19610    }
19611}
19612impl<Prev: Rec> Drop for PushIflaVlanQos<Prev> {
19613    fn drop(&mut self) {
19614        if let Some(prev) = &mut self.prev {
19615            if let Some(header_offset) = &self.header_offset {
19616                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19617            }
19618        }
19619    }
19620}
19621pub struct PushLinkinfoVrfAttrs<Prev: Rec> {
19622    pub(crate) prev: Option<Prev>,
19623    pub(crate) header_offset: Option<usize>,
19624}
19625impl<Prev: Rec> Rec for PushLinkinfoVrfAttrs<Prev> {
19626    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19627        self.prev.as_mut().unwrap().as_rec_mut()
19628    }
19629}
19630impl<Prev: Rec> PushLinkinfoVrfAttrs<Prev> {
19631    pub fn new(prev: Prev) -> Self {
19632        Self {
19633            prev: Some(prev),
19634            header_offset: None,
19635        }
19636    }
19637    pub fn end_nested(mut self) -> Prev {
19638        let mut prev = self.prev.take().unwrap();
19639        if let Some(header_offset) = &self.header_offset {
19640            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19641        }
19642        prev
19643    }
19644    pub fn push_table(mut self, value: u32) -> Self {
19645        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19646        self.as_rec_mut().extend(value.to_ne_bytes());
19647        self
19648    }
19649}
19650impl<Prev: Rec> Drop for PushLinkinfoVrfAttrs<Prev> {
19651    fn drop(&mut self) {
19652        if let Some(prev) = &mut self.prev {
19653            if let Some(header_offset) = &self.header_offset {
19654                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19655            }
19656        }
19657    }
19658}
19659pub struct PushXdpAttrs<Prev: Rec> {
19660    pub(crate) prev: Option<Prev>,
19661    pub(crate) header_offset: Option<usize>,
19662}
19663impl<Prev: Rec> Rec for PushXdpAttrs<Prev> {
19664    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19665        self.prev.as_mut().unwrap().as_rec_mut()
19666    }
19667}
19668impl<Prev: Rec> PushXdpAttrs<Prev> {
19669    pub fn new(prev: Prev) -> Self {
19670        Self {
19671            prev: Some(prev),
19672            header_offset: None,
19673        }
19674    }
19675    pub fn end_nested(mut self) -> Prev {
19676        let mut prev = self.prev.take().unwrap();
19677        if let Some(header_offset) = &self.header_offset {
19678            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19679        }
19680        prev
19681    }
19682    pub fn push_fd(mut self, value: i32) -> Self {
19683        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19684        self.as_rec_mut().extend(value.to_ne_bytes());
19685        self
19686    }
19687    pub fn push_attached(mut self, value: u8) -> Self {
19688        push_header(self.as_rec_mut(), 2u16, 1 as u16);
19689        self.as_rec_mut().extend(value.to_ne_bytes());
19690        self
19691    }
19692    pub fn push_flags(mut self, value: u32) -> Self {
19693        push_header(self.as_rec_mut(), 3u16, 4 as u16);
19694        self.as_rec_mut().extend(value.to_ne_bytes());
19695        self
19696    }
19697    pub fn push_prog_id(mut self, value: u32) -> Self {
19698        push_header(self.as_rec_mut(), 4u16, 4 as u16);
19699        self.as_rec_mut().extend(value.to_ne_bytes());
19700        self
19701    }
19702    pub fn push_drv_prog_id(mut self, value: u32) -> Self {
19703        push_header(self.as_rec_mut(), 5u16, 4 as u16);
19704        self.as_rec_mut().extend(value.to_ne_bytes());
19705        self
19706    }
19707    pub fn push_skb_prog_id(mut self, value: u32) -> Self {
19708        push_header(self.as_rec_mut(), 6u16, 4 as u16);
19709        self.as_rec_mut().extend(value.to_ne_bytes());
19710        self
19711    }
19712    pub fn push_hw_prog_id(mut self, value: u32) -> Self {
19713        push_header(self.as_rec_mut(), 7u16, 4 as u16);
19714        self.as_rec_mut().extend(value.to_ne_bytes());
19715        self
19716    }
19717    pub fn push_expected_fd(mut self, value: i32) -> Self {
19718        push_header(self.as_rec_mut(), 8u16, 4 as u16);
19719        self.as_rec_mut().extend(value.to_ne_bytes());
19720        self
19721    }
19722}
19723impl<Prev: Rec> Drop for PushXdpAttrs<Prev> {
19724    fn drop(&mut self) {
19725        if let Some(prev) = &mut self.prev {
19726            if let Some(header_offset) = &self.header_offset {
19727                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19728            }
19729        }
19730    }
19731}
19732pub struct PushIflaAttrs<Prev: Rec> {
19733    pub(crate) prev: Option<Prev>,
19734    pub(crate) header_offset: Option<usize>,
19735}
19736impl<Prev: Rec> Rec for PushIflaAttrs<Prev> {
19737    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19738        self.prev.as_mut().unwrap().as_rec_mut()
19739    }
19740}
19741impl<Prev: Rec> PushIflaAttrs<Prev> {
19742    pub fn new(prev: Prev) -> Self {
19743        Self {
19744            prev: Some(prev),
19745            header_offset: None,
19746        }
19747    }
19748    pub fn end_nested(mut self) -> Prev {
19749        let mut prev = self.prev.take().unwrap();
19750        if let Some(header_offset) = &self.header_offset {
19751            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19752        }
19753        prev
19754    }
19755    #[doc = "u32 indexed by ipv4-devconf - 1 on output, on input it's a nest"]
19756    pub fn push_conf(mut self, value: &[u8]) -> Self {
19757        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
19758        self.as_rec_mut().extend(value);
19759        self
19760    }
19761}
19762impl<Prev: Rec> Drop for PushIflaAttrs<Prev> {
19763    fn drop(&mut self) {
19764        if let Some(prev) = &mut self.prev {
19765            if let Some(header_offset) = &self.header_offset {
19766                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19767            }
19768        }
19769    }
19770}
19771pub struct PushIfla6Attrs<Prev: Rec> {
19772    pub(crate) prev: Option<Prev>,
19773    pub(crate) header_offset: Option<usize>,
19774}
19775impl<Prev: Rec> Rec for PushIfla6Attrs<Prev> {
19776    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19777        self.prev.as_mut().unwrap().as_rec_mut()
19778    }
19779}
19780impl<Prev: Rec> PushIfla6Attrs<Prev> {
19781    pub fn new(prev: Prev) -> Self {
19782        Self {
19783            prev: Some(prev),
19784            header_offset: None,
19785        }
19786    }
19787    pub fn end_nested(mut self) -> Prev {
19788        let mut prev = self.prev.take().unwrap();
19789        if let Some(header_offset) = &self.header_offset {
19790            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19791        }
19792        prev
19793    }
19794    pub fn push_flags(mut self, value: u32) -> Self {
19795        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19796        self.as_rec_mut().extend(value.to_ne_bytes());
19797        self
19798    }
19799    #[doc = "u32 indexed by ipv6-devconf - 1 on output, on input it's a nest"]
19800    pub fn push_conf(mut self, value: &[u8]) -> Self {
19801        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19802        self.as_rec_mut().extend(value);
19803        self
19804    }
19805    pub fn push_stats(mut self, value: &[u8]) -> Self {
19806        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
19807        self.as_rec_mut().extend(value);
19808        self
19809    }
19810    pub fn push_mcast(mut self, value: &[u8]) -> Self {
19811        push_header(self.as_rec_mut(), 4u16, value.len() as u16);
19812        self.as_rec_mut().extend(value);
19813        self
19814    }
19815    pub fn push_cacheinfo(mut self, value: PushIflaCacheinfo) -> Self {
19816        push_header(self.as_rec_mut(), 5u16, value.as_slice().len() as u16);
19817        self.as_rec_mut().extend(value.as_slice());
19818        self
19819    }
19820    pub fn push_icmp6stats(mut self, value: &[u8]) -> Self {
19821        push_header(self.as_rec_mut(), 6u16, value.len() as u16);
19822        self.as_rec_mut().extend(value);
19823        self
19824    }
19825    pub fn push_token(mut self, value: &[u8]) -> Self {
19826        push_header(self.as_rec_mut(), 7u16, value.len() as u16);
19827        self.as_rec_mut().extend(value);
19828        self
19829    }
19830    pub fn push_addr_gen_mode(mut self, value: u8) -> Self {
19831        push_header(self.as_rec_mut(), 8u16, 1 as u16);
19832        self.as_rec_mut().extend(value.to_ne_bytes());
19833        self
19834    }
19835    pub fn push_ra_mtu(mut self, value: u32) -> Self {
19836        push_header(self.as_rec_mut(), 9u16, 4 as u16);
19837        self.as_rec_mut().extend(value.to_ne_bytes());
19838        self
19839    }
19840}
19841impl<Prev: Rec> Drop for PushIfla6Attrs<Prev> {
19842    fn drop(&mut self) {
19843        if let Some(prev) = &mut self.prev {
19844            if let Some(header_offset) = &self.header_offset {
19845                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19846            }
19847        }
19848    }
19849}
19850pub struct PushMctpAttrs<Prev: Rec> {
19851    pub(crate) prev: Option<Prev>,
19852    pub(crate) header_offset: Option<usize>,
19853}
19854impl<Prev: Rec> Rec for PushMctpAttrs<Prev> {
19855    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19856        self.prev.as_mut().unwrap().as_rec_mut()
19857    }
19858}
19859impl<Prev: Rec> PushMctpAttrs<Prev> {
19860    pub fn new(prev: Prev) -> Self {
19861        Self {
19862            prev: Some(prev),
19863            header_offset: None,
19864        }
19865    }
19866    pub fn end_nested(mut self) -> Prev {
19867        let mut prev = self.prev.take().unwrap();
19868        if let Some(header_offset) = &self.header_offset {
19869            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19870        }
19871        prev
19872    }
19873    pub fn push_net(mut self, value: u32) -> Self {
19874        push_header(self.as_rec_mut(), 1u16, 4 as u16);
19875        self.as_rec_mut().extend(value.to_ne_bytes());
19876        self
19877    }
19878    pub fn push_phys_binding(mut self, value: u8) -> Self {
19879        push_header(self.as_rec_mut(), 2u16, 1 as u16);
19880        self.as_rec_mut().extend(value.to_ne_bytes());
19881        self
19882    }
19883}
19884impl<Prev: Rec> Drop for PushMctpAttrs<Prev> {
19885    fn drop(&mut self) {
19886        if let Some(prev) = &mut self.prev {
19887            if let Some(header_offset) = &self.header_offset {
19888                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19889            }
19890        }
19891    }
19892}
19893pub struct PushStatsAttrs<Prev: Rec> {
19894    pub(crate) prev: Option<Prev>,
19895    pub(crate) header_offset: Option<usize>,
19896}
19897impl<Prev: Rec> Rec for PushStatsAttrs<Prev> {
19898    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19899        self.prev.as_mut().unwrap().as_rec_mut()
19900    }
19901}
19902impl<Prev: Rec> PushStatsAttrs<Prev> {
19903    pub fn new(prev: Prev) -> Self {
19904        Self {
19905            prev: Some(prev),
19906            header_offset: None,
19907        }
19908    }
19909    pub fn end_nested(mut self) -> Prev {
19910        let mut prev = self.prev.take().unwrap();
19911        if let Some(header_offset) = &self.header_offset {
19912            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19913        }
19914        prev
19915    }
19916    pub fn push_link_64(mut self, value: PushRtnlLinkStats64) -> Self {
19917        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
19918        self.as_rec_mut().extend(value.as_slice());
19919        self
19920    }
19921    pub fn push_link_xstats(mut self, value: &[u8]) -> Self {
19922        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
19923        self.as_rec_mut().extend(value);
19924        self
19925    }
19926    pub fn push_link_xstats_slave(mut self, value: &[u8]) -> Self {
19927        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
19928        self.as_rec_mut().extend(value);
19929        self
19930    }
19931    pub fn nested_link_offload_xstats(mut self) -> PushLinkOffloadXstats<Self> {
19932        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
19933        PushLinkOffloadXstats {
19934            prev: Some(self),
19935            header_offset: Some(header_offset),
19936        }
19937    }
19938    pub fn push_af_spec(mut self, value: &[u8]) -> Self {
19939        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
19940        self.as_rec_mut().extend(value);
19941        self
19942    }
19943}
19944impl<Prev: Rec> Drop for PushStatsAttrs<Prev> {
19945    fn drop(&mut self) {
19946        if let Some(prev) = &mut self.prev {
19947            if let Some(header_offset) = &self.header_offset {
19948                finalize_nested_header(prev.as_rec_mut(), *header_offset);
19949            }
19950        }
19951    }
19952}
19953pub struct PushLinkOffloadXstats<Prev: Rec> {
19954    pub(crate) prev: Option<Prev>,
19955    pub(crate) header_offset: Option<usize>,
19956}
19957impl<Prev: Rec> Rec for PushLinkOffloadXstats<Prev> {
19958    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19959        self.prev.as_mut().unwrap().as_rec_mut()
19960    }
19961}
19962pub struct PushArrayHwSInfoOne<Prev: Rec> {
19963    pub(crate) prev: Option<Prev>,
19964    pub(crate) header_offset: Option<usize>,
19965    pub(crate) counter: u16,
19966}
19967impl<Prev: Rec> Rec for PushArrayHwSInfoOne<Prev> {
19968    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
19969        self.prev.as_mut().unwrap().as_rec_mut()
19970    }
19971}
19972impl<Prev: Rec> PushArrayHwSInfoOne<Prev> {
19973    pub fn new(prev: Prev) -> Self {
19974        Self {
19975            prev: Some(prev),
19976            header_offset: None,
19977            counter: 0,
19978        }
19979    }
19980    pub fn end_array(mut self) -> Prev {
19981        let mut prev = self.prev.take().unwrap();
19982        if let Some(header_offset) = &self.header_offset {
19983            finalize_nested_header(prev.as_rec_mut(), *header_offset);
19984        }
19985        prev
19986    }
19987    pub fn entry_nested(mut self) -> PushHwSInfoOne<Self> {
19988        let index = self.counter;
19989        self.counter += 1;
19990        let header_offset = push_nested_header(self.as_rec_mut(), index);
19991        PushHwSInfoOne {
19992            prev: Some(self),
19993            header_offset: Some(header_offset),
19994        }
19995    }
19996}
19997impl<Prev: Rec> Drop for PushArrayHwSInfoOne<Prev> {
19998    fn drop(&mut self) {
19999        if let Some(prev) = &mut self.prev {
20000            if let Some(header_offset) = &self.header_offset {
20001                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20002            }
20003        }
20004    }
20005}
20006impl<Prev: Rec> PushLinkOffloadXstats<Prev> {
20007    pub fn new(prev: Prev) -> Self {
20008        Self {
20009            prev: Some(prev),
20010            header_offset: None,
20011        }
20012    }
20013    pub fn end_nested(mut self) -> Prev {
20014        let mut prev = self.prev.take().unwrap();
20015        if let Some(header_offset) = &self.header_offset {
20016            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20017        }
20018        prev
20019    }
20020    pub fn push_cpu_hit(mut self, value: &[u8]) -> Self {
20021        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
20022        self.as_rec_mut().extend(value);
20023        self
20024    }
20025    pub fn array_hw_s_info(mut self) -> PushArrayHwSInfoOne<Self> {
20026        let header_offset = push_nested_header(self.as_rec_mut(), 2u16);
20027        PushArrayHwSInfoOne {
20028            prev: Some(self),
20029            header_offset: Some(header_offset),
20030            counter: 0,
20031        }
20032    }
20033    pub fn push_l3_stats(mut self, value: &[u8]) -> Self {
20034        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
20035        self.as_rec_mut().extend(value);
20036        self
20037    }
20038}
20039impl<Prev: Rec> Drop for PushLinkOffloadXstats<Prev> {
20040    fn drop(&mut self) {
20041        if let Some(prev) = &mut self.prev {
20042            if let Some(header_offset) = &self.header_offset {
20043                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20044            }
20045        }
20046    }
20047}
20048pub struct PushHwSInfoOne<Prev: Rec> {
20049    pub(crate) prev: Option<Prev>,
20050    pub(crate) header_offset: Option<usize>,
20051}
20052impl<Prev: Rec> Rec for PushHwSInfoOne<Prev> {
20053    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
20054        self.prev.as_mut().unwrap().as_rec_mut()
20055    }
20056}
20057impl<Prev: Rec> PushHwSInfoOne<Prev> {
20058    pub fn new(prev: Prev) -> Self {
20059        Self {
20060            prev: Some(prev),
20061            header_offset: None,
20062        }
20063    }
20064    pub fn end_nested(mut self) -> Prev {
20065        let mut prev = self.prev.take().unwrap();
20066        if let Some(header_offset) = &self.header_offset {
20067            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20068        }
20069        prev
20070    }
20071    pub fn push_request(mut self, value: u8) -> Self {
20072        push_header(self.as_rec_mut(), 1u16, 1 as u16);
20073        self.as_rec_mut().extend(value.to_ne_bytes());
20074        self
20075    }
20076    pub fn push_used(mut self, value: u8) -> Self {
20077        push_header(self.as_rec_mut(), 2u16, 1 as u16);
20078        self.as_rec_mut().extend(value.to_ne_bytes());
20079        self
20080    }
20081}
20082impl<Prev: Rec> Drop for PushHwSInfoOne<Prev> {
20083    fn drop(&mut self) {
20084        if let Some(prev) = &mut self.prev {
20085            if let Some(header_offset) = &self.header_offset {
20086                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20087            }
20088        }
20089    }
20090}
20091pub struct PushLinkDpllPinAttrs<Prev: Rec> {
20092    pub(crate) prev: Option<Prev>,
20093    pub(crate) header_offset: Option<usize>,
20094}
20095impl<Prev: Rec> Rec for PushLinkDpllPinAttrs<Prev> {
20096    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
20097        self.prev.as_mut().unwrap().as_rec_mut()
20098    }
20099}
20100impl<Prev: Rec> PushLinkDpllPinAttrs<Prev> {
20101    pub fn new(prev: Prev) -> Self {
20102        Self {
20103            prev: Some(prev),
20104            header_offset: None,
20105        }
20106    }
20107    pub fn end_nested(mut self) -> Prev {
20108        let mut prev = self.prev.take().unwrap();
20109        if let Some(header_offset) = &self.header_offset {
20110            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20111        }
20112        prev
20113    }
20114    pub fn push_id(mut self, value: u32) -> Self {
20115        push_header(self.as_rec_mut(), 1u16, 4 as u16);
20116        self.as_rec_mut().extend(value.to_ne_bytes());
20117        self
20118    }
20119}
20120impl<Prev: Rec> Drop for PushLinkDpllPinAttrs<Prev> {
20121    fn drop(&mut self) {
20122        if let Some(prev) = &mut self.prev {
20123            if let Some(header_offset) = &self.header_offset {
20124                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20125            }
20126        }
20127    }
20128}
20129pub struct PushLinkinfoNetkitAttrs<Prev: Rec> {
20130    pub(crate) prev: Option<Prev>,
20131    pub(crate) header_offset: Option<usize>,
20132}
20133impl<Prev: Rec> Rec for PushLinkinfoNetkitAttrs<Prev> {
20134    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
20135        self.prev.as_mut().unwrap().as_rec_mut()
20136    }
20137}
20138impl<Prev: Rec> PushLinkinfoNetkitAttrs<Prev> {
20139    pub fn new(prev: Prev) -> Self {
20140        Self {
20141            prev: Some(prev),
20142            header_offset: None,
20143        }
20144    }
20145    pub fn end_nested(mut self) -> Prev {
20146        let mut prev = self.prev.take().unwrap();
20147        if let Some(header_offset) = &self.header_offset {
20148            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20149        }
20150        prev
20151    }
20152    pub fn push_peer_info(mut self, value: &[u8]) -> Self {
20153        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
20154        self.as_rec_mut().extend(value);
20155        self
20156    }
20157    pub fn push_primary(mut self, value: u8) -> Self {
20158        push_header(self.as_rec_mut(), 2u16, 1 as u16);
20159        self.as_rec_mut().extend(value.to_ne_bytes());
20160        self
20161    }
20162    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
20163    pub fn push_policy(mut self, value: u32) -> Self {
20164        push_header(self.as_rec_mut(), 3u16, 4 as u16);
20165        self.as_rec_mut().extend(value.to_ne_bytes());
20166        self
20167    }
20168    #[doc = "Associated type: \"NetkitPolicy\" (enum)"]
20169    pub fn push_peer_policy(mut self, value: u32) -> Self {
20170        push_header(self.as_rec_mut(), 4u16, 4 as u16);
20171        self.as_rec_mut().extend(value.to_ne_bytes());
20172        self
20173    }
20174    #[doc = "Associated type: \"NetkitMode\" (enum)"]
20175    pub fn push_mode(mut self, value: u32) -> Self {
20176        push_header(self.as_rec_mut(), 5u16, 4 as u16);
20177        self.as_rec_mut().extend(value.to_ne_bytes());
20178        self
20179    }
20180    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
20181    pub fn push_scrub(mut self, value: u32) -> Self {
20182        push_header(self.as_rec_mut(), 6u16, 4 as u16);
20183        self.as_rec_mut().extend(value.to_ne_bytes());
20184        self
20185    }
20186    #[doc = "Associated type: \"NetkitScrub\" (enum)"]
20187    pub fn push_peer_scrub(mut self, value: u32) -> Self {
20188        push_header(self.as_rec_mut(), 7u16, 4 as u16);
20189        self.as_rec_mut().extend(value.to_ne_bytes());
20190        self
20191    }
20192    pub fn push_headroom(mut self, value: u16) -> Self {
20193        push_header(self.as_rec_mut(), 8u16, 2 as u16);
20194        self.as_rec_mut().extend(value.to_ne_bytes());
20195        self
20196    }
20197    pub fn push_tailroom(mut self, value: u16) -> Self {
20198        push_header(self.as_rec_mut(), 9u16, 2 as u16);
20199        self.as_rec_mut().extend(value.to_ne_bytes());
20200        self
20201    }
20202}
20203impl<Prev: Rec> Drop for PushLinkinfoNetkitAttrs<Prev> {
20204    fn drop(&mut self) {
20205        if let Some(prev) = &mut self.prev {
20206            if let Some(header_offset) = &self.header_offset {
20207                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20208            }
20209        }
20210    }
20211}
20212pub struct PushLinkinfoOvpnAttrs<Prev: Rec> {
20213    pub(crate) prev: Option<Prev>,
20214    pub(crate) header_offset: Option<usize>,
20215}
20216impl<Prev: Rec> Rec for PushLinkinfoOvpnAttrs<Prev> {
20217    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
20218        self.prev.as_mut().unwrap().as_rec_mut()
20219    }
20220}
20221impl<Prev: Rec> PushLinkinfoOvpnAttrs<Prev> {
20222    pub fn new(prev: Prev) -> Self {
20223        Self {
20224            prev: Some(prev),
20225            header_offset: None,
20226        }
20227    }
20228    pub fn end_nested(mut self) -> Prev {
20229        let mut prev = self.prev.take().unwrap();
20230        if let Some(header_offset) = &self.header_offset {
20231            finalize_nested_header(prev.as_rec_mut(), *header_offset);
20232        }
20233        prev
20234    }
20235    #[doc = "Associated type: \"OvpnMode\" (enum)"]
20236    pub fn push_mode(mut self, value: u8) -> Self {
20237        push_header(self.as_rec_mut(), 1u16, 1 as u16);
20238        self.as_rec_mut().extend(value.to_ne_bytes());
20239        self
20240    }
20241}
20242impl<Prev: Rec> Drop for PushLinkinfoOvpnAttrs<Prev> {
20243    fn drop(&mut self) {
20244        if let Some(prev) = &mut self.prev {
20245            if let Some(header_offset) = &self.header_offset {
20246                finalize_nested_header(prev.as_rec_mut(), *header_offset);
20247            }
20248        }
20249    }
20250}
20251#[derive(Clone)]
20252pub struct PushRtgenmsg {
20253    pub(crate) buf: [u8; 1usize],
20254}
20255#[doc = "Create zero-initialized struct"]
20256impl Default for PushRtgenmsg {
20257    fn default() -> Self {
20258        Self { buf: [0u8; 1usize] }
20259    }
20260}
20261impl PushRtgenmsg {
20262    #[doc = "Create zero-initialized struct"]
20263    pub fn new() -> Self {
20264        Default::default()
20265    }
20266    #[doc = "Copy from contents from other slice"]
20267    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20268        if other.len() != Self::len() {
20269            return None;
20270        }
20271        let mut buf = [0u8; Self::len()];
20272        buf.clone_from_slice(other);
20273        Some(Self { buf })
20274    }
20275    pub fn as_slice(&self) -> &[u8] {
20276        &self.buf
20277    }
20278    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20279        &mut self.buf
20280    }
20281    pub const fn len() -> usize {
20282        1usize
20283    }
20284    pub fn family(&self) -> u8 {
20285        parse_u8(&self.buf[0usize..1usize]).unwrap()
20286    }
20287    pub fn set_family(&mut self, value: u8) {
20288        self.buf[0usize..1usize].copy_from_slice(&value.to_ne_bytes())
20289    }
20290}
20291impl std::fmt::Debug for PushRtgenmsg {
20292    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20293        fmt.debug_struct("Rtgenmsg")
20294            .field("family", &self.family())
20295            .finish()
20296    }
20297}
20298#[derive(Clone)]
20299pub struct PushIfinfomsg {
20300    pub(crate) buf: [u8; 16usize],
20301}
20302#[doc = "Create zero-initialized struct"]
20303impl Default for PushIfinfomsg {
20304    fn default() -> Self {
20305        Self {
20306            buf: [0u8; 16usize],
20307        }
20308    }
20309}
20310impl PushIfinfomsg {
20311    #[doc = "Create zero-initialized struct"]
20312    pub fn new() -> Self {
20313        Default::default()
20314    }
20315    #[doc = "Copy from contents from other slice"]
20316    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20317        if other.len() != Self::len() {
20318            return None;
20319        }
20320        let mut buf = [0u8; Self::len()];
20321        buf.clone_from_slice(other);
20322        Some(Self { buf })
20323    }
20324    pub fn as_slice(&self) -> &[u8] {
20325        &self.buf
20326    }
20327    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20328        &mut self.buf
20329    }
20330    pub const fn len() -> usize {
20331        16usize
20332    }
20333    pub fn ifi_family(&self) -> u8 {
20334        parse_u8(&self.buf[0usize..1usize]).unwrap()
20335    }
20336    pub fn set_ifi_family(&mut self, value: u8) {
20337        self.buf[0usize..1usize].copy_from_slice(&value.to_ne_bytes())
20338    }
20339    pub fn ifi_type(&self) -> u16 {
20340        parse_u16(&self.buf[2usize..4usize]).unwrap()
20341    }
20342    pub fn set_ifi_type(&mut self, value: u16) {
20343        self.buf[2usize..4usize].copy_from_slice(&value.to_ne_bytes())
20344    }
20345    pub fn ifi_index(&self) -> i32 {
20346        parse_i32(&self.buf[4usize..8usize]).unwrap()
20347    }
20348    pub fn set_ifi_index(&mut self, value: i32) {
20349        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
20350    }
20351    #[doc = "Associated type: \"IfinfoFlags\" (1 bit per enumeration)"]
20352    pub fn ifi_flags(&self) -> u32 {
20353        parse_u32(&self.buf[8usize..12usize]).unwrap()
20354    }
20355    #[doc = "Associated type: \"IfinfoFlags\" (1 bit per enumeration)"]
20356    pub fn set_ifi_flags(&mut self, value: u32) {
20357        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
20358    }
20359    pub fn ifi_change(&self) -> u32 {
20360        parse_u32(&self.buf[12usize..16usize]).unwrap()
20361    }
20362    pub fn set_ifi_change(&mut self, value: u32) {
20363        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
20364    }
20365}
20366impl std::fmt::Debug for PushIfinfomsg {
20367    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20368        fmt.debug_struct("Ifinfomsg")
20369            .field("ifi_family", &self.ifi_family())
20370            .field("ifi_type", &self.ifi_type())
20371            .field("ifi_index", &self.ifi_index())
20372            .field("ifi_flags", &self.ifi_flags())
20373            .field("ifi_change", &self.ifi_change())
20374            .finish()
20375    }
20376}
20377#[derive(Clone)]
20378pub struct PushIflaBridgeId {
20379    pub(crate) buf: [u8; 2usize],
20380}
20381#[doc = "Create zero-initialized struct"]
20382impl Default for PushIflaBridgeId {
20383    fn default() -> Self {
20384        Self { buf: [0u8; 2usize] }
20385    }
20386}
20387impl PushIflaBridgeId {
20388    #[doc = "Create zero-initialized struct"]
20389    pub fn new() -> Self {
20390        Default::default()
20391    }
20392    #[doc = "Copy from contents from other slice"]
20393    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20394        if other.len() != Self::len() {
20395            return None;
20396        }
20397        let mut buf = [0u8; Self::len()];
20398        buf.clone_from_slice(other);
20399        Some(Self { buf })
20400    }
20401    pub fn as_slice(&self) -> &[u8] {
20402        &self.buf
20403    }
20404    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20405        &mut self.buf
20406    }
20407    pub const fn len() -> usize {
20408        2usize
20409    }
20410    pub fn prio(&self) -> u16 {
20411        parse_u16(&self.buf[0usize..2usize]).unwrap()
20412    }
20413    pub fn set_prio(&mut self, value: u16) {
20414        self.buf[0usize..2usize].copy_from_slice(&value.to_ne_bytes())
20415    }
20416    pub fn addr(&self) -> [u8; 6usize] {
20417        self.buf[2usize..8usize].try_into().unwrap()
20418    }
20419    pub fn set_addr(&mut self, value: [u8; 6usize]) {
20420        self.buf[2usize..8usize].copy_from_slice(&value)
20421    }
20422}
20423impl std::fmt::Debug for PushIflaBridgeId {
20424    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20425        fmt.debug_struct("IflaBridgeId")
20426            .field("prio", &self.prio())
20427            .field("addr", &self.addr())
20428            .finish()
20429    }
20430}
20431#[derive(Clone)]
20432pub struct PushIflaCacheinfo {
20433    pub(crate) buf: [u8; 16usize],
20434}
20435#[doc = "Create zero-initialized struct"]
20436impl Default for PushIflaCacheinfo {
20437    fn default() -> Self {
20438        Self {
20439            buf: [0u8; 16usize],
20440        }
20441    }
20442}
20443impl PushIflaCacheinfo {
20444    #[doc = "Create zero-initialized struct"]
20445    pub fn new() -> Self {
20446        Default::default()
20447    }
20448    #[doc = "Copy from contents from other slice"]
20449    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20450        if other.len() != Self::len() {
20451            return None;
20452        }
20453        let mut buf = [0u8; Self::len()];
20454        buf.clone_from_slice(other);
20455        Some(Self { buf })
20456    }
20457    pub fn as_slice(&self) -> &[u8] {
20458        &self.buf
20459    }
20460    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20461        &mut self.buf
20462    }
20463    pub const fn len() -> usize {
20464        16usize
20465    }
20466    pub fn max_reasm_len(&self) -> u32 {
20467        parse_u32(&self.buf[0usize..4usize]).unwrap()
20468    }
20469    pub fn set_max_reasm_len(&mut self, value: u32) {
20470        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
20471    }
20472    pub fn tstamp(&self) -> u32 {
20473        parse_u32(&self.buf[4usize..8usize]).unwrap()
20474    }
20475    pub fn set_tstamp(&mut self, value: u32) {
20476        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
20477    }
20478    pub fn reachable_time(&self) -> i32 {
20479        parse_i32(&self.buf[8usize..12usize]).unwrap()
20480    }
20481    pub fn set_reachable_time(&mut self, value: i32) {
20482        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
20483    }
20484    pub fn retrans_time(&self) -> u32 {
20485        parse_u32(&self.buf[12usize..16usize]).unwrap()
20486    }
20487    pub fn set_retrans_time(&mut self, value: u32) {
20488        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
20489    }
20490}
20491impl std::fmt::Debug for PushIflaCacheinfo {
20492    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20493        fmt.debug_struct("IflaCacheinfo")
20494            .field("max_reasm_len", &self.max_reasm_len())
20495            .field("tstamp", &self.tstamp())
20496            .field("reachable_time", &self.reachable_time())
20497            .field("retrans_time", &self.retrans_time())
20498            .finish()
20499    }
20500}
20501#[derive(Clone)]
20502pub struct PushRtnlLinkStats {
20503    pub(crate) buf: [u8; 96usize],
20504}
20505#[doc = "Create zero-initialized struct"]
20506impl Default for PushRtnlLinkStats {
20507    fn default() -> Self {
20508        Self {
20509            buf: [0u8; 96usize],
20510        }
20511    }
20512}
20513impl PushRtnlLinkStats {
20514    #[doc = "Create zero-initialized struct"]
20515    pub fn new() -> Self {
20516        Default::default()
20517    }
20518    #[doc = "Copy from contents from other slice"]
20519    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20520        if other.len() != Self::len() {
20521            return None;
20522        }
20523        let mut buf = [0u8; Self::len()];
20524        buf.clone_from_slice(other);
20525        Some(Self { buf })
20526    }
20527    pub fn as_slice(&self) -> &[u8] {
20528        &self.buf
20529    }
20530    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20531        &mut self.buf
20532    }
20533    pub const fn len() -> usize {
20534        96usize
20535    }
20536    pub fn rx_packets(&self) -> u32 {
20537        parse_u32(&self.buf[0usize..4usize]).unwrap()
20538    }
20539    pub fn set_rx_packets(&mut self, value: u32) {
20540        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
20541    }
20542    pub fn tx_packets(&self) -> u32 {
20543        parse_u32(&self.buf[4usize..8usize]).unwrap()
20544    }
20545    pub fn set_tx_packets(&mut self, value: u32) {
20546        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
20547    }
20548    pub fn rx_bytes(&self) -> u32 {
20549        parse_u32(&self.buf[8usize..12usize]).unwrap()
20550    }
20551    pub fn set_rx_bytes(&mut self, value: u32) {
20552        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
20553    }
20554    pub fn tx_bytes(&self) -> u32 {
20555        parse_u32(&self.buf[12usize..16usize]).unwrap()
20556    }
20557    pub fn set_tx_bytes(&mut self, value: u32) {
20558        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
20559    }
20560    pub fn rx_errors(&self) -> u32 {
20561        parse_u32(&self.buf[16usize..20usize]).unwrap()
20562    }
20563    pub fn set_rx_errors(&mut self, value: u32) {
20564        self.buf[16usize..20usize].copy_from_slice(&value.to_ne_bytes())
20565    }
20566    pub fn tx_errors(&self) -> u32 {
20567        parse_u32(&self.buf[20usize..24usize]).unwrap()
20568    }
20569    pub fn set_tx_errors(&mut self, value: u32) {
20570        self.buf[20usize..24usize].copy_from_slice(&value.to_ne_bytes())
20571    }
20572    pub fn rx_dropped(&self) -> u32 {
20573        parse_u32(&self.buf[24usize..28usize]).unwrap()
20574    }
20575    pub fn set_rx_dropped(&mut self, value: u32) {
20576        self.buf[24usize..28usize].copy_from_slice(&value.to_ne_bytes())
20577    }
20578    pub fn tx_dropped(&self) -> u32 {
20579        parse_u32(&self.buf[28usize..32usize]).unwrap()
20580    }
20581    pub fn set_tx_dropped(&mut self, value: u32) {
20582        self.buf[28usize..32usize].copy_from_slice(&value.to_ne_bytes())
20583    }
20584    pub fn multicast(&self) -> u32 {
20585        parse_u32(&self.buf[32usize..36usize]).unwrap()
20586    }
20587    pub fn set_multicast(&mut self, value: u32) {
20588        self.buf[32usize..36usize].copy_from_slice(&value.to_ne_bytes())
20589    }
20590    pub fn collisions(&self) -> u32 {
20591        parse_u32(&self.buf[36usize..40usize]).unwrap()
20592    }
20593    pub fn set_collisions(&mut self, value: u32) {
20594        self.buf[36usize..40usize].copy_from_slice(&value.to_ne_bytes())
20595    }
20596    pub fn rx_length_errors(&self) -> u32 {
20597        parse_u32(&self.buf[40usize..44usize]).unwrap()
20598    }
20599    pub fn set_rx_length_errors(&mut self, value: u32) {
20600        self.buf[40usize..44usize].copy_from_slice(&value.to_ne_bytes())
20601    }
20602    pub fn rx_over_errors(&self) -> u32 {
20603        parse_u32(&self.buf[44usize..48usize]).unwrap()
20604    }
20605    pub fn set_rx_over_errors(&mut self, value: u32) {
20606        self.buf[44usize..48usize].copy_from_slice(&value.to_ne_bytes())
20607    }
20608    pub fn rx_crc_errors(&self) -> u32 {
20609        parse_u32(&self.buf[48usize..52usize]).unwrap()
20610    }
20611    pub fn set_rx_crc_errors(&mut self, value: u32) {
20612        self.buf[48usize..52usize].copy_from_slice(&value.to_ne_bytes())
20613    }
20614    pub fn rx_frame_errors(&self) -> u32 {
20615        parse_u32(&self.buf[52usize..56usize]).unwrap()
20616    }
20617    pub fn set_rx_frame_errors(&mut self, value: u32) {
20618        self.buf[52usize..56usize].copy_from_slice(&value.to_ne_bytes())
20619    }
20620    pub fn rx_fifo_errors(&self) -> u32 {
20621        parse_u32(&self.buf[56usize..60usize]).unwrap()
20622    }
20623    pub fn set_rx_fifo_errors(&mut self, value: u32) {
20624        self.buf[56usize..60usize].copy_from_slice(&value.to_ne_bytes())
20625    }
20626    pub fn rx_missed_errors(&self) -> u32 {
20627        parse_u32(&self.buf[60usize..64usize]).unwrap()
20628    }
20629    pub fn set_rx_missed_errors(&mut self, value: u32) {
20630        self.buf[60usize..64usize].copy_from_slice(&value.to_ne_bytes())
20631    }
20632    pub fn tx_aborted_errors(&self) -> u32 {
20633        parse_u32(&self.buf[64usize..68usize]).unwrap()
20634    }
20635    pub fn set_tx_aborted_errors(&mut self, value: u32) {
20636        self.buf[64usize..68usize].copy_from_slice(&value.to_ne_bytes())
20637    }
20638    pub fn tx_carrier_errors(&self) -> u32 {
20639        parse_u32(&self.buf[68usize..72usize]).unwrap()
20640    }
20641    pub fn set_tx_carrier_errors(&mut self, value: u32) {
20642        self.buf[68usize..72usize].copy_from_slice(&value.to_ne_bytes())
20643    }
20644    pub fn tx_fifo_errors(&self) -> u32 {
20645        parse_u32(&self.buf[72usize..76usize]).unwrap()
20646    }
20647    pub fn set_tx_fifo_errors(&mut self, value: u32) {
20648        self.buf[72usize..76usize].copy_from_slice(&value.to_ne_bytes())
20649    }
20650    pub fn tx_heartbeat_errors(&self) -> u32 {
20651        parse_u32(&self.buf[76usize..80usize]).unwrap()
20652    }
20653    pub fn set_tx_heartbeat_errors(&mut self, value: u32) {
20654        self.buf[76usize..80usize].copy_from_slice(&value.to_ne_bytes())
20655    }
20656    pub fn tx_window_errors(&self) -> u32 {
20657        parse_u32(&self.buf[80usize..84usize]).unwrap()
20658    }
20659    pub fn set_tx_window_errors(&mut self, value: u32) {
20660        self.buf[80usize..84usize].copy_from_slice(&value.to_ne_bytes())
20661    }
20662    pub fn rx_compressed(&self) -> u32 {
20663        parse_u32(&self.buf[84usize..88usize]).unwrap()
20664    }
20665    pub fn set_rx_compressed(&mut self, value: u32) {
20666        self.buf[84usize..88usize].copy_from_slice(&value.to_ne_bytes())
20667    }
20668    pub fn tx_compressed(&self) -> u32 {
20669        parse_u32(&self.buf[88usize..92usize]).unwrap()
20670    }
20671    pub fn set_tx_compressed(&mut self, value: u32) {
20672        self.buf[88usize..92usize].copy_from_slice(&value.to_ne_bytes())
20673    }
20674    pub fn rx_nohandler(&self) -> u32 {
20675        parse_u32(&self.buf[92usize..96usize]).unwrap()
20676    }
20677    pub fn set_rx_nohandler(&mut self, value: u32) {
20678        self.buf[92usize..96usize].copy_from_slice(&value.to_ne_bytes())
20679    }
20680}
20681impl std::fmt::Debug for PushRtnlLinkStats {
20682    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20683        fmt.debug_struct("RtnlLinkStats")
20684            .field("rx_packets", &self.rx_packets())
20685            .field("tx_packets", &self.tx_packets())
20686            .field("rx_bytes", &self.rx_bytes())
20687            .field("tx_bytes", &self.tx_bytes())
20688            .field("rx_errors", &self.rx_errors())
20689            .field("tx_errors", &self.tx_errors())
20690            .field("rx_dropped", &self.rx_dropped())
20691            .field("tx_dropped", &self.tx_dropped())
20692            .field("multicast", &self.multicast())
20693            .field("collisions", &self.collisions())
20694            .field("rx_length_errors", &self.rx_length_errors())
20695            .field("rx_over_errors", &self.rx_over_errors())
20696            .field("rx_crc_errors", &self.rx_crc_errors())
20697            .field("rx_frame_errors", &self.rx_frame_errors())
20698            .field("rx_fifo_errors", &self.rx_fifo_errors())
20699            .field("rx_missed_errors", &self.rx_missed_errors())
20700            .field("tx_aborted_errors", &self.tx_aborted_errors())
20701            .field("tx_carrier_errors", &self.tx_carrier_errors())
20702            .field("tx_fifo_errors", &self.tx_fifo_errors())
20703            .field("tx_heartbeat_errors", &self.tx_heartbeat_errors())
20704            .field("tx_window_errors", &self.tx_window_errors())
20705            .field("rx_compressed", &self.rx_compressed())
20706            .field("tx_compressed", &self.tx_compressed())
20707            .field("rx_nohandler", &self.rx_nohandler())
20708            .finish()
20709    }
20710}
20711#[derive(Clone)]
20712pub struct PushRtnlLinkStats64 {
20713    pub(crate) buf: [u8; 200usize],
20714}
20715#[doc = "Create zero-initialized struct"]
20716impl Default for PushRtnlLinkStats64 {
20717    fn default() -> Self {
20718        Self {
20719            buf: [0u8; 200usize],
20720        }
20721    }
20722}
20723impl PushRtnlLinkStats64 {
20724    #[doc = "Create zero-initialized struct"]
20725    pub fn new() -> Self {
20726        Default::default()
20727    }
20728    #[doc = "Copy from contents from other slice"]
20729    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20730        if other.len() != Self::len() {
20731            return None;
20732        }
20733        let mut buf = [0u8; Self::len()];
20734        buf.clone_from_slice(other);
20735        Some(Self { buf })
20736    }
20737    pub fn as_slice(&self) -> &[u8] {
20738        &self.buf
20739    }
20740    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20741        &mut self.buf
20742    }
20743    pub const fn len() -> usize {
20744        200usize
20745    }
20746    pub fn rx_packets(&self) -> u64 {
20747        parse_u64(&self.buf[0usize..8usize]).unwrap()
20748    }
20749    pub fn set_rx_packets(&mut self, value: u64) {
20750        self.buf[0usize..8usize].copy_from_slice(&value.to_ne_bytes())
20751    }
20752    pub fn tx_packets(&self) -> u64 {
20753        parse_u64(&self.buf[8usize..16usize]).unwrap()
20754    }
20755    pub fn set_tx_packets(&mut self, value: u64) {
20756        self.buf[8usize..16usize].copy_from_slice(&value.to_ne_bytes())
20757    }
20758    pub fn rx_bytes(&self) -> u64 {
20759        parse_u64(&self.buf[16usize..24usize]).unwrap()
20760    }
20761    pub fn set_rx_bytes(&mut self, value: u64) {
20762        self.buf[16usize..24usize].copy_from_slice(&value.to_ne_bytes())
20763    }
20764    pub fn tx_bytes(&self) -> u64 {
20765        parse_u64(&self.buf[24usize..32usize]).unwrap()
20766    }
20767    pub fn set_tx_bytes(&mut self, value: u64) {
20768        self.buf[24usize..32usize].copy_from_slice(&value.to_ne_bytes())
20769    }
20770    pub fn rx_errors(&self) -> u64 {
20771        parse_u64(&self.buf[32usize..40usize]).unwrap()
20772    }
20773    pub fn set_rx_errors(&mut self, value: u64) {
20774        self.buf[32usize..40usize].copy_from_slice(&value.to_ne_bytes())
20775    }
20776    pub fn tx_errors(&self) -> u64 {
20777        parse_u64(&self.buf[40usize..48usize]).unwrap()
20778    }
20779    pub fn set_tx_errors(&mut self, value: u64) {
20780        self.buf[40usize..48usize].copy_from_slice(&value.to_ne_bytes())
20781    }
20782    pub fn rx_dropped(&self) -> u64 {
20783        parse_u64(&self.buf[48usize..56usize]).unwrap()
20784    }
20785    pub fn set_rx_dropped(&mut self, value: u64) {
20786        self.buf[48usize..56usize].copy_from_slice(&value.to_ne_bytes())
20787    }
20788    pub fn tx_dropped(&self) -> u64 {
20789        parse_u64(&self.buf[56usize..64usize]).unwrap()
20790    }
20791    pub fn set_tx_dropped(&mut self, value: u64) {
20792        self.buf[56usize..64usize].copy_from_slice(&value.to_ne_bytes())
20793    }
20794    pub fn multicast(&self) -> u64 {
20795        parse_u64(&self.buf[64usize..72usize]).unwrap()
20796    }
20797    pub fn set_multicast(&mut self, value: u64) {
20798        self.buf[64usize..72usize].copy_from_slice(&value.to_ne_bytes())
20799    }
20800    pub fn collisions(&self) -> u64 {
20801        parse_u64(&self.buf[72usize..80usize]).unwrap()
20802    }
20803    pub fn set_collisions(&mut self, value: u64) {
20804        self.buf[72usize..80usize].copy_from_slice(&value.to_ne_bytes())
20805    }
20806    pub fn rx_length_errors(&self) -> u64 {
20807        parse_u64(&self.buf[80usize..88usize]).unwrap()
20808    }
20809    pub fn set_rx_length_errors(&mut self, value: u64) {
20810        self.buf[80usize..88usize].copy_from_slice(&value.to_ne_bytes())
20811    }
20812    pub fn rx_over_errors(&self) -> u64 {
20813        parse_u64(&self.buf[88usize..96usize]).unwrap()
20814    }
20815    pub fn set_rx_over_errors(&mut self, value: u64) {
20816        self.buf[88usize..96usize].copy_from_slice(&value.to_ne_bytes())
20817    }
20818    pub fn rx_crc_errors(&self) -> u64 {
20819        parse_u64(&self.buf[96usize..104usize]).unwrap()
20820    }
20821    pub fn set_rx_crc_errors(&mut self, value: u64) {
20822        self.buf[96usize..104usize].copy_from_slice(&value.to_ne_bytes())
20823    }
20824    pub fn rx_frame_errors(&self) -> u64 {
20825        parse_u64(&self.buf[104usize..112usize]).unwrap()
20826    }
20827    pub fn set_rx_frame_errors(&mut self, value: u64) {
20828        self.buf[104usize..112usize].copy_from_slice(&value.to_ne_bytes())
20829    }
20830    pub fn rx_fifo_errors(&self) -> u64 {
20831        parse_u64(&self.buf[112usize..120usize]).unwrap()
20832    }
20833    pub fn set_rx_fifo_errors(&mut self, value: u64) {
20834        self.buf[112usize..120usize].copy_from_slice(&value.to_ne_bytes())
20835    }
20836    pub fn rx_missed_errors(&self) -> u64 {
20837        parse_u64(&self.buf[120usize..128usize]).unwrap()
20838    }
20839    pub fn set_rx_missed_errors(&mut self, value: u64) {
20840        self.buf[120usize..128usize].copy_from_slice(&value.to_ne_bytes())
20841    }
20842    pub fn tx_aborted_errors(&self) -> u64 {
20843        parse_u64(&self.buf[128usize..136usize]).unwrap()
20844    }
20845    pub fn set_tx_aborted_errors(&mut self, value: u64) {
20846        self.buf[128usize..136usize].copy_from_slice(&value.to_ne_bytes())
20847    }
20848    pub fn tx_carrier_errors(&self) -> u64 {
20849        parse_u64(&self.buf[136usize..144usize]).unwrap()
20850    }
20851    pub fn set_tx_carrier_errors(&mut self, value: u64) {
20852        self.buf[136usize..144usize].copy_from_slice(&value.to_ne_bytes())
20853    }
20854    pub fn tx_fifo_errors(&self) -> u64 {
20855        parse_u64(&self.buf[144usize..152usize]).unwrap()
20856    }
20857    pub fn set_tx_fifo_errors(&mut self, value: u64) {
20858        self.buf[144usize..152usize].copy_from_slice(&value.to_ne_bytes())
20859    }
20860    pub fn tx_heartbeat_errors(&self) -> u64 {
20861        parse_u64(&self.buf[152usize..160usize]).unwrap()
20862    }
20863    pub fn set_tx_heartbeat_errors(&mut self, value: u64) {
20864        self.buf[152usize..160usize].copy_from_slice(&value.to_ne_bytes())
20865    }
20866    pub fn tx_window_errors(&self) -> u64 {
20867        parse_u64(&self.buf[160usize..168usize]).unwrap()
20868    }
20869    pub fn set_tx_window_errors(&mut self, value: u64) {
20870        self.buf[160usize..168usize].copy_from_slice(&value.to_ne_bytes())
20871    }
20872    pub fn rx_compressed(&self) -> u64 {
20873        parse_u64(&self.buf[168usize..176usize]).unwrap()
20874    }
20875    pub fn set_rx_compressed(&mut self, value: u64) {
20876        self.buf[168usize..176usize].copy_from_slice(&value.to_ne_bytes())
20877    }
20878    pub fn tx_compressed(&self) -> u64 {
20879        parse_u64(&self.buf[176usize..184usize]).unwrap()
20880    }
20881    pub fn set_tx_compressed(&mut self, value: u64) {
20882        self.buf[176usize..184usize].copy_from_slice(&value.to_ne_bytes())
20883    }
20884    pub fn rx_nohandler(&self) -> u64 {
20885        parse_u64(&self.buf[184usize..192usize]).unwrap()
20886    }
20887    pub fn set_rx_nohandler(&mut self, value: u64) {
20888        self.buf[184usize..192usize].copy_from_slice(&value.to_ne_bytes())
20889    }
20890    pub fn rx_otherhost_dropped(&self) -> u64 {
20891        parse_u64(&self.buf[192usize..200usize]).unwrap()
20892    }
20893    pub fn set_rx_otherhost_dropped(&mut self, value: u64) {
20894        self.buf[192usize..200usize].copy_from_slice(&value.to_ne_bytes())
20895    }
20896}
20897impl std::fmt::Debug for PushRtnlLinkStats64 {
20898    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20899        fmt.debug_struct("RtnlLinkStats64")
20900            .field("rx_packets", &self.rx_packets())
20901            .field("tx_packets", &self.tx_packets())
20902            .field("rx_bytes", &self.rx_bytes())
20903            .field("tx_bytes", &self.tx_bytes())
20904            .field("rx_errors", &self.rx_errors())
20905            .field("tx_errors", &self.tx_errors())
20906            .field("rx_dropped", &self.rx_dropped())
20907            .field("tx_dropped", &self.tx_dropped())
20908            .field("multicast", &self.multicast())
20909            .field("collisions", &self.collisions())
20910            .field("rx_length_errors", &self.rx_length_errors())
20911            .field("rx_over_errors", &self.rx_over_errors())
20912            .field("rx_crc_errors", &self.rx_crc_errors())
20913            .field("rx_frame_errors", &self.rx_frame_errors())
20914            .field("rx_fifo_errors", &self.rx_fifo_errors())
20915            .field("rx_missed_errors", &self.rx_missed_errors())
20916            .field("tx_aborted_errors", &self.tx_aborted_errors())
20917            .field("tx_carrier_errors", &self.tx_carrier_errors())
20918            .field("tx_fifo_errors", &self.tx_fifo_errors())
20919            .field("tx_heartbeat_errors", &self.tx_heartbeat_errors())
20920            .field("tx_window_errors", &self.tx_window_errors())
20921            .field("rx_compressed", &self.rx_compressed())
20922            .field("tx_compressed", &self.tx_compressed())
20923            .field("rx_nohandler", &self.rx_nohandler())
20924            .field("rx_otherhost_dropped", &self.rx_otherhost_dropped())
20925            .finish()
20926    }
20927}
20928#[derive(Clone)]
20929pub struct PushRtnlLinkIfmap {
20930    pub(crate) buf: [u8; 32usize],
20931}
20932#[doc = "Create zero-initialized struct"]
20933impl Default for PushRtnlLinkIfmap {
20934    fn default() -> Self {
20935        Self {
20936            buf: [0u8; 32usize],
20937        }
20938    }
20939}
20940impl PushRtnlLinkIfmap {
20941    #[doc = "Create zero-initialized struct"]
20942    pub fn new() -> Self {
20943        Default::default()
20944    }
20945    #[doc = "Copy from contents from other slice"]
20946    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
20947        if other.len() != Self::len() {
20948            return None;
20949        }
20950        let mut buf = [0u8; Self::len()];
20951        buf.clone_from_slice(other);
20952        Some(Self { buf })
20953    }
20954    pub fn as_slice(&self) -> &[u8] {
20955        &self.buf
20956    }
20957    pub fn as_mut_slice(&mut self) -> &mut [u8] {
20958        &mut self.buf
20959    }
20960    pub const fn len() -> usize {
20961        32usize
20962    }
20963    pub fn mem_start(&self) -> u64 {
20964        parse_u64(&self.buf[0usize..8usize]).unwrap()
20965    }
20966    pub fn set_mem_start(&mut self, value: u64) {
20967        self.buf[0usize..8usize].copy_from_slice(&value.to_ne_bytes())
20968    }
20969    pub fn mem_end(&self) -> u64 {
20970        parse_u64(&self.buf[8usize..16usize]).unwrap()
20971    }
20972    pub fn set_mem_end(&mut self, value: u64) {
20973        self.buf[8usize..16usize].copy_from_slice(&value.to_ne_bytes())
20974    }
20975    pub fn base_addr(&self) -> u64 {
20976        parse_u64(&self.buf[16usize..24usize]).unwrap()
20977    }
20978    pub fn set_base_addr(&mut self, value: u64) {
20979        self.buf[16usize..24usize].copy_from_slice(&value.to_ne_bytes())
20980    }
20981    pub fn irq(&self) -> u16 {
20982        parse_u16(&self.buf[24usize..26usize]).unwrap()
20983    }
20984    pub fn set_irq(&mut self, value: u16) {
20985        self.buf[24usize..26usize].copy_from_slice(&value.to_ne_bytes())
20986    }
20987    pub fn dma(&self) -> u8 {
20988        parse_u8(&self.buf[26usize..27usize]).unwrap()
20989    }
20990    pub fn set_dma(&mut self, value: u8) {
20991        self.buf[26usize..27usize].copy_from_slice(&value.to_ne_bytes())
20992    }
20993    pub fn port(&self) -> u8 {
20994        parse_u8(&self.buf[27usize..28usize]).unwrap()
20995    }
20996    pub fn set_port(&mut self, value: u8) {
20997        self.buf[27usize..28usize].copy_from_slice(&value.to_ne_bytes())
20998    }
20999}
21000impl std::fmt::Debug for PushRtnlLinkIfmap {
21001    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21002        fmt.debug_struct("RtnlLinkIfmap")
21003            .field("mem_start", &self.mem_start())
21004            .field("mem_end", &self.mem_end())
21005            .field("base_addr", &self.base_addr())
21006            .field("irq", &self.irq())
21007            .field("dma", &self.dma())
21008            .field("port", &self.port())
21009            .finish()
21010    }
21011}
21012#[derive(Clone)]
21013pub struct PushBrBooloptMulti {
21014    pub(crate) buf: [u8; 8usize],
21015}
21016#[doc = "Create zero-initialized struct"]
21017impl Default for PushBrBooloptMulti {
21018    fn default() -> Self {
21019        Self { buf: [0u8; 8usize] }
21020    }
21021}
21022impl PushBrBooloptMulti {
21023    #[doc = "Create zero-initialized struct"]
21024    pub fn new() -> Self {
21025        Default::default()
21026    }
21027    #[doc = "Copy from contents from other slice"]
21028    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21029        if other.len() != Self::len() {
21030            return None;
21031        }
21032        let mut buf = [0u8; Self::len()];
21033        buf.clone_from_slice(other);
21034        Some(Self { buf })
21035    }
21036    pub fn as_slice(&self) -> &[u8] {
21037        &self.buf
21038    }
21039    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21040        &mut self.buf
21041    }
21042    pub const fn len() -> usize {
21043        8usize
21044    }
21045    pub fn optval(&self) -> u32 {
21046        parse_u32(&self.buf[0usize..4usize]).unwrap()
21047    }
21048    pub fn set_optval(&mut self, value: u32) {
21049        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21050    }
21051    pub fn optmask(&self) -> u32 {
21052        parse_u32(&self.buf[4usize..8usize]).unwrap()
21053    }
21054    pub fn set_optmask(&mut self, value: u32) {
21055        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21056    }
21057}
21058impl std::fmt::Debug for PushBrBooloptMulti {
21059    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21060        fmt.debug_struct("BrBooloptMulti")
21061            .field("optval", &self.optval())
21062            .field("optmask", &self.optmask())
21063            .finish()
21064    }
21065}
21066#[derive(Clone)]
21067pub struct PushIfStatsMsg {
21068    pub(crate) buf: [u8; 12usize],
21069}
21070#[doc = "Create zero-initialized struct"]
21071impl Default for PushIfStatsMsg {
21072    fn default() -> Self {
21073        Self {
21074            buf: [0u8; 12usize],
21075        }
21076    }
21077}
21078impl PushIfStatsMsg {
21079    #[doc = "Create zero-initialized struct"]
21080    pub fn new() -> Self {
21081        Default::default()
21082    }
21083    #[doc = "Copy from contents from other slice"]
21084    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21085        if other.len() != Self::len() {
21086            return None;
21087        }
21088        let mut buf = [0u8; Self::len()];
21089        buf.clone_from_slice(other);
21090        Some(Self { buf })
21091    }
21092    pub fn as_slice(&self) -> &[u8] {
21093        &self.buf
21094    }
21095    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21096        &mut self.buf
21097    }
21098    pub const fn len() -> usize {
21099        12usize
21100    }
21101    pub fn family(&self) -> u8 {
21102        parse_u8(&self.buf[0usize..1usize]).unwrap()
21103    }
21104    pub fn set_family(&mut self, value: u8) {
21105        self.buf[0usize..1usize].copy_from_slice(&value.to_ne_bytes())
21106    }
21107    pub fn ifindex(&self) -> u32 {
21108        parse_u32(&self.buf[4usize..8usize]).unwrap()
21109    }
21110    pub fn set_ifindex(&mut self, value: u32) {
21111        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21112    }
21113    pub fn filter_mask(&self) -> u32 {
21114        parse_u32(&self.buf[8usize..12usize]).unwrap()
21115    }
21116    pub fn set_filter_mask(&mut self, value: u32) {
21117        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
21118    }
21119}
21120impl std::fmt::Debug for PushIfStatsMsg {
21121    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21122        fmt.debug_struct("IfStatsMsg")
21123            .field("family", &self.family())
21124            .field("ifindex", &self.ifindex())
21125            .field("filter_mask", &self.filter_mask())
21126            .finish()
21127    }
21128}
21129#[derive(Clone)]
21130pub struct PushIflaVlanFlags {
21131    pub(crate) buf: [u8; 8usize],
21132}
21133#[doc = "Create zero-initialized struct"]
21134impl Default for PushIflaVlanFlags {
21135    fn default() -> Self {
21136        Self { buf: [0u8; 8usize] }
21137    }
21138}
21139impl PushIflaVlanFlags {
21140    #[doc = "Create zero-initialized struct"]
21141    pub fn new() -> Self {
21142        Default::default()
21143    }
21144    #[doc = "Copy from contents from other slice"]
21145    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21146        if other.len() != Self::len() {
21147            return None;
21148        }
21149        let mut buf = [0u8; Self::len()];
21150        buf.clone_from_slice(other);
21151        Some(Self { buf })
21152    }
21153    pub fn as_slice(&self) -> &[u8] {
21154        &self.buf
21155    }
21156    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21157        &mut self.buf
21158    }
21159    pub const fn len() -> usize {
21160        8usize
21161    }
21162    #[doc = "Associated type: \"VlanFlags\" (1 bit per enumeration)"]
21163    pub fn flags(&self) -> u32 {
21164        parse_u32(&self.buf[0usize..4usize]).unwrap()
21165    }
21166    #[doc = "Associated type: \"VlanFlags\" (1 bit per enumeration)"]
21167    pub fn set_flags(&mut self, value: u32) {
21168        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21169    }
21170    pub fn mask(&self) -> u32 {
21171        parse_u32(&self.buf[4usize..8usize]).unwrap()
21172    }
21173    pub fn set_mask(&mut self, value: u32) {
21174        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21175    }
21176}
21177impl std::fmt::Debug for PushIflaVlanFlags {
21178    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21179        fmt.debug_struct("IflaVlanFlags")
21180            .field("flags", &self.flags())
21181            .field("mask", &self.mask())
21182            .finish()
21183    }
21184}
21185#[derive(Clone)]
21186pub struct PushIflaVlanQosMapping {
21187    pub(crate) buf: [u8; 8usize],
21188}
21189#[doc = "Create zero-initialized struct"]
21190impl Default for PushIflaVlanQosMapping {
21191    fn default() -> Self {
21192        Self { buf: [0u8; 8usize] }
21193    }
21194}
21195impl PushIflaVlanQosMapping {
21196    #[doc = "Create zero-initialized struct"]
21197    pub fn new() -> Self {
21198        Default::default()
21199    }
21200    #[doc = "Copy from contents from other slice"]
21201    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21202        if other.len() != Self::len() {
21203            return None;
21204        }
21205        let mut buf = [0u8; Self::len()];
21206        buf.clone_from_slice(other);
21207        Some(Self { buf })
21208    }
21209    pub fn as_slice(&self) -> &[u8] {
21210        &self.buf
21211    }
21212    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21213        &mut self.buf
21214    }
21215    pub const fn len() -> usize {
21216        8usize
21217    }
21218    pub fn from(&self) -> u32 {
21219        parse_u32(&self.buf[0usize..4usize]).unwrap()
21220    }
21221    pub fn set_from(&mut self, value: u32) {
21222        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21223    }
21224    pub fn to(&self) -> u32 {
21225        parse_u32(&self.buf[4usize..8usize]).unwrap()
21226    }
21227    pub fn set_to(&mut self, value: u32) {
21228        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21229    }
21230}
21231impl std::fmt::Debug for PushIflaVlanQosMapping {
21232    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21233        fmt.debug_struct("IflaVlanQosMapping")
21234            .field("from", &self.from())
21235            .field("to", &self.to())
21236            .finish()
21237    }
21238}
21239#[derive(Clone)]
21240pub struct PushIflaGenevePortRange {
21241    pub(crate) buf: [u8; 4usize],
21242}
21243#[doc = "Create zero-initialized struct"]
21244impl Default for PushIflaGenevePortRange {
21245    fn default() -> Self {
21246        Self { buf: [0u8; 4usize] }
21247    }
21248}
21249impl PushIflaGenevePortRange {
21250    #[doc = "Create zero-initialized struct"]
21251    pub fn new() -> Self {
21252        Default::default()
21253    }
21254    #[doc = "Copy from contents from other slice"]
21255    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21256        if other.len() != Self::len() {
21257            return None;
21258        }
21259        let mut buf = [0u8; Self::len()];
21260        buf.clone_from_slice(other);
21261        Some(Self { buf })
21262    }
21263    pub fn as_slice(&self) -> &[u8] {
21264        &self.buf
21265    }
21266    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21267        &mut self.buf
21268    }
21269    pub const fn len() -> usize {
21270        4usize
21271    }
21272    pub fn low(&self) -> u16 {
21273        parse_be_u16(&self.buf[0usize..2usize]).unwrap()
21274    }
21275    pub fn set_low(&mut self, value: u16) {
21276        self.buf[0usize..2usize].copy_from_slice(&value.to_be_bytes())
21277    }
21278    pub fn high(&self) -> u16 {
21279        parse_be_u16(&self.buf[2usize..4usize]).unwrap()
21280    }
21281    pub fn set_high(&mut self, value: u16) {
21282        self.buf[2usize..4usize].copy_from_slice(&value.to_be_bytes())
21283    }
21284}
21285impl std::fmt::Debug for PushIflaGenevePortRange {
21286    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21287        fmt.debug_struct("IflaGenevePortRange")
21288            .field("low", &self.low())
21289            .field("high", &self.high())
21290            .finish()
21291    }
21292}
21293#[derive(Clone)]
21294pub struct PushIflaVfMac {
21295    pub(crate) buf: [u8; 4usize],
21296}
21297#[doc = "Create zero-initialized struct"]
21298impl Default for PushIflaVfMac {
21299    fn default() -> Self {
21300        Self { buf: [0u8; 4usize] }
21301    }
21302}
21303impl PushIflaVfMac {
21304    #[doc = "Create zero-initialized struct"]
21305    pub fn new() -> Self {
21306        Default::default()
21307    }
21308    #[doc = "Copy from contents from other slice"]
21309    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21310        if other.len() != Self::len() {
21311            return None;
21312        }
21313        let mut buf = [0u8; Self::len()];
21314        buf.clone_from_slice(other);
21315        Some(Self { buf })
21316    }
21317    pub fn as_slice(&self) -> &[u8] {
21318        &self.buf
21319    }
21320    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21321        &mut self.buf
21322    }
21323    pub const fn len() -> usize {
21324        4usize
21325    }
21326    pub fn vf(&self) -> u32 {
21327        parse_u32(&self.buf[0usize..4usize]).unwrap()
21328    }
21329    pub fn set_vf(&mut self, value: u32) {
21330        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21331    }
21332    pub fn mac(&self) -> [u8; 32usize] {
21333        self.buf[4usize..36usize].try_into().unwrap()
21334    }
21335    pub fn set_mac(&mut self, value: [u8; 32usize]) {
21336        self.buf[4usize..36usize].copy_from_slice(&value)
21337    }
21338}
21339impl std::fmt::Debug for PushIflaVfMac {
21340    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21341        fmt.debug_struct("IflaVfMac")
21342            .field("vf", &self.vf())
21343            .field("mac", &self.mac())
21344            .finish()
21345    }
21346}
21347#[derive(Clone)]
21348pub struct PushIflaVfVlan {
21349    pub(crate) buf: [u8; 12usize],
21350}
21351#[doc = "Create zero-initialized struct"]
21352impl Default for PushIflaVfVlan {
21353    fn default() -> Self {
21354        Self {
21355            buf: [0u8; 12usize],
21356        }
21357    }
21358}
21359impl PushIflaVfVlan {
21360    #[doc = "Create zero-initialized struct"]
21361    pub fn new() -> Self {
21362        Default::default()
21363    }
21364    #[doc = "Copy from contents from other slice"]
21365    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21366        if other.len() != Self::len() {
21367            return None;
21368        }
21369        let mut buf = [0u8; Self::len()];
21370        buf.clone_from_slice(other);
21371        Some(Self { buf })
21372    }
21373    pub fn as_slice(&self) -> &[u8] {
21374        &self.buf
21375    }
21376    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21377        &mut self.buf
21378    }
21379    pub const fn len() -> usize {
21380        12usize
21381    }
21382    pub fn vf(&self) -> u32 {
21383        parse_u32(&self.buf[0usize..4usize]).unwrap()
21384    }
21385    pub fn set_vf(&mut self, value: u32) {
21386        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21387    }
21388    pub fn vlan(&self) -> u32 {
21389        parse_u32(&self.buf[4usize..8usize]).unwrap()
21390    }
21391    pub fn set_vlan(&mut self, value: u32) {
21392        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21393    }
21394    pub fn qos(&self) -> u32 {
21395        parse_u32(&self.buf[8usize..12usize]).unwrap()
21396    }
21397    pub fn set_qos(&mut self, value: u32) {
21398        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
21399    }
21400}
21401impl std::fmt::Debug for PushIflaVfVlan {
21402    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21403        fmt.debug_struct("IflaVfVlan")
21404            .field("vf", &self.vf())
21405            .field("vlan", &self.vlan())
21406            .field("qos", &self.qos())
21407            .finish()
21408    }
21409}
21410#[derive(Clone)]
21411pub struct PushIflaVfTxRate {
21412    pub(crate) buf: [u8; 8usize],
21413}
21414#[doc = "Create zero-initialized struct"]
21415impl Default for PushIflaVfTxRate {
21416    fn default() -> Self {
21417        Self { buf: [0u8; 8usize] }
21418    }
21419}
21420impl PushIflaVfTxRate {
21421    #[doc = "Create zero-initialized struct"]
21422    pub fn new() -> Self {
21423        Default::default()
21424    }
21425    #[doc = "Copy from contents from other slice"]
21426    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21427        if other.len() != Self::len() {
21428            return None;
21429        }
21430        let mut buf = [0u8; Self::len()];
21431        buf.clone_from_slice(other);
21432        Some(Self { buf })
21433    }
21434    pub fn as_slice(&self) -> &[u8] {
21435        &self.buf
21436    }
21437    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21438        &mut self.buf
21439    }
21440    pub const fn len() -> usize {
21441        8usize
21442    }
21443    pub fn vf(&self) -> u32 {
21444        parse_u32(&self.buf[0usize..4usize]).unwrap()
21445    }
21446    pub fn set_vf(&mut self, value: u32) {
21447        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21448    }
21449    pub fn rate(&self) -> u32 {
21450        parse_u32(&self.buf[4usize..8usize]).unwrap()
21451    }
21452    pub fn set_rate(&mut self, value: u32) {
21453        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21454    }
21455}
21456impl std::fmt::Debug for PushIflaVfTxRate {
21457    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21458        fmt.debug_struct("IflaVfTxRate")
21459            .field("vf", &self.vf())
21460            .field("rate", &self.rate())
21461            .finish()
21462    }
21463}
21464#[derive(Clone)]
21465pub struct PushIflaVfSpoofchk {
21466    pub(crate) buf: [u8; 8usize],
21467}
21468#[doc = "Create zero-initialized struct"]
21469impl Default for PushIflaVfSpoofchk {
21470    fn default() -> Self {
21471        Self { buf: [0u8; 8usize] }
21472    }
21473}
21474impl PushIflaVfSpoofchk {
21475    #[doc = "Create zero-initialized struct"]
21476    pub fn new() -> Self {
21477        Default::default()
21478    }
21479    #[doc = "Copy from contents from other slice"]
21480    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21481        if other.len() != Self::len() {
21482            return None;
21483        }
21484        let mut buf = [0u8; Self::len()];
21485        buf.clone_from_slice(other);
21486        Some(Self { buf })
21487    }
21488    pub fn as_slice(&self) -> &[u8] {
21489        &self.buf
21490    }
21491    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21492        &mut self.buf
21493    }
21494    pub const fn len() -> usize {
21495        8usize
21496    }
21497    pub fn vf(&self) -> u32 {
21498        parse_u32(&self.buf[0usize..4usize]).unwrap()
21499    }
21500    pub fn set_vf(&mut self, value: u32) {
21501        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21502    }
21503    pub fn setting(&self) -> u32 {
21504        parse_u32(&self.buf[4usize..8usize]).unwrap()
21505    }
21506    pub fn set_setting(&mut self, value: u32) {
21507        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21508    }
21509}
21510impl std::fmt::Debug for PushIflaVfSpoofchk {
21511    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21512        fmt.debug_struct("IflaVfSpoofchk")
21513            .field("vf", &self.vf())
21514            .field("setting", &self.setting())
21515            .finish()
21516    }
21517}
21518#[derive(Clone)]
21519pub struct PushIflaVfLinkState {
21520    pub(crate) buf: [u8; 8usize],
21521}
21522#[doc = "Create zero-initialized struct"]
21523impl Default for PushIflaVfLinkState {
21524    fn default() -> Self {
21525        Self { buf: [0u8; 8usize] }
21526    }
21527}
21528impl PushIflaVfLinkState {
21529    #[doc = "Create zero-initialized struct"]
21530    pub fn new() -> Self {
21531        Default::default()
21532    }
21533    #[doc = "Copy from contents from other slice"]
21534    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21535        if other.len() != Self::len() {
21536            return None;
21537        }
21538        let mut buf = [0u8; Self::len()];
21539        buf.clone_from_slice(other);
21540        Some(Self { buf })
21541    }
21542    pub fn as_slice(&self) -> &[u8] {
21543        &self.buf
21544    }
21545    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21546        &mut self.buf
21547    }
21548    pub const fn len() -> usize {
21549        8usize
21550    }
21551    pub fn vf(&self) -> u32 {
21552        parse_u32(&self.buf[0usize..4usize]).unwrap()
21553    }
21554    pub fn set_vf(&mut self, value: u32) {
21555        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21556    }
21557    #[doc = "Associated type: \"IflaVfLinkStateEnum\" (enum)"]
21558    pub fn link_state(&self) -> u32 {
21559        parse_u32(&self.buf[4usize..8usize]).unwrap()
21560    }
21561    #[doc = "Associated type: \"IflaVfLinkStateEnum\" (enum)"]
21562    pub fn set_link_state(&mut self, value: u32) {
21563        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21564    }
21565}
21566impl std::fmt::Debug for PushIflaVfLinkState {
21567    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21568        fmt.debug_struct("IflaVfLinkState")
21569            .field("vf", &self.vf())
21570            .field("link_state", &self.link_state())
21571            .finish()
21572    }
21573}
21574#[derive(Clone)]
21575pub struct PushIflaVfRate {
21576    pub(crate) buf: [u8; 12usize],
21577}
21578#[doc = "Create zero-initialized struct"]
21579impl Default for PushIflaVfRate {
21580    fn default() -> Self {
21581        Self {
21582            buf: [0u8; 12usize],
21583        }
21584    }
21585}
21586impl PushIflaVfRate {
21587    #[doc = "Create zero-initialized struct"]
21588    pub fn new() -> Self {
21589        Default::default()
21590    }
21591    #[doc = "Copy from contents from other slice"]
21592    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21593        if other.len() != Self::len() {
21594            return None;
21595        }
21596        let mut buf = [0u8; Self::len()];
21597        buf.clone_from_slice(other);
21598        Some(Self { buf })
21599    }
21600    pub fn as_slice(&self) -> &[u8] {
21601        &self.buf
21602    }
21603    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21604        &mut self.buf
21605    }
21606    pub const fn len() -> usize {
21607        12usize
21608    }
21609    pub fn vf(&self) -> u32 {
21610        parse_u32(&self.buf[0usize..4usize]).unwrap()
21611    }
21612    pub fn set_vf(&mut self, value: u32) {
21613        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21614    }
21615    pub fn min_tx_rate(&self) -> u32 {
21616        parse_u32(&self.buf[4usize..8usize]).unwrap()
21617    }
21618    pub fn set_min_tx_rate(&mut self, value: u32) {
21619        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21620    }
21621    pub fn max_tx_rate(&self) -> u32 {
21622        parse_u32(&self.buf[8usize..12usize]).unwrap()
21623    }
21624    pub fn set_max_tx_rate(&mut self, value: u32) {
21625        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
21626    }
21627}
21628impl std::fmt::Debug for PushIflaVfRate {
21629    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21630        fmt.debug_struct("IflaVfRate")
21631            .field("vf", &self.vf())
21632            .field("min_tx_rate", &self.min_tx_rate())
21633            .field("max_tx_rate", &self.max_tx_rate())
21634            .finish()
21635    }
21636}
21637#[derive(Clone)]
21638pub struct PushIflaVfRssQueryEn {
21639    pub(crate) buf: [u8; 8usize],
21640}
21641#[doc = "Create zero-initialized struct"]
21642impl Default for PushIflaVfRssQueryEn {
21643    fn default() -> Self {
21644        Self { buf: [0u8; 8usize] }
21645    }
21646}
21647impl PushIflaVfRssQueryEn {
21648    #[doc = "Create zero-initialized struct"]
21649    pub fn new() -> Self {
21650        Default::default()
21651    }
21652    #[doc = "Copy from contents from other slice"]
21653    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21654        if other.len() != Self::len() {
21655            return None;
21656        }
21657        let mut buf = [0u8; Self::len()];
21658        buf.clone_from_slice(other);
21659        Some(Self { buf })
21660    }
21661    pub fn as_slice(&self) -> &[u8] {
21662        &self.buf
21663    }
21664    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21665        &mut self.buf
21666    }
21667    pub const fn len() -> usize {
21668        8usize
21669    }
21670    pub fn vf(&self) -> u32 {
21671        parse_u32(&self.buf[0usize..4usize]).unwrap()
21672    }
21673    pub fn set_vf(&mut self, value: u32) {
21674        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21675    }
21676    pub fn setting(&self) -> u32 {
21677        parse_u32(&self.buf[4usize..8usize]).unwrap()
21678    }
21679    pub fn set_setting(&mut self, value: u32) {
21680        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21681    }
21682}
21683impl std::fmt::Debug for PushIflaVfRssQueryEn {
21684    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21685        fmt.debug_struct("IflaVfRssQueryEn")
21686            .field("vf", &self.vf())
21687            .field("setting", &self.setting())
21688            .finish()
21689    }
21690}
21691#[derive(Clone)]
21692pub struct PushIflaVfTrust {
21693    pub(crate) buf: [u8; 8usize],
21694}
21695#[doc = "Create zero-initialized struct"]
21696impl Default for PushIflaVfTrust {
21697    fn default() -> Self {
21698        Self { buf: [0u8; 8usize] }
21699    }
21700}
21701impl PushIflaVfTrust {
21702    #[doc = "Create zero-initialized struct"]
21703    pub fn new() -> Self {
21704        Default::default()
21705    }
21706    #[doc = "Copy from contents from other slice"]
21707    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21708        if other.len() != Self::len() {
21709            return None;
21710        }
21711        let mut buf = [0u8; Self::len()];
21712        buf.clone_from_slice(other);
21713        Some(Self { buf })
21714    }
21715    pub fn as_slice(&self) -> &[u8] {
21716        &self.buf
21717    }
21718    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21719        &mut self.buf
21720    }
21721    pub const fn len() -> usize {
21722        8usize
21723    }
21724    pub fn vf(&self) -> u32 {
21725        parse_u32(&self.buf[0usize..4usize]).unwrap()
21726    }
21727    pub fn set_vf(&mut self, value: u32) {
21728        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21729    }
21730    pub fn setting(&self) -> u32 {
21731        parse_u32(&self.buf[4usize..8usize]).unwrap()
21732    }
21733    pub fn set_setting(&mut self, value: u32) {
21734        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21735    }
21736}
21737impl std::fmt::Debug for PushIflaVfTrust {
21738    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21739        fmt.debug_struct("IflaVfTrust")
21740            .field("vf", &self.vf())
21741            .field("setting", &self.setting())
21742            .finish()
21743    }
21744}
21745#[derive(Clone)]
21746pub struct PushIflaVfGuid {
21747    pub(crate) buf: [u8; 16usize],
21748}
21749#[doc = "Create zero-initialized struct"]
21750impl Default for PushIflaVfGuid {
21751    fn default() -> Self {
21752        Self {
21753            buf: [0u8; 16usize],
21754        }
21755    }
21756}
21757impl PushIflaVfGuid {
21758    #[doc = "Create zero-initialized struct"]
21759    pub fn new() -> Self {
21760        Default::default()
21761    }
21762    #[doc = "Copy from contents from other slice"]
21763    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21764        if other.len() != Self::len() {
21765            return None;
21766        }
21767        let mut buf = [0u8; Self::len()];
21768        buf.clone_from_slice(other);
21769        Some(Self { buf })
21770    }
21771    pub fn as_slice(&self) -> &[u8] {
21772        &self.buf
21773    }
21774    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21775        &mut self.buf
21776    }
21777    pub const fn len() -> usize {
21778        16usize
21779    }
21780    pub fn vf(&self) -> u32 {
21781        parse_u32(&self.buf[0usize..4usize]).unwrap()
21782    }
21783    pub fn set_vf(&mut self, value: u32) {
21784        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21785    }
21786    pub fn guid(&self) -> u64 {
21787        parse_u64(&self.buf[8usize..16usize]).unwrap()
21788    }
21789    pub fn set_guid(&mut self, value: u64) {
21790        self.buf[8usize..16usize].copy_from_slice(&value.to_ne_bytes())
21791    }
21792}
21793impl std::fmt::Debug for PushIflaVfGuid {
21794    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21795        fmt.debug_struct("IflaVfGuid")
21796            .field("vf", &self.vf())
21797            .field("guid", &self.guid())
21798            .finish()
21799    }
21800}
21801#[derive(Clone)]
21802pub struct PushIflaVfVlanInfo {
21803    pub(crate) buf: [u8; 16usize],
21804}
21805#[doc = "Create zero-initialized struct"]
21806impl Default for PushIflaVfVlanInfo {
21807    fn default() -> Self {
21808        Self {
21809            buf: [0u8; 16usize],
21810        }
21811    }
21812}
21813impl PushIflaVfVlanInfo {
21814    #[doc = "Create zero-initialized struct"]
21815    pub fn new() -> Self {
21816        Default::default()
21817    }
21818    #[doc = "Copy from contents from other slice"]
21819    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
21820        if other.len() != Self::len() {
21821            return None;
21822        }
21823        let mut buf = [0u8; Self::len()];
21824        buf.clone_from_slice(other);
21825        Some(Self { buf })
21826    }
21827    pub fn as_slice(&self) -> &[u8] {
21828        &self.buf
21829    }
21830    pub fn as_mut_slice(&mut self) -> &mut [u8] {
21831        &mut self.buf
21832    }
21833    pub const fn len() -> usize {
21834        16usize
21835    }
21836    pub fn vf(&self) -> u32 {
21837        parse_u32(&self.buf[0usize..4usize]).unwrap()
21838    }
21839    pub fn set_vf(&mut self, value: u32) {
21840        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
21841    }
21842    pub fn vlan(&self) -> u32 {
21843        parse_u32(&self.buf[4usize..8usize]).unwrap()
21844    }
21845    pub fn set_vlan(&mut self, value: u32) {
21846        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
21847    }
21848    pub fn qos(&self) -> u32 {
21849        parse_u32(&self.buf[8usize..12usize]).unwrap()
21850    }
21851    pub fn set_qos(&mut self, value: u32) {
21852        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
21853    }
21854    pub fn vlan_proto(&self) -> u32 {
21855        parse_u32(&self.buf[12usize..16usize]).unwrap()
21856    }
21857    pub fn set_vlan_proto(&mut self, value: u32) {
21858        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
21859    }
21860}
21861impl std::fmt::Debug for PushIflaVfVlanInfo {
21862    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21863        fmt.debug_struct("IflaVfVlanInfo")
21864            .field("vf", &self.vf())
21865            .field("vlan", &self.vlan())
21866            .field("qos", &self.qos())
21867            .field("vlan_proto", &self.vlan_proto())
21868            .finish()
21869    }
21870}
21871#[doc = "Create a new link."]
21872pub struct PushOpNewlinkDoRequest<Prev: Rec> {
21873    pub(crate) prev: Option<Prev>,
21874    pub(crate) header_offset: Option<usize>,
21875}
21876impl<Prev: Rec> Rec for PushOpNewlinkDoRequest<Prev> {
21877    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
21878        self.prev.as_mut().unwrap().as_rec_mut()
21879    }
21880}
21881impl<Prev: Rec> PushOpNewlinkDoRequest<Prev> {
21882    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
21883        Self::write_header(&mut prev, header);
21884        Self::new_without_header(prev)
21885    }
21886    fn new_without_header(prev: Prev) -> Self {
21887        Self {
21888            prev: Some(prev),
21889            header_offset: None,
21890        }
21891    }
21892    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
21893        prev.as_rec_mut().extend(header.as_slice());
21894    }
21895    pub fn end_nested(mut self) -> Prev {
21896        let mut prev = self.prev.take().unwrap();
21897        if let Some(header_offset) = &self.header_offset {
21898            finalize_nested_header(prev.as_rec_mut(), *header_offset);
21899        }
21900        prev
21901    }
21902    pub fn push_address(mut self, value: &[u8]) -> Self {
21903        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
21904        self.as_rec_mut().extend(value);
21905        self
21906    }
21907    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
21908        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
21909        self.as_rec_mut().extend(value);
21910        self
21911    }
21912    pub fn push_ifname(mut self, value: &CStr) -> Self {
21913        push_header(
21914            self.as_rec_mut(),
21915            3u16,
21916            value.to_bytes_with_nul().len() as u16,
21917        );
21918        self.as_rec_mut().extend(value.to_bytes_with_nul());
21919        self
21920    }
21921    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
21922        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
21923        self.as_rec_mut().extend(value);
21924        self.as_rec_mut().push(0);
21925        self
21926    }
21927    pub fn push_mtu(mut self, value: u32) -> Self {
21928        push_header(self.as_rec_mut(), 4u16, 4 as u16);
21929        self.as_rec_mut().extend(value.to_ne_bytes());
21930        self
21931    }
21932    pub fn push_txqlen(mut self, value: u32) -> Self {
21933        push_header(self.as_rec_mut(), 13u16, 4 as u16);
21934        self.as_rec_mut().extend(value.to_ne_bytes());
21935        self
21936    }
21937    pub fn push_operstate(mut self, value: u8) -> Self {
21938        push_header(self.as_rec_mut(), 16u16, 1 as u16);
21939        self.as_rec_mut().extend(value.to_ne_bytes());
21940        self
21941    }
21942    pub fn push_linkmode(mut self, value: u8) -> Self {
21943        push_header(self.as_rec_mut(), 17u16, 1 as u16);
21944        self.as_rec_mut().extend(value.to_ne_bytes());
21945        self
21946    }
21947    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
21948        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
21949        PushLinkinfoAttrs {
21950            prev: Some(self),
21951            header_offset: Some(header_offset),
21952        }
21953    }
21954    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
21955        push_header(self.as_rec_mut(), 19u16, 4 as u16);
21956        self.as_rec_mut().extend(value.to_ne_bytes());
21957        self
21958    }
21959    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
21960        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
21961        PushAfSpecAttrs {
21962            prev: Some(self),
21963            header_offset: Some(header_offset),
21964        }
21965    }
21966    pub fn push_group(mut self, value: u32) -> Self {
21967        push_header(self.as_rec_mut(), 27u16, 4 as u16);
21968        self.as_rec_mut().extend(value.to_ne_bytes());
21969        self
21970    }
21971    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
21972        push_header(self.as_rec_mut(), 28u16, 4 as u16);
21973        self.as_rec_mut().extend(value.to_ne_bytes());
21974        self
21975    }
21976    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
21977        push_header(self.as_rec_mut(), 31u16, 4 as u16);
21978        self.as_rec_mut().extend(value.to_ne_bytes());
21979        self
21980    }
21981    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
21982        push_header(self.as_rec_mut(), 32u16, 4 as u16);
21983        self.as_rec_mut().extend(value.to_ne_bytes());
21984        self
21985    }
21986    pub fn push_link_netnsid(mut self, value: i32) -> Self {
21987        push_header(self.as_rec_mut(), 37u16, 4 as u16);
21988        self.as_rec_mut().extend(value.to_ne_bytes());
21989        self
21990    }
21991    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
21992        push_header(self.as_rec_mut(), 40u16, 4 as u16);
21993        self.as_rec_mut().extend(value.to_ne_bytes());
21994        self
21995    }
21996    pub fn push_gso_max_size(mut self, value: u32) -> Self {
21997        push_header(self.as_rec_mut(), 41u16, 4 as u16);
21998        self.as_rec_mut().extend(value.to_ne_bytes());
21999        self
22000    }
22001    pub fn push_target_netnsid(mut self, value: i32) -> Self {
22002        push_header(self.as_rec_mut(), 46u16, 4 as u16);
22003        self.as_rec_mut().extend(value.to_ne_bytes());
22004        self
22005    }
22006    pub fn push_gro_max_size(mut self, value: u32) -> Self {
22007        push_header(self.as_rec_mut(), 58u16, 4 as u16);
22008        self.as_rec_mut().extend(value.to_ne_bytes());
22009        self
22010    }
22011    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
22012        push_header(self.as_rec_mut(), 63u16, 4 as u16);
22013        self.as_rec_mut().extend(value.to_ne_bytes());
22014        self
22015    }
22016    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
22017        push_header(self.as_rec_mut(), 64u16, 4 as u16);
22018        self.as_rec_mut().extend(value.to_ne_bytes());
22019        self
22020    }
22021}
22022impl<Prev: Rec> Drop for PushOpNewlinkDoRequest<Prev> {
22023    fn drop(&mut self) {
22024        if let Some(prev) = &mut self.prev {
22025            if let Some(header_offset) = &self.header_offset {
22026                finalize_nested_header(prev.as_rec_mut(), *header_offset);
22027            }
22028        }
22029    }
22030}
22031#[doc = "Create a new link."]
22032#[derive(Clone)]
22033pub enum OpNewlinkDoRequest<'a> {
22034    Address(&'a [u8]),
22035    Broadcast(&'a [u8]),
22036    Ifname(&'a CStr),
22037    Mtu(u32),
22038    Txqlen(u32),
22039    Operstate(u8),
22040    Linkmode(u8),
22041    Linkinfo(IterableLinkinfoAttrs<'a>),
22042    NetNsPid(u32),
22043    AfSpec(IterableAfSpecAttrs<'a>),
22044    Group(u32),
22045    NetNsFd(u32),
22046    NumTxQueues(u32),
22047    NumRxQueues(u32),
22048    LinkNetnsid(i32),
22049    GsoMaxSegs(u32),
22050    GsoMaxSize(u32),
22051    TargetNetnsid(i32),
22052    GroMaxSize(u32),
22053    GsoIpv4MaxSize(u32),
22054    GroIpv4MaxSize(u32),
22055}
22056impl<'a> IterableOpNewlinkDoRequest<'a> {
22057    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
22058        let mut iter = self.clone();
22059        iter.pos = 0;
22060        for attr in iter {
22061            if let OpNewlinkDoRequest::Address(val) = attr? {
22062                return Ok(val);
22063            }
22064        }
22065        Err(ErrorContext::new_missing(
22066            "OpNewlinkDoRequest",
22067            "Address",
22068            self.orig_loc,
22069            self.buf.as_ptr() as usize,
22070        ))
22071    }
22072    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
22073        let mut iter = self.clone();
22074        iter.pos = 0;
22075        for attr in iter {
22076            if let OpNewlinkDoRequest::Broadcast(val) = attr? {
22077                return Ok(val);
22078            }
22079        }
22080        Err(ErrorContext::new_missing(
22081            "OpNewlinkDoRequest",
22082            "Broadcast",
22083            self.orig_loc,
22084            self.buf.as_ptr() as usize,
22085        ))
22086    }
22087    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
22088        let mut iter = self.clone();
22089        iter.pos = 0;
22090        for attr in iter {
22091            if let OpNewlinkDoRequest::Ifname(val) = attr? {
22092                return Ok(val);
22093            }
22094        }
22095        Err(ErrorContext::new_missing(
22096            "OpNewlinkDoRequest",
22097            "Ifname",
22098            self.orig_loc,
22099            self.buf.as_ptr() as usize,
22100        ))
22101    }
22102    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
22103        let mut iter = self.clone();
22104        iter.pos = 0;
22105        for attr in iter {
22106            if let OpNewlinkDoRequest::Mtu(val) = attr? {
22107                return Ok(val);
22108            }
22109        }
22110        Err(ErrorContext::new_missing(
22111            "OpNewlinkDoRequest",
22112            "Mtu",
22113            self.orig_loc,
22114            self.buf.as_ptr() as usize,
22115        ))
22116    }
22117    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
22118        let mut iter = self.clone();
22119        iter.pos = 0;
22120        for attr in iter {
22121            if let OpNewlinkDoRequest::Txqlen(val) = attr? {
22122                return Ok(val);
22123            }
22124        }
22125        Err(ErrorContext::new_missing(
22126            "OpNewlinkDoRequest",
22127            "Txqlen",
22128            self.orig_loc,
22129            self.buf.as_ptr() as usize,
22130        ))
22131    }
22132    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
22133        let mut iter = self.clone();
22134        iter.pos = 0;
22135        for attr in iter {
22136            if let OpNewlinkDoRequest::Operstate(val) = attr? {
22137                return Ok(val);
22138            }
22139        }
22140        Err(ErrorContext::new_missing(
22141            "OpNewlinkDoRequest",
22142            "Operstate",
22143            self.orig_loc,
22144            self.buf.as_ptr() as usize,
22145        ))
22146    }
22147    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
22148        let mut iter = self.clone();
22149        iter.pos = 0;
22150        for attr in iter {
22151            if let OpNewlinkDoRequest::Linkmode(val) = attr? {
22152                return Ok(val);
22153            }
22154        }
22155        Err(ErrorContext::new_missing(
22156            "OpNewlinkDoRequest",
22157            "Linkmode",
22158            self.orig_loc,
22159            self.buf.as_ptr() as usize,
22160        ))
22161    }
22162    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
22163        let mut iter = self.clone();
22164        iter.pos = 0;
22165        for attr in iter {
22166            if let OpNewlinkDoRequest::Linkinfo(val) = attr? {
22167                return Ok(val);
22168            }
22169        }
22170        Err(ErrorContext::new_missing(
22171            "OpNewlinkDoRequest",
22172            "Linkinfo",
22173            self.orig_loc,
22174            self.buf.as_ptr() as usize,
22175        ))
22176    }
22177    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
22178        let mut iter = self.clone();
22179        iter.pos = 0;
22180        for attr in iter {
22181            if let OpNewlinkDoRequest::NetNsPid(val) = attr? {
22182                return Ok(val);
22183            }
22184        }
22185        Err(ErrorContext::new_missing(
22186            "OpNewlinkDoRequest",
22187            "NetNsPid",
22188            self.orig_loc,
22189            self.buf.as_ptr() as usize,
22190        ))
22191    }
22192    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
22193        let mut iter = self.clone();
22194        iter.pos = 0;
22195        for attr in iter {
22196            if let OpNewlinkDoRequest::AfSpec(val) = attr? {
22197                return Ok(val);
22198            }
22199        }
22200        Err(ErrorContext::new_missing(
22201            "OpNewlinkDoRequest",
22202            "AfSpec",
22203            self.orig_loc,
22204            self.buf.as_ptr() as usize,
22205        ))
22206    }
22207    pub fn get_group(&self) -> Result<u32, ErrorContext> {
22208        let mut iter = self.clone();
22209        iter.pos = 0;
22210        for attr in iter {
22211            if let OpNewlinkDoRequest::Group(val) = attr? {
22212                return Ok(val);
22213            }
22214        }
22215        Err(ErrorContext::new_missing(
22216            "OpNewlinkDoRequest",
22217            "Group",
22218            self.orig_loc,
22219            self.buf.as_ptr() as usize,
22220        ))
22221    }
22222    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
22223        let mut iter = self.clone();
22224        iter.pos = 0;
22225        for attr in iter {
22226            if let OpNewlinkDoRequest::NetNsFd(val) = attr? {
22227                return Ok(val);
22228            }
22229        }
22230        Err(ErrorContext::new_missing(
22231            "OpNewlinkDoRequest",
22232            "NetNsFd",
22233            self.orig_loc,
22234            self.buf.as_ptr() as usize,
22235        ))
22236    }
22237    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
22238        let mut iter = self.clone();
22239        iter.pos = 0;
22240        for attr in iter {
22241            if let OpNewlinkDoRequest::NumTxQueues(val) = attr? {
22242                return Ok(val);
22243            }
22244        }
22245        Err(ErrorContext::new_missing(
22246            "OpNewlinkDoRequest",
22247            "NumTxQueues",
22248            self.orig_loc,
22249            self.buf.as_ptr() as usize,
22250        ))
22251    }
22252    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
22253        let mut iter = self.clone();
22254        iter.pos = 0;
22255        for attr in iter {
22256            if let OpNewlinkDoRequest::NumRxQueues(val) = attr? {
22257                return Ok(val);
22258            }
22259        }
22260        Err(ErrorContext::new_missing(
22261            "OpNewlinkDoRequest",
22262            "NumRxQueues",
22263            self.orig_loc,
22264            self.buf.as_ptr() as usize,
22265        ))
22266    }
22267    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
22268        let mut iter = self.clone();
22269        iter.pos = 0;
22270        for attr in iter {
22271            if let OpNewlinkDoRequest::LinkNetnsid(val) = attr? {
22272                return Ok(val);
22273            }
22274        }
22275        Err(ErrorContext::new_missing(
22276            "OpNewlinkDoRequest",
22277            "LinkNetnsid",
22278            self.orig_loc,
22279            self.buf.as_ptr() as usize,
22280        ))
22281    }
22282    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
22283        let mut iter = self.clone();
22284        iter.pos = 0;
22285        for attr in iter {
22286            if let OpNewlinkDoRequest::GsoMaxSegs(val) = attr? {
22287                return Ok(val);
22288            }
22289        }
22290        Err(ErrorContext::new_missing(
22291            "OpNewlinkDoRequest",
22292            "GsoMaxSegs",
22293            self.orig_loc,
22294            self.buf.as_ptr() as usize,
22295        ))
22296    }
22297    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
22298        let mut iter = self.clone();
22299        iter.pos = 0;
22300        for attr in iter {
22301            if let OpNewlinkDoRequest::GsoMaxSize(val) = attr? {
22302                return Ok(val);
22303            }
22304        }
22305        Err(ErrorContext::new_missing(
22306            "OpNewlinkDoRequest",
22307            "GsoMaxSize",
22308            self.orig_loc,
22309            self.buf.as_ptr() as usize,
22310        ))
22311    }
22312    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
22313        let mut iter = self.clone();
22314        iter.pos = 0;
22315        for attr in iter {
22316            if let OpNewlinkDoRequest::TargetNetnsid(val) = attr? {
22317                return Ok(val);
22318            }
22319        }
22320        Err(ErrorContext::new_missing(
22321            "OpNewlinkDoRequest",
22322            "TargetNetnsid",
22323            self.orig_loc,
22324            self.buf.as_ptr() as usize,
22325        ))
22326    }
22327    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
22328        let mut iter = self.clone();
22329        iter.pos = 0;
22330        for attr in iter {
22331            if let OpNewlinkDoRequest::GroMaxSize(val) = attr? {
22332                return Ok(val);
22333            }
22334        }
22335        Err(ErrorContext::new_missing(
22336            "OpNewlinkDoRequest",
22337            "GroMaxSize",
22338            self.orig_loc,
22339            self.buf.as_ptr() as usize,
22340        ))
22341    }
22342    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
22343        let mut iter = self.clone();
22344        iter.pos = 0;
22345        for attr in iter {
22346            if let OpNewlinkDoRequest::GsoIpv4MaxSize(val) = attr? {
22347                return Ok(val);
22348            }
22349        }
22350        Err(ErrorContext::new_missing(
22351            "OpNewlinkDoRequest",
22352            "GsoIpv4MaxSize",
22353            self.orig_loc,
22354            self.buf.as_ptr() as usize,
22355        ))
22356    }
22357    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
22358        let mut iter = self.clone();
22359        iter.pos = 0;
22360        for attr in iter {
22361            if let OpNewlinkDoRequest::GroIpv4MaxSize(val) = attr? {
22362                return Ok(val);
22363            }
22364        }
22365        Err(ErrorContext::new_missing(
22366            "OpNewlinkDoRequest",
22367            "GroIpv4MaxSize",
22368            self.orig_loc,
22369            self.buf.as_ptr() as usize,
22370        ))
22371    }
22372}
22373impl<'a> OpNewlinkDoRequest<'a> {
22374    pub fn new(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpNewlinkDoRequest<'a>) {
22375        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
22376        (
22377            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
22378            IterableOpNewlinkDoRequest::with_loc(attrs, buf.as_ptr() as usize),
22379        )
22380    }
22381    fn attr_from_type(r#type: u16) -> Option<&'static str> {
22382        LinkAttrs::attr_from_type(r#type)
22383    }
22384}
22385#[derive(Clone, Copy, Default)]
22386pub struct IterableOpNewlinkDoRequest<'a> {
22387    buf: &'a [u8],
22388    pos: usize,
22389    orig_loc: usize,
22390}
22391impl<'a> IterableOpNewlinkDoRequest<'a> {
22392    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
22393        Self {
22394            buf,
22395            pos: 0,
22396            orig_loc,
22397        }
22398    }
22399    pub fn get_buf(&self) -> &'a [u8] {
22400        self.buf
22401    }
22402}
22403impl<'a> Iterator for IterableOpNewlinkDoRequest<'a> {
22404    type Item = Result<OpNewlinkDoRequest<'a>, ErrorContext>;
22405    fn next(&mut self) -> Option<Self::Item> {
22406        if self.buf.len() == self.pos {
22407            return None;
22408        }
22409        let pos = self.pos;
22410        let mut r#type = None;
22411        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
22412            r#type = Some(header.r#type);
22413            let res = match header.r#type {
22414                1u16 => OpNewlinkDoRequest::Address({
22415                    let res = Some(next);
22416                    let Some(val) = res else { break };
22417                    val
22418                }),
22419                2u16 => OpNewlinkDoRequest::Broadcast({
22420                    let res = Some(next);
22421                    let Some(val) = res else { break };
22422                    val
22423                }),
22424                3u16 => OpNewlinkDoRequest::Ifname({
22425                    let res = CStr::from_bytes_with_nul(next).ok();
22426                    let Some(val) = res else { break };
22427                    val
22428                }),
22429                4u16 => OpNewlinkDoRequest::Mtu({
22430                    let res = parse_u32(next);
22431                    let Some(val) = res else { break };
22432                    val
22433                }),
22434                13u16 => OpNewlinkDoRequest::Txqlen({
22435                    let res = parse_u32(next);
22436                    let Some(val) = res else { break };
22437                    val
22438                }),
22439                16u16 => OpNewlinkDoRequest::Operstate({
22440                    let res = parse_u8(next);
22441                    let Some(val) = res else { break };
22442                    val
22443                }),
22444                17u16 => OpNewlinkDoRequest::Linkmode({
22445                    let res = parse_u8(next);
22446                    let Some(val) = res else { break };
22447                    val
22448                }),
22449                18u16 => OpNewlinkDoRequest::Linkinfo({
22450                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
22451                    let Some(val) = res else { break };
22452                    val
22453                }),
22454                19u16 => OpNewlinkDoRequest::NetNsPid({
22455                    let res = parse_u32(next);
22456                    let Some(val) = res else { break };
22457                    val
22458                }),
22459                26u16 => OpNewlinkDoRequest::AfSpec({
22460                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
22461                    let Some(val) = res else { break };
22462                    val
22463                }),
22464                27u16 => OpNewlinkDoRequest::Group({
22465                    let res = parse_u32(next);
22466                    let Some(val) = res else { break };
22467                    val
22468                }),
22469                28u16 => OpNewlinkDoRequest::NetNsFd({
22470                    let res = parse_u32(next);
22471                    let Some(val) = res else { break };
22472                    val
22473                }),
22474                31u16 => OpNewlinkDoRequest::NumTxQueues({
22475                    let res = parse_u32(next);
22476                    let Some(val) = res else { break };
22477                    val
22478                }),
22479                32u16 => OpNewlinkDoRequest::NumRxQueues({
22480                    let res = parse_u32(next);
22481                    let Some(val) = res else { break };
22482                    val
22483                }),
22484                37u16 => OpNewlinkDoRequest::LinkNetnsid({
22485                    let res = parse_i32(next);
22486                    let Some(val) = res else { break };
22487                    val
22488                }),
22489                40u16 => OpNewlinkDoRequest::GsoMaxSegs({
22490                    let res = parse_u32(next);
22491                    let Some(val) = res else { break };
22492                    val
22493                }),
22494                41u16 => OpNewlinkDoRequest::GsoMaxSize({
22495                    let res = parse_u32(next);
22496                    let Some(val) = res else { break };
22497                    val
22498                }),
22499                46u16 => OpNewlinkDoRequest::TargetNetnsid({
22500                    let res = parse_i32(next);
22501                    let Some(val) = res else { break };
22502                    val
22503                }),
22504                58u16 => OpNewlinkDoRequest::GroMaxSize({
22505                    let res = parse_u32(next);
22506                    let Some(val) = res else { break };
22507                    val
22508                }),
22509                63u16 => OpNewlinkDoRequest::GsoIpv4MaxSize({
22510                    let res = parse_u32(next);
22511                    let Some(val) = res else { break };
22512                    val
22513                }),
22514                64u16 => OpNewlinkDoRequest::GroIpv4MaxSize({
22515                    let res = parse_u32(next);
22516                    let Some(val) = res else { break };
22517                    val
22518                }),
22519                n => {
22520                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
22521                        break;
22522                    } else {
22523                        continue;
22524                    }
22525                }
22526            };
22527            return Some(Ok(res));
22528        }
22529        Some(Err(ErrorContext::new(
22530            "OpNewlinkDoRequest",
22531            r#type.and_then(|t| OpNewlinkDoRequest::attr_from_type(t)),
22532            self.orig_loc,
22533            self.buf.as_ptr().wrapping_add(pos) as usize,
22534        )))
22535    }
22536}
22537impl<'a> std::fmt::Debug for IterableOpNewlinkDoRequest<'_> {
22538    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22539        let mut fmt = f.debug_struct("OpNewlinkDoRequest");
22540        for attr in self.clone() {
22541            let attr = match attr {
22542                Ok(a) => a,
22543                Err(err) => {
22544                    fmt.finish()?;
22545                    f.write_str("Err(")?;
22546                    err.fmt(f)?;
22547                    return f.write_str(")");
22548                }
22549            };
22550            match attr {
22551                OpNewlinkDoRequest::Address(val) => fmt.field("Address", &val),
22552                OpNewlinkDoRequest::Broadcast(val) => fmt.field("Broadcast", &val),
22553                OpNewlinkDoRequest::Ifname(val) => fmt.field("Ifname", &val),
22554                OpNewlinkDoRequest::Mtu(val) => fmt.field("Mtu", &val),
22555                OpNewlinkDoRequest::Txqlen(val) => fmt.field("Txqlen", &val),
22556                OpNewlinkDoRequest::Operstate(val) => fmt.field("Operstate", &val),
22557                OpNewlinkDoRequest::Linkmode(val) => fmt.field("Linkmode", &val),
22558                OpNewlinkDoRequest::Linkinfo(val) => fmt.field("Linkinfo", &val),
22559                OpNewlinkDoRequest::NetNsPid(val) => fmt.field("NetNsPid", &val),
22560                OpNewlinkDoRequest::AfSpec(val) => fmt.field("AfSpec", &val),
22561                OpNewlinkDoRequest::Group(val) => fmt.field("Group", &val),
22562                OpNewlinkDoRequest::NetNsFd(val) => fmt.field("NetNsFd", &val),
22563                OpNewlinkDoRequest::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
22564                OpNewlinkDoRequest::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
22565                OpNewlinkDoRequest::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
22566                OpNewlinkDoRequest::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
22567                OpNewlinkDoRequest::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
22568                OpNewlinkDoRequest::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
22569                OpNewlinkDoRequest::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
22570                OpNewlinkDoRequest::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
22571                OpNewlinkDoRequest::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
22572            };
22573        }
22574        fmt.finish()
22575    }
22576}
22577impl IterableOpNewlinkDoRequest<'_> {
22578    pub fn lookup_attr(
22579        &self,
22580        offset: usize,
22581        missing_type: Option<u16>,
22582    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
22583        let mut stack = Vec::new();
22584        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
22585        if cur == offset + PushIfinfomsg::len() {
22586            stack.push(("OpNewlinkDoRequest", offset));
22587            return (
22588                stack,
22589                missing_type.and_then(|t| OpNewlinkDoRequest::attr_from_type(t)),
22590            );
22591        }
22592        if cur > offset || cur + self.buf.len() < offset {
22593            return (stack, None);
22594        }
22595        let mut attrs = self.clone();
22596        let mut last_off = cur + attrs.pos;
22597        let mut missing = None;
22598        while let Some(attr) = attrs.next() {
22599            let Ok(attr) = attr else { break };
22600            match attr {
22601                OpNewlinkDoRequest::Address(val) => {
22602                    if last_off == offset {
22603                        stack.push(("Address", last_off));
22604                        break;
22605                    }
22606                }
22607                OpNewlinkDoRequest::Broadcast(val) => {
22608                    if last_off == offset {
22609                        stack.push(("Broadcast", last_off));
22610                        break;
22611                    }
22612                }
22613                OpNewlinkDoRequest::Ifname(val) => {
22614                    if last_off == offset {
22615                        stack.push(("Ifname", last_off));
22616                        break;
22617                    }
22618                }
22619                OpNewlinkDoRequest::Mtu(val) => {
22620                    if last_off == offset {
22621                        stack.push(("Mtu", last_off));
22622                        break;
22623                    }
22624                }
22625                OpNewlinkDoRequest::Txqlen(val) => {
22626                    if last_off == offset {
22627                        stack.push(("Txqlen", last_off));
22628                        break;
22629                    }
22630                }
22631                OpNewlinkDoRequest::Operstate(val) => {
22632                    if last_off == offset {
22633                        stack.push(("Operstate", last_off));
22634                        break;
22635                    }
22636                }
22637                OpNewlinkDoRequest::Linkmode(val) => {
22638                    if last_off == offset {
22639                        stack.push(("Linkmode", last_off));
22640                        break;
22641                    }
22642                }
22643                OpNewlinkDoRequest::Linkinfo(val) => {
22644                    (stack, missing) = val.lookup_attr(offset, missing_type);
22645                    if !stack.is_empty() {
22646                        break;
22647                    }
22648                }
22649                OpNewlinkDoRequest::NetNsPid(val) => {
22650                    if last_off == offset {
22651                        stack.push(("NetNsPid", last_off));
22652                        break;
22653                    }
22654                }
22655                OpNewlinkDoRequest::AfSpec(val) => {
22656                    (stack, missing) = val.lookup_attr(offset, missing_type);
22657                    if !stack.is_empty() {
22658                        break;
22659                    }
22660                }
22661                OpNewlinkDoRequest::Group(val) => {
22662                    if last_off == offset {
22663                        stack.push(("Group", last_off));
22664                        break;
22665                    }
22666                }
22667                OpNewlinkDoRequest::NetNsFd(val) => {
22668                    if last_off == offset {
22669                        stack.push(("NetNsFd", last_off));
22670                        break;
22671                    }
22672                }
22673                OpNewlinkDoRequest::NumTxQueues(val) => {
22674                    if last_off == offset {
22675                        stack.push(("NumTxQueues", last_off));
22676                        break;
22677                    }
22678                }
22679                OpNewlinkDoRequest::NumRxQueues(val) => {
22680                    if last_off == offset {
22681                        stack.push(("NumRxQueues", last_off));
22682                        break;
22683                    }
22684                }
22685                OpNewlinkDoRequest::LinkNetnsid(val) => {
22686                    if last_off == offset {
22687                        stack.push(("LinkNetnsid", last_off));
22688                        break;
22689                    }
22690                }
22691                OpNewlinkDoRequest::GsoMaxSegs(val) => {
22692                    if last_off == offset {
22693                        stack.push(("GsoMaxSegs", last_off));
22694                        break;
22695                    }
22696                }
22697                OpNewlinkDoRequest::GsoMaxSize(val) => {
22698                    if last_off == offset {
22699                        stack.push(("GsoMaxSize", last_off));
22700                        break;
22701                    }
22702                }
22703                OpNewlinkDoRequest::TargetNetnsid(val) => {
22704                    if last_off == offset {
22705                        stack.push(("TargetNetnsid", last_off));
22706                        break;
22707                    }
22708                }
22709                OpNewlinkDoRequest::GroMaxSize(val) => {
22710                    if last_off == offset {
22711                        stack.push(("GroMaxSize", last_off));
22712                        break;
22713                    }
22714                }
22715                OpNewlinkDoRequest::GsoIpv4MaxSize(val) => {
22716                    if last_off == offset {
22717                        stack.push(("GsoIpv4MaxSize", last_off));
22718                        break;
22719                    }
22720                }
22721                OpNewlinkDoRequest::GroIpv4MaxSize(val) => {
22722                    if last_off == offset {
22723                        stack.push(("GroIpv4MaxSize", last_off));
22724                        break;
22725                    }
22726                }
22727                _ => {}
22728            };
22729            last_off = cur + attrs.pos;
22730        }
22731        if !stack.is_empty() {
22732            stack.push(("OpNewlinkDoRequest", cur));
22733        }
22734        (stack, missing)
22735    }
22736}
22737#[doc = "Create a new link."]
22738pub struct PushOpNewlinkDoReply<Prev: Rec> {
22739    pub(crate) prev: Option<Prev>,
22740    pub(crate) header_offset: Option<usize>,
22741}
22742impl<Prev: Rec> Rec for PushOpNewlinkDoReply<Prev> {
22743    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
22744        self.prev.as_mut().unwrap().as_rec_mut()
22745    }
22746}
22747impl<Prev: Rec> PushOpNewlinkDoReply<Prev> {
22748    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
22749        Self::write_header(&mut prev, header);
22750        Self::new_without_header(prev)
22751    }
22752    fn new_without_header(prev: Prev) -> Self {
22753        Self {
22754            prev: Some(prev),
22755            header_offset: None,
22756        }
22757    }
22758    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
22759        prev.as_rec_mut().extend(header.as_slice());
22760    }
22761    pub fn end_nested(mut self) -> Prev {
22762        let mut prev = self.prev.take().unwrap();
22763        if let Some(header_offset) = &self.header_offset {
22764            finalize_nested_header(prev.as_rec_mut(), *header_offset);
22765        }
22766        prev
22767    }
22768}
22769impl<Prev: Rec> Drop for PushOpNewlinkDoReply<Prev> {
22770    fn drop(&mut self) {
22771        if let Some(prev) = &mut self.prev {
22772            if let Some(header_offset) = &self.header_offset {
22773                finalize_nested_header(prev.as_rec_mut(), *header_offset);
22774            }
22775        }
22776    }
22777}
22778#[doc = "Create a new link."]
22779#[derive(Clone)]
22780pub enum OpNewlinkDoReply {}
22781impl<'a> IterableOpNewlinkDoReply<'a> {}
22782impl OpNewlinkDoReply {
22783    pub fn new(buf: &'_ [u8]) -> (PushIfinfomsg, IterableOpNewlinkDoReply<'_>) {
22784        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
22785        (
22786            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
22787            IterableOpNewlinkDoReply::with_loc(attrs, buf.as_ptr() as usize),
22788        )
22789    }
22790    fn attr_from_type(r#type: u16) -> Option<&'static str> {
22791        LinkAttrs::attr_from_type(r#type)
22792    }
22793}
22794#[derive(Clone, Copy, Default)]
22795pub struct IterableOpNewlinkDoReply<'a> {
22796    buf: &'a [u8],
22797    pos: usize,
22798    orig_loc: usize,
22799}
22800impl<'a> IterableOpNewlinkDoReply<'a> {
22801    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
22802        Self {
22803            buf,
22804            pos: 0,
22805            orig_loc,
22806        }
22807    }
22808    pub fn get_buf(&self) -> &'a [u8] {
22809        self.buf
22810    }
22811}
22812impl<'a> Iterator for IterableOpNewlinkDoReply<'a> {
22813    type Item = Result<OpNewlinkDoReply, ErrorContext>;
22814    fn next(&mut self) -> Option<Self::Item> {
22815        if self.buf.len() == self.pos {
22816            return None;
22817        }
22818        let pos = self.pos;
22819        let mut r#type = None;
22820        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
22821            r#type = Some(header.r#type);
22822            let res = match header.r#type {
22823                n => {
22824                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
22825                        break;
22826                    } else {
22827                        continue;
22828                    }
22829                }
22830            };
22831            return Some(Ok(res));
22832        }
22833        Some(Err(ErrorContext::new(
22834            "OpNewlinkDoReply",
22835            r#type.and_then(|t| OpNewlinkDoReply::attr_from_type(t)),
22836            self.orig_loc,
22837            self.buf.as_ptr().wrapping_add(pos) as usize,
22838        )))
22839    }
22840}
22841impl std::fmt::Debug for IterableOpNewlinkDoReply<'_> {
22842    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22843        let mut fmt = f.debug_struct("OpNewlinkDoReply");
22844        for attr in self.clone() {
22845            let attr = match attr {
22846                Ok(a) => a,
22847                Err(err) => {
22848                    fmt.finish()?;
22849                    f.write_str("Err(")?;
22850                    err.fmt(f)?;
22851                    return f.write_str(")");
22852                }
22853            };
22854            match attr {};
22855        }
22856        fmt.finish()
22857    }
22858}
22859impl IterableOpNewlinkDoReply<'_> {
22860    pub fn lookup_attr(
22861        &self,
22862        offset: usize,
22863        missing_type: Option<u16>,
22864    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
22865        let mut stack = Vec::new();
22866        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
22867        if cur == offset + PushIfinfomsg::len() {
22868            stack.push(("OpNewlinkDoReply", offset));
22869            return (
22870                stack,
22871                missing_type.and_then(|t| OpNewlinkDoReply::attr_from_type(t)),
22872            );
22873        }
22874        (stack, None)
22875    }
22876}
22877#[derive(Debug)]
22878pub struct RequestOpNewlinkDoRequest<'r> {
22879    request: Request<'r>,
22880}
22881impl<'r> RequestOpNewlinkDoRequest<'r> {
22882    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
22883        PushOpNewlinkDoRequest::write_header(&mut request.buf_mut(), header);
22884        Self { request: request }
22885    }
22886    pub fn encode(&mut self) -> PushOpNewlinkDoRequest<&mut Vec<u8>> {
22887        PushOpNewlinkDoRequest::new_without_header(self.request.buf_mut())
22888    }
22889    pub fn into_encoder(self) -> PushOpNewlinkDoRequest<RequestBuf<'r>> {
22890        PushOpNewlinkDoRequest::new_without_header(self.request.buf)
22891    }
22892}
22893impl NetlinkRequest for RequestOpNewlinkDoRequest<'_> {
22894    type ReplyType<'buf> = (PushIfinfomsg, IterableOpNewlinkDoReply<'buf>);
22895    fn protocol(&self) -> Protocol {
22896        Protocol::Raw {
22897            protonum: 0u16,
22898            request_type: 16u16,
22899        }
22900    }
22901    fn flags(&self) -> u16 {
22902        self.request.flags
22903    }
22904    fn payload(&self) -> &[u8] {
22905        self.request.buf()
22906    }
22907    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
22908        OpNewlinkDoReply::new(buf)
22909    }
22910    fn lookup(
22911        buf: &[u8],
22912        offset: usize,
22913        missing_type: Option<u16>,
22914    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
22915        OpNewlinkDoRequest::new(buf)
22916            .1
22917            .lookup_attr(offset, missing_type)
22918    }
22919}
22920#[doc = "Delete an existing link."]
22921pub struct PushOpDellinkDoRequest<Prev: Rec> {
22922    pub(crate) prev: Option<Prev>,
22923    pub(crate) header_offset: Option<usize>,
22924}
22925impl<Prev: Rec> Rec for PushOpDellinkDoRequest<Prev> {
22926    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
22927        self.prev.as_mut().unwrap().as_rec_mut()
22928    }
22929}
22930impl<Prev: Rec> PushOpDellinkDoRequest<Prev> {
22931    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
22932        Self::write_header(&mut prev, header);
22933        Self::new_without_header(prev)
22934    }
22935    fn new_without_header(prev: Prev) -> Self {
22936        Self {
22937            prev: Some(prev),
22938            header_offset: None,
22939        }
22940    }
22941    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
22942        prev.as_rec_mut().extend(header.as_slice());
22943    }
22944    pub fn end_nested(mut self) -> Prev {
22945        let mut prev = self.prev.take().unwrap();
22946        if let Some(header_offset) = &self.header_offset {
22947            finalize_nested_header(prev.as_rec_mut(), *header_offset);
22948        }
22949        prev
22950    }
22951    pub fn push_ifname(mut self, value: &CStr) -> Self {
22952        push_header(
22953            self.as_rec_mut(),
22954            3u16,
22955            value.to_bytes_with_nul().len() as u16,
22956        );
22957        self.as_rec_mut().extend(value.to_bytes_with_nul());
22958        self
22959    }
22960    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
22961        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
22962        self.as_rec_mut().extend(value);
22963        self.as_rec_mut().push(0);
22964        self
22965    }
22966}
22967impl<Prev: Rec> Drop for PushOpDellinkDoRequest<Prev> {
22968    fn drop(&mut self) {
22969        if let Some(prev) = &mut self.prev {
22970            if let Some(header_offset) = &self.header_offset {
22971                finalize_nested_header(prev.as_rec_mut(), *header_offset);
22972            }
22973        }
22974    }
22975}
22976#[doc = "Delete an existing link."]
22977#[derive(Clone)]
22978pub enum OpDellinkDoRequest<'a> {
22979    Ifname(&'a CStr),
22980}
22981impl<'a> IterableOpDellinkDoRequest<'a> {
22982    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
22983        let mut iter = self.clone();
22984        iter.pos = 0;
22985        for attr in iter {
22986            if let OpDellinkDoRequest::Ifname(val) = attr? {
22987                return Ok(val);
22988            }
22989        }
22990        Err(ErrorContext::new_missing(
22991            "OpDellinkDoRequest",
22992            "Ifname",
22993            self.orig_loc,
22994            self.buf.as_ptr() as usize,
22995        ))
22996    }
22997}
22998impl<'a> OpDellinkDoRequest<'a> {
22999    pub fn new(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpDellinkDoRequest<'a>) {
23000        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
23001        (
23002            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
23003            IterableOpDellinkDoRequest::with_loc(attrs, buf.as_ptr() as usize),
23004        )
23005    }
23006    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23007        LinkAttrs::attr_from_type(r#type)
23008    }
23009}
23010#[derive(Clone, Copy, Default)]
23011pub struct IterableOpDellinkDoRequest<'a> {
23012    buf: &'a [u8],
23013    pos: usize,
23014    orig_loc: usize,
23015}
23016impl<'a> IterableOpDellinkDoRequest<'a> {
23017    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23018        Self {
23019            buf,
23020            pos: 0,
23021            orig_loc,
23022        }
23023    }
23024    pub fn get_buf(&self) -> &'a [u8] {
23025        self.buf
23026    }
23027}
23028impl<'a> Iterator for IterableOpDellinkDoRequest<'a> {
23029    type Item = Result<OpDellinkDoRequest<'a>, ErrorContext>;
23030    fn next(&mut self) -> Option<Self::Item> {
23031        if self.buf.len() == self.pos {
23032            return None;
23033        }
23034        let pos = self.pos;
23035        let mut r#type = None;
23036        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
23037            r#type = Some(header.r#type);
23038            let res = match header.r#type {
23039                3u16 => OpDellinkDoRequest::Ifname({
23040                    let res = CStr::from_bytes_with_nul(next).ok();
23041                    let Some(val) = res else { break };
23042                    val
23043                }),
23044                n => {
23045                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
23046                        break;
23047                    } else {
23048                        continue;
23049                    }
23050                }
23051            };
23052            return Some(Ok(res));
23053        }
23054        Some(Err(ErrorContext::new(
23055            "OpDellinkDoRequest",
23056            r#type.and_then(|t| OpDellinkDoRequest::attr_from_type(t)),
23057            self.orig_loc,
23058            self.buf.as_ptr().wrapping_add(pos) as usize,
23059        )))
23060    }
23061}
23062impl<'a> std::fmt::Debug for IterableOpDellinkDoRequest<'_> {
23063    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23064        let mut fmt = f.debug_struct("OpDellinkDoRequest");
23065        for attr in self.clone() {
23066            let attr = match attr {
23067                Ok(a) => a,
23068                Err(err) => {
23069                    fmt.finish()?;
23070                    f.write_str("Err(")?;
23071                    err.fmt(f)?;
23072                    return f.write_str(")");
23073                }
23074            };
23075            match attr {
23076                OpDellinkDoRequest::Ifname(val) => fmt.field("Ifname", &val),
23077            };
23078        }
23079        fmt.finish()
23080    }
23081}
23082impl IterableOpDellinkDoRequest<'_> {
23083    pub fn lookup_attr(
23084        &self,
23085        offset: usize,
23086        missing_type: Option<u16>,
23087    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23088        let mut stack = Vec::new();
23089        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23090        if cur == offset + PushIfinfomsg::len() {
23091            stack.push(("OpDellinkDoRequest", offset));
23092            return (
23093                stack,
23094                missing_type.and_then(|t| OpDellinkDoRequest::attr_from_type(t)),
23095            );
23096        }
23097        if cur > offset || cur + self.buf.len() < offset {
23098            return (stack, None);
23099        }
23100        let mut attrs = self.clone();
23101        let mut last_off = cur + attrs.pos;
23102        while let Some(attr) = attrs.next() {
23103            let Ok(attr) = attr else { break };
23104            match attr {
23105                OpDellinkDoRequest::Ifname(val) => {
23106                    if last_off == offset {
23107                        stack.push(("Ifname", last_off));
23108                        break;
23109                    }
23110                }
23111                _ => {}
23112            };
23113            last_off = cur + attrs.pos;
23114        }
23115        if !stack.is_empty() {
23116            stack.push(("OpDellinkDoRequest", cur));
23117        }
23118        (stack, None)
23119    }
23120}
23121#[doc = "Delete an existing link."]
23122pub struct PushOpDellinkDoReply<Prev: Rec> {
23123    pub(crate) prev: Option<Prev>,
23124    pub(crate) header_offset: Option<usize>,
23125}
23126impl<Prev: Rec> Rec for PushOpDellinkDoReply<Prev> {
23127    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
23128        self.prev.as_mut().unwrap().as_rec_mut()
23129    }
23130}
23131impl<Prev: Rec> PushOpDellinkDoReply<Prev> {
23132    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
23133        Self::write_header(&mut prev, header);
23134        Self::new_without_header(prev)
23135    }
23136    fn new_without_header(prev: Prev) -> Self {
23137        Self {
23138            prev: Some(prev),
23139            header_offset: None,
23140        }
23141    }
23142    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
23143        prev.as_rec_mut().extend(header.as_slice());
23144    }
23145    pub fn end_nested(mut self) -> Prev {
23146        let mut prev = self.prev.take().unwrap();
23147        if let Some(header_offset) = &self.header_offset {
23148            finalize_nested_header(prev.as_rec_mut(), *header_offset);
23149        }
23150        prev
23151    }
23152}
23153impl<Prev: Rec> Drop for PushOpDellinkDoReply<Prev> {
23154    fn drop(&mut self) {
23155        if let Some(prev) = &mut self.prev {
23156            if let Some(header_offset) = &self.header_offset {
23157                finalize_nested_header(prev.as_rec_mut(), *header_offset);
23158            }
23159        }
23160    }
23161}
23162#[doc = "Delete an existing link."]
23163#[derive(Clone)]
23164pub enum OpDellinkDoReply {}
23165impl<'a> IterableOpDellinkDoReply<'a> {}
23166impl OpDellinkDoReply {
23167    pub fn new(buf: &'_ [u8]) -> (PushIfinfomsg, IterableOpDellinkDoReply<'_>) {
23168        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
23169        (
23170            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
23171            IterableOpDellinkDoReply::with_loc(attrs, buf.as_ptr() as usize),
23172        )
23173    }
23174    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23175        LinkAttrs::attr_from_type(r#type)
23176    }
23177}
23178#[derive(Clone, Copy, Default)]
23179pub struct IterableOpDellinkDoReply<'a> {
23180    buf: &'a [u8],
23181    pos: usize,
23182    orig_loc: usize,
23183}
23184impl<'a> IterableOpDellinkDoReply<'a> {
23185    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23186        Self {
23187            buf,
23188            pos: 0,
23189            orig_loc,
23190        }
23191    }
23192    pub fn get_buf(&self) -> &'a [u8] {
23193        self.buf
23194    }
23195}
23196impl<'a> Iterator for IterableOpDellinkDoReply<'a> {
23197    type Item = Result<OpDellinkDoReply, ErrorContext>;
23198    fn next(&mut self) -> Option<Self::Item> {
23199        if self.buf.len() == self.pos {
23200            return None;
23201        }
23202        let pos = self.pos;
23203        let mut r#type = None;
23204        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
23205            r#type = Some(header.r#type);
23206            let res = match header.r#type {
23207                n => {
23208                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
23209                        break;
23210                    } else {
23211                        continue;
23212                    }
23213                }
23214            };
23215            return Some(Ok(res));
23216        }
23217        Some(Err(ErrorContext::new(
23218            "OpDellinkDoReply",
23219            r#type.and_then(|t| OpDellinkDoReply::attr_from_type(t)),
23220            self.orig_loc,
23221            self.buf.as_ptr().wrapping_add(pos) as usize,
23222        )))
23223    }
23224}
23225impl std::fmt::Debug for IterableOpDellinkDoReply<'_> {
23226    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23227        let mut fmt = f.debug_struct("OpDellinkDoReply");
23228        for attr in self.clone() {
23229            let attr = match attr {
23230                Ok(a) => a,
23231                Err(err) => {
23232                    fmt.finish()?;
23233                    f.write_str("Err(")?;
23234                    err.fmt(f)?;
23235                    return f.write_str(")");
23236                }
23237            };
23238            match attr {};
23239        }
23240        fmt.finish()
23241    }
23242}
23243impl IterableOpDellinkDoReply<'_> {
23244    pub fn lookup_attr(
23245        &self,
23246        offset: usize,
23247        missing_type: Option<u16>,
23248    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23249        let mut stack = Vec::new();
23250        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23251        if cur == offset + PushIfinfomsg::len() {
23252            stack.push(("OpDellinkDoReply", offset));
23253            return (
23254                stack,
23255                missing_type.and_then(|t| OpDellinkDoReply::attr_from_type(t)),
23256            );
23257        }
23258        (stack, None)
23259    }
23260}
23261#[derive(Debug)]
23262pub struct RequestOpDellinkDoRequest<'r> {
23263    request: Request<'r>,
23264}
23265impl<'r> RequestOpDellinkDoRequest<'r> {
23266    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
23267        PushOpDellinkDoRequest::write_header(&mut request.buf_mut(), header);
23268        Self { request: request }
23269    }
23270    pub fn encode(&mut self) -> PushOpDellinkDoRequest<&mut Vec<u8>> {
23271        PushOpDellinkDoRequest::new_without_header(self.request.buf_mut())
23272    }
23273    pub fn into_encoder(self) -> PushOpDellinkDoRequest<RequestBuf<'r>> {
23274        PushOpDellinkDoRequest::new_without_header(self.request.buf)
23275    }
23276}
23277impl NetlinkRequest for RequestOpDellinkDoRequest<'_> {
23278    type ReplyType<'buf> = (PushIfinfomsg, IterableOpDellinkDoReply<'buf>);
23279    fn protocol(&self) -> Protocol {
23280        Protocol::Raw {
23281            protonum: 0u16,
23282            request_type: 17u16,
23283        }
23284    }
23285    fn flags(&self) -> u16 {
23286        self.request.flags
23287    }
23288    fn payload(&self) -> &[u8] {
23289        self.request.buf()
23290    }
23291    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
23292        OpDellinkDoReply::new(buf)
23293    }
23294    fn lookup(
23295        buf: &[u8],
23296        offset: usize,
23297        missing_type: Option<u16>,
23298    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23299        OpDellinkDoRequest::new(buf)
23300            .1
23301            .lookup_attr(offset, missing_type)
23302    }
23303}
23304#[doc = "Get / dump information about a link."]
23305pub struct PushOpGetlinkDumpRequest<Prev: Rec> {
23306    pub(crate) prev: Option<Prev>,
23307    pub(crate) header_offset: Option<usize>,
23308}
23309impl<Prev: Rec> Rec for PushOpGetlinkDumpRequest<Prev> {
23310    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
23311        self.prev.as_mut().unwrap().as_rec_mut()
23312    }
23313}
23314impl<Prev: Rec> PushOpGetlinkDumpRequest<Prev> {
23315    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
23316        Self::write_header(&mut prev, header);
23317        Self::new_without_header(prev)
23318    }
23319    fn new_without_header(prev: Prev) -> Self {
23320        Self {
23321            prev: Some(prev),
23322            header_offset: None,
23323        }
23324    }
23325    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
23326        prev.as_rec_mut().extend(header.as_slice());
23327    }
23328    pub fn end_nested(mut self) -> Prev {
23329        let mut prev = self.prev.take().unwrap();
23330        if let Some(header_offset) = &self.header_offset {
23331            finalize_nested_header(prev.as_rec_mut(), *header_offset);
23332        }
23333        prev
23334    }
23335    pub fn push_master(mut self, value: u32) -> Self {
23336        push_header(self.as_rec_mut(), 10u16, 4 as u16);
23337        self.as_rec_mut().extend(value.to_ne_bytes());
23338        self
23339    }
23340    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
23341        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
23342        PushLinkinfoAttrs {
23343            prev: Some(self),
23344            header_offset: Some(header_offset),
23345        }
23346    }
23347    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
23348    pub fn push_ext_mask(mut self, value: u32) -> Self {
23349        push_header(self.as_rec_mut(), 29u16, 4 as u16);
23350        self.as_rec_mut().extend(value.to_ne_bytes());
23351        self
23352    }
23353    pub fn push_target_netnsid(mut self, value: i32) -> Self {
23354        push_header(self.as_rec_mut(), 46u16, 4 as u16);
23355        self.as_rec_mut().extend(value.to_ne_bytes());
23356        self
23357    }
23358}
23359impl<Prev: Rec> Drop for PushOpGetlinkDumpRequest<Prev> {
23360    fn drop(&mut self) {
23361        if let Some(prev) = &mut self.prev {
23362            if let Some(header_offset) = &self.header_offset {
23363                finalize_nested_header(prev.as_rec_mut(), *header_offset);
23364            }
23365        }
23366    }
23367}
23368#[doc = "Get / dump information about a link."]
23369#[derive(Clone)]
23370pub enum OpGetlinkDumpRequest<'a> {
23371    Master(u32),
23372    Linkinfo(IterableLinkinfoAttrs<'a>),
23373    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
23374    ExtMask(u32),
23375    TargetNetnsid(i32),
23376}
23377impl<'a> IterableOpGetlinkDumpRequest<'a> {
23378    pub fn get_master(&self) -> Result<u32, ErrorContext> {
23379        let mut iter = self.clone();
23380        iter.pos = 0;
23381        for attr in iter {
23382            if let OpGetlinkDumpRequest::Master(val) = attr? {
23383                return Ok(val);
23384            }
23385        }
23386        Err(ErrorContext::new_missing(
23387            "OpGetlinkDumpRequest",
23388            "Master",
23389            self.orig_loc,
23390            self.buf.as_ptr() as usize,
23391        ))
23392    }
23393    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
23394        let mut iter = self.clone();
23395        iter.pos = 0;
23396        for attr in iter {
23397            if let OpGetlinkDumpRequest::Linkinfo(val) = attr? {
23398                return Ok(val);
23399            }
23400        }
23401        Err(ErrorContext::new_missing(
23402            "OpGetlinkDumpRequest",
23403            "Linkinfo",
23404            self.orig_loc,
23405            self.buf.as_ptr() as usize,
23406        ))
23407    }
23408    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
23409    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
23410        let mut iter = self.clone();
23411        iter.pos = 0;
23412        for attr in iter {
23413            if let OpGetlinkDumpRequest::ExtMask(val) = attr? {
23414                return Ok(val);
23415            }
23416        }
23417        Err(ErrorContext::new_missing(
23418            "OpGetlinkDumpRequest",
23419            "ExtMask",
23420            self.orig_loc,
23421            self.buf.as_ptr() as usize,
23422        ))
23423    }
23424    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
23425        let mut iter = self.clone();
23426        iter.pos = 0;
23427        for attr in iter {
23428            if let OpGetlinkDumpRequest::TargetNetnsid(val) = attr? {
23429                return Ok(val);
23430            }
23431        }
23432        Err(ErrorContext::new_missing(
23433            "OpGetlinkDumpRequest",
23434            "TargetNetnsid",
23435            self.orig_loc,
23436            self.buf.as_ptr() as usize,
23437        ))
23438    }
23439}
23440impl<'a> OpGetlinkDumpRequest<'a> {
23441    pub fn new(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpGetlinkDumpRequest<'a>) {
23442        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
23443        (
23444            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
23445            IterableOpGetlinkDumpRequest::with_loc(attrs, buf.as_ptr() as usize),
23446        )
23447    }
23448    fn attr_from_type(r#type: u16) -> Option<&'static str> {
23449        LinkAttrs::attr_from_type(r#type)
23450    }
23451}
23452#[derive(Clone, Copy, Default)]
23453pub struct IterableOpGetlinkDumpRequest<'a> {
23454    buf: &'a [u8],
23455    pos: usize,
23456    orig_loc: usize,
23457}
23458impl<'a> IterableOpGetlinkDumpRequest<'a> {
23459    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
23460        Self {
23461            buf,
23462            pos: 0,
23463            orig_loc,
23464        }
23465    }
23466    pub fn get_buf(&self) -> &'a [u8] {
23467        self.buf
23468    }
23469}
23470impl<'a> Iterator for IterableOpGetlinkDumpRequest<'a> {
23471    type Item = Result<OpGetlinkDumpRequest<'a>, ErrorContext>;
23472    fn next(&mut self) -> Option<Self::Item> {
23473        if self.buf.len() == self.pos {
23474            return None;
23475        }
23476        let pos = self.pos;
23477        let mut r#type = None;
23478        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
23479            r#type = Some(header.r#type);
23480            let res = match header.r#type {
23481                10u16 => OpGetlinkDumpRequest::Master({
23482                    let res = parse_u32(next);
23483                    let Some(val) = res else { break };
23484                    val
23485                }),
23486                18u16 => OpGetlinkDumpRequest::Linkinfo({
23487                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
23488                    let Some(val) = res else { break };
23489                    val
23490                }),
23491                29u16 => OpGetlinkDumpRequest::ExtMask({
23492                    let res = parse_u32(next);
23493                    let Some(val) = res else { break };
23494                    val
23495                }),
23496                46u16 => OpGetlinkDumpRequest::TargetNetnsid({
23497                    let res = parse_i32(next);
23498                    let Some(val) = res else { break };
23499                    val
23500                }),
23501                n => {
23502                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
23503                        break;
23504                    } else {
23505                        continue;
23506                    }
23507                }
23508            };
23509            return Some(Ok(res));
23510        }
23511        Some(Err(ErrorContext::new(
23512            "OpGetlinkDumpRequest",
23513            r#type.and_then(|t| OpGetlinkDumpRequest::attr_from_type(t)),
23514            self.orig_loc,
23515            self.buf.as_ptr().wrapping_add(pos) as usize,
23516        )))
23517    }
23518}
23519impl<'a> std::fmt::Debug for IterableOpGetlinkDumpRequest<'_> {
23520    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23521        let mut fmt = f.debug_struct("OpGetlinkDumpRequest");
23522        for attr in self.clone() {
23523            let attr = match attr {
23524                Ok(a) => a,
23525                Err(err) => {
23526                    fmt.finish()?;
23527                    f.write_str("Err(")?;
23528                    err.fmt(f)?;
23529                    return f.write_str(")");
23530                }
23531            };
23532            match attr {
23533                OpGetlinkDumpRequest::Master(val) => fmt.field("Master", &val),
23534                OpGetlinkDumpRequest::Linkinfo(val) => fmt.field("Linkinfo", &val),
23535                OpGetlinkDumpRequest::ExtMask(val) => {
23536                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
23537                }
23538                OpGetlinkDumpRequest::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
23539            };
23540        }
23541        fmt.finish()
23542    }
23543}
23544impl IterableOpGetlinkDumpRequest<'_> {
23545    pub fn lookup_attr(
23546        &self,
23547        offset: usize,
23548        missing_type: Option<u16>,
23549    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
23550        let mut stack = Vec::new();
23551        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
23552        if cur == offset + PushIfinfomsg::len() {
23553            stack.push(("OpGetlinkDumpRequest", offset));
23554            return (
23555                stack,
23556                missing_type.and_then(|t| OpGetlinkDumpRequest::attr_from_type(t)),
23557            );
23558        }
23559        if cur > offset || cur + self.buf.len() < offset {
23560            return (stack, None);
23561        }
23562        let mut attrs = self.clone();
23563        let mut last_off = cur + attrs.pos;
23564        let mut missing = None;
23565        while let Some(attr) = attrs.next() {
23566            let Ok(attr) = attr else { break };
23567            match attr {
23568                OpGetlinkDumpRequest::Master(val) => {
23569                    if last_off == offset {
23570                        stack.push(("Master", last_off));
23571                        break;
23572                    }
23573                }
23574                OpGetlinkDumpRequest::Linkinfo(val) => {
23575                    (stack, missing) = val.lookup_attr(offset, missing_type);
23576                    if !stack.is_empty() {
23577                        break;
23578                    }
23579                }
23580                OpGetlinkDumpRequest::ExtMask(val) => {
23581                    if last_off == offset {
23582                        stack.push(("ExtMask", last_off));
23583                        break;
23584                    }
23585                }
23586                OpGetlinkDumpRequest::TargetNetnsid(val) => {
23587                    if last_off == offset {
23588                        stack.push(("TargetNetnsid", last_off));
23589                        break;
23590                    }
23591                }
23592                _ => {}
23593            };
23594            last_off = cur + attrs.pos;
23595        }
23596        if !stack.is_empty() {
23597            stack.push(("OpGetlinkDumpRequest", cur));
23598        }
23599        (stack, missing)
23600    }
23601}
23602#[doc = "Get / dump information about a link."]
23603pub struct PushOpGetlinkDumpReply<Prev: Rec> {
23604    pub(crate) prev: Option<Prev>,
23605    pub(crate) header_offset: Option<usize>,
23606}
23607impl<Prev: Rec> Rec for PushOpGetlinkDumpReply<Prev> {
23608    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
23609        self.prev.as_mut().unwrap().as_rec_mut()
23610    }
23611}
23612impl<Prev: Rec> PushOpGetlinkDumpReply<Prev> {
23613    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
23614        Self::write_header(&mut prev, header);
23615        Self::new_without_header(prev)
23616    }
23617    fn new_without_header(prev: Prev) -> Self {
23618        Self {
23619            prev: Some(prev),
23620            header_offset: None,
23621        }
23622    }
23623    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
23624        prev.as_rec_mut().extend(header.as_slice());
23625    }
23626    pub fn end_nested(mut self) -> Prev {
23627        let mut prev = self.prev.take().unwrap();
23628        if let Some(header_offset) = &self.header_offset {
23629            finalize_nested_header(prev.as_rec_mut(), *header_offset);
23630        }
23631        prev
23632    }
23633    pub fn push_address(mut self, value: &[u8]) -> Self {
23634        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
23635        self.as_rec_mut().extend(value);
23636        self
23637    }
23638    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
23639        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
23640        self.as_rec_mut().extend(value);
23641        self
23642    }
23643    pub fn push_ifname(mut self, value: &CStr) -> Self {
23644        push_header(
23645            self.as_rec_mut(),
23646            3u16,
23647            value.to_bytes_with_nul().len() as u16,
23648        );
23649        self.as_rec_mut().extend(value.to_bytes_with_nul());
23650        self
23651    }
23652    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
23653        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
23654        self.as_rec_mut().extend(value);
23655        self.as_rec_mut().push(0);
23656        self
23657    }
23658    pub fn push_mtu(mut self, value: u32) -> Self {
23659        push_header(self.as_rec_mut(), 4u16, 4 as u16);
23660        self.as_rec_mut().extend(value.to_ne_bytes());
23661        self
23662    }
23663    pub fn push_link(mut self, value: u32) -> Self {
23664        push_header(self.as_rec_mut(), 5u16, 4 as u16);
23665        self.as_rec_mut().extend(value.to_ne_bytes());
23666        self
23667    }
23668    pub fn push_qdisc(mut self, value: &CStr) -> Self {
23669        push_header(
23670            self.as_rec_mut(),
23671            6u16,
23672            value.to_bytes_with_nul().len() as u16,
23673        );
23674        self.as_rec_mut().extend(value.to_bytes_with_nul());
23675        self
23676    }
23677    pub fn push_qdisc_bytes(mut self, value: &[u8]) -> Self {
23678        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
23679        self.as_rec_mut().extend(value);
23680        self.as_rec_mut().push(0);
23681        self
23682    }
23683    pub fn push_stats(mut self, value: PushRtnlLinkStats) -> Self {
23684        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
23685        self.as_rec_mut().extend(value.as_slice());
23686        self
23687    }
23688    pub fn push_cost(mut self, value: &CStr) -> Self {
23689        push_header(
23690            self.as_rec_mut(),
23691            8u16,
23692            value.to_bytes_with_nul().len() as u16,
23693        );
23694        self.as_rec_mut().extend(value.to_bytes_with_nul());
23695        self
23696    }
23697    pub fn push_cost_bytes(mut self, value: &[u8]) -> Self {
23698        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
23699        self.as_rec_mut().extend(value);
23700        self.as_rec_mut().push(0);
23701        self
23702    }
23703    pub fn push_priority(mut self, value: &CStr) -> Self {
23704        push_header(
23705            self.as_rec_mut(),
23706            9u16,
23707            value.to_bytes_with_nul().len() as u16,
23708        );
23709        self.as_rec_mut().extend(value.to_bytes_with_nul());
23710        self
23711    }
23712    pub fn push_priority_bytes(mut self, value: &[u8]) -> Self {
23713        push_header(self.as_rec_mut(), 9u16, (value.len() + 1) as u16);
23714        self.as_rec_mut().extend(value);
23715        self.as_rec_mut().push(0);
23716        self
23717    }
23718    pub fn push_master(mut self, value: u32) -> Self {
23719        push_header(self.as_rec_mut(), 10u16, 4 as u16);
23720        self.as_rec_mut().extend(value.to_ne_bytes());
23721        self
23722    }
23723    pub fn push_wireless(mut self, value: &CStr) -> Self {
23724        push_header(
23725            self.as_rec_mut(),
23726            11u16,
23727            value.to_bytes_with_nul().len() as u16,
23728        );
23729        self.as_rec_mut().extend(value.to_bytes_with_nul());
23730        self
23731    }
23732    pub fn push_wireless_bytes(mut self, value: &[u8]) -> Self {
23733        push_header(self.as_rec_mut(), 11u16, (value.len() + 1) as u16);
23734        self.as_rec_mut().extend(value);
23735        self.as_rec_mut().push(0);
23736        self
23737    }
23738    pub fn push_protinfo(mut self, value: &CStr) -> Self {
23739        push_header(
23740            self.as_rec_mut(),
23741            12u16,
23742            value.to_bytes_with_nul().len() as u16,
23743        );
23744        self.as_rec_mut().extend(value.to_bytes_with_nul());
23745        self
23746    }
23747    pub fn push_protinfo_bytes(mut self, value: &[u8]) -> Self {
23748        push_header(self.as_rec_mut(), 12u16, (value.len() + 1) as u16);
23749        self.as_rec_mut().extend(value);
23750        self.as_rec_mut().push(0);
23751        self
23752    }
23753    pub fn push_txqlen(mut self, value: u32) -> Self {
23754        push_header(self.as_rec_mut(), 13u16, 4 as u16);
23755        self.as_rec_mut().extend(value.to_ne_bytes());
23756        self
23757    }
23758    pub fn push_map(mut self, value: PushRtnlLinkIfmap) -> Self {
23759        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
23760        self.as_rec_mut().extend(value.as_slice());
23761        self
23762    }
23763    pub fn push_weight(mut self, value: u32) -> Self {
23764        push_header(self.as_rec_mut(), 15u16, 4 as u16);
23765        self.as_rec_mut().extend(value.to_ne_bytes());
23766        self
23767    }
23768    pub fn push_operstate(mut self, value: u8) -> Self {
23769        push_header(self.as_rec_mut(), 16u16, 1 as u16);
23770        self.as_rec_mut().extend(value.to_ne_bytes());
23771        self
23772    }
23773    pub fn push_linkmode(mut self, value: u8) -> Self {
23774        push_header(self.as_rec_mut(), 17u16, 1 as u16);
23775        self.as_rec_mut().extend(value.to_ne_bytes());
23776        self
23777    }
23778    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
23779        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
23780        PushLinkinfoAttrs {
23781            prev: Some(self),
23782            header_offset: Some(header_offset),
23783        }
23784    }
23785    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
23786        push_header(self.as_rec_mut(), 19u16, 4 as u16);
23787        self.as_rec_mut().extend(value.to_ne_bytes());
23788        self
23789    }
23790    pub fn push_ifalias(mut self, value: &CStr) -> Self {
23791        push_header(
23792            self.as_rec_mut(),
23793            20u16,
23794            value.to_bytes_with_nul().len() as u16,
23795        );
23796        self.as_rec_mut().extend(value.to_bytes_with_nul());
23797        self
23798    }
23799    pub fn push_ifalias_bytes(mut self, value: &[u8]) -> Self {
23800        push_header(self.as_rec_mut(), 20u16, (value.len() + 1) as u16);
23801        self.as_rec_mut().extend(value);
23802        self.as_rec_mut().push(0);
23803        self
23804    }
23805    pub fn push_num_vf(mut self, value: u32) -> Self {
23806        push_header(self.as_rec_mut(), 21u16, 4 as u16);
23807        self.as_rec_mut().extend(value.to_ne_bytes());
23808        self
23809    }
23810    pub fn nested_vfinfo_list(mut self) -> PushVfinfoListAttrs<Self> {
23811        let header_offset = push_nested_header(self.as_rec_mut(), 22u16);
23812        PushVfinfoListAttrs {
23813            prev: Some(self),
23814            header_offset: Some(header_offset),
23815        }
23816    }
23817    pub fn push_stats64(mut self, value: PushRtnlLinkStats64) -> Self {
23818        push_header(self.as_rec_mut(), 23u16, value.as_slice().len() as u16);
23819        self.as_rec_mut().extend(value.as_slice());
23820        self
23821    }
23822    pub fn nested_vf_ports(mut self) -> PushVfPortsAttrs<Self> {
23823        let header_offset = push_nested_header(self.as_rec_mut(), 24u16);
23824        PushVfPortsAttrs {
23825            prev: Some(self),
23826            header_offset: Some(header_offset),
23827        }
23828    }
23829    pub fn nested_port_self(mut self) -> PushPortSelfAttrs<Self> {
23830        let header_offset = push_nested_header(self.as_rec_mut(), 25u16);
23831        PushPortSelfAttrs {
23832            prev: Some(self),
23833            header_offset: Some(header_offset),
23834        }
23835    }
23836    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
23837        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
23838        PushAfSpecAttrs {
23839            prev: Some(self),
23840            header_offset: Some(header_offset),
23841        }
23842    }
23843    pub fn push_group(mut self, value: u32) -> Self {
23844        push_header(self.as_rec_mut(), 27u16, 4 as u16);
23845        self.as_rec_mut().extend(value.to_ne_bytes());
23846        self
23847    }
23848    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
23849        push_header(self.as_rec_mut(), 28u16, 4 as u16);
23850        self.as_rec_mut().extend(value.to_ne_bytes());
23851        self
23852    }
23853    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
23854    pub fn push_ext_mask(mut self, value: u32) -> Self {
23855        push_header(self.as_rec_mut(), 29u16, 4 as u16);
23856        self.as_rec_mut().extend(value.to_ne_bytes());
23857        self
23858    }
23859    pub fn push_promiscuity(mut self, value: u32) -> Self {
23860        push_header(self.as_rec_mut(), 30u16, 4 as u16);
23861        self.as_rec_mut().extend(value.to_ne_bytes());
23862        self
23863    }
23864    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
23865        push_header(self.as_rec_mut(), 31u16, 4 as u16);
23866        self.as_rec_mut().extend(value.to_ne_bytes());
23867        self
23868    }
23869    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
23870        push_header(self.as_rec_mut(), 32u16, 4 as u16);
23871        self.as_rec_mut().extend(value.to_ne_bytes());
23872        self
23873    }
23874    pub fn push_carrier(mut self, value: u8) -> Self {
23875        push_header(self.as_rec_mut(), 33u16, 1 as u16);
23876        self.as_rec_mut().extend(value.to_ne_bytes());
23877        self
23878    }
23879    pub fn push_phys_port_id(mut self, value: &[u8]) -> Self {
23880        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
23881        self.as_rec_mut().extend(value);
23882        self
23883    }
23884    pub fn push_carrier_changes(mut self, value: u32) -> Self {
23885        push_header(self.as_rec_mut(), 35u16, 4 as u16);
23886        self.as_rec_mut().extend(value.to_ne_bytes());
23887        self
23888    }
23889    pub fn push_phys_switch_id(mut self, value: &[u8]) -> Self {
23890        push_header(self.as_rec_mut(), 36u16, value.len() as u16);
23891        self.as_rec_mut().extend(value);
23892        self
23893    }
23894    pub fn push_link_netnsid(mut self, value: i32) -> Self {
23895        push_header(self.as_rec_mut(), 37u16, 4 as u16);
23896        self.as_rec_mut().extend(value.to_ne_bytes());
23897        self
23898    }
23899    pub fn push_phys_port_name(mut self, value: &CStr) -> Self {
23900        push_header(
23901            self.as_rec_mut(),
23902            38u16,
23903            value.to_bytes_with_nul().len() as u16,
23904        );
23905        self.as_rec_mut().extend(value.to_bytes_with_nul());
23906        self
23907    }
23908    pub fn push_phys_port_name_bytes(mut self, value: &[u8]) -> Self {
23909        push_header(self.as_rec_mut(), 38u16, (value.len() + 1) as u16);
23910        self.as_rec_mut().extend(value);
23911        self.as_rec_mut().push(0);
23912        self
23913    }
23914    pub fn push_proto_down(mut self, value: u8) -> Self {
23915        push_header(self.as_rec_mut(), 39u16, 1 as u16);
23916        self.as_rec_mut().extend(value.to_ne_bytes());
23917        self
23918    }
23919    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
23920        push_header(self.as_rec_mut(), 40u16, 4 as u16);
23921        self.as_rec_mut().extend(value.to_ne_bytes());
23922        self
23923    }
23924    pub fn push_gso_max_size(mut self, value: u32) -> Self {
23925        push_header(self.as_rec_mut(), 41u16, 4 as u16);
23926        self.as_rec_mut().extend(value.to_ne_bytes());
23927        self
23928    }
23929    pub fn push_pad(mut self, value: &[u8]) -> Self {
23930        push_header(self.as_rec_mut(), 42u16, value.len() as u16);
23931        self.as_rec_mut().extend(value);
23932        self
23933    }
23934    pub fn nested_xdp(mut self) -> PushXdpAttrs<Self> {
23935        let header_offset = push_nested_header(self.as_rec_mut(), 43u16);
23936        PushXdpAttrs {
23937            prev: Some(self),
23938            header_offset: Some(header_offset),
23939        }
23940    }
23941    pub fn push_event(mut self, value: u32) -> Self {
23942        push_header(self.as_rec_mut(), 44u16, 4 as u16);
23943        self.as_rec_mut().extend(value.to_ne_bytes());
23944        self
23945    }
23946    pub fn push_new_netnsid(mut self, value: i32) -> Self {
23947        push_header(self.as_rec_mut(), 45u16, 4 as u16);
23948        self.as_rec_mut().extend(value.to_ne_bytes());
23949        self
23950    }
23951    pub fn push_target_netnsid(mut self, value: i32) -> Self {
23952        push_header(self.as_rec_mut(), 46u16, 4 as u16);
23953        self.as_rec_mut().extend(value.to_ne_bytes());
23954        self
23955    }
23956    pub fn push_carrier_up_count(mut self, value: u32) -> Self {
23957        push_header(self.as_rec_mut(), 47u16, 4 as u16);
23958        self.as_rec_mut().extend(value.to_ne_bytes());
23959        self
23960    }
23961    pub fn push_carrier_down_count(mut self, value: u32) -> Self {
23962        push_header(self.as_rec_mut(), 48u16, 4 as u16);
23963        self.as_rec_mut().extend(value.to_ne_bytes());
23964        self
23965    }
23966    pub fn push_new_ifindex(mut self, value: i32) -> Self {
23967        push_header(self.as_rec_mut(), 49u16, 4 as u16);
23968        self.as_rec_mut().extend(value.to_ne_bytes());
23969        self
23970    }
23971    pub fn push_min_mtu(mut self, value: u32) -> Self {
23972        push_header(self.as_rec_mut(), 50u16, 4 as u16);
23973        self.as_rec_mut().extend(value.to_ne_bytes());
23974        self
23975    }
23976    pub fn push_max_mtu(mut self, value: u32) -> Self {
23977        push_header(self.as_rec_mut(), 51u16, 4 as u16);
23978        self.as_rec_mut().extend(value.to_ne_bytes());
23979        self
23980    }
23981    pub fn nested_prop_list(mut self) -> PushPropListLinkAttrs<Self> {
23982        let header_offset = push_nested_header(self.as_rec_mut(), 52u16);
23983        PushPropListLinkAttrs {
23984            prev: Some(self),
23985            header_offset: Some(header_offset),
23986        }
23987    }
23988    pub fn push_perm_address(mut self, value: &[u8]) -> Self {
23989        push_header(self.as_rec_mut(), 54u16, value.len() as u16);
23990        self.as_rec_mut().extend(value);
23991        self
23992    }
23993    pub fn push_proto_down_reason(mut self, value: &CStr) -> Self {
23994        push_header(
23995            self.as_rec_mut(),
23996            55u16,
23997            value.to_bytes_with_nul().len() as u16,
23998        );
23999        self.as_rec_mut().extend(value.to_bytes_with_nul());
24000        self
24001    }
24002    pub fn push_proto_down_reason_bytes(mut self, value: &[u8]) -> Self {
24003        push_header(self.as_rec_mut(), 55u16, (value.len() + 1) as u16);
24004        self.as_rec_mut().extend(value);
24005        self.as_rec_mut().push(0);
24006        self
24007    }
24008    pub fn push_parent_dev_name(mut self, value: &CStr) -> Self {
24009        push_header(
24010            self.as_rec_mut(),
24011            56u16,
24012            value.to_bytes_with_nul().len() as u16,
24013        );
24014        self.as_rec_mut().extend(value.to_bytes_with_nul());
24015        self
24016    }
24017    pub fn push_parent_dev_name_bytes(mut self, value: &[u8]) -> Self {
24018        push_header(self.as_rec_mut(), 56u16, (value.len() + 1) as u16);
24019        self.as_rec_mut().extend(value);
24020        self.as_rec_mut().push(0);
24021        self
24022    }
24023    pub fn push_parent_dev_bus_name(mut self, value: &CStr) -> Self {
24024        push_header(
24025            self.as_rec_mut(),
24026            57u16,
24027            value.to_bytes_with_nul().len() as u16,
24028        );
24029        self.as_rec_mut().extend(value.to_bytes_with_nul());
24030        self
24031    }
24032    pub fn push_parent_dev_bus_name_bytes(mut self, value: &[u8]) -> Self {
24033        push_header(self.as_rec_mut(), 57u16, (value.len() + 1) as u16);
24034        self.as_rec_mut().extend(value);
24035        self.as_rec_mut().push(0);
24036        self
24037    }
24038    pub fn push_gro_max_size(mut self, value: u32) -> Self {
24039        push_header(self.as_rec_mut(), 58u16, 4 as u16);
24040        self.as_rec_mut().extend(value.to_ne_bytes());
24041        self
24042    }
24043    pub fn push_tso_max_size(mut self, value: u32) -> Self {
24044        push_header(self.as_rec_mut(), 59u16, 4 as u16);
24045        self.as_rec_mut().extend(value.to_ne_bytes());
24046        self
24047    }
24048    pub fn push_tso_max_segs(mut self, value: u32) -> Self {
24049        push_header(self.as_rec_mut(), 60u16, 4 as u16);
24050        self.as_rec_mut().extend(value.to_ne_bytes());
24051        self
24052    }
24053    pub fn push_allmulti(mut self, value: u32) -> Self {
24054        push_header(self.as_rec_mut(), 61u16, 4 as u16);
24055        self.as_rec_mut().extend(value.to_ne_bytes());
24056        self
24057    }
24058    pub fn push_devlink_port(mut self, value: &[u8]) -> Self {
24059        push_header(self.as_rec_mut(), 62u16, value.len() as u16);
24060        self.as_rec_mut().extend(value);
24061        self
24062    }
24063    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
24064        push_header(self.as_rec_mut(), 63u16, 4 as u16);
24065        self.as_rec_mut().extend(value.to_ne_bytes());
24066        self
24067    }
24068    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
24069        push_header(self.as_rec_mut(), 64u16, 4 as u16);
24070        self.as_rec_mut().extend(value.to_ne_bytes());
24071        self
24072    }
24073    pub fn nested_dpll_pin(mut self) -> PushLinkDpllPinAttrs<Self> {
24074        let header_offset = push_nested_header(self.as_rec_mut(), 65u16);
24075        PushLinkDpllPinAttrs {
24076            prev: Some(self),
24077            header_offset: Some(header_offset),
24078        }
24079    }
24080    #[doc = "EDT offload horizon supported by the device (in nsec)."]
24081    pub fn push_max_pacing_offload_horizon(mut self, value: u32) -> Self {
24082        push_header(self.as_rec_mut(), 66u16, 4 as u16);
24083        self.as_rec_mut().extend(value.to_ne_bytes());
24084        self
24085    }
24086    pub fn push_netns_immutable(mut self, value: u8) -> Self {
24087        push_header(self.as_rec_mut(), 67u16, 1 as u16);
24088        self.as_rec_mut().extend(value.to_ne_bytes());
24089        self
24090    }
24091}
24092impl<Prev: Rec> Drop for PushOpGetlinkDumpReply<Prev> {
24093    fn drop(&mut self) {
24094        if let Some(prev) = &mut self.prev {
24095            if let Some(header_offset) = &self.header_offset {
24096                finalize_nested_header(prev.as_rec_mut(), *header_offset);
24097            }
24098        }
24099    }
24100}
24101#[doc = "Get / dump information about a link."]
24102#[derive(Clone)]
24103pub enum OpGetlinkDumpReply<'a> {
24104    Address(&'a [u8]),
24105    Broadcast(&'a [u8]),
24106    Ifname(&'a CStr),
24107    Mtu(u32),
24108    Link(u32),
24109    Qdisc(&'a CStr),
24110    Stats(PushRtnlLinkStats),
24111    Cost(&'a CStr),
24112    Priority(&'a CStr),
24113    Master(u32),
24114    Wireless(&'a CStr),
24115    Protinfo(&'a CStr),
24116    Txqlen(u32),
24117    Map(PushRtnlLinkIfmap),
24118    Weight(u32),
24119    Operstate(u8),
24120    Linkmode(u8),
24121    Linkinfo(IterableLinkinfoAttrs<'a>),
24122    NetNsPid(u32),
24123    Ifalias(&'a CStr),
24124    NumVf(u32),
24125    VfinfoList(IterableVfinfoListAttrs<'a>),
24126    Stats64(PushRtnlLinkStats64),
24127    VfPorts(IterableVfPortsAttrs<'a>),
24128    PortSelf(IterablePortSelfAttrs<'a>),
24129    AfSpec(IterableAfSpecAttrs<'a>),
24130    Group(u32),
24131    NetNsFd(u32),
24132    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
24133    ExtMask(u32),
24134    Promiscuity(u32),
24135    NumTxQueues(u32),
24136    NumRxQueues(u32),
24137    Carrier(u8),
24138    PhysPortId(&'a [u8]),
24139    CarrierChanges(u32),
24140    PhysSwitchId(&'a [u8]),
24141    LinkNetnsid(i32),
24142    PhysPortName(&'a CStr),
24143    ProtoDown(u8),
24144    GsoMaxSegs(u32),
24145    GsoMaxSize(u32),
24146    Pad(&'a [u8]),
24147    Xdp(IterableXdpAttrs<'a>),
24148    Event(u32),
24149    NewNetnsid(i32),
24150    TargetNetnsid(i32),
24151    CarrierUpCount(u32),
24152    CarrierDownCount(u32),
24153    NewIfindex(i32),
24154    MinMtu(u32),
24155    MaxMtu(u32),
24156    PropList(IterablePropListLinkAttrs<'a>),
24157    PermAddress(&'a [u8]),
24158    ProtoDownReason(&'a CStr),
24159    ParentDevName(&'a CStr),
24160    ParentDevBusName(&'a CStr),
24161    GroMaxSize(u32),
24162    TsoMaxSize(u32),
24163    TsoMaxSegs(u32),
24164    Allmulti(u32),
24165    DevlinkPort(&'a [u8]),
24166    GsoIpv4MaxSize(u32),
24167    GroIpv4MaxSize(u32),
24168    DpllPin(IterableLinkDpllPinAttrs<'a>),
24169    #[doc = "EDT offload horizon supported by the device (in nsec)."]
24170    MaxPacingOffloadHorizon(u32),
24171    NetnsImmutable(u8),
24172}
24173impl<'a> IterableOpGetlinkDumpReply<'a> {
24174    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
24175        let mut iter = self.clone();
24176        iter.pos = 0;
24177        for attr in iter {
24178            if let OpGetlinkDumpReply::Address(val) = attr? {
24179                return Ok(val);
24180            }
24181        }
24182        Err(ErrorContext::new_missing(
24183            "OpGetlinkDumpReply",
24184            "Address",
24185            self.orig_loc,
24186            self.buf.as_ptr() as usize,
24187        ))
24188    }
24189    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
24190        let mut iter = self.clone();
24191        iter.pos = 0;
24192        for attr in iter {
24193            if let OpGetlinkDumpReply::Broadcast(val) = attr? {
24194                return Ok(val);
24195            }
24196        }
24197        Err(ErrorContext::new_missing(
24198            "OpGetlinkDumpReply",
24199            "Broadcast",
24200            self.orig_loc,
24201            self.buf.as_ptr() as usize,
24202        ))
24203    }
24204    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
24205        let mut iter = self.clone();
24206        iter.pos = 0;
24207        for attr in iter {
24208            if let OpGetlinkDumpReply::Ifname(val) = attr? {
24209                return Ok(val);
24210            }
24211        }
24212        Err(ErrorContext::new_missing(
24213            "OpGetlinkDumpReply",
24214            "Ifname",
24215            self.orig_loc,
24216            self.buf.as_ptr() as usize,
24217        ))
24218    }
24219    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
24220        let mut iter = self.clone();
24221        iter.pos = 0;
24222        for attr in iter {
24223            if let OpGetlinkDumpReply::Mtu(val) = attr? {
24224                return Ok(val);
24225            }
24226        }
24227        Err(ErrorContext::new_missing(
24228            "OpGetlinkDumpReply",
24229            "Mtu",
24230            self.orig_loc,
24231            self.buf.as_ptr() as usize,
24232        ))
24233    }
24234    pub fn get_link(&self) -> Result<u32, ErrorContext> {
24235        let mut iter = self.clone();
24236        iter.pos = 0;
24237        for attr in iter {
24238            if let OpGetlinkDumpReply::Link(val) = attr? {
24239                return Ok(val);
24240            }
24241        }
24242        Err(ErrorContext::new_missing(
24243            "OpGetlinkDumpReply",
24244            "Link",
24245            self.orig_loc,
24246            self.buf.as_ptr() as usize,
24247        ))
24248    }
24249    pub fn get_qdisc(&self) -> Result<&'a CStr, ErrorContext> {
24250        let mut iter = self.clone();
24251        iter.pos = 0;
24252        for attr in iter {
24253            if let OpGetlinkDumpReply::Qdisc(val) = attr? {
24254                return Ok(val);
24255            }
24256        }
24257        Err(ErrorContext::new_missing(
24258            "OpGetlinkDumpReply",
24259            "Qdisc",
24260            self.orig_loc,
24261            self.buf.as_ptr() as usize,
24262        ))
24263    }
24264    pub fn get_stats(&self) -> Result<PushRtnlLinkStats, ErrorContext> {
24265        let mut iter = self.clone();
24266        iter.pos = 0;
24267        for attr in iter {
24268            if let OpGetlinkDumpReply::Stats(val) = attr? {
24269                return Ok(val);
24270            }
24271        }
24272        Err(ErrorContext::new_missing(
24273            "OpGetlinkDumpReply",
24274            "Stats",
24275            self.orig_loc,
24276            self.buf.as_ptr() as usize,
24277        ))
24278    }
24279    pub fn get_cost(&self) -> Result<&'a CStr, ErrorContext> {
24280        let mut iter = self.clone();
24281        iter.pos = 0;
24282        for attr in iter {
24283            if let OpGetlinkDumpReply::Cost(val) = attr? {
24284                return Ok(val);
24285            }
24286        }
24287        Err(ErrorContext::new_missing(
24288            "OpGetlinkDumpReply",
24289            "Cost",
24290            self.orig_loc,
24291            self.buf.as_ptr() as usize,
24292        ))
24293    }
24294    pub fn get_priority(&self) -> Result<&'a CStr, ErrorContext> {
24295        let mut iter = self.clone();
24296        iter.pos = 0;
24297        for attr in iter {
24298            if let OpGetlinkDumpReply::Priority(val) = attr? {
24299                return Ok(val);
24300            }
24301        }
24302        Err(ErrorContext::new_missing(
24303            "OpGetlinkDumpReply",
24304            "Priority",
24305            self.orig_loc,
24306            self.buf.as_ptr() as usize,
24307        ))
24308    }
24309    pub fn get_master(&self) -> Result<u32, ErrorContext> {
24310        let mut iter = self.clone();
24311        iter.pos = 0;
24312        for attr in iter {
24313            if let OpGetlinkDumpReply::Master(val) = attr? {
24314                return Ok(val);
24315            }
24316        }
24317        Err(ErrorContext::new_missing(
24318            "OpGetlinkDumpReply",
24319            "Master",
24320            self.orig_loc,
24321            self.buf.as_ptr() as usize,
24322        ))
24323    }
24324    pub fn get_wireless(&self) -> Result<&'a CStr, ErrorContext> {
24325        let mut iter = self.clone();
24326        iter.pos = 0;
24327        for attr in iter {
24328            if let OpGetlinkDumpReply::Wireless(val) = attr? {
24329                return Ok(val);
24330            }
24331        }
24332        Err(ErrorContext::new_missing(
24333            "OpGetlinkDumpReply",
24334            "Wireless",
24335            self.orig_loc,
24336            self.buf.as_ptr() as usize,
24337        ))
24338    }
24339    pub fn get_protinfo(&self) -> Result<&'a CStr, ErrorContext> {
24340        let mut iter = self.clone();
24341        iter.pos = 0;
24342        for attr in iter {
24343            if let OpGetlinkDumpReply::Protinfo(val) = attr? {
24344                return Ok(val);
24345            }
24346        }
24347        Err(ErrorContext::new_missing(
24348            "OpGetlinkDumpReply",
24349            "Protinfo",
24350            self.orig_loc,
24351            self.buf.as_ptr() as usize,
24352        ))
24353    }
24354    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
24355        let mut iter = self.clone();
24356        iter.pos = 0;
24357        for attr in iter {
24358            if let OpGetlinkDumpReply::Txqlen(val) = attr? {
24359                return Ok(val);
24360            }
24361        }
24362        Err(ErrorContext::new_missing(
24363            "OpGetlinkDumpReply",
24364            "Txqlen",
24365            self.orig_loc,
24366            self.buf.as_ptr() as usize,
24367        ))
24368    }
24369    pub fn get_map(&self) -> Result<PushRtnlLinkIfmap, ErrorContext> {
24370        let mut iter = self.clone();
24371        iter.pos = 0;
24372        for attr in iter {
24373            if let OpGetlinkDumpReply::Map(val) = attr? {
24374                return Ok(val);
24375            }
24376        }
24377        Err(ErrorContext::new_missing(
24378            "OpGetlinkDumpReply",
24379            "Map",
24380            self.orig_loc,
24381            self.buf.as_ptr() as usize,
24382        ))
24383    }
24384    pub fn get_weight(&self) -> Result<u32, ErrorContext> {
24385        let mut iter = self.clone();
24386        iter.pos = 0;
24387        for attr in iter {
24388            if let OpGetlinkDumpReply::Weight(val) = attr? {
24389                return Ok(val);
24390            }
24391        }
24392        Err(ErrorContext::new_missing(
24393            "OpGetlinkDumpReply",
24394            "Weight",
24395            self.orig_loc,
24396            self.buf.as_ptr() as usize,
24397        ))
24398    }
24399    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
24400        let mut iter = self.clone();
24401        iter.pos = 0;
24402        for attr in iter {
24403            if let OpGetlinkDumpReply::Operstate(val) = attr? {
24404                return Ok(val);
24405            }
24406        }
24407        Err(ErrorContext::new_missing(
24408            "OpGetlinkDumpReply",
24409            "Operstate",
24410            self.orig_loc,
24411            self.buf.as_ptr() as usize,
24412        ))
24413    }
24414    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
24415        let mut iter = self.clone();
24416        iter.pos = 0;
24417        for attr in iter {
24418            if let OpGetlinkDumpReply::Linkmode(val) = attr? {
24419                return Ok(val);
24420            }
24421        }
24422        Err(ErrorContext::new_missing(
24423            "OpGetlinkDumpReply",
24424            "Linkmode",
24425            self.orig_loc,
24426            self.buf.as_ptr() as usize,
24427        ))
24428    }
24429    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
24430        let mut iter = self.clone();
24431        iter.pos = 0;
24432        for attr in iter {
24433            if let OpGetlinkDumpReply::Linkinfo(val) = attr? {
24434                return Ok(val);
24435            }
24436        }
24437        Err(ErrorContext::new_missing(
24438            "OpGetlinkDumpReply",
24439            "Linkinfo",
24440            self.orig_loc,
24441            self.buf.as_ptr() as usize,
24442        ))
24443    }
24444    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
24445        let mut iter = self.clone();
24446        iter.pos = 0;
24447        for attr in iter {
24448            if let OpGetlinkDumpReply::NetNsPid(val) = attr? {
24449                return Ok(val);
24450            }
24451        }
24452        Err(ErrorContext::new_missing(
24453            "OpGetlinkDumpReply",
24454            "NetNsPid",
24455            self.orig_loc,
24456            self.buf.as_ptr() as usize,
24457        ))
24458    }
24459    pub fn get_ifalias(&self) -> Result<&'a CStr, ErrorContext> {
24460        let mut iter = self.clone();
24461        iter.pos = 0;
24462        for attr in iter {
24463            if let OpGetlinkDumpReply::Ifalias(val) = attr? {
24464                return Ok(val);
24465            }
24466        }
24467        Err(ErrorContext::new_missing(
24468            "OpGetlinkDumpReply",
24469            "Ifalias",
24470            self.orig_loc,
24471            self.buf.as_ptr() as usize,
24472        ))
24473    }
24474    pub fn get_num_vf(&self) -> Result<u32, ErrorContext> {
24475        let mut iter = self.clone();
24476        iter.pos = 0;
24477        for attr in iter {
24478            if let OpGetlinkDumpReply::NumVf(val) = attr? {
24479                return Ok(val);
24480            }
24481        }
24482        Err(ErrorContext::new_missing(
24483            "OpGetlinkDumpReply",
24484            "NumVf",
24485            self.orig_loc,
24486            self.buf.as_ptr() as usize,
24487        ))
24488    }
24489    pub fn get_vfinfo_list(&self) -> Result<IterableVfinfoListAttrs<'a>, ErrorContext> {
24490        let mut iter = self.clone();
24491        iter.pos = 0;
24492        for attr in iter {
24493            if let OpGetlinkDumpReply::VfinfoList(val) = attr? {
24494                return Ok(val);
24495            }
24496        }
24497        Err(ErrorContext::new_missing(
24498            "OpGetlinkDumpReply",
24499            "VfinfoList",
24500            self.orig_loc,
24501            self.buf.as_ptr() as usize,
24502        ))
24503    }
24504    pub fn get_stats64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
24505        let mut iter = self.clone();
24506        iter.pos = 0;
24507        for attr in iter {
24508            if let OpGetlinkDumpReply::Stats64(val) = attr? {
24509                return Ok(val);
24510            }
24511        }
24512        Err(ErrorContext::new_missing(
24513            "OpGetlinkDumpReply",
24514            "Stats64",
24515            self.orig_loc,
24516            self.buf.as_ptr() as usize,
24517        ))
24518    }
24519    pub fn get_vf_ports(&self) -> Result<IterableVfPortsAttrs<'a>, ErrorContext> {
24520        let mut iter = self.clone();
24521        iter.pos = 0;
24522        for attr in iter {
24523            if let OpGetlinkDumpReply::VfPorts(val) = attr? {
24524                return Ok(val);
24525            }
24526        }
24527        Err(ErrorContext::new_missing(
24528            "OpGetlinkDumpReply",
24529            "VfPorts",
24530            self.orig_loc,
24531            self.buf.as_ptr() as usize,
24532        ))
24533    }
24534    pub fn get_port_self(&self) -> Result<IterablePortSelfAttrs<'a>, ErrorContext> {
24535        let mut iter = self.clone();
24536        iter.pos = 0;
24537        for attr in iter {
24538            if let OpGetlinkDumpReply::PortSelf(val) = attr? {
24539                return Ok(val);
24540            }
24541        }
24542        Err(ErrorContext::new_missing(
24543            "OpGetlinkDumpReply",
24544            "PortSelf",
24545            self.orig_loc,
24546            self.buf.as_ptr() as usize,
24547        ))
24548    }
24549    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
24550        let mut iter = self.clone();
24551        iter.pos = 0;
24552        for attr in iter {
24553            if let OpGetlinkDumpReply::AfSpec(val) = attr? {
24554                return Ok(val);
24555            }
24556        }
24557        Err(ErrorContext::new_missing(
24558            "OpGetlinkDumpReply",
24559            "AfSpec",
24560            self.orig_loc,
24561            self.buf.as_ptr() as usize,
24562        ))
24563    }
24564    pub fn get_group(&self) -> Result<u32, ErrorContext> {
24565        let mut iter = self.clone();
24566        iter.pos = 0;
24567        for attr in iter {
24568            if let OpGetlinkDumpReply::Group(val) = attr? {
24569                return Ok(val);
24570            }
24571        }
24572        Err(ErrorContext::new_missing(
24573            "OpGetlinkDumpReply",
24574            "Group",
24575            self.orig_loc,
24576            self.buf.as_ptr() as usize,
24577        ))
24578    }
24579    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
24580        let mut iter = self.clone();
24581        iter.pos = 0;
24582        for attr in iter {
24583            if let OpGetlinkDumpReply::NetNsFd(val) = attr? {
24584                return Ok(val);
24585            }
24586        }
24587        Err(ErrorContext::new_missing(
24588            "OpGetlinkDumpReply",
24589            "NetNsFd",
24590            self.orig_loc,
24591            self.buf.as_ptr() as usize,
24592        ))
24593    }
24594    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
24595    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
24596        let mut iter = self.clone();
24597        iter.pos = 0;
24598        for attr in iter {
24599            if let OpGetlinkDumpReply::ExtMask(val) = attr? {
24600                return Ok(val);
24601            }
24602        }
24603        Err(ErrorContext::new_missing(
24604            "OpGetlinkDumpReply",
24605            "ExtMask",
24606            self.orig_loc,
24607            self.buf.as_ptr() as usize,
24608        ))
24609    }
24610    pub fn get_promiscuity(&self) -> Result<u32, ErrorContext> {
24611        let mut iter = self.clone();
24612        iter.pos = 0;
24613        for attr in iter {
24614            if let OpGetlinkDumpReply::Promiscuity(val) = attr? {
24615                return Ok(val);
24616            }
24617        }
24618        Err(ErrorContext::new_missing(
24619            "OpGetlinkDumpReply",
24620            "Promiscuity",
24621            self.orig_loc,
24622            self.buf.as_ptr() as usize,
24623        ))
24624    }
24625    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
24626        let mut iter = self.clone();
24627        iter.pos = 0;
24628        for attr in iter {
24629            if let OpGetlinkDumpReply::NumTxQueues(val) = attr? {
24630                return Ok(val);
24631            }
24632        }
24633        Err(ErrorContext::new_missing(
24634            "OpGetlinkDumpReply",
24635            "NumTxQueues",
24636            self.orig_loc,
24637            self.buf.as_ptr() as usize,
24638        ))
24639    }
24640    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
24641        let mut iter = self.clone();
24642        iter.pos = 0;
24643        for attr in iter {
24644            if let OpGetlinkDumpReply::NumRxQueues(val) = attr? {
24645                return Ok(val);
24646            }
24647        }
24648        Err(ErrorContext::new_missing(
24649            "OpGetlinkDumpReply",
24650            "NumRxQueues",
24651            self.orig_loc,
24652            self.buf.as_ptr() as usize,
24653        ))
24654    }
24655    pub fn get_carrier(&self) -> Result<u8, ErrorContext> {
24656        let mut iter = self.clone();
24657        iter.pos = 0;
24658        for attr in iter {
24659            if let OpGetlinkDumpReply::Carrier(val) = attr? {
24660                return Ok(val);
24661            }
24662        }
24663        Err(ErrorContext::new_missing(
24664            "OpGetlinkDumpReply",
24665            "Carrier",
24666            self.orig_loc,
24667            self.buf.as_ptr() as usize,
24668        ))
24669    }
24670    pub fn get_phys_port_id(&self) -> Result<&'a [u8], ErrorContext> {
24671        let mut iter = self.clone();
24672        iter.pos = 0;
24673        for attr in iter {
24674            if let OpGetlinkDumpReply::PhysPortId(val) = attr? {
24675                return Ok(val);
24676            }
24677        }
24678        Err(ErrorContext::new_missing(
24679            "OpGetlinkDumpReply",
24680            "PhysPortId",
24681            self.orig_loc,
24682            self.buf.as_ptr() as usize,
24683        ))
24684    }
24685    pub fn get_carrier_changes(&self) -> Result<u32, ErrorContext> {
24686        let mut iter = self.clone();
24687        iter.pos = 0;
24688        for attr in iter {
24689            if let OpGetlinkDumpReply::CarrierChanges(val) = attr? {
24690                return Ok(val);
24691            }
24692        }
24693        Err(ErrorContext::new_missing(
24694            "OpGetlinkDumpReply",
24695            "CarrierChanges",
24696            self.orig_loc,
24697            self.buf.as_ptr() as usize,
24698        ))
24699    }
24700    pub fn get_phys_switch_id(&self) -> Result<&'a [u8], ErrorContext> {
24701        let mut iter = self.clone();
24702        iter.pos = 0;
24703        for attr in iter {
24704            if let OpGetlinkDumpReply::PhysSwitchId(val) = attr? {
24705                return Ok(val);
24706            }
24707        }
24708        Err(ErrorContext::new_missing(
24709            "OpGetlinkDumpReply",
24710            "PhysSwitchId",
24711            self.orig_loc,
24712            self.buf.as_ptr() as usize,
24713        ))
24714    }
24715    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
24716        let mut iter = self.clone();
24717        iter.pos = 0;
24718        for attr in iter {
24719            if let OpGetlinkDumpReply::LinkNetnsid(val) = attr? {
24720                return Ok(val);
24721            }
24722        }
24723        Err(ErrorContext::new_missing(
24724            "OpGetlinkDumpReply",
24725            "LinkNetnsid",
24726            self.orig_loc,
24727            self.buf.as_ptr() as usize,
24728        ))
24729    }
24730    pub fn get_phys_port_name(&self) -> Result<&'a CStr, ErrorContext> {
24731        let mut iter = self.clone();
24732        iter.pos = 0;
24733        for attr in iter {
24734            if let OpGetlinkDumpReply::PhysPortName(val) = attr? {
24735                return Ok(val);
24736            }
24737        }
24738        Err(ErrorContext::new_missing(
24739            "OpGetlinkDumpReply",
24740            "PhysPortName",
24741            self.orig_loc,
24742            self.buf.as_ptr() as usize,
24743        ))
24744    }
24745    pub fn get_proto_down(&self) -> Result<u8, ErrorContext> {
24746        let mut iter = self.clone();
24747        iter.pos = 0;
24748        for attr in iter {
24749            if let OpGetlinkDumpReply::ProtoDown(val) = attr? {
24750                return Ok(val);
24751            }
24752        }
24753        Err(ErrorContext::new_missing(
24754            "OpGetlinkDumpReply",
24755            "ProtoDown",
24756            self.orig_loc,
24757            self.buf.as_ptr() as usize,
24758        ))
24759    }
24760    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
24761        let mut iter = self.clone();
24762        iter.pos = 0;
24763        for attr in iter {
24764            if let OpGetlinkDumpReply::GsoMaxSegs(val) = attr? {
24765                return Ok(val);
24766            }
24767        }
24768        Err(ErrorContext::new_missing(
24769            "OpGetlinkDumpReply",
24770            "GsoMaxSegs",
24771            self.orig_loc,
24772            self.buf.as_ptr() as usize,
24773        ))
24774    }
24775    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
24776        let mut iter = self.clone();
24777        iter.pos = 0;
24778        for attr in iter {
24779            if let OpGetlinkDumpReply::GsoMaxSize(val) = attr? {
24780                return Ok(val);
24781            }
24782        }
24783        Err(ErrorContext::new_missing(
24784            "OpGetlinkDumpReply",
24785            "GsoMaxSize",
24786            self.orig_loc,
24787            self.buf.as_ptr() as usize,
24788        ))
24789    }
24790    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
24791        let mut iter = self.clone();
24792        iter.pos = 0;
24793        for attr in iter {
24794            if let OpGetlinkDumpReply::Pad(val) = attr? {
24795                return Ok(val);
24796            }
24797        }
24798        Err(ErrorContext::new_missing(
24799            "OpGetlinkDumpReply",
24800            "Pad",
24801            self.orig_loc,
24802            self.buf.as_ptr() as usize,
24803        ))
24804    }
24805    pub fn get_xdp(&self) -> Result<IterableXdpAttrs<'a>, ErrorContext> {
24806        let mut iter = self.clone();
24807        iter.pos = 0;
24808        for attr in iter {
24809            if let OpGetlinkDumpReply::Xdp(val) = attr? {
24810                return Ok(val);
24811            }
24812        }
24813        Err(ErrorContext::new_missing(
24814            "OpGetlinkDumpReply",
24815            "Xdp",
24816            self.orig_loc,
24817            self.buf.as_ptr() as usize,
24818        ))
24819    }
24820    pub fn get_event(&self) -> Result<u32, ErrorContext> {
24821        let mut iter = self.clone();
24822        iter.pos = 0;
24823        for attr in iter {
24824            if let OpGetlinkDumpReply::Event(val) = attr? {
24825                return Ok(val);
24826            }
24827        }
24828        Err(ErrorContext::new_missing(
24829            "OpGetlinkDumpReply",
24830            "Event",
24831            self.orig_loc,
24832            self.buf.as_ptr() as usize,
24833        ))
24834    }
24835    pub fn get_new_netnsid(&self) -> Result<i32, ErrorContext> {
24836        let mut iter = self.clone();
24837        iter.pos = 0;
24838        for attr in iter {
24839            if let OpGetlinkDumpReply::NewNetnsid(val) = attr? {
24840                return Ok(val);
24841            }
24842        }
24843        Err(ErrorContext::new_missing(
24844            "OpGetlinkDumpReply",
24845            "NewNetnsid",
24846            self.orig_loc,
24847            self.buf.as_ptr() as usize,
24848        ))
24849    }
24850    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
24851        let mut iter = self.clone();
24852        iter.pos = 0;
24853        for attr in iter {
24854            if let OpGetlinkDumpReply::TargetNetnsid(val) = attr? {
24855                return Ok(val);
24856            }
24857        }
24858        Err(ErrorContext::new_missing(
24859            "OpGetlinkDumpReply",
24860            "TargetNetnsid",
24861            self.orig_loc,
24862            self.buf.as_ptr() as usize,
24863        ))
24864    }
24865    pub fn get_carrier_up_count(&self) -> Result<u32, ErrorContext> {
24866        let mut iter = self.clone();
24867        iter.pos = 0;
24868        for attr in iter {
24869            if let OpGetlinkDumpReply::CarrierUpCount(val) = attr? {
24870                return Ok(val);
24871            }
24872        }
24873        Err(ErrorContext::new_missing(
24874            "OpGetlinkDumpReply",
24875            "CarrierUpCount",
24876            self.orig_loc,
24877            self.buf.as_ptr() as usize,
24878        ))
24879    }
24880    pub fn get_carrier_down_count(&self) -> Result<u32, ErrorContext> {
24881        let mut iter = self.clone();
24882        iter.pos = 0;
24883        for attr in iter {
24884            if let OpGetlinkDumpReply::CarrierDownCount(val) = attr? {
24885                return Ok(val);
24886            }
24887        }
24888        Err(ErrorContext::new_missing(
24889            "OpGetlinkDumpReply",
24890            "CarrierDownCount",
24891            self.orig_loc,
24892            self.buf.as_ptr() as usize,
24893        ))
24894    }
24895    pub fn get_new_ifindex(&self) -> Result<i32, ErrorContext> {
24896        let mut iter = self.clone();
24897        iter.pos = 0;
24898        for attr in iter {
24899            if let OpGetlinkDumpReply::NewIfindex(val) = attr? {
24900                return Ok(val);
24901            }
24902        }
24903        Err(ErrorContext::new_missing(
24904            "OpGetlinkDumpReply",
24905            "NewIfindex",
24906            self.orig_loc,
24907            self.buf.as_ptr() as usize,
24908        ))
24909    }
24910    pub fn get_min_mtu(&self) -> Result<u32, ErrorContext> {
24911        let mut iter = self.clone();
24912        iter.pos = 0;
24913        for attr in iter {
24914            if let OpGetlinkDumpReply::MinMtu(val) = attr? {
24915                return Ok(val);
24916            }
24917        }
24918        Err(ErrorContext::new_missing(
24919            "OpGetlinkDumpReply",
24920            "MinMtu",
24921            self.orig_loc,
24922            self.buf.as_ptr() as usize,
24923        ))
24924    }
24925    pub fn get_max_mtu(&self) -> Result<u32, ErrorContext> {
24926        let mut iter = self.clone();
24927        iter.pos = 0;
24928        for attr in iter {
24929            if let OpGetlinkDumpReply::MaxMtu(val) = attr? {
24930                return Ok(val);
24931            }
24932        }
24933        Err(ErrorContext::new_missing(
24934            "OpGetlinkDumpReply",
24935            "MaxMtu",
24936            self.orig_loc,
24937            self.buf.as_ptr() as usize,
24938        ))
24939    }
24940    pub fn get_prop_list(&self) -> Result<IterablePropListLinkAttrs<'a>, ErrorContext> {
24941        let mut iter = self.clone();
24942        iter.pos = 0;
24943        for attr in iter {
24944            if let OpGetlinkDumpReply::PropList(val) = attr? {
24945                return Ok(val);
24946            }
24947        }
24948        Err(ErrorContext::new_missing(
24949            "OpGetlinkDumpReply",
24950            "PropList",
24951            self.orig_loc,
24952            self.buf.as_ptr() as usize,
24953        ))
24954    }
24955    pub fn get_perm_address(&self) -> Result<&'a [u8], ErrorContext> {
24956        let mut iter = self.clone();
24957        iter.pos = 0;
24958        for attr in iter {
24959            if let OpGetlinkDumpReply::PermAddress(val) = attr? {
24960                return Ok(val);
24961            }
24962        }
24963        Err(ErrorContext::new_missing(
24964            "OpGetlinkDumpReply",
24965            "PermAddress",
24966            self.orig_loc,
24967            self.buf.as_ptr() as usize,
24968        ))
24969    }
24970    pub fn get_proto_down_reason(&self) -> Result<&'a CStr, ErrorContext> {
24971        let mut iter = self.clone();
24972        iter.pos = 0;
24973        for attr in iter {
24974            if let OpGetlinkDumpReply::ProtoDownReason(val) = attr? {
24975                return Ok(val);
24976            }
24977        }
24978        Err(ErrorContext::new_missing(
24979            "OpGetlinkDumpReply",
24980            "ProtoDownReason",
24981            self.orig_loc,
24982            self.buf.as_ptr() as usize,
24983        ))
24984    }
24985    pub fn get_parent_dev_name(&self) -> Result<&'a CStr, ErrorContext> {
24986        let mut iter = self.clone();
24987        iter.pos = 0;
24988        for attr in iter {
24989            if let OpGetlinkDumpReply::ParentDevName(val) = attr? {
24990                return Ok(val);
24991            }
24992        }
24993        Err(ErrorContext::new_missing(
24994            "OpGetlinkDumpReply",
24995            "ParentDevName",
24996            self.orig_loc,
24997            self.buf.as_ptr() as usize,
24998        ))
24999    }
25000    pub fn get_parent_dev_bus_name(&self) -> Result<&'a CStr, ErrorContext> {
25001        let mut iter = self.clone();
25002        iter.pos = 0;
25003        for attr in iter {
25004            if let OpGetlinkDumpReply::ParentDevBusName(val) = attr? {
25005                return Ok(val);
25006            }
25007        }
25008        Err(ErrorContext::new_missing(
25009            "OpGetlinkDumpReply",
25010            "ParentDevBusName",
25011            self.orig_loc,
25012            self.buf.as_ptr() as usize,
25013        ))
25014    }
25015    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
25016        let mut iter = self.clone();
25017        iter.pos = 0;
25018        for attr in iter {
25019            if let OpGetlinkDumpReply::GroMaxSize(val) = attr? {
25020                return Ok(val);
25021            }
25022        }
25023        Err(ErrorContext::new_missing(
25024            "OpGetlinkDumpReply",
25025            "GroMaxSize",
25026            self.orig_loc,
25027            self.buf.as_ptr() as usize,
25028        ))
25029    }
25030    pub fn get_tso_max_size(&self) -> Result<u32, ErrorContext> {
25031        let mut iter = self.clone();
25032        iter.pos = 0;
25033        for attr in iter {
25034            if let OpGetlinkDumpReply::TsoMaxSize(val) = attr? {
25035                return Ok(val);
25036            }
25037        }
25038        Err(ErrorContext::new_missing(
25039            "OpGetlinkDumpReply",
25040            "TsoMaxSize",
25041            self.orig_loc,
25042            self.buf.as_ptr() as usize,
25043        ))
25044    }
25045    pub fn get_tso_max_segs(&self) -> Result<u32, ErrorContext> {
25046        let mut iter = self.clone();
25047        iter.pos = 0;
25048        for attr in iter {
25049            if let OpGetlinkDumpReply::TsoMaxSegs(val) = attr? {
25050                return Ok(val);
25051            }
25052        }
25053        Err(ErrorContext::new_missing(
25054            "OpGetlinkDumpReply",
25055            "TsoMaxSegs",
25056            self.orig_loc,
25057            self.buf.as_ptr() as usize,
25058        ))
25059    }
25060    pub fn get_allmulti(&self) -> Result<u32, ErrorContext> {
25061        let mut iter = self.clone();
25062        iter.pos = 0;
25063        for attr in iter {
25064            if let OpGetlinkDumpReply::Allmulti(val) = attr? {
25065                return Ok(val);
25066            }
25067        }
25068        Err(ErrorContext::new_missing(
25069            "OpGetlinkDumpReply",
25070            "Allmulti",
25071            self.orig_loc,
25072            self.buf.as_ptr() as usize,
25073        ))
25074    }
25075    pub fn get_devlink_port(&self) -> Result<&'a [u8], ErrorContext> {
25076        let mut iter = self.clone();
25077        iter.pos = 0;
25078        for attr in iter {
25079            if let OpGetlinkDumpReply::DevlinkPort(val) = attr? {
25080                return Ok(val);
25081            }
25082        }
25083        Err(ErrorContext::new_missing(
25084            "OpGetlinkDumpReply",
25085            "DevlinkPort",
25086            self.orig_loc,
25087            self.buf.as_ptr() as usize,
25088        ))
25089    }
25090    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
25091        let mut iter = self.clone();
25092        iter.pos = 0;
25093        for attr in iter {
25094            if let OpGetlinkDumpReply::GsoIpv4MaxSize(val) = attr? {
25095                return Ok(val);
25096            }
25097        }
25098        Err(ErrorContext::new_missing(
25099            "OpGetlinkDumpReply",
25100            "GsoIpv4MaxSize",
25101            self.orig_loc,
25102            self.buf.as_ptr() as usize,
25103        ))
25104    }
25105    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
25106        let mut iter = self.clone();
25107        iter.pos = 0;
25108        for attr in iter {
25109            if let OpGetlinkDumpReply::GroIpv4MaxSize(val) = attr? {
25110                return Ok(val);
25111            }
25112        }
25113        Err(ErrorContext::new_missing(
25114            "OpGetlinkDumpReply",
25115            "GroIpv4MaxSize",
25116            self.orig_loc,
25117            self.buf.as_ptr() as usize,
25118        ))
25119    }
25120    pub fn get_dpll_pin(&self) -> Result<IterableLinkDpllPinAttrs<'a>, ErrorContext> {
25121        let mut iter = self.clone();
25122        iter.pos = 0;
25123        for attr in iter {
25124            if let OpGetlinkDumpReply::DpllPin(val) = attr? {
25125                return Ok(val);
25126            }
25127        }
25128        Err(ErrorContext::new_missing(
25129            "OpGetlinkDumpReply",
25130            "DpllPin",
25131            self.orig_loc,
25132            self.buf.as_ptr() as usize,
25133        ))
25134    }
25135    #[doc = "EDT offload horizon supported by the device (in nsec)."]
25136    pub fn get_max_pacing_offload_horizon(&self) -> Result<u32, ErrorContext> {
25137        let mut iter = self.clone();
25138        iter.pos = 0;
25139        for attr in iter {
25140            if let OpGetlinkDumpReply::MaxPacingOffloadHorizon(val) = attr? {
25141                return Ok(val);
25142            }
25143        }
25144        Err(ErrorContext::new_missing(
25145            "OpGetlinkDumpReply",
25146            "MaxPacingOffloadHorizon",
25147            self.orig_loc,
25148            self.buf.as_ptr() as usize,
25149        ))
25150    }
25151    pub fn get_netns_immutable(&self) -> Result<u8, ErrorContext> {
25152        let mut iter = self.clone();
25153        iter.pos = 0;
25154        for attr in iter {
25155            if let OpGetlinkDumpReply::NetnsImmutable(val) = attr? {
25156                return Ok(val);
25157            }
25158        }
25159        Err(ErrorContext::new_missing(
25160            "OpGetlinkDumpReply",
25161            "NetnsImmutable",
25162            self.orig_loc,
25163            self.buf.as_ptr() as usize,
25164        ))
25165    }
25166}
25167impl<'a> OpGetlinkDumpReply<'a> {
25168    pub fn new(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpGetlinkDumpReply<'a>) {
25169        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
25170        (
25171            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
25172            IterableOpGetlinkDumpReply::with_loc(attrs, buf.as_ptr() as usize),
25173        )
25174    }
25175    fn attr_from_type(r#type: u16) -> Option<&'static str> {
25176        LinkAttrs::attr_from_type(r#type)
25177    }
25178}
25179#[derive(Clone, Copy, Default)]
25180pub struct IterableOpGetlinkDumpReply<'a> {
25181    buf: &'a [u8],
25182    pos: usize,
25183    orig_loc: usize,
25184}
25185impl<'a> IterableOpGetlinkDumpReply<'a> {
25186    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
25187        Self {
25188            buf,
25189            pos: 0,
25190            orig_loc,
25191        }
25192    }
25193    pub fn get_buf(&self) -> &'a [u8] {
25194        self.buf
25195    }
25196}
25197impl<'a> Iterator for IterableOpGetlinkDumpReply<'a> {
25198    type Item = Result<OpGetlinkDumpReply<'a>, ErrorContext>;
25199    fn next(&mut self) -> Option<Self::Item> {
25200        if self.buf.len() == self.pos {
25201            return None;
25202        }
25203        let pos = self.pos;
25204        let mut r#type = None;
25205        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
25206            r#type = Some(header.r#type);
25207            let res = match header.r#type {
25208                1u16 => OpGetlinkDumpReply::Address({
25209                    let res = Some(next);
25210                    let Some(val) = res else { break };
25211                    val
25212                }),
25213                2u16 => OpGetlinkDumpReply::Broadcast({
25214                    let res = Some(next);
25215                    let Some(val) = res else { break };
25216                    val
25217                }),
25218                3u16 => OpGetlinkDumpReply::Ifname({
25219                    let res = CStr::from_bytes_with_nul(next).ok();
25220                    let Some(val) = res else { break };
25221                    val
25222                }),
25223                4u16 => OpGetlinkDumpReply::Mtu({
25224                    let res = parse_u32(next);
25225                    let Some(val) = res else { break };
25226                    val
25227                }),
25228                5u16 => OpGetlinkDumpReply::Link({
25229                    let res = parse_u32(next);
25230                    let Some(val) = res else { break };
25231                    val
25232                }),
25233                6u16 => OpGetlinkDumpReply::Qdisc({
25234                    let res = CStr::from_bytes_with_nul(next).ok();
25235                    let Some(val) = res else { break };
25236                    val
25237                }),
25238                7u16 => OpGetlinkDumpReply::Stats({
25239                    let res = PushRtnlLinkStats::new_from_slice(next);
25240                    let Some(val) = res else { break };
25241                    val
25242                }),
25243                8u16 => OpGetlinkDumpReply::Cost({
25244                    let res = CStr::from_bytes_with_nul(next).ok();
25245                    let Some(val) = res else { break };
25246                    val
25247                }),
25248                9u16 => OpGetlinkDumpReply::Priority({
25249                    let res = CStr::from_bytes_with_nul(next).ok();
25250                    let Some(val) = res else { break };
25251                    val
25252                }),
25253                10u16 => OpGetlinkDumpReply::Master({
25254                    let res = parse_u32(next);
25255                    let Some(val) = res else { break };
25256                    val
25257                }),
25258                11u16 => OpGetlinkDumpReply::Wireless({
25259                    let res = CStr::from_bytes_with_nul(next).ok();
25260                    let Some(val) = res else { break };
25261                    val
25262                }),
25263                12u16 => OpGetlinkDumpReply::Protinfo({
25264                    let res = CStr::from_bytes_with_nul(next).ok();
25265                    let Some(val) = res else { break };
25266                    val
25267                }),
25268                13u16 => OpGetlinkDumpReply::Txqlen({
25269                    let res = parse_u32(next);
25270                    let Some(val) = res else { break };
25271                    val
25272                }),
25273                14u16 => OpGetlinkDumpReply::Map({
25274                    let res = PushRtnlLinkIfmap::new_from_slice(next);
25275                    let Some(val) = res else { break };
25276                    val
25277                }),
25278                15u16 => OpGetlinkDumpReply::Weight({
25279                    let res = parse_u32(next);
25280                    let Some(val) = res else { break };
25281                    val
25282                }),
25283                16u16 => OpGetlinkDumpReply::Operstate({
25284                    let res = parse_u8(next);
25285                    let Some(val) = res else { break };
25286                    val
25287                }),
25288                17u16 => OpGetlinkDumpReply::Linkmode({
25289                    let res = parse_u8(next);
25290                    let Some(val) = res else { break };
25291                    val
25292                }),
25293                18u16 => OpGetlinkDumpReply::Linkinfo({
25294                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
25295                    let Some(val) = res else { break };
25296                    val
25297                }),
25298                19u16 => OpGetlinkDumpReply::NetNsPid({
25299                    let res = parse_u32(next);
25300                    let Some(val) = res else { break };
25301                    val
25302                }),
25303                20u16 => OpGetlinkDumpReply::Ifalias({
25304                    let res = CStr::from_bytes_with_nul(next).ok();
25305                    let Some(val) = res else { break };
25306                    val
25307                }),
25308                21u16 => OpGetlinkDumpReply::NumVf({
25309                    let res = parse_u32(next);
25310                    let Some(val) = res else { break };
25311                    val
25312                }),
25313                22u16 => OpGetlinkDumpReply::VfinfoList({
25314                    let res = Some(IterableVfinfoListAttrs::with_loc(next, self.orig_loc));
25315                    let Some(val) = res else { break };
25316                    val
25317                }),
25318                23u16 => OpGetlinkDumpReply::Stats64({
25319                    let res = PushRtnlLinkStats64::new_from_slice(next);
25320                    let Some(val) = res else { break };
25321                    val
25322                }),
25323                24u16 => OpGetlinkDumpReply::VfPorts({
25324                    let res = Some(IterableVfPortsAttrs::with_loc(next, self.orig_loc));
25325                    let Some(val) = res else { break };
25326                    val
25327                }),
25328                25u16 => OpGetlinkDumpReply::PortSelf({
25329                    let res = Some(IterablePortSelfAttrs::with_loc(next, self.orig_loc));
25330                    let Some(val) = res else { break };
25331                    val
25332                }),
25333                26u16 => OpGetlinkDumpReply::AfSpec({
25334                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
25335                    let Some(val) = res else { break };
25336                    val
25337                }),
25338                27u16 => OpGetlinkDumpReply::Group({
25339                    let res = parse_u32(next);
25340                    let Some(val) = res else { break };
25341                    val
25342                }),
25343                28u16 => OpGetlinkDumpReply::NetNsFd({
25344                    let res = parse_u32(next);
25345                    let Some(val) = res else { break };
25346                    val
25347                }),
25348                29u16 => OpGetlinkDumpReply::ExtMask({
25349                    let res = parse_u32(next);
25350                    let Some(val) = res else { break };
25351                    val
25352                }),
25353                30u16 => OpGetlinkDumpReply::Promiscuity({
25354                    let res = parse_u32(next);
25355                    let Some(val) = res else { break };
25356                    val
25357                }),
25358                31u16 => OpGetlinkDumpReply::NumTxQueues({
25359                    let res = parse_u32(next);
25360                    let Some(val) = res else { break };
25361                    val
25362                }),
25363                32u16 => OpGetlinkDumpReply::NumRxQueues({
25364                    let res = parse_u32(next);
25365                    let Some(val) = res else { break };
25366                    val
25367                }),
25368                33u16 => OpGetlinkDumpReply::Carrier({
25369                    let res = parse_u8(next);
25370                    let Some(val) = res else { break };
25371                    val
25372                }),
25373                34u16 => OpGetlinkDumpReply::PhysPortId({
25374                    let res = Some(next);
25375                    let Some(val) = res else { break };
25376                    val
25377                }),
25378                35u16 => OpGetlinkDumpReply::CarrierChanges({
25379                    let res = parse_u32(next);
25380                    let Some(val) = res else { break };
25381                    val
25382                }),
25383                36u16 => OpGetlinkDumpReply::PhysSwitchId({
25384                    let res = Some(next);
25385                    let Some(val) = res else { break };
25386                    val
25387                }),
25388                37u16 => OpGetlinkDumpReply::LinkNetnsid({
25389                    let res = parse_i32(next);
25390                    let Some(val) = res else { break };
25391                    val
25392                }),
25393                38u16 => OpGetlinkDumpReply::PhysPortName({
25394                    let res = CStr::from_bytes_with_nul(next).ok();
25395                    let Some(val) = res else { break };
25396                    val
25397                }),
25398                39u16 => OpGetlinkDumpReply::ProtoDown({
25399                    let res = parse_u8(next);
25400                    let Some(val) = res else { break };
25401                    val
25402                }),
25403                40u16 => OpGetlinkDumpReply::GsoMaxSegs({
25404                    let res = parse_u32(next);
25405                    let Some(val) = res else { break };
25406                    val
25407                }),
25408                41u16 => OpGetlinkDumpReply::GsoMaxSize({
25409                    let res = parse_u32(next);
25410                    let Some(val) = res else { break };
25411                    val
25412                }),
25413                42u16 => OpGetlinkDumpReply::Pad({
25414                    let res = Some(next);
25415                    let Some(val) = res else { break };
25416                    val
25417                }),
25418                43u16 => OpGetlinkDumpReply::Xdp({
25419                    let res = Some(IterableXdpAttrs::with_loc(next, self.orig_loc));
25420                    let Some(val) = res else { break };
25421                    val
25422                }),
25423                44u16 => OpGetlinkDumpReply::Event({
25424                    let res = parse_u32(next);
25425                    let Some(val) = res else { break };
25426                    val
25427                }),
25428                45u16 => OpGetlinkDumpReply::NewNetnsid({
25429                    let res = parse_i32(next);
25430                    let Some(val) = res else { break };
25431                    val
25432                }),
25433                46u16 => OpGetlinkDumpReply::TargetNetnsid({
25434                    let res = parse_i32(next);
25435                    let Some(val) = res else { break };
25436                    val
25437                }),
25438                47u16 => OpGetlinkDumpReply::CarrierUpCount({
25439                    let res = parse_u32(next);
25440                    let Some(val) = res else { break };
25441                    val
25442                }),
25443                48u16 => OpGetlinkDumpReply::CarrierDownCount({
25444                    let res = parse_u32(next);
25445                    let Some(val) = res else { break };
25446                    val
25447                }),
25448                49u16 => OpGetlinkDumpReply::NewIfindex({
25449                    let res = parse_i32(next);
25450                    let Some(val) = res else { break };
25451                    val
25452                }),
25453                50u16 => OpGetlinkDumpReply::MinMtu({
25454                    let res = parse_u32(next);
25455                    let Some(val) = res else { break };
25456                    val
25457                }),
25458                51u16 => OpGetlinkDumpReply::MaxMtu({
25459                    let res = parse_u32(next);
25460                    let Some(val) = res else { break };
25461                    val
25462                }),
25463                52u16 => OpGetlinkDumpReply::PropList({
25464                    let res = Some(IterablePropListLinkAttrs::with_loc(next, self.orig_loc));
25465                    let Some(val) = res else { break };
25466                    val
25467                }),
25468                54u16 => OpGetlinkDumpReply::PermAddress({
25469                    let res = Some(next);
25470                    let Some(val) = res else { break };
25471                    val
25472                }),
25473                55u16 => OpGetlinkDumpReply::ProtoDownReason({
25474                    let res = CStr::from_bytes_with_nul(next).ok();
25475                    let Some(val) = res else { break };
25476                    val
25477                }),
25478                56u16 => OpGetlinkDumpReply::ParentDevName({
25479                    let res = CStr::from_bytes_with_nul(next).ok();
25480                    let Some(val) = res else { break };
25481                    val
25482                }),
25483                57u16 => OpGetlinkDumpReply::ParentDevBusName({
25484                    let res = CStr::from_bytes_with_nul(next).ok();
25485                    let Some(val) = res else { break };
25486                    val
25487                }),
25488                58u16 => OpGetlinkDumpReply::GroMaxSize({
25489                    let res = parse_u32(next);
25490                    let Some(val) = res else { break };
25491                    val
25492                }),
25493                59u16 => OpGetlinkDumpReply::TsoMaxSize({
25494                    let res = parse_u32(next);
25495                    let Some(val) = res else { break };
25496                    val
25497                }),
25498                60u16 => OpGetlinkDumpReply::TsoMaxSegs({
25499                    let res = parse_u32(next);
25500                    let Some(val) = res else { break };
25501                    val
25502                }),
25503                61u16 => OpGetlinkDumpReply::Allmulti({
25504                    let res = parse_u32(next);
25505                    let Some(val) = res else { break };
25506                    val
25507                }),
25508                62u16 => OpGetlinkDumpReply::DevlinkPort({
25509                    let res = Some(next);
25510                    let Some(val) = res else { break };
25511                    val
25512                }),
25513                63u16 => OpGetlinkDumpReply::GsoIpv4MaxSize({
25514                    let res = parse_u32(next);
25515                    let Some(val) = res else { break };
25516                    val
25517                }),
25518                64u16 => OpGetlinkDumpReply::GroIpv4MaxSize({
25519                    let res = parse_u32(next);
25520                    let Some(val) = res else { break };
25521                    val
25522                }),
25523                65u16 => OpGetlinkDumpReply::DpllPin({
25524                    let res = Some(IterableLinkDpllPinAttrs::with_loc(next, self.orig_loc));
25525                    let Some(val) = res else { break };
25526                    val
25527                }),
25528                66u16 => OpGetlinkDumpReply::MaxPacingOffloadHorizon({
25529                    let res = parse_u32(next);
25530                    let Some(val) = res else { break };
25531                    val
25532                }),
25533                67u16 => OpGetlinkDumpReply::NetnsImmutable({
25534                    let res = parse_u8(next);
25535                    let Some(val) = res else { break };
25536                    val
25537                }),
25538                n => {
25539                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
25540                        break;
25541                    } else {
25542                        continue;
25543                    }
25544                }
25545            };
25546            return Some(Ok(res));
25547        }
25548        Some(Err(ErrorContext::new(
25549            "OpGetlinkDumpReply",
25550            r#type.and_then(|t| OpGetlinkDumpReply::attr_from_type(t)),
25551            self.orig_loc,
25552            self.buf.as_ptr().wrapping_add(pos) as usize,
25553        )))
25554    }
25555}
25556impl<'a> std::fmt::Debug for IterableOpGetlinkDumpReply<'_> {
25557    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25558        let mut fmt = f.debug_struct("OpGetlinkDumpReply");
25559        for attr in self.clone() {
25560            let attr = match attr {
25561                Ok(a) => a,
25562                Err(err) => {
25563                    fmt.finish()?;
25564                    f.write_str("Err(")?;
25565                    err.fmt(f)?;
25566                    return f.write_str(")");
25567                }
25568            };
25569            match attr {
25570                OpGetlinkDumpReply::Address(val) => fmt.field("Address", &val),
25571                OpGetlinkDumpReply::Broadcast(val) => fmt.field("Broadcast", &val),
25572                OpGetlinkDumpReply::Ifname(val) => fmt.field("Ifname", &val),
25573                OpGetlinkDumpReply::Mtu(val) => fmt.field("Mtu", &val),
25574                OpGetlinkDumpReply::Link(val) => fmt.field("Link", &val),
25575                OpGetlinkDumpReply::Qdisc(val) => fmt.field("Qdisc", &val),
25576                OpGetlinkDumpReply::Stats(val) => fmt.field("Stats", &val),
25577                OpGetlinkDumpReply::Cost(val) => fmt.field("Cost", &val),
25578                OpGetlinkDumpReply::Priority(val) => fmt.field("Priority", &val),
25579                OpGetlinkDumpReply::Master(val) => fmt.field("Master", &val),
25580                OpGetlinkDumpReply::Wireless(val) => fmt.field("Wireless", &val),
25581                OpGetlinkDumpReply::Protinfo(val) => fmt.field("Protinfo", &val),
25582                OpGetlinkDumpReply::Txqlen(val) => fmt.field("Txqlen", &val),
25583                OpGetlinkDumpReply::Map(val) => fmt.field("Map", &val),
25584                OpGetlinkDumpReply::Weight(val) => fmt.field("Weight", &val),
25585                OpGetlinkDumpReply::Operstate(val) => fmt.field("Operstate", &val),
25586                OpGetlinkDumpReply::Linkmode(val) => fmt.field("Linkmode", &val),
25587                OpGetlinkDumpReply::Linkinfo(val) => fmt.field("Linkinfo", &val),
25588                OpGetlinkDumpReply::NetNsPid(val) => fmt.field("NetNsPid", &val),
25589                OpGetlinkDumpReply::Ifalias(val) => fmt.field("Ifalias", &val),
25590                OpGetlinkDumpReply::NumVf(val) => fmt.field("NumVf", &val),
25591                OpGetlinkDumpReply::VfinfoList(val) => fmt.field("VfinfoList", &val),
25592                OpGetlinkDumpReply::Stats64(val) => fmt.field("Stats64", &val),
25593                OpGetlinkDumpReply::VfPorts(val) => fmt.field("VfPorts", &val),
25594                OpGetlinkDumpReply::PortSelf(val) => fmt.field("PortSelf", &val),
25595                OpGetlinkDumpReply::AfSpec(val) => fmt.field("AfSpec", &val),
25596                OpGetlinkDumpReply::Group(val) => fmt.field("Group", &val),
25597                OpGetlinkDumpReply::NetNsFd(val) => fmt.field("NetNsFd", &val),
25598                OpGetlinkDumpReply::ExtMask(val) => {
25599                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
25600                }
25601                OpGetlinkDumpReply::Promiscuity(val) => fmt.field("Promiscuity", &val),
25602                OpGetlinkDumpReply::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
25603                OpGetlinkDumpReply::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
25604                OpGetlinkDumpReply::Carrier(val) => fmt.field("Carrier", &val),
25605                OpGetlinkDumpReply::PhysPortId(val) => fmt.field("PhysPortId", &val),
25606                OpGetlinkDumpReply::CarrierChanges(val) => fmt.field("CarrierChanges", &val),
25607                OpGetlinkDumpReply::PhysSwitchId(val) => fmt.field("PhysSwitchId", &val),
25608                OpGetlinkDumpReply::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
25609                OpGetlinkDumpReply::PhysPortName(val) => fmt.field("PhysPortName", &val),
25610                OpGetlinkDumpReply::ProtoDown(val) => fmt.field("ProtoDown", &val),
25611                OpGetlinkDumpReply::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
25612                OpGetlinkDumpReply::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
25613                OpGetlinkDumpReply::Pad(val) => fmt.field("Pad", &val),
25614                OpGetlinkDumpReply::Xdp(val) => fmt.field("Xdp", &val),
25615                OpGetlinkDumpReply::Event(val) => fmt.field("Event", &val),
25616                OpGetlinkDumpReply::NewNetnsid(val) => fmt.field("NewNetnsid", &val),
25617                OpGetlinkDumpReply::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
25618                OpGetlinkDumpReply::CarrierUpCount(val) => fmt.field("CarrierUpCount", &val),
25619                OpGetlinkDumpReply::CarrierDownCount(val) => fmt.field("CarrierDownCount", &val),
25620                OpGetlinkDumpReply::NewIfindex(val) => fmt.field("NewIfindex", &val),
25621                OpGetlinkDumpReply::MinMtu(val) => fmt.field("MinMtu", &val),
25622                OpGetlinkDumpReply::MaxMtu(val) => fmt.field("MaxMtu", &val),
25623                OpGetlinkDumpReply::PropList(val) => fmt.field("PropList", &val),
25624                OpGetlinkDumpReply::PermAddress(val) => fmt.field("PermAddress", &val),
25625                OpGetlinkDumpReply::ProtoDownReason(val) => fmt.field("ProtoDownReason", &val),
25626                OpGetlinkDumpReply::ParentDevName(val) => fmt.field("ParentDevName", &val),
25627                OpGetlinkDumpReply::ParentDevBusName(val) => fmt.field("ParentDevBusName", &val),
25628                OpGetlinkDumpReply::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
25629                OpGetlinkDumpReply::TsoMaxSize(val) => fmt.field("TsoMaxSize", &val),
25630                OpGetlinkDumpReply::TsoMaxSegs(val) => fmt.field("TsoMaxSegs", &val),
25631                OpGetlinkDumpReply::Allmulti(val) => fmt.field("Allmulti", &val),
25632                OpGetlinkDumpReply::DevlinkPort(val) => fmt.field("DevlinkPort", &val),
25633                OpGetlinkDumpReply::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
25634                OpGetlinkDumpReply::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
25635                OpGetlinkDumpReply::DpllPin(val) => fmt.field("DpllPin", &val),
25636                OpGetlinkDumpReply::MaxPacingOffloadHorizon(val) => {
25637                    fmt.field("MaxPacingOffloadHorizon", &val)
25638                }
25639                OpGetlinkDumpReply::NetnsImmutable(val) => fmt.field("NetnsImmutable", &val),
25640            };
25641        }
25642        fmt.finish()
25643    }
25644}
25645impl IterableOpGetlinkDumpReply<'_> {
25646    pub fn lookup_attr(
25647        &self,
25648        offset: usize,
25649        missing_type: Option<u16>,
25650    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
25651        let mut stack = Vec::new();
25652        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
25653        if cur == offset + PushIfinfomsg::len() {
25654            stack.push(("OpGetlinkDumpReply", offset));
25655            return (
25656                stack,
25657                missing_type.and_then(|t| OpGetlinkDumpReply::attr_from_type(t)),
25658            );
25659        }
25660        if cur > offset || cur + self.buf.len() < offset {
25661            return (stack, None);
25662        }
25663        let mut attrs = self.clone();
25664        let mut last_off = cur + attrs.pos;
25665        let mut missing = None;
25666        while let Some(attr) = attrs.next() {
25667            let Ok(attr) = attr else { break };
25668            match attr {
25669                OpGetlinkDumpReply::Address(val) => {
25670                    if last_off == offset {
25671                        stack.push(("Address", last_off));
25672                        break;
25673                    }
25674                }
25675                OpGetlinkDumpReply::Broadcast(val) => {
25676                    if last_off == offset {
25677                        stack.push(("Broadcast", last_off));
25678                        break;
25679                    }
25680                }
25681                OpGetlinkDumpReply::Ifname(val) => {
25682                    if last_off == offset {
25683                        stack.push(("Ifname", last_off));
25684                        break;
25685                    }
25686                }
25687                OpGetlinkDumpReply::Mtu(val) => {
25688                    if last_off == offset {
25689                        stack.push(("Mtu", last_off));
25690                        break;
25691                    }
25692                }
25693                OpGetlinkDumpReply::Link(val) => {
25694                    if last_off == offset {
25695                        stack.push(("Link", last_off));
25696                        break;
25697                    }
25698                }
25699                OpGetlinkDumpReply::Qdisc(val) => {
25700                    if last_off == offset {
25701                        stack.push(("Qdisc", last_off));
25702                        break;
25703                    }
25704                }
25705                OpGetlinkDumpReply::Stats(val) => {
25706                    if last_off == offset {
25707                        stack.push(("Stats", last_off));
25708                        break;
25709                    }
25710                }
25711                OpGetlinkDumpReply::Cost(val) => {
25712                    if last_off == offset {
25713                        stack.push(("Cost", last_off));
25714                        break;
25715                    }
25716                }
25717                OpGetlinkDumpReply::Priority(val) => {
25718                    if last_off == offset {
25719                        stack.push(("Priority", last_off));
25720                        break;
25721                    }
25722                }
25723                OpGetlinkDumpReply::Master(val) => {
25724                    if last_off == offset {
25725                        stack.push(("Master", last_off));
25726                        break;
25727                    }
25728                }
25729                OpGetlinkDumpReply::Wireless(val) => {
25730                    if last_off == offset {
25731                        stack.push(("Wireless", last_off));
25732                        break;
25733                    }
25734                }
25735                OpGetlinkDumpReply::Protinfo(val) => {
25736                    if last_off == offset {
25737                        stack.push(("Protinfo", last_off));
25738                        break;
25739                    }
25740                }
25741                OpGetlinkDumpReply::Txqlen(val) => {
25742                    if last_off == offset {
25743                        stack.push(("Txqlen", last_off));
25744                        break;
25745                    }
25746                }
25747                OpGetlinkDumpReply::Map(val) => {
25748                    if last_off == offset {
25749                        stack.push(("Map", last_off));
25750                        break;
25751                    }
25752                }
25753                OpGetlinkDumpReply::Weight(val) => {
25754                    if last_off == offset {
25755                        stack.push(("Weight", last_off));
25756                        break;
25757                    }
25758                }
25759                OpGetlinkDumpReply::Operstate(val) => {
25760                    if last_off == offset {
25761                        stack.push(("Operstate", last_off));
25762                        break;
25763                    }
25764                }
25765                OpGetlinkDumpReply::Linkmode(val) => {
25766                    if last_off == offset {
25767                        stack.push(("Linkmode", last_off));
25768                        break;
25769                    }
25770                }
25771                OpGetlinkDumpReply::Linkinfo(val) => {
25772                    (stack, missing) = val.lookup_attr(offset, missing_type);
25773                    if !stack.is_empty() {
25774                        break;
25775                    }
25776                }
25777                OpGetlinkDumpReply::NetNsPid(val) => {
25778                    if last_off == offset {
25779                        stack.push(("NetNsPid", last_off));
25780                        break;
25781                    }
25782                }
25783                OpGetlinkDumpReply::Ifalias(val) => {
25784                    if last_off == offset {
25785                        stack.push(("Ifalias", last_off));
25786                        break;
25787                    }
25788                }
25789                OpGetlinkDumpReply::NumVf(val) => {
25790                    if last_off == offset {
25791                        stack.push(("NumVf", last_off));
25792                        break;
25793                    }
25794                }
25795                OpGetlinkDumpReply::VfinfoList(val) => {
25796                    (stack, missing) = val.lookup_attr(offset, missing_type);
25797                    if !stack.is_empty() {
25798                        break;
25799                    }
25800                }
25801                OpGetlinkDumpReply::Stats64(val) => {
25802                    if last_off == offset {
25803                        stack.push(("Stats64", last_off));
25804                        break;
25805                    }
25806                }
25807                OpGetlinkDumpReply::VfPorts(val) => {
25808                    (stack, missing) = val.lookup_attr(offset, missing_type);
25809                    if !stack.is_empty() {
25810                        break;
25811                    }
25812                }
25813                OpGetlinkDumpReply::PortSelf(val) => {
25814                    (stack, missing) = val.lookup_attr(offset, missing_type);
25815                    if !stack.is_empty() {
25816                        break;
25817                    }
25818                }
25819                OpGetlinkDumpReply::AfSpec(val) => {
25820                    (stack, missing) = val.lookup_attr(offset, missing_type);
25821                    if !stack.is_empty() {
25822                        break;
25823                    }
25824                }
25825                OpGetlinkDumpReply::Group(val) => {
25826                    if last_off == offset {
25827                        stack.push(("Group", last_off));
25828                        break;
25829                    }
25830                }
25831                OpGetlinkDumpReply::NetNsFd(val) => {
25832                    if last_off == offset {
25833                        stack.push(("NetNsFd", last_off));
25834                        break;
25835                    }
25836                }
25837                OpGetlinkDumpReply::ExtMask(val) => {
25838                    if last_off == offset {
25839                        stack.push(("ExtMask", last_off));
25840                        break;
25841                    }
25842                }
25843                OpGetlinkDumpReply::Promiscuity(val) => {
25844                    if last_off == offset {
25845                        stack.push(("Promiscuity", last_off));
25846                        break;
25847                    }
25848                }
25849                OpGetlinkDumpReply::NumTxQueues(val) => {
25850                    if last_off == offset {
25851                        stack.push(("NumTxQueues", last_off));
25852                        break;
25853                    }
25854                }
25855                OpGetlinkDumpReply::NumRxQueues(val) => {
25856                    if last_off == offset {
25857                        stack.push(("NumRxQueues", last_off));
25858                        break;
25859                    }
25860                }
25861                OpGetlinkDumpReply::Carrier(val) => {
25862                    if last_off == offset {
25863                        stack.push(("Carrier", last_off));
25864                        break;
25865                    }
25866                }
25867                OpGetlinkDumpReply::PhysPortId(val) => {
25868                    if last_off == offset {
25869                        stack.push(("PhysPortId", last_off));
25870                        break;
25871                    }
25872                }
25873                OpGetlinkDumpReply::CarrierChanges(val) => {
25874                    if last_off == offset {
25875                        stack.push(("CarrierChanges", last_off));
25876                        break;
25877                    }
25878                }
25879                OpGetlinkDumpReply::PhysSwitchId(val) => {
25880                    if last_off == offset {
25881                        stack.push(("PhysSwitchId", last_off));
25882                        break;
25883                    }
25884                }
25885                OpGetlinkDumpReply::LinkNetnsid(val) => {
25886                    if last_off == offset {
25887                        stack.push(("LinkNetnsid", last_off));
25888                        break;
25889                    }
25890                }
25891                OpGetlinkDumpReply::PhysPortName(val) => {
25892                    if last_off == offset {
25893                        stack.push(("PhysPortName", last_off));
25894                        break;
25895                    }
25896                }
25897                OpGetlinkDumpReply::ProtoDown(val) => {
25898                    if last_off == offset {
25899                        stack.push(("ProtoDown", last_off));
25900                        break;
25901                    }
25902                }
25903                OpGetlinkDumpReply::GsoMaxSegs(val) => {
25904                    if last_off == offset {
25905                        stack.push(("GsoMaxSegs", last_off));
25906                        break;
25907                    }
25908                }
25909                OpGetlinkDumpReply::GsoMaxSize(val) => {
25910                    if last_off == offset {
25911                        stack.push(("GsoMaxSize", last_off));
25912                        break;
25913                    }
25914                }
25915                OpGetlinkDumpReply::Pad(val) => {
25916                    if last_off == offset {
25917                        stack.push(("Pad", last_off));
25918                        break;
25919                    }
25920                }
25921                OpGetlinkDumpReply::Xdp(val) => {
25922                    (stack, missing) = val.lookup_attr(offset, missing_type);
25923                    if !stack.is_empty() {
25924                        break;
25925                    }
25926                }
25927                OpGetlinkDumpReply::Event(val) => {
25928                    if last_off == offset {
25929                        stack.push(("Event", last_off));
25930                        break;
25931                    }
25932                }
25933                OpGetlinkDumpReply::NewNetnsid(val) => {
25934                    if last_off == offset {
25935                        stack.push(("NewNetnsid", last_off));
25936                        break;
25937                    }
25938                }
25939                OpGetlinkDumpReply::TargetNetnsid(val) => {
25940                    if last_off == offset {
25941                        stack.push(("TargetNetnsid", last_off));
25942                        break;
25943                    }
25944                }
25945                OpGetlinkDumpReply::CarrierUpCount(val) => {
25946                    if last_off == offset {
25947                        stack.push(("CarrierUpCount", last_off));
25948                        break;
25949                    }
25950                }
25951                OpGetlinkDumpReply::CarrierDownCount(val) => {
25952                    if last_off == offset {
25953                        stack.push(("CarrierDownCount", last_off));
25954                        break;
25955                    }
25956                }
25957                OpGetlinkDumpReply::NewIfindex(val) => {
25958                    if last_off == offset {
25959                        stack.push(("NewIfindex", last_off));
25960                        break;
25961                    }
25962                }
25963                OpGetlinkDumpReply::MinMtu(val) => {
25964                    if last_off == offset {
25965                        stack.push(("MinMtu", last_off));
25966                        break;
25967                    }
25968                }
25969                OpGetlinkDumpReply::MaxMtu(val) => {
25970                    if last_off == offset {
25971                        stack.push(("MaxMtu", last_off));
25972                        break;
25973                    }
25974                }
25975                OpGetlinkDumpReply::PropList(val) => {
25976                    (stack, missing) = val.lookup_attr(offset, missing_type);
25977                    if !stack.is_empty() {
25978                        break;
25979                    }
25980                }
25981                OpGetlinkDumpReply::PermAddress(val) => {
25982                    if last_off == offset {
25983                        stack.push(("PermAddress", last_off));
25984                        break;
25985                    }
25986                }
25987                OpGetlinkDumpReply::ProtoDownReason(val) => {
25988                    if last_off == offset {
25989                        stack.push(("ProtoDownReason", last_off));
25990                        break;
25991                    }
25992                }
25993                OpGetlinkDumpReply::ParentDevName(val) => {
25994                    if last_off == offset {
25995                        stack.push(("ParentDevName", last_off));
25996                        break;
25997                    }
25998                }
25999                OpGetlinkDumpReply::ParentDevBusName(val) => {
26000                    if last_off == offset {
26001                        stack.push(("ParentDevBusName", last_off));
26002                        break;
26003                    }
26004                }
26005                OpGetlinkDumpReply::GroMaxSize(val) => {
26006                    if last_off == offset {
26007                        stack.push(("GroMaxSize", last_off));
26008                        break;
26009                    }
26010                }
26011                OpGetlinkDumpReply::TsoMaxSize(val) => {
26012                    if last_off == offset {
26013                        stack.push(("TsoMaxSize", last_off));
26014                        break;
26015                    }
26016                }
26017                OpGetlinkDumpReply::TsoMaxSegs(val) => {
26018                    if last_off == offset {
26019                        stack.push(("TsoMaxSegs", last_off));
26020                        break;
26021                    }
26022                }
26023                OpGetlinkDumpReply::Allmulti(val) => {
26024                    if last_off == offset {
26025                        stack.push(("Allmulti", last_off));
26026                        break;
26027                    }
26028                }
26029                OpGetlinkDumpReply::DevlinkPort(val) => {
26030                    if last_off == offset {
26031                        stack.push(("DevlinkPort", last_off));
26032                        break;
26033                    }
26034                }
26035                OpGetlinkDumpReply::GsoIpv4MaxSize(val) => {
26036                    if last_off == offset {
26037                        stack.push(("GsoIpv4MaxSize", last_off));
26038                        break;
26039                    }
26040                }
26041                OpGetlinkDumpReply::GroIpv4MaxSize(val) => {
26042                    if last_off == offset {
26043                        stack.push(("GroIpv4MaxSize", last_off));
26044                        break;
26045                    }
26046                }
26047                OpGetlinkDumpReply::DpllPin(val) => {
26048                    (stack, missing) = val.lookup_attr(offset, missing_type);
26049                    if !stack.is_empty() {
26050                        break;
26051                    }
26052                }
26053                OpGetlinkDumpReply::MaxPacingOffloadHorizon(val) => {
26054                    if last_off == offset {
26055                        stack.push(("MaxPacingOffloadHorizon", last_off));
26056                        break;
26057                    }
26058                }
26059                OpGetlinkDumpReply::NetnsImmutable(val) => {
26060                    if last_off == offset {
26061                        stack.push(("NetnsImmutable", last_off));
26062                        break;
26063                    }
26064                }
26065                _ => {}
26066            };
26067            last_off = cur + attrs.pos;
26068        }
26069        if !stack.is_empty() {
26070            stack.push(("OpGetlinkDumpReply", cur));
26071        }
26072        (stack, missing)
26073    }
26074}
26075#[derive(Debug)]
26076pub struct RequestOpGetlinkDumpRequest<'r> {
26077    request: Request<'r>,
26078}
26079impl<'r> RequestOpGetlinkDumpRequest<'r> {
26080    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
26081        PushOpGetlinkDumpRequest::write_header(&mut request.buf_mut(), header);
26082        Self {
26083            request: request.set_dump(),
26084        }
26085    }
26086    pub fn encode(&mut self) -> PushOpGetlinkDumpRequest<&mut Vec<u8>> {
26087        PushOpGetlinkDumpRequest::new_without_header(self.request.buf_mut())
26088    }
26089    pub fn into_encoder(self) -> PushOpGetlinkDumpRequest<RequestBuf<'r>> {
26090        PushOpGetlinkDumpRequest::new_without_header(self.request.buf)
26091    }
26092}
26093impl NetlinkRequest for RequestOpGetlinkDumpRequest<'_> {
26094    type ReplyType<'buf> = (PushIfinfomsg, IterableOpGetlinkDumpReply<'buf>);
26095    fn protocol(&self) -> Protocol {
26096        Protocol::Raw {
26097            protonum: 0u16,
26098            request_type: 18u16,
26099        }
26100    }
26101    fn flags(&self) -> u16 {
26102        self.request.flags
26103    }
26104    fn payload(&self) -> &[u8] {
26105        self.request.buf()
26106    }
26107    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
26108        OpGetlinkDumpReply::new(buf)
26109    }
26110    fn lookup(
26111        buf: &[u8],
26112        offset: usize,
26113        missing_type: Option<u16>,
26114    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
26115        OpGetlinkDumpRequest::new(buf)
26116            .1
26117            .lookup_attr(offset, missing_type)
26118    }
26119}
26120#[doc = "Get / dump information about a link."]
26121pub struct PushOpGetlinkDoRequest<Prev: Rec> {
26122    pub(crate) prev: Option<Prev>,
26123    pub(crate) header_offset: Option<usize>,
26124}
26125impl<Prev: Rec> Rec for PushOpGetlinkDoRequest<Prev> {
26126    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
26127        self.prev.as_mut().unwrap().as_rec_mut()
26128    }
26129}
26130impl<Prev: Rec> PushOpGetlinkDoRequest<Prev> {
26131    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
26132        Self::write_header(&mut prev, header);
26133        Self::new_without_header(prev)
26134    }
26135    fn new_without_header(prev: Prev) -> Self {
26136        Self {
26137            prev: Some(prev),
26138            header_offset: None,
26139        }
26140    }
26141    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
26142        prev.as_rec_mut().extend(header.as_slice());
26143    }
26144    pub fn end_nested(mut self) -> Prev {
26145        let mut prev = self.prev.take().unwrap();
26146        if let Some(header_offset) = &self.header_offset {
26147            finalize_nested_header(prev.as_rec_mut(), *header_offset);
26148        }
26149        prev
26150    }
26151    pub fn push_ifname(mut self, value: &CStr) -> Self {
26152        push_header(
26153            self.as_rec_mut(),
26154            3u16,
26155            value.to_bytes_with_nul().len() as u16,
26156        );
26157        self.as_rec_mut().extend(value.to_bytes_with_nul());
26158        self
26159    }
26160    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
26161        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
26162        self.as_rec_mut().extend(value);
26163        self.as_rec_mut().push(0);
26164        self
26165    }
26166    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26167    pub fn push_ext_mask(mut self, value: u32) -> Self {
26168        push_header(self.as_rec_mut(), 29u16, 4 as u16);
26169        self.as_rec_mut().extend(value.to_ne_bytes());
26170        self
26171    }
26172    pub fn push_target_netnsid(mut self, value: i32) -> Self {
26173        push_header(self.as_rec_mut(), 46u16, 4 as u16);
26174        self.as_rec_mut().extend(value.to_ne_bytes());
26175        self
26176    }
26177    pub fn push_alt_ifname(mut self, value: &CStr) -> Self {
26178        push_header(
26179            self.as_rec_mut(),
26180            53u16,
26181            value.to_bytes_with_nul().len() as u16,
26182        );
26183        self.as_rec_mut().extend(value.to_bytes_with_nul());
26184        self
26185    }
26186    pub fn push_alt_ifname_bytes(mut self, value: &[u8]) -> Self {
26187        push_header(self.as_rec_mut(), 53u16, (value.len() + 1) as u16);
26188        self.as_rec_mut().extend(value);
26189        self.as_rec_mut().push(0);
26190        self
26191    }
26192}
26193impl<Prev: Rec> Drop for PushOpGetlinkDoRequest<Prev> {
26194    fn drop(&mut self) {
26195        if let Some(prev) = &mut self.prev {
26196            if let Some(header_offset) = &self.header_offset {
26197                finalize_nested_header(prev.as_rec_mut(), *header_offset);
26198            }
26199        }
26200    }
26201}
26202#[doc = "Get / dump information about a link."]
26203#[derive(Clone)]
26204pub enum OpGetlinkDoRequest<'a> {
26205    Ifname(&'a CStr),
26206    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26207    ExtMask(u32),
26208    TargetNetnsid(i32),
26209    AltIfname(&'a CStr),
26210}
26211impl<'a> IterableOpGetlinkDoRequest<'a> {
26212    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
26213        let mut iter = self.clone();
26214        iter.pos = 0;
26215        for attr in iter {
26216            if let OpGetlinkDoRequest::Ifname(val) = attr? {
26217                return Ok(val);
26218            }
26219        }
26220        Err(ErrorContext::new_missing(
26221            "OpGetlinkDoRequest",
26222            "Ifname",
26223            self.orig_loc,
26224            self.buf.as_ptr() as usize,
26225        ))
26226    }
26227    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26228    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
26229        let mut iter = self.clone();
26230        iter.pos = 0;
26231        for attr in iter {
26232            if let OpGetlinkDoRequest::ExtMask(val) = attr? {
26233                return Ok(val);
26234            }
26235        }
26236        Err(ErrorContext::new_missing(
26237            "OpGetlinkDoRequest",
26238            "ExtMask",
26239            self.orig_loc,
26240            self.buf.as_ptr() as usize,
26241        ))
26242    }
26243    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
26244        let mut iter = self.clone();
26245        iter.pos = 0;
26246        for attr in iter {
26247            if let OpGetlinkDoRequest::TargetNetnsid(val) = attr? {
26248                return Ok(val);
26249            }
26250        }
26251        Err(ErrorContext::new_missing(
26252            "OpGetlinkDoRequest",
26253            "TargetNetnsid",
26254            self.orig_loc,
26255            self.buf.as_ptr() as usize,
26256        ))
26257    }
26258    pub fn get_alt_ifname(&self) -> Result<&'a CStr, ErrorContext> {
26259        let mut iter = self.clone();
26260        iter.pos = 0;
26261        for attr in iter {
26262            if let OpGetlinkDoRequest::AltIfname(val) = attr? {
26263                return Ok(val);
26264            }
26265        }
26266        Err(ErrorContext::new_missing(
26267            "OpGetlinkDoRequest",
26268            "AltIfname",
26269            self.orig_loc,
26270            self.buf.as_ptr() as usize,
26271        ))
26272    }
26273}
26274impl<'a> OpGetlinkDoRequest<'a> {
26275    pub fn new(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpGetlinkDoRequest<'a>) {
26276        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
26277        (
26278            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
26279            IterableOpGetlinkDoRequest::with_loc(attrs, buf.as_ptr() as usize),
26280        )
26281    }
26282    fn attr_from_type(r#type: u16) -> Option<&'static str> {
26283        LinkAttrs::attr_from_type(r#type)
26284    }
26285}
26286#[derive(Clone, Copy, Default)]
26287pub struct IterableOpGetlinkDoRequest<'a> {
26288    buf: &'a [u8],
26289    pos: usize,
26290    orig_loc: usize,
26291}
26292impl<'a> IterableOpGetlinkDoRequest<'a> {
26293    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
26294        Self {
26295            buf,
26296            pos: 0,
26297            orig_loc,
26298        }
26299    }
26300    pub fn get_buf(&self) -> &'a [u8] {
26301        self.buf
26302    }
26303}
26304impl<'a> Iterator for IterableOpGetlinkDoRequest<'a> {
26305    type Item = Result<OpGetlinkDoRequest<'a>, ErrorContext>;
26306    fn next(&mut self) -> Option<Self::Item> {
26307        if self.buf.len() == self.pos {
26308            return None;
26309        }
26310        let pos = self.pos;
26311        let mut r#type = None;
26312        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
26313            r#type = Some(header.r#type);
26314            let res = match header.r#type {
26315                3u16 => OpGetlinkDoRequest::Ifname({
26316                    let res = CStr::from_bytes_with_nul(next).ok();
26317                    let Some(val) = res else { break };
26318                    val
26319                }),
26320                29u16 => OpGetlinkDoRequest::ExtMask({
26321                    let res = parse_u32(next);
26322                    let Some(val) = res else { break };
26323                    val
26324                }),
26325                46u16 => OpGetlinkDoRequest::TargetNetnsid({
26326                    let res = parse_i32(next);
26327                    let Some(val) = res else { break };
26328                    val
26329                }),
26330                53u16 => OpGetlinkDoRequest::AltIfname({
26331                    let res = CStr::from_bytes_with_nul(next).ok();
26332                    let Some(val) = res else { break };
26333                    val
26334                }),
26335                n => {
26336                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
26337                        break;
26338                    } else {
26339                        continue;
26340                    }
26341                }
26342            };
26343            return Some(Ok(res));
26344        }
26345        Some(Err(ErrorContext::new(
26346            "OpGetlinkDoRequest",
26347            r#type.and_then(|t| OpGetlinkDoRequest::attr_from_type(t)),
26348            self.orig_loc,
26349            self.buf.as_ptr().wrapping_add(pos) as usize,
26350        )))
26351    }
26352}
26353impl<'a> std::fmt::Debug for IterableOpGetlinkDoRequest<'_> {
26354    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26355        let mut fmt = f.debug_struct("OpGetlinkDoRequest");
26356        for attr in self.clone() {
26357            let attr = match attr {
26358                Ok(a) => a,
26359                Err(err) => {
26360                    fmt.finish()?;
26361                    f.write_str("Err(")?;
26362                    err.fmt(f)?;
26363                    return f.write_str(")");
26364                }
26365            };
26366            match attr {
26367                OpGetlinkDoRequest::Ifname(val) => fmt.field("Ifname", &val),
26368                OpGetlinkDoRequest::ExtMask(val) => {
26369                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
26370                }
26371                OpGetlinkDoRequest::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
26372                OpGetlinkDoRequest::AltIfname(val) => fmt.field("AltIfname", &val),
26373            };
26374        }
26375        fmt.finish()
26376    }
26377}
26378impl IterableOpGetlinkDoRequest<'_> {
26379    pub fn lookup_attr(
26380        &self,
26381        offset: usize,
26382        missing_type: Option<u16>,
26383    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
26384        let mut stack = Vec::new();
26385        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
26386        if cur == offset + PushIfinfomsg::len() {
26387            stack.push(("OpGetlinkDoRequest", offset));
26388            return (
26389                stack,
26390                missing_type.and_then(|t| OpGetlinkDoRequest::attr_from_type(t)),
26391            );
26392        }
26393        if cur > offset || cur + self.buf.len() < offset {
26394            return (stack, None);
26395        }
26396        let mut attrs = self.clone();
26397        let mut last_off = cur + attrs.pos;
26398        while let Some(attr) = attrs.next() {
26399            let Ok(attr) = attr else { break };
26400            match attr {
26401                OpGetlinkDoRequest::Ifname(val) => {
26402                    if last_off == offset {
26403                        stack.push(("Ifname", last_off));
26404                        break;
26405                    }
26406                }
26407                OpGetlinkDoRequest::ExtMask(val) => {
26408                    if last_off == offset {
26409                        stack.push(("ExtMask", last_off));
26410                        break;
26411                    }
26412                }
26413                OpGetlinkDoRequest::TargetNetnsid(val) => {
26414                    if last_off == offset {
26415                        stack.push(("TargetNetnsid", last_off));
26416                        break;
26417                    }
26418                }
26419                OpGetlinkDoRequest::AltIfname(val) => {
26420                    if last_off == offset {
26421                        stack.push(("AltIfname", last_off));
26422                        break;
26423                    }
26424                }
26425                _ => {}
26426            };
26427            last_off = cur + attrs.pos;
26428        }
26429        if !stack.is_empty() {
26430            stack.push(("OpGetlinkDoRequest", cur));
26431        }
26432        (stack, None)
26433    }
26434}
26435#[doc = "Get / dump information about a link."]
26436pub struct PushOpGetlinkDoReply<Prev: Rec> {
26437    pub(crate) prev: Option<Prev>,
26438    pub(crate) header_offset: Option<usize>,
26439}
26440impl<Prev: Rec> Rec for PushOpGetlinkDoReply<Prev> {
26441    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
26442        self.prev.as_mut().unwrap().as_rec_mut()
26443    }
26444}
26445impl<Prev: Rec> PushOpGetlinkDoReply<Prev> {
26446    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
26447        Self::write_header(&mut prev, header);
26448        Self::new_without_header(prev)
26449    }
26450    fn new_without_header(prev: Prev) -> Self {
26451        Self {
26452            prev: Some(prev),
26453            header_offset: None,
26454        }
26455    }
26456    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
26457        prev.as_rec_mut().extend(header.as_slice());
26458    }
26459    pub fn end_nested(mut self) -> Prev {
26460        let mut prev = self.prev.take().unwrap();
26461        if let Some(header_offset) = &self.header_offset {
26462            finalize_nested_header(prev.as_rec_mut(), *header_offset);
26463        }
26464        prev
26465    }
26466    pub fn push_address(mut self, value: &[u8]) -> Self {
26467        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
26468        self.as_rec_mut().extend(value);
26469        self
26470    }
26471    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
26472        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
26473        self.as_rec_mut().extend(value);
26474        self
26475    }
26476    pub fn push_ifname(mut self, value: &CStr) -> Self {
26477        push_header(
26478            self.as_rec_mut(),
26479            3u16,
26480            value.to_bytes_with_nul().len() as u16,
26481        );
26482        self.as_rec_mut().extend(value.to_bytes_with_nul());
26483        self
26484    }
26485    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
26486        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
26487        self.as_rec_mut().extend(value);
26488        self.as_rec_mut().push(0);
26489        self
26490    }
26491    pub fn push_mtu(mut self, value: u32) -> Self {
26492        push_header(self.as_rec_mut(), 4u16, 4 as u16);
26493        self.as_rec_mut().extend(value.to_ne_bytes());
26494        self
26495    }
26496    pub fn push_link(mut self, value: u32) -> Self {
26497        push_header(self.as_rec_mut(), 5u16, 4 as u16);
26498        self.as_rec_mut().extend(value.to_ne_bytes());
26499        self
26500    }
26501    pub fn push_qdisc(mut self, value: &CStr) -> Self {
26502        push_header(
26503            self.as_rec_mut(),
26504            6u16,
26505            value.to_bytes_with_nul().len() as u16,
26506        );
26507        self.as_rec_mut().extend(value.to_bytes_with_nul());
26508        self
26509    }
26510    pub fn push_qdisc_bytes(mut self, value: &[u8]) -> Self {
26511        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
26512        self.as_rec_mut().extend(value);
26513        self.as_rec_mut().push(0);
26514        self
26515    }
26516    pub fn push_stats(mut self, value: PushRtnlLinkStats) -> Self {
26517        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
26518        self.as_rec_mut().extend(value.as_slice());
26519        self
26520    }
26521    pub fn push_cost(mut self, value: &CStr) -> Self {
26522        push_header(
26523            self.as_rec_mut(),
26524            8u16,
26525            value.to_bytes_with_nul().len() as u16,
26526        );
26527        self.as_rec_mut().extend(value.to_bytes_with_nul());
26528        self
26529    }
26530    pub fn push_cost_bytes(mut self, value: &[u8]) -> Self {
26531        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
26532        self.as_rec_mut().extend(value);
26533        self.as_rec_mut().push(0);
26534        self
26535    }
26536    pub fn push_priority(mut self, value: &CStr) -> Self {
26537        push_header(
26538            self.as_rec_mut(),
26539            9u16,
26540            value.to_bytes_with_nul().len() as u16,
26541        );
26542        self.as_rec_mut().extend(value.to_bytes_with_nul());
26543        self
26544    }
26545    pub fn push_priority_bytes(mut self, value: &[u8]) -> Self {
26546        push_header(self.as_rec_mut(), 9u16, (value.len() + 1) as u16);
26547        self.as_rec_mut().extend(value);
26548        self.as_rec_mut().push(0);
26549        self
26550    }
26551    pub fn push_master(mut self, value: u32) -> Self {
26552        push_header(self.as_rec_mut(), 10u16, 4 as u16);
26553        self.as_rec_mut().extend(value.to_ne_bytes());
26554        self
26555    }
26556    pub fn push_wireless(mut self, value: &CStr) -> Self {
26557        push_header(
26558            self.as_rec_mut(),
26559            11u16,
26560            value.to_bytes_with_nul().len() as u16,
26561        );
26562        self.as_rec_mut().extend(value.to_bytes_with_nul());
26563        self
26564    }
26565    pub fn push_wireless_bytes(mut self, value: &[u8]) -> Self {
26566        push_header(self.as_rec_mut(), 11u16, (value.len() + 1) as u16);
26567        self.as_rec_mut().extend(value);
26568        self.as_rec_mut().push(0);
26569        self
26570    }
26571    pub fn push_protinfo(mut self, value: &CStr) -> Self {
26572        push_header(
26573            self.as_rec_mut(),
26574            12u16,
26575            value.to_bytes_with_nul().len() as u16,
26576        );
26577        self.as_rec_mut().extend(value.to_bytes_with_nul());
26578        self
26579    }
26580    pub fn push_protinfo_bytes(mut self, value: &[u8]) -> Self {
26581        push_header(self.as_rec_mut(), 12u16, (value.len() + 1) as u16);
26582        self.as_rec_mut().extend(value);
26583        self.as_rec_mut().push(0);
26584        self
26585    }
26586    pub fn push_txqlen(mut self, value: u32) -> Self {
26587        push_header(self.as_rec_mut(), 13u16, 4 as u16);
26588        self.as_rec_mut().extend(value.to_ne_bytes());
26589        self
26590    }
26591    pub fn push_map(mut self, value: PushRtnlLinkIfmap) -> Self {
26592        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
26593        self.as_rec_mut().extend(value.as_slice());
26594        self
26595    }
26596    pub fn push_weight(mut self, value: u32) -> Self {
26597        push_header(self.as_rec_mut(), 15u16, 4 as u16);
26598        self.as_rec_mut().extend(value.to_ne_bytes());
26599        self
26600    }
26601    pub fn push_operstate(mut self, value: u8) -> Self {
26602        push_header(self.as_rec_mut(), 16u16, 1 as u16);
26603        self.as_rec_mut().extend(value.to_ne_bytes());
26604        self
26605    }
26606    pub fn push_linkmode(mut self, value: u8) -> Self {
26607        push_header(self.as_rec_mut(), 17u16, 1 as u16);
26608        self.as_rec_mut().extend(value.to_ne_bytes());
26609        self
26610    }
26611    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
26612        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
26613        PushLinkinfoAttrs {
26614            prev: Some(self),
26615            header_offset: Some(header_offset),
26616        }
26617    }
26618    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
26619        push_header(self.as_rec_mut(), 19u16, 4 as u16);
26620        self.as_rec_mut().extend(value.to_ne_bytes());
26621        self
26622    }
26623    pub fn push_ifalias(mut self, value: &CStr) -> Self {
26624        push_header(
26625            self.as_rec_mut(),
26626            20u16,
26627            value.to_bytes_with_nul().len() as u16,
26628        );
26629        self.as_rec_mut().extend(value.to_bytes_with_nul());
26630        self
26631    }
26632    pub fn push_ifalias_bytes(mut self, value: &[u8]) -> Self {
26633        push_header(self.as_rec_mut(), 20u16, (value.len() + 1) as u16);
26634        self.as_rec_mut().extend(value);
26635        self.as_rec_mut().push(0);
26636        self
26637    }
26638    pub fn push_num_vf(mut self, value: u32) -> Self {
26639        push_header(self.as_rec_mut(), 21u16, 4 as u16);
26640        self.as_rec_mut().extend(value.to_ne_bytes());
26641        self
26642    }
26643    pub fn nested_vfinfo_list(mut self) -> PushVfinfoListAttrs<Self> {
26644        let header_offset = push_nested_header(self.as_rec_mut(), 22u16);
26645        PushVfinfoListAttrs {
26646            prev: Some(self),
26647            header_offset: Some(header_offset),
26648        }
26649    }
26650    pub fn push_stats64(mut self, value: PushRtnlLinkStats64) -> Self {
26651        push_header(self.as_rec_mut(), 23u16, value.as_slice().len() as u16);
26652        self.as_rec_mut().extend(value.as_slice());
26653        self
26654    }
26655    pub fn nested_vf_ports(mut self) -> PushVfPortsAttrs<Self> {
26656        let header_offset = push_nested_header(self.as_rec_mut(), 24u16);
26657        PushVfPortsAttrs {
26658            prev: Some(self),
26659            header_offset: Some(header_offset),
26660        }
26661    }
26662    pub fn nested_port_self(mut self) -> PushPortSelfAttrs<Self> {
26663        let header_offset = push_nested_header(self.as_rec_mut(), 25u16);
26664        PushPortSelfAttrs {
26665            prev: Some(self),
26666            header_offset: Some(header_offset),
26667        }
26668    }
26669    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
26670        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
26671        PushAfSpecAttrs {
26672            prev: Some(self),
26673            header_offset: Some(header_offset),
26674        }
26675    }
26676    pub fn push_group(mut self, value: u32) -> Self {
26677        push_header(self.as_rec_mut(), 27u16, 4 as u16);
26678        self.as_rec_mut().extend(value.to_ne_bytes());
26679        self
26680    }
26681    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
26682        push_header(self.as_rec_mut(), 28u16, 4 as u16);
26683        self.as_rec_mut().extend(value.to_ne_bytes());
26684        self
26685    }
26686    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26687    pub fn push_ext_mask(mut self, value: u32) -> Self {
26688        push_header(self.as_rec_mut(), 29u16, 4 as u16);
26689        self.as_rec_mut().extend(value.to_ne_bytes());
26690        self
26691    }
26692    pub fn push_promiscuity(mut self, value: u32) -> Self {
26693        push_header(self.as_rec_mut(), 30u16, 4 as u16);
26694        self.as_rec_mut().extend(value.to_ne_bytes());
26695        self
26696    }
26697    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
26698        push_header(self.as_rec_mut(), 31u16, 4 as u16);
26699        self.as_rec_mut().extend(value.to_ne_bytes());
26700        self
26701    }
26702    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
26703        push_header(self.as_rec_mut(), 32u16, 4 as u16);
26704        self.as_rec_mut().extend(value.to_ne_bytes());
26705        self
26706    }
26707    pub fn push_carrier(mut self, value: u8) -> Self {
26708        push_header(self.as_rec_mut(), 33u16, 1 as u16);
26709        self.as_rec_mut().extend(value.to_ne_bytes());
26710        self
26711    }
26712    pub fn push_phys_port_id(mut self, value: &[u8]) -> Self {
26713        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
26714        self.as_rec_mut().extend(value);
26715        self
26716    }
26717    pub fn push_carrier_changes(mut self, value: u32) -> Self {
26718        push_header(self.as_rec_mut(), 35u16, 4 as u16);
26719        self.as_rec_mut().extend(value.to_ne_bytes());
26720        self
26721    }
26722    pub fn push_phys_switch_id(mut self, value: &[u8]) -> Self {
26723        push_header(self.as_rec_mut(), 36u16, value.len() as u16);
26724        self.as_rec_mut().extend(value);
26725        self
26726    }
26727    pub fn push_link_netnsid(mut self, value: i32) -> Self {
26728        push_header(self.as_rec_mut(), 37u16, 4 as u16);
26729        self.as_rec_mut().extend(value.to_ne_bytes());
26730        self
26731    }
26732    pub fn push_phys_port_name(mut self, value: &CStr) -> Self {
26733        push_header(
26734            self.as_rec_mut(),
26735            38u16,
26736            value.to_bytes_with_nul().len() as u16,
26737        );
26738        self.as_rec_mut().extend(value.to_bytes_with_nul());
26739        self
26740    }
26741    pub fn push_phys_port_name_bytes(mut self, value: &[u8]) -> Self {
26742        push_header(self.as_rec_mut(), 38u16, (value.len() + 1) as u16);
26743        self.as_rec_mut().extend(value);
26744        self.as_rec_mut().push(0);
26745        self
26746    }
26747    pub fn push_proto_down(mut self, value: u8) -> Self {
26748        push_header(self.as_rec_mut(), 39u16, 1 as u16);
26749        self.as_rec_mut().extend(value.to_ne_bytes());
26750        self
26751    }
26752    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
26753        push_header(self.as_rec_mut(), 40u16, 4 as u16);
26754        self.as_rec_mut().extend(value.to_ne_bytes());
26755        self
26756    }
26757    pub fn push_gso_max_size(mut self, value: u32) -> Self {
26758        push_header(self.as_rec_mut(), 41u16, 4 as u16);
26759        self.as_rec_mut().extend(value.to_ne_bytes());
26760        self
26761    }
26762    pub fn push_pad(mut self, value: &[u8]) -> Self {
26763        push_header(self.as_rec_mut(), 42u16, value.len() as u16);
26764        self.as_rec_mut().extend(value);
26765        self
26766    }
26767    pub fn nested_xdp(mut self) -> PushXdpAttrs<Self> {
26768        let header_offset = push_nested_header(self.as_rec_mut(), 43u16);
26769        PushXdpAttrs {
26770            prev: Some(self),
26771            header_offset: Some(header_offset),
26772        }
26773    }
26774    pub fn push_event(mut self, value: u32) -> Self {
26775        push_header(self.as_rec_mut(), 44u16, 4 as u16);
26776        self.as_rec_mut().extend(value.to_ne_bytes());
26777        self
26778    }
26779    pub fn push_new_netnsid(mut self, value: i32) -> Self {
26780        push_header(self.as_rec_mut(), 45u16, 4 as u16);
26781        self.as_rec_mut().extend(value.to_ne_bytes());
26782        self
26783    }
26784    pub fn push_target_netnsid(mut self, value: i32) -> Self {
26785        push_header(self.as_rec_mut(), 46u16, 4 as u16);
26786        self.as_rec_mut().extend(value.to_ne_bytes());
26787        self
26788    }
26789    pub fn push_carrier_up_count(mut self, value: u32) -> Self {
26790        push_header(self.as_rec_mut(), 47u16, 4 as u16);
26791        self.as_rec_mut().extend(value.to_ne_bytes());
26792        self
26793    }
26794    pub fn push_carrier_down_count(mut self, value: u32) -> Self {
26795        push_header(self.as_rec_mut(), 48u16, 4 as u16);
26796        self.as_rec_mut().extend(value.to_ne_bytes());
26797        self
26798    }
26799    pub fn push_new_ifindex(mut self, value: i32) -> Self {
26800        push_header(self.as_rec_mut(), 49u16, 4 as u16);
26801        self.as_rec_mut().extend(value.to_ne_bytes());
26802        self
26803    }
26804    pub fn push_min_mtu(mut self, value: u32) -> Self {
26805        push_header(self.as_rec_mut(), 50u16, 4 as u16);
26806        self.as_rec_mut().extend(value.to_ne_bytes());
26807        self
26808    }
26809    pub fn push_max_mtu(mut self, value: u32) -> Self {
26810        push_header(self.as_rec_mut(), 51u16, 4 as u16);
26811        self.as_rec_mut().extend(value.to_ne_bytes());
26812        self
26813    }
26814    pub fn nested_prop_list(mut self) -> PushPropListLinkAttrs<Self> {
26815        let header_offset = push_nested_header(self.as_rec_mut(), 52u16);
26816        PushPropListLinkAttrs {
26817            prev: Some(self),
26818            header_offset: Some(header_offset),
26819        }
26820    }
26821    pub fn push_perm_address(mut self, value: &[u8]) -> Self {
26822        push_header(self.as_rec_mut(), 54u16, value.len() as u16);
26823        self.as_rec_mut().extend(value);
26824        self
26825    }
26826    pub fn push_proto_down_reason(mut self, value: &CStr) -> Self {
26827        push_header(
26828            self.as_rec_mut(),
26829            55u16,
26830            value.to_bytes_with_nul().len() as u16,
26831        );
26832        self.as_rec_mut().extend(value.to_bytes_with_nul());
26833        self
26834    }
26835    pub fn push_proto_down_reason_bytes(mut self, value: &[u8]) -> Self {
26836        push_header(self.as_rec_mut(), 55u16, (value.len() + 1) as u16);
26837        self.as_rec_mut().extend(value);
26838        self.as_rec_mut().push(0);
26839        self
26840    }
26841    pub fn push_parent_dev_name(mut self, value: &CStr) -> Self {
26842        push_header(
26843            self.as_rec_mut(),
26844            56u16,
26845            value.to_bytes_with_nul().len() as u16,
26846        );
26847        self.as_rec_mut().extend(value.to_bytes_with_nul());
26848        self
26849    }
26850    pub fn push_parent_dev_name_bytes(mut self, value: &[u8]) -> Self {
26851        push_header(self.as_rec_mut(), 56u16, (value.len() + 1) as u16);
26852        self.as_rec_mut().extend(value);
26853        self.as_rec_mut().push(0);
26854        self
26855    }
26856    pub fn push_parent_dev_bus_name(mut self, value: &CStr) -> Self {
26857        push_header(
26858            self.as_rec_mut(),
26859            57u16,
26860            value.to_bytes_with_nul().len() as u16,
26861        );
26862        self.as_rec_mut().extend(value.to_bytes_with_nul());
26863        self
26864    }
26865    pub fn push_parent_dev_bus_name_bytes(mut self, value: &[u8]) -> Self {
26866        push_header(self.as_rec_mut(), 57u16, (value.len() + 1) as u16);
26867        self.as_rec_mut().extend(value);
26868        self.as_rec_mut().push(0);
26869        self
26870    }
26871    pub fn push_gro_max_size(mut self, value: u32) -> Self {
26872        push_header(self.as_rec_mut(), 58u16, 4 as u16);
26873        self.as_rec_mut().extend(value.to_ne_bytes());
26874        self
26875    }
26876    pub fn push_tso_max_size(mut self, value: u32) -> Self {
26877        push_header(self.as_rec_mut(), 59u16, 4 as u16);
26878        self.as_rec_mut().extend(value.to_ne_bytes());
26879        self
26880    }
26881    pub fn push_tso_max_segs(mut self, value: u32) -> Self {
26882        push_header(self.as_rec_mut(), 60u16, 4 as u16);
26883        self.as_rec_mut().extend(value.to_ne_bytes());
26884        self
26885    }
26886    pub fn push_allmulti(mut self, value: u32) -> Self {
26887        push_header(self.as_rec_mut(), 61u16, 4 as u16);
26888        self.as_rec_mut().extend(value.to_ne_bytes());
26889        self
26890    }
26891    pub fn push_devlink_port(mut self, value: &[u8]) -> Self {
26892        push_header(self.as_rec_mut(), 62u16, value.len() as u16);
26893        self.as_rec_mut().extend(value);
26894        self
26895    }
26896    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
26897        push_header(self.as_rec_mut(), 63u16, 4 as u16);
26898        self.as_rec_mut().extend(value.to_ne_bytes());
26899        self
26900    }
26901    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
26902        push_header(self.as_rec_mut(), 64u16, 4 as u16);
26903        self.as_rec_mut().extend(value.to_ne_bytes());
26904        self
26905    }
26906    pub fn nested_dpll_pin(mut self) -> PushLinkDpllPinAttrs<Self> {
26907        let header_offset = push_nested_header(self.as_rec_mut(), 65u16);
26908        PushLinkDpllPinAttrs {
26909            prev: Some(self),
26910            header_offset: Some(header_offset),
26911        }
26912    }
26913    #[doc = "EDT offload horizon supported by the device (in nsec)."]
26914    pub fn push_max_pacing_offload_horizon(mut self, value: u32) -> Self {
26915        push_header(self.as_rec_mut(), 66u16, 4 as u16);
26916        self.as_rec_mut().extend(value.to_ne_bytes());
26917        self
26918    }
26919    pub fn push_netns_immutable(mut self, value: u8) -> Self {
26920        push_header(self.as_rec_mut(), 67u16, 1 as u16);
26921        self.as_rec_mut().extend(value.to_ne_bytes());
26922        self
26923    }
26924}
26925impl<Prev: Rec> Drop for PushOpGetlinkDoReply<Prev> {
26926    fn drop(&mut self) {
26927        if let Some(prev) = &mut self.prev {
26928            if let Some(header_offset) = &self.header_offset {
26929                finalize_nested_header(prev.as_rec_mut(), *header_offset);
26930            }
26931        }
26932    }
26933}
26934#[doc = "Get / dump information about a link."]
26935#[derive(Clone)]
26936pub enum OpGetlinkDoReply<'a> {
26937    Address(&'a [u8]),
26938    Broadcast(&'a [u8]),
26939    Ifname(&'a CStr),
26940    Mtu(u32),
26941    Link(u32),
26942    Qdisc(&'a CStr),
26943    Stats(PushRtnlLinkStats),
26944    Cost(&'a CStr),
26945    Priority(&'a CStr),
26946    Master(u32),
26947    Wireless(&'a CStr),
26948    Protinfo(&'a CStr),
26949    Txqlen(u32),
26950    Map(PushRtnlLinkIfmap),
26951    Weight(u32),
26952    Operstate(u8),
26953    Linkmode(u8),
26954    Linkinfo(IterableLinkinfoAttrs<'a>),
26955    NetNsPid(u32),
26956    Ifalias(&'a CStr),
26957    NumVf(u32),
26958    VfinfoList(IterableVfinfoListAttrs<'a>),
26959    Stats64(PushRtnlLinkStats64),
26960    VfPorts(IterableVfPortsAttrs<'a>),
26961    PortSelf(IterablePortSelfAttrs<'a>),
26962    AfSpec(IterableAfSpecAttrs<'a>),
26963    Group(u32),
26964    NetNsFd(u32),
26965    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
26966    ExtMask(u32),
26967    Promiscuity(u32),
26968    NumTxQueues(u32),
26969    NumRxQueues(u32),
26970    Carrier(u8),
26971    PhysPortId(&'a [u8]),
26972    CarrierChanges(u32),
26973    PhysSwitchId(&'a [u8]),
26974    LinkNetnsid(i32),
26975    PhysPortName(&'a CStr),
26976    ProtoDown(u8),
26977    GsoMaxSegs(u32),
26978    GsoMaxSize(u32),
26979    Pad(&'a [u8]),
26980    Xdp(IterableXdpAttrs<'a>),
26981    Event(u32),
26982    NewNetnsid(i32),
26983    TargetNetnsid(i32),
26984    CarrierUpCount(u32),
26985    CarrierDownCount(u32),
26986    NewIfindex(i32),
26987    MinMtu(u32),
26988    MaxMtu(u32),
26989    PropList(IterablePropListLinkAttrs<'a>),
26990    PermAddress(&'a [u8]),
26991    ProtoDownReason(&'a CStr),
26992    ParentDevName(&'a CStr),
26993    ParentDevBusName(&'a CStr),
26994    GroMaxSize(u32),
26995    TsoMaxSize(u32),
26996    TsoMaxSegs(u32),
26997    Allmulti(u32),
26998    DevlinkPort(&'a [u8]),
26999    GsoIpv4MaxSize(u32),
27000    GroIpv4MaxSize(u32),
27001    DpllPin(IterableLinkDpllPinAttrs<'a>),
27002    #[doc = "EDT offload horizon supported by the device (in nsec)."]
27003    MaxPacingOffloadHorizon(u32),
27004    NetnsImmutable(u8),
27005}
27006impl<'a> IterableOpGetlinkDoReply<'a> {
27007    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
27008        let mut iter = self.clone();
27009        iter.pos = 0;
27010        for attr in iter {
27011            if let OpGetlinkDoReply::Address(val) = attr? {
27012                return Ok(val);
27013            }
27014        }
27015        Err(ErrorContext::new_missing(
27016            "OpGetlinkDoReply",
27017            "Address",
27018            self.orig_loc,
27019            self.buf.as_ptr() as usize,
27020        ))
27021    }
27022    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
27023        let mut iter = self.clone();
27024        iter.pos = 0;
27025        for attr in iter {
27026            if let OpGetlinkDoReply::Broadcast(val) = attr? {
27027                return Ok(val);
27028            }
27029        }
27030        Err(ErrorContext::new_missing(
27031            "OpGetlinkDoReply",
27032            "Broadcast",
27033            self.orig_loc,
27034            self.buf.as_ptr() as usize,
27035        ))
27036    }
27037    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
27038        let mut iter = self.clone();
27039        iter.pos = 0;
27040        for attr in iter {
27041            if let OpGetlinkDoReply::Ifname(val) = attr? {
27042                return Ok(val);
27043            }
27044        }
27045        Err(ErrorContext::new_missing(
27046            "OpGetlinkDoReply",
27047            "Ifname",
27048            self.orig_loc,
27049            self.buf.as_ptr() as usize,
27050        ))
27051    }
27052    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
27053        let mut iter = self.clone();
27054        iter.pos = 0;
27055        for attr in iter {
27056            if let OpGetlinkDoReply::Mtu(val) = attr? {
27057                return Ok(val);
27058            }
27059        }
27060        Err(ErrorContext::new_missing(
27061            "OpGetlinkDoReply",
27062            "Mtu",
27063            self.orig_loc,
27064            self.buf.as_ptr() as usize,
27065        ))
27066    }
27067    pub fn get_link(&self) -> Result<u32, ErrorContext> {
27068        let mut iter = self.clone();
27069        iter.pos = 0;
27070        for attr in iter {
27071            if let OpGetlinkDoReply::Link(val) = attr? {
27072                return Ok(val);
27073            }
27074        }
27075        Err(ErrorContext::new_missing(
27076            "OpGetlinkDoReply",
27077            "Link",
27078            self.orig_loc,
27079            self.buf.as_ptr() as usize,
27080        ))
27081    }
27082    pub fn get_qdisc(&self) -> Result<&'a CStr, ErrorContext> {
27083        let mut iter = self.clone();
27084        iter.pos = 0;
27085        for attr in iter {
27086            if let OpGetlinkDoReply::Qdisc(val) = attr? {
27087                return Ok(val);
27088            }
27089        }
27090        Err(ErrorContext::new_missing(
27091            "OpGetlinkDoReply",
27092            "Qdisc",
27093            self.orig_loc,
27094            self.buf.as_ptr() as usize,
27095        ))
27096    }
27097    pub fn get_stats(&self) -> Result<PushRtnlLinkStats, ErrorContext> {
27098        let mut iter = self.clone();
27099        iter.pos = 0;
27100        for attr in iter {
27101            if let OpGetlinkDoReply::Stats(val) = attr? {
27102                return Ok(val);
27103            }
27104        }
27105        Err(ErrorContext::new_missing(
27106            "OpGetlinkDoReply",
27107            "Stats",
27108            self.orig_loc,
27109            self.buf.as_ptr() as usize,
27110        ))
27111    }
27112    pub fn get_cost(&self) -> Result<&'a CStr, ErrorContext> {
27113        let mut iter = self.clone();
27114        iter.pos = 0;
27115        for attr in iter {
27116            if let OpGetlinkDoReply::Cost(val) = attr? {
27117                return Ok(val);
27118            }
27119        }
27120        Err(ErrorContext::new_missing(
27121            "OpGetlinkDoReply",
27122            "Cost",
27123            self.orig_loc,
27124            self.buf.as_ptr() as usize,
27125        ))
27126    }
27127    pub fn get_priority(&self) -> Result<&'a CStr, ErrorContext> {
27128        let mut iter = self.clone();
27129        iter.pos = 0;
27130        for attr in iter {
27131            if let OpGetlinkDoReply::Priority(val) = attr? {
27132                return Ok(val);
27133            }
27134        }
27135        Err(ErrorContext::new_missing(
27136            "OpGetlinkDoReply",
27137            "Priority",
27138            self.orig_loc,
27139            self.buf.as_ptr() as usize,
27140        ))
27141    }
27142    pub fn get_master(&self) -> Result<u32, ErrorContext> {
27143        let mut iter = self.clone();
27144        iter.pos = 0;
27145        for attr in iter {
27146            if let OpGetlinkDoReply::Master(val) = attr? {
27147                return Ok(val);
27148            }
27149        }
27150        Err(ErrorContext::new_missing(
27151            "OpGetlinkDoReply",
27152            "Master",
27153            self.orig_loc,
27154            self.buf.as_ptr() as usize,
27155        ))
27156    }
27157    pub fn get_wireless(&self) -> Result<&'a CStr, ErrorContext> {
27158        let mut iter = self.clone();
27159        iter.pos = 0;
27160        for attr in iter {
27161            if let OpGetlinkDoReply::Wireless(val) = attr? {
27162                return Ok(val);
27163            }
27164        }
27165        Err(ErrorContext::new_missing(
27166            "OpGetlinkDoReply",
27167            "Wireless",
27168            self.orig_loc,
27169            self.buf.as_ptr() as usize,
27170        ))
27171    }
27172    pub fn get_protinfo(&self) -> Result<&'a CStr, ErrorContext> {
27173        let mut iter = self.clone();
27174        iter.pos = 0;
27175        for attr in iter {
27176            if let OpGetlinkDoReply::Protinfo(val) = attr? {
27177                return Ok(val);
27178            }
27179        }
27180        Err(ErrorContext::new_missing(
27181            "OpGetlinkDoReply",
27182            "Protinfo",
27183            self.orig_loc,
27184            self.buf.as_ptr() as usize,
27185        ))
27186    }
27187    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
27188        let mut iter = self.clone();
27189        iter.pos = 0;
27190        for attr in iter {
27191            if let OpGetlinkDoReply::Txqlen(val) = attr? {
27192                return Ok(val);
27193            }
27194        }
27195        Err(ErrorContext::new_missing(
27196            "OpGetlinkDoReply",
27197            "Txqlen",
27198            self.orig_loc,
27199            self.buf.as_ptr() as usize,
27200        ))
27201    }
27202    pub fn get_map(&self) -> Result<PushRtnlLinkIfmap, ErrorContext> {
27203        let mut iter = self.clone();
27204        iter.pos = 0;
27205        for attr in iter {
27206            if let OpGetlinkDoReply::Map(val) = attr? {
27207                return Ok(val);
27208            }
27209        }
27210        Err(ErrorContext::new_missing(
27211            "OpGetlinkDoReply",
27212            "Map",
27213            self.orig_loc,
27214            self.buf.as_ptr() as usize,
27215        ))
27216    }
27217    pub fn get_weight(&self) -> Result<u32, ErrorContext> {
27218        let mut iter = self.clone();
27219        iter.pos = 0;
27220        for attr in iter {
27221            if let OpGetlinkDoReply::Weight(val) = attr? {
27222                return Ok(val);
27223            }
27224        }
27225        Err(ErrorContext::new_missing(
27226            "OpGetlinkDoReply",
27227            "Weight",
27228            self.orig_loc,
27229            self.buf.as_ptr() as usize,
27230        ))
27231    }
27232    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
27233        let mut iter = self.clone();
27234        iter.pos = 0;
27235        for attr in iter {
27236            if let OpGetlinkDoReply::Operstate(val) = attr? {
27237                return Ok(val);
27238            }
27239        }
27240        Err(ErrorContext::new_missing(
27241            "OpGetlinkDoReply",
27242            "Operstate",
27243            self.orig_loc,
27244            self.buf.as_ptr() as usize,
27245        ))
27246    }
27247    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
27248        let mut iter = self.clone();
27249        iter.pos = 0;
27250        for attr in iter {
27251            if let OpGetlinkDoReply::Linkmode(val) = attr? {
27252                return Ok(val);
27253            }
27254        }
27255        Err(ErrorContext::new_missing(
27256            "OpGetlinkDoReply",
27257            "Linkmode",
27258            self.orig_loc,
27259            self.buf.as_ptr() as usize,
27260        ))
27261    }
27262    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
27263        let mut iter = self.clone();
27264        iter.pos = 0;
27265        for attr in iter {
27266            if let OpGetlinkDoReply::Linkinfo(val) = attr? {
27267                return Ok(val);
27268            }
27269        }
27270        Err(ErrorContext::new_missing(
27271            "OpGetlinkDoReply",
27272            "Linkinfo",
27273            self.orig_loc,
27274            self.buf.as_ptr() as usize,
27275        ))
27276    }
27277    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
27278        let mut iter = self.clone();
27279        iter.pos = 0;
27280        for attr in iter {
27281            if let OpGetlinkDoReply::NetNsPid(val) = attr? {
27282                return Ok(val);
27283            }
27284        }
27285        Err(ErrorContext::new_missing(
27286            "OpGetlinkDoReply",
27287            "NetNsPid",
27288            self.orig_loc,
27289            self.buf.as_ptr() as usize,
27290        ))
27291    }
27292    pub fn get_ifalias(&self) -> Result<&'a CStr, ErrorContext> {
27293        let mut iter = self.clone();
27294        iter.pos = 0;
27295        for attr in iter {
27296            if let OpGetlinkDoReply::Ifalias(val) = attr? {
27297                return Ok(val);
27298            }
27299        }
27300        Err(ErrorContext::new_missing(
27301            "OpGetlinkDoReply",
27302            "Ifalias",
27303            self.orig_loc,
27304            self.buf.as_ptr() as usize,
27305        ))
27306    }
27307    pub fn get_num_vf(&self) -> Result<u32, ErrorContext> {
27308        let mut iter = self.clone();
27309        iter.pos = 0;
27310        for attr in iter {
27311            if let OpGetlinkDoReply::NumVf(val) = attr? {
27312                return Ok(val);
27313            }
27314        }
27315        Err(ErrorContext::new_missing(
27316            "OpGetlinkDoReply",
27317            "NumVf",
27318            self.orig_loc,
27319            self.buf.as_ptr() as usize,
27320        ))
27321    }
27322    pub fn get_vfinfo_list(&self) -> Result<IterableVfinfoListAttrs<'a>, ErrorContext> {
27323        let mut iter = self.clone();
27324        iter.pos = 0;
27325        for attr in iter {
27326            if let OpGetlinkDoReply::VfinfoList(val) = attr? {
27327                return Ok(val);
27328            }
27329        }
27330        Err(ErrorContext::new_missing(
27331            "OpGetlinkDoReply",
27332            "VfinfoList",
27333            self.orig_loc,
27334            self.buf.as_ptr() as usize,
27335        ))
27336    }
27337    pub fn get_stats64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
27338        let mut iter = self.clone();
27339        iter.pos = 0;
27340        for attr in iter {
27341            if let OpGetlinkDoReply::Stats64(val) = attr? {
27342                return Ok(val);
27343            }
27344        }
27345        Err(ErrorContext::new_missing(
27346            "OpGetlinkDoReply",
27347            "Stats64",
27348            self.orig_loc,
27349            self.buf.as_ptr() as usize,
27350        ))
27351    }
27352    pub fn get_vf_ports(&self) -> Result<IterableVfPortsAttrs<'a>, ErrorContext> {
27353        let mut iter = self.clone();
27354        iter.pos = 0;
27355        for attr in iter {
27356            if let OpGetlinkDoReply::VfPorts(val) = attr? {
27357                return Ok(val);
27358            }
27359        }
27360        Err(ErrorContext::new_missing(
27361            "OpGetlinkDoReply",
27362            "VfPorts",
27363            self.orig_loc,
27364            self.buf.as_ptr() as usize,
27365        ))
27366    }
27367    pub fn get_port_self(&self) -> Result<IterablePortSelfAttrs<'a>, ErrorContext> {
27368        let mut iter = self.clone();
27369        iter.pos = 0;
27370        for attr in iter {
27371            if let OpGetlinkDoReply::PortSelf(val) = attr? {
27372                return Ok(val);
27373            }
27374        }
27375        Err(ErrorContext::new_missing(
27376            "OpGetlinkDoReply",
27377            "PortSelf",
27378            self.orig_loc,
27379            self.buf.as_ptr() as usize,
27380        ))
27381    }
27382    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
27383        let mut iter = self.clone();
27384        iter.pos = 0;
27385        for attr in iter {
27386            if let OpGetlinkDoReply::AfSpec(val) = attr? {
27387                return Ok(val);
27388            }
27389        }
27390        Err(ErrorContext::new_missing(
27391            "OpGetlinkDoReply",
27392            "AfSpec",
27393            self.orig_loc,
27394            self.buf.as_ptr() as usize,
27395        ))
27396    }
27397    pub fn get_group(&self) -> Result<u32, ErrorContext> {
27398        let mut iter = self.clone();
27399        iter.pos = 0;
27400        for attr in iter {
27401            if let OpGetlinkDoReply::Group(val) = attr? {
27402                return Ok(val);
27403            }
27404        }
27405        Err(ErrorContext::new_missing(
27406            "OpGetlinkDoReply",
27407            "Group",
27408            self.orig_loc,
27409            self.buf.as_ptr() as usize,
27410        ))
27411    }
27412    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
27413        let mut iter = self.clone();
27414        iter.pos = 0;
27415        for attr in iter {
27416            if let OpGetlinkDoReply::NetNsFd(val) = attr? {
27417                return Ok(val);
27418            }
27419        }
27420        Err(ErrorContext::new_missing(
27421            "OpGetlinkDoReply",
27422            "NetNsFd",
27423            self.orig_loc,
27424            self.buf.as_ptr() as usize,
27425        ))
27426    }
27427    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
27428    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
27429        let mut iter = self.clone();
27430        iter.pos = 0;
27431        for attr in iter {
27432            if let OpGetlinkDoReply::ExtMask(val) = attr? {
27433                return Ok(val);
27434            }
27435        }
27436        Err(ErrorContext::new_missing(
27437            "OpGetlinkDoReply",
27438            "ExtMask",
27439            self.orig_loc,
27440            self.buf.as_ptr() as usize,
27441        ))
27442    }
27443    pub fn get_promiscuity(&self) -> Result<u32, ErrorContext> {
27444        let mut iter = self.clone();
27445        iter.pos = 0;
27446        for attr in iter {
27447            if let OpGetlinkDoReply::Promiscuity(val) = attr? {
27448                return Ok(val);
27449            }
27450        }
27451        Err(ErrorContext::new_missing(
27452            "OpGetlinkDoReply",
27453            "Promiscuity",
27454            self.orig_loc,
27455            self.buf.as_ptr() as usize,
27456        ))
27457    }
27458    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
27459        let mut iter = self.clone();
27460        iter.pos = 0;
27461        for attr in iter {
27462            if let OpGetlinkDoReply::NumTxQueues(val) = attr? {
27463                return Ok(val);
27464            }
27465        }
27466        Err(ErrorContext::new_missing(
27467            "OpGetlinkDoReply",
27468            "NumTxQueues",
27469            self.orig_loc,
27470            self.buf.as_ptr() as usize,
27471        ))
27472    }
27473    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
27474        let mut iter = self.clone();
27475        iter.pos = 0;
27476        for attr in iter {
27477            if let OpGetlinkDoReply::NumRxQueues(val) = attr? {
27478                return Ok(val);
27479            }
27480        }
27481        Err(ErrorContext::new_missing(
27482            "OpGetlinkDoReply",
27483            "NumRxQueues",
27484            self.orig_loc,
27485            self.buf.as_ptr() as usize,
27486        ))
27487    }
27488    pub fn get_carrier(&self) -> Result<u8, ErrorContext> {
27489        let mut iter = self.clone();
27490        iter.pos = 0;
27491        for attr in iter {
27492            if let OpGetlinkDoReply::Carrier(val) = attr? {
27493                return Ok(val);
27494            }
27495        }
27496        Err(ErrorContext::new_missing(
27497            "OpGetlinkDoReply",
27498            "Carrier",
27499            self.orig_loc,
27500            self.buf.as_ptr() as usize,
27501        ))
27502    }
27503    pub fn get_phys_port_id(&self) -> Result<&'a [u8], ErrorContext> {
27504        let mut iter = self.clone();
27505        iter.pos = 0;
27506        for attr in iter {
27507            if let OpGetlinkDoReply::PhysPortId(val) = attr? {
27508                return Ok(val);
27509            }
27510        }
27511        Err(ErrorContext::new_missing(
27512            "OpGetlinkDoReply",
27513            "PhysPortId",
27514            self.orig_loc,
27515            self.buf.as_ptr() as usize,
27516        ))
27517    }
27518    pub fn get_carrier_changes(&self) -> Result<u32, ErrorContext> {
27519        let mut iter = self.clone();
27520        iter.pos = 0;
27521        for attr in iter {
27522            if let OpGetlinkDoReply::CarrierChanges(val) = attr? {
27523                return Ok(val);
27524            }
27525        }
27526        Err(ErrorContext::new_missing(
27527            "OpGetlinkDoReply",
27528            "CarrierChanges",
27529            self.orig_loc,
27530            self.buf.as_ptr() as usize,
27531        ))
27532    }
27533    pub fn get_phys_switch_id(&self) -> Result<&'a [u8], ErrorContext> {
27534        let mut iter = self.clone();
27535        iter.pos = 0;
27536        for attr in iter {
27537            if let OpGetlinkDoReply::PhysSwitchId(val) = attr? {
27538                return Ok(val);
27539            }
27540        }
27541        Err(ErrorContext::new_missing(
27542            "OpGetlinkDoReply",
27543            "PhysSwitchId",
27544            self.orig_loc,
27545            self.buf.as_ptr() as usize,
27546        ))
27547    }
27548    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
27549        let mut iter = self.clone();
27550        iter.pos = 0;
27551        for attr in iter {
27552            if let OpGetlinkDoReply::LinkNetnsid(val) = attr? {
27553                return Ok(val);
27554            }
27555        }
27556        Err(ErrorContext::new_missing(
27557            "OpGetlinkDoReply",
27558            "LinkNetnsid",
27559            self.orig_loc,
27560            self.buf.as_ptr() as usize,
27561        ))
27562    }
27563    pub fn get_phys_port_name(&self) -> Result<&'a CStr, ErrorContext> {
27564        let mut iter = self.clone();
27565        iter.pos = 0;
27566        for attr in iter {
27567            if let OpGetlinkDoReply::PhysPortName(val) = attr? {
27568                return Ok(val);
27569            }
27570        }
27571        Err(ErrorContext::new_missing(
27572            "OpGetlinkDoReply",
27573            "PhysPortName",
27574            self.orig_loc,
27575            self.buf.as_ptr() as usize,
27576        ))
27577    }
27578    pub fn get_proto_down(&self) -> Result<u8, ErrorContext> {
27579        let mut iter = self.clone();
27580        iter.pos = 0;
27581        for attr in iter {
27582            if let OpGetlinkDoReply::ProtoDown(val) = attr? {
27583                return Ok(val);
27584            }
27585        }
27586        Err(ErrorContext::new_missing(
27587            "OpGetlinkDoReply",
27588            "ProtoDown",
27589            self.orig_loc,
27590            self.buf.as_ptr() as usize,
27591        ))
27592    }
27593    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
27594        let mut iter = self.clone();
27595        iter.pos = 0;
27596        for attr in iter {
27597            if let OpGetlinkDoReply::GsoMaxSegs(val) = attr? {
27598                return Ok(val);
27599            }
27600        }
27601        Err(ErrorContext::new_missing(
27602            "OpGetlinkDoReply",
27603            "GsoMaxSegs",
27604            self.orig_loc,
27605            self.buf.as_ptr() as usize,
27606        ))
27607    }
27608    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
27609        let mut iter = self.clone();
27610        iter.pos = 0;
27611        for attr in iter {
27612            if let OpGetlinkDoReply::GsoMaxSize(val) = attr? {
27613                return Ok(val);
27614            }
27615        }
27616        Err(ErrorContext::new_missing(
27617            "OpGetlinkDoReply",
27618            "GsoMaxSize",
27619            self.orig_loc,
27620            self.buf.as_ptr() as usize,
27621        ))
27622    }
27623    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
27624        let mut iter = self.clone();
27625        iter.pos = 0;
27626        for attr in iter {
27627            if let OpGetlinkDoReply::Pad(val) = attr? {
27628                return Ok(val);
27629            }
27630        }
27631        Err(ErrorContext::new_missing(
27632            "OpGetlinkDoReply",
27633            "Pad",
27634            self.orig_loc,
27635            self.buf.as_ptr() as usize,
27636        ))
27637    }
27638    pub fn get_xdp(&self) -> Result<IterableXdpAttrs<'a>, ErrorContext> {
27639        let mut iter = self.clone();
27640        iter.pos = 0;
27641        for attr in iter {
27642            if let OpGetlinkDoReply::Xdp(val) = attr? {
27643                return Ok(val);
27644            }
27645        }
27646        Err(ErrorContext::new_missing(
27647            "OpGetlinkDoReply",
27648            "Xdp",
27649            self.orig_loc,
27650            self.buf.as_ptr() as usize,
27651        ))
27652    }
27653    pub fn get_event(&self) -> Result<u32, ErrorContext> {
27654        let mut iter = self.clone();
27655        iter.pos = 0;
27656        for attr in iter {
27657            if let OpGetlinkDoReply::Event(val) = attr? {
27658                return Ok(val);
27659            }
27660        }
27661        Err(ErrorContext::new_missing(
27662            "OpGetlinkDoReply",
27663            "Event",
27664            self.orig_loc,
27665            self.buf.as_ptr() as usize,
27666        ))
27667    }
27668    pub fn get_new_netnsid(&self) -> Result<i32, ErrorContext> {
27669        let mut iter = self.clone();
27670        iter.pos = 0;
27671        for attr in iter {
27672            if let OpGetlinkDoReply::NewNetnsid(val) = attr? {
27673                return Ok(val);
27674            }
27675        }
27676        Err(ErrorContext::new_missing(
27677            "OpGetlinkDoReply",
27678            "NewNetnsid",
27679            self.orig_loc,
27680            self.buf.as_ptr() as usize,
27681        ))
27682    }
27683    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
27684        let mut iter = self.clone();
27685        iter.pos = 0;
27686        for attr in iter {
27687            if let OpGetlinkDoReply::TargetNetnsid(val) = attr? {
27688                return Ok(val);
27689            }
27690        }
27691        Err(ErrorContext::new_missing(
27692            "OpGetlinkDoReply",
27693            "TargetNetnsid",
27694            self.orig_loc,
27695            self.buf.as_ptr() as usize,
27696        ))
27697    }
27698    pub fn get_carrier_up_count(&self) -> Result<u32, ErrorContext> {
27699        let mut iter = self.clone();
27700        iter.pos = 0;
27701        for attr in iter {
27702            if let OpGetlinkDoReply::CarrierUpCount(val) = attr? {
27703                return Ok(val);
27704            }
27705        }
27706        Err(ErrorContext::new_missing(
27707            "OpGetlinkDoReply",
27708            "CarrierUpCount",
27709            self.orig_loc,
27710            self.buf.as_ptr() as usize,
27711        ))
27712    }
27713    pub fn get_carrier_down_count(&self) -> Result<u32, ErrorContext> {
27714        let mut iter = self.clone();
27715        iter.pos = 0;
27716        for attr in iter {
27717            if let OpGetlinkDoReply::CarrierDownCount(val) = attr? {
27718                return Ok(val);
27719            }
27720        }
27721        Err(ErrorContext::new_missing(
27722            "OpGetlinkDoReply",
27723            "CarrierDownCount",
27724            self.orig_loc,
27725            self.buf.as_ptr() as usize,
27726        ))
27727    }
27728    pub fn get_new_ifindex(&self) -> Result<i32, ErrorContext> {
27729        let mut iter = self.clone();
27730        iter.pos = 0;
27731        for attr in iter {
27732            if let OpGetlinkDoReply::NewIfindex(val) = attr? {
27733                return Ok(val);
27734            }
27735        }
27736        Err(ErrorContext::new_missing(
27737            "OpGetlinkDoReply",
27738            "NewIfindex",
27739            self.orig_loc,
27740            self.buf.as_ptr() as usize,
27741        ))
27742    }
27743    pub fn get_min_mtu(&self) -> Result<u32, ErrorContext> {
27744        let mut iter = self.clone();
27745        iter.pos = 0;
27746        for attr in iter {
27747            if let OpGetlinkDoReply::MinMtu(val) = attr? {
27748                return Ok(val);
27749            }
27750        }
27751        Err(ErrorContext::new_missing(
27752            "OpGetlinkDoReply",
27753            "MinMtu",
27754            self.orig_loc,
27755            self.buf.as_ptr() as usize,
27756        ))
27757    }
27758    pub fn get_max_mtu(&self) -> Result<u32, ErrorContext> {
27759        let mut iter = self.clone();
27760        iter.pos = 0;
27761        for attr in iter {
27762            if let OpGetlinkDoReply::MaxMtu(val) = attr? {
27763                return Ok(val);
27764            }
27765        }
27766        Err(ErrorContext::new_missing(
27767            "OpGetlinkDoReply",
27768            "MaxMtu",
27769            self.orig_loc,
27770            self.buf.as_ptr() as usize,
27771        ))
27772    }
27773    pub fn get_prop_list(&self) -> Result<IterablePropListLinkAttrs<'a>, ErrorContext> {
27774        let mut iter = self.clone();
27775        iter.pos = 0;
27776        for attr in iter {
27777            if let OpGetlinkDoReply::PropList(val) = attr? {
27778                return Ok(val);
27779            }
27780        }
27781        Err(ErrorContext::new_missing(
27782            "OpGetlinkDoReply",
27783            "PropList",
27784            self.orig_loc,
27785            self.buf.as_ptr() as usize,
27786        ))
27787    }
27788    pub fn get_perm_address(&self) -> Result<&'a [u8], ErrorContext> {
27789        let mut iter = self.clone();
27790        iter.pos = 0;
27791        for attr in iter {
27792            if let OpGetlinkDoReply::PermAddress(val) = attr? {
27793                return Ok(val);
27794            }
27795        }
27796        Err(ErrorContext::new_missing(
27797            "OpGetlinkDoReply",
27798            "PermAddress",
27799            self.orig_loc,
27800            self.buf.as_ptr() as usize,
27801        ))
27802    }
27803    pub fn get_proto_down_reason(&self) -> Result<&'a CStr, ErrorContext> {
27804        let mut iter = self.clone();
27805        iter.pos = 0;
27806        for attr in iter {
27807            if let OpGetlinkDoReply::ProtoDownReason(val) = attr? {
27808                return Ok(val);
27809            }
27810        }
27811        Err(ErrorContext::new_missing(
27812            "OpGetlinkDoReply",
27813            "ProtoDownReason",
27814            self.orig_loc,
27815            self.buf.as_ptr() as usize,
27816        ))
27817    }
27818    pub fn get_parent_dev_name(&self) -> Result<&'a CStr, ErrorContext> {
27819        let mut iter = self.clone();
27820        iter.pos = 0;
27821        for attr in iter {
27822            if let OpGetlinkDoReply::ParentDevName(val) = attr? {
27823                return Ok(val);
27824            }
27825        }
27826        Err(ErrorContext::new_missing(
27827            "OpGetlinkDoReply",
27828            "ParentDevName",
27829            self.orig_loc,
27830            self.buf.as_ptr() as usize,
27831        ))
27832    }
27833    pub fn get_parent_dev_bus_name(&self) -> Result<&'a CStr, ErrorContext> {
27834        let mut iter = self.clone();
27835        iter.pos = 0;
27836        for attr in iter {
27837            if let OpGetlinkDoReply::ParentDevBusName(val) = attr? {
27838                return Ok(val);
27839            }
27840        }
27841        Err(ErrorContext::new_missing(
27842            "OpGetlinkDoReply",
27843            "ParentDevBusName",
27844            self.orig_loc,
27845            self.buf.as_ptr() as usize,
27846        ))
27847    }
27848    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
27849        let mut iter = self.clone();
27850        iter.pos = 0;
27851        for attr in iter {
27852            if let OpGetlinkDoReply::GroMaxSize(val) = attr? {
27853                return Ok(val);
27854            }
27855        }
27856        Err(ErrorContext::new_missing(
27857            "OpGetlinkDoReply",
27858            "GroMaxSize",
27859            self.orig_loc,
27860            self.buf.as_ptr() as usize,
27861        ))
27862    }
27863    pub fn get_tso_max_size(&self) -> Result<u32, ErrorContext> {
27864        let mut iter = self.clone();
27865        iter.pos = 0;
27866        for attr in iter {
27867            if let OpGetlinkDoReply::TsoMaxSize(val) = attr? {
27868                return Ok(val);
27869            }
27870        }
27871        Err(ErrorContext::new_missing(
27872            "OpGetlinkDoReply",
27873            "TsoMaxSize",
27874            self.orig_loc,
27875            self.buf.as_ptr() as usize,
27876        ))
27877    }
27878    pub fn get_tso_max_segs(&self) -> Result<u32, ErrorContext> {
27879        let mut iter = self.clone();
27880        iter.pos = 0;
27881        for attr in iter {
27882            if let OpGetlinkDoReply::TsoMaxSegs(val) = attr? {
27883                return Ok(val);
27884            }
27885        }
27886        Err(ErrorContext::new_missing(
27887            "OpGetlinkDoReply",
27888            "TsoMaxSegs",
27889            self.orig_loc,
27890            self.buf.as_ptr() as usize,
27891        ))
27892    }
27893    pub fn get_allmulti(&self) -> Result<u32, ErrorContext> {
27894        let mut iter = self.clone();
27895        iter.pos = 0;
27896        for attr in iter {
27897            if let OpGetlinkDoReply::Allmulti(val) = attr? {
27898                return Ok(val);
27899            }
27900        }
27901        Err(ErrorContext::new_missing(
27902            "OpGetlinkDoReply",
27903            "Allmulti",
27904            self.orig_loc,
27905            self.buf.as_ptr() as usize,
27906        ))
27907    }
27908    pub fn get_devlink_port(&self) -> Result<&'a [u8], ErrorContext> {
27909        let mut iter = self.clone();
27910        iter.pos = 0;
27911        for attr in iter {
27912            if let OpGetlinkDoReply::DevlinkPort(val) = attr? {
27913                return Ok(val);
27914            }
27915        }
27916        Err(ErrorContext::new_missing(
27917            "OpGetlinkDoReply",
27918            "DevlinkPort",
27919            self.orig_loc,
27920            self.buf.as_ptr() as usize,
27921        ))
27922    }
27923    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
27924        let mut iter = self.clone();
27925        iter.pos = 0;
27926        for attr in iter {
27927            if let OpGetlinkDoReply::GsoIpv4MaxSize(val) = attr? {
27928                return Ok(val);
27929            }
27930        }
27931        Err(ErrorContext::new_missing(
27932            "OpGetlinkDoReply",
27933            "GsoIpv4MaxSize",
27934            self.orig_loc,
27935            self.buf.as_ptr() as usize,
27936        ))
27937    }
27938    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
27939        let mut iter = self.clone();
27940        iter.pos = 0;
27941        for attr in iter {
27942            if let OpGetlinkDoReply::GroIpv4MaxSize(val) = attr? {
27943                return Ok(val);
27944            }
27945        }
27946        Err(ErrorContext::new_missing(
27947            "OpGetlinkDoReply",
27948            "GroIpv4MaxSize",
27949            self.orig_loc,
27950            self.buf.as_ptr() as usize,
27951        ))
27952    }
27953    pub fn get_dpll_pin(&self) -> Result<IterableLinkDpllPinAttrs<'a>, ErrorContext> {
27954        let mut iter = self.clone();
27955        iter.pos = 0;
27956        for attr in iter {
27957            if let OpGetlinkDoReply::DpllPin(val) = attr? {
27958                return Ok(val);
27959            }
27960        }
27961        Err(ErrorContext::new_missing(
27962            "OpGetlinkDoReply",
27963            "DpllPin",
27964            self.orig_loc,
27965            self.buf.as_ptr() as usize,
27966        ))
27967    }
27968    #[doc = "EDT offload horizon supported by the device (in nsec)."]
27969    pub fn get_max_pacing_offload_horizon(&self) -> Result<u32, ErrorContext> {
27970        let mut iter = self.clone();
27971        iter.pos = 0;
27972        for attr in iter {
27973            if let OpGetlinkDoReply::MaxPacingOffloadHorizon(val) = attr? {
27974                return Ok(val);
27975            }
27976        }
27977        Err(ErrorContext::new_missing(
27978            "OpGetlinkDoReply",
27979            "MaxPacingOffloadHorizon",
27980            self.orig_loc,
27981            self.buf.as_ptr() as usize,
27982        ))
27983    }
27984    pub fn get_netns_immutable(&self) -> Result<u8, ErrorContext> {
27985        let mut iter = self.clone();
27986        iter.pos = 0;
27987        for attr in iter {
27988            if let OpGetlinkDoReply::NetnsImmutable(val) = attr? {
27989                return Ok(val);
27990            }
27991        }
27992        Err(ErrorContext::new_missing(
27993            "OpGetlinkDoReply",
27994            "NetnsImmutable",
27995            self.orig_loc,
27996            self.buf.as_ptr() as usize,
27997        ))
27998    }
27999}
28000impl<'a> OpGetlinkDoReply<'a> {
28001    pub fn new(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpGetlinkDoReply<'a>) {
28002        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
28003        (
28004            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
28005            IterableOpGetlinkDoReply::with_loc(attrs, buf.as_ptr() as usize),
28006        )
28007    }
28008    fn attr_from_type(r#type: u16) -> Option<&'static str> {
28009        LinkAttrs::attr_from_type(r#type)
28010    }
28011}
28012#[derive(Clone, Copy, Default)]
28013pub struct IterableOpGetlinkDoReply<'a> {
28014    buf: &'a [u8],
28015    pos: usize,
28016    orig_loc: usize,
28017}
28018impl<'a> IterableOpGetlinkDoReply<'a> {
28019    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
28020        Self {
28021            buf,
28022            pos: 0,
28023            orig_loc,
28024        }
28025    }
28026    pub fn get_buf(&self) -> &'a [u8] {
28027        self.buf
28028    }
28029}
28030impl<'a> Iterator for IterableOpGetlinkDoReply<'a> {
28031    type Item = Result<OpGetlinkDoReply<'a>, ErrorContext>;
28032    fn next(&mut self) -> Option<Self::Item> {
28033        if self.buf.len() == self.pos {
28034            return None;
28035        }
28036        let pos = self.pos;
28037        let mut r#type = None;
28038        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
28039            r#type = Some(header.r#type);
28040            let res = match header.r#type {
28041                1u16 => OpGetlinkDoReply::Address({
28042                    let res = Some(next);
28043                    let Some(val) = res else { break };
28044                    val
28045                }),
28046                2u16 => OpGetlinkDoReply::Broadcast({
28047                    let res = Some(next);
28048                    let Some(val) = res else { break };
28049                    val
28050                }),
28051                3u16 => OpGetlinkDoReply::Ifname({
28052                    let res = CStr::from_bytes_with_nul(next).ok();
28053                    let Some(val) = res else { break };
28054                    val
28055                }),
28056                4u16 => OpGetlinkDoReply::Mtu({
28057                    let res = parse_u32(next);
28058                    let Some(val) = res else { break };
28059                    val
28060                }),
28061                5u16 => OpGetlinkDoReply::Link({
28062                    let res = parse_u32(next);
28063                    let Some(val) = res else { break };
28064                    val
28065                }),
28066                6u16 => OpGetlinkDoReply::Qdisc({
28067                    let res = CStr::from_bytes_with_nul(next).ok();
28068                    let Some(val) = res else { break };
28069                    val
28070                }),
28071                7u16 => OpGetlinkDoReply::Stats({
28072                    let res = PushRtnlLinkStats::new_from_slice(next);
28073                    let Some(val) = res else { break };
28074                    val
28075                }),
28076                8u16 => OpGetlinkDoReply::Cost({
28077                    let res = CStr::from_bytes_with_nul(next).ok();
28078                    let Some(val) = res else { break };
28079                    val
28080                }),
28081                9u16 => OpGetlinkDoReply::Priority({
28082                    let res = CStr::from_bytes_with_nul(next).ok();
28083                    let Some(val) = res else { break };
28084                    val
28085                }),
28086                10u16 => OpGetlinkDoReply::Master({
28087                    let res = parse_u32(next);
28088                    let Some(val) = res else { break };
28089                    val
28090                }),
28091                11u16 => OpGetlinkDoReply::Wireless({
28092                    let res = CStr::from_bytes_with_nul(next).ok();
28093                    let Some(val) = res else { break };
28094                    val
28095                }),
28096                12u16 => OpGetlinkDoReply::Protinfo({
28097                    let res = CStr::from_bytes_with_nul(next).ok();
28098                    let Some(val) = res else { break };
28099                    val
28100                }),
28101                13u16 => OpGetlinkDoReply::Txqlen({
28102                    let res = parse_u32(next);
28103                    let Some(val) = res else { break };
28104                    val
28105                }),
28106                14u16 => OpGetlinkDoReply::Map({
28107                    let res = PushRtnlLinkIfmap::new_from_slice(next);
28108                    let Some(val) = res else { break };
28109                    val
28110                }),
28111                15u16 => OpGetlinkDoReply::Weight({
28112                    let res = parse_u32(next);
28113                    let Some(val) = res else { break };
28114                    val
28115                }),
28116                16u16 => OpGetlinkDoReply::Operstate({
28117                    let res = parse_u8(next);
28118                    let Some(val) = res else { break };
28119                    val
28120                }),
28121                17u16 => OpGetlinkDoReply::Linkmode({
28122                    let res = parse_u8(next);
28123                    let Some(val) = res else { break };
28124                    val
28125                }),
28126                18u16 => OpGetlinkDoReply::Linkinfo({
28127                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
28128                    let Some(val) = res else { break };
28129                    val
28130                }),
28131                19u16 => OpGetlinkDoReply::NetNsPid({
28132                    let res = parse_u32(next);
28133                    let Some(val) = res else { break };
28134                    val
28135                }),
28136                20u16 => OpGetlinkDoReply::Ifalias({
28137                    let res = CStr::from_bytes_with_nul(next).ok();
28138                    let Some(val) = res else { break };
28139                    val
28140                }),
28141                21u16 => OpGetlinkDoReply::NumVf({
28142                    let res = parse_u32(next);
28143                    let Some(val) = res else { break };
28144                    val
28145                }),
28146                22u16 => OpGetlinkDoReply::VfinfoList({
28147                    let res = Some(IterableVfinfoListAttrs::with_loc(next, self.orig_loc));
28148                    let Some(val) = res else { break };
28149                    val
28150                }),
28151                23u16 => OpGetlinkDoReply::Stats64({
28152                    let res = PushRtnlLinkStats64::new_from_slice(next);
28153                    let Some(val) = res else { break };
28154                    val
28155                }),
28156                24u16 => OpGetlinkDoReply::VfPorts({
28157                    let res = Some(IterableVfPortsAttrs::with_loc(next, self.orig_loc));
28158                    let Some(val) = res else { break };
28159                    val
28160                }),
28161                25u16 => OpGetlinkDoReply::PortSelf({
28162                    let res = Some(IterablePortSelfAttrs::with_loc(next, self.orig_loc));
28163                    let Some(val) = res else { break };
28164                    val
28165                }),
28166                26u16 => OpGetlinkDoReply::AfSpec({
28167                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
28168                    let Some(val) = res else { break };
28169                    val
28170                }),
28171                27u16 => OpGetlinkDoReply::Group({
28172                    let res = parse_u32(next);
28173                    let Some(val) = res else { break };
28174                    val
28175                }),
28176                28u16 => OpGetlinkDoReply::NetNsFd({
28177                    let res = parse_u32(next);
28178                    let Some(val) = res else { break };
28179                    val
28180                }),
28181                29u16 => OpGetlinkDoReply::ExtMask({
28182                    let res = parse_u32(next);
28183                    let Some(val) = res else { break };
28184                    val
28185                }),
28186                30u16 => OpGetlinkDoReply::Promiscuity({
28187                    let res = parse_u32(next);
28188                    let Some(val) = res else { break };
28189                    val
28190                }),
28191                31u16 => OpGetlinkDoReply::NumTxQueues({
28192                    let res = parse_u32(next);
28193                    let Some(val) = res else { break };
28194                    val
28195                }),
28196                32u16 => OpGetlinkDoReply::NumRxQueues({
28197                    let res = parse_u32(next);
28198                    let Some(val) = res else { break };
28199                    val
28200                }),
28201                33u16 => OpGetlinkDoReply::Carrier({
28202                    let res = parse_u8(next);
28203                    let Some(val) = res else { break };
28204                    val
28205                }),
28206                34u16 => OpGetlinkDoReply::PhysPortId({
28207                    let res = Some(next);
28208                    let Some(val) = res else { break };
28209                    val
28210                }),
28211                35u16 => OpGetlinkDoReply::CarrierChanges({
28212                    let res = parse_u32(next);
28213                    let Some(val) = res else { break };
28214                    val
28215                }),
28216                36u16 => OpGetlinkDoReply::PhysSwitchId({
28217                    let res = Some(next);
28218                    let Some(val) = res else { break };
28219                    val
28220                }),
28221                37u16 => OpGetlinkDoReply::LinkNetnsid({
28222                    let res = parse_i32(next);
28223                    let Some(val) = res else { break };
28224                    val
28225                }),
28226                38u16 => OpGetlinkDoReply::PhysPortName({
28227                    let res = CStr::from_bytes_with_nul(next).ok();
28228                    let Some(val) = res else { break };
28229                    val
28230                }),
28231                39u16 => OpGetlinkDoReply::ProtoDown({
28232                    let res = parse_u8(next);
28233                    let Some(val) = res else { break };
28234                    val
28235                }),
28236                40u16 => OpGetlinkDoReply::GsoMaxSegs({
28237                    let res = parse_u32(next);
28238                    let Some(val) = res else { break };
28239                    val
28240                }),
28241                41u16 => OpGetlinkDoReply::GsoMaxSize({
28242                    let res = parse_u32(next);
28243                    let Some(val) = res else { break };
28244                    val
28245                }),
28246                42u16 => OpGetlinkDoReply::Pad({
28247                    let res = Some(next);
28248                    let Some(val) = res else { break };
28249                    val
28250                }),
28251                43u16 => OpGetlinkDoReply::Xdp({
28252                    let res = Some(IterableXdpAttrs::with_loc(next, self.orig_loc));
28253                    let Some(val) = res else { break };
28254                    val
28255                }),
28256                44u16 => OpGetlinkDoReply::Event({
28257                    let res = parse_u32(next);
28258                    let Some(val) = res else { break };
28259                    val
28260                }),
28261                45u16 => OpGetlinkDoReply::NewNetnsid({
28262                    let res = parse_i32(next);
28263                    let Some(val) = res else { break };
28264                    val
28265                }),
28266                46u16 => OpGetlinkDoReply::TargetNetnsid({
28267                    let res = parse_i32(next);
28268                    let Some(val) = res else { break };
28269                    val
28270                }),
28271                47u16 => OpGetlinkDoReply::CarrierUpCount({
28272                    let res = parse_u32(next);
28273                    let Some(val) = res else { break };
28274                    val
28275                }),
28276                48u16 => OpGetlinkDoReply::CarrierDownCount({
28277                    let res = parse_u32(next);
28278                    let Some(val) = res else { break };
28279                    val
28280                }),
28281                49u16 => OpGetlinkDoReply::NewIfindex({
28282                    let res = parse_i32(next);
28283                    let Some(val) = res else { break };
28284                    val
28285                }),
28286                50u16 => OpGetlinkDoReply::MinMtu({
28287                    let res = parse_u32(next);
28288                    let Some(val) = res else { break };
28289                    val
28290                }),
28291                51u16 => OpGetlinkDoReply::MaxMtu({
28292                    let res = parse_u32(next);
28293                    let Some(val) = res else { break };
28294                    val
28295                }),
28296                52u16 => OpGetlinkDoReply::PropList({
28297                    let res = Some(IterablePropListLinkAttrs::with_loc(next, self.orig_loc));
28298                    let Some(val) = res else { break };
28299                    val
28300                }),
28301                54u16 => OpGetlinkDoReply::PermAddress({
28302                    let res = Some(next);
28303                    let Some(val) = res else { break };
28304                    val
28305                }),
28306                55u16 => OpGetlinkDoReply::ProtoDownReason({
28307                    let res = CStr::from_bytes_with_nul(next).ok();
28308                    let Some(val) = res else { break };
28309                    val
28310                }),
28311                56u16 => OpGetlinkDoReply::ParentDevName({
28312                    let res = CStr::from_bytes_with_nul(next).ok();
28313                    let Some(val) = res else { break };
28314                    val
28315                }),
28316                57u16 => OpGetlinkDoReply::ParentDevBusName({
28317                    let res = CStr::from_bytes_with_nul(next).ok();
28318                    let Some(val) = res else { break };
28319                    val
28320                }),
28321                58u16 => OpGetlinkDoReply::GroMaxSize({
28322                    let res = parse_u32(next);
28323                    let Some(val) = res else { break };
28324                    val
28325                }),
28326                59u16 => OpGetlinkDoReply::TsoMaxSize({
28327                    let res = parse_u32(next);
28328                    let Some(val) = res else { break };
28329                    val
28330                }),
28331                60u16 => OpGetlinkDoReply::TsoMaxSegs({
28332                    let res = parse_u32(next);
28333                    let Some(val) = res else { break };
28334                    val
28335                }),
28336                61u16 => OpGetlinkDoReply::Allmulti({
28337                    let res = parse_u32(next);
28338                    let Some(val) = res else { break };
28339                    val
28340                }),
28341                62u16 => OpGetlinkDoReply::DevlinkPort({
28342                    let res = Some(next);
28343                    let Some(val) = res else { break };
28344                    val
28345                }),
28346                63u16 => OpGetlinkDoReply::GsoIpv4MaxSize({
28347                    let res = parse_u32(next);
28348                    let Some(val) = res else { break };
28349                    val
28350                }),
28351                64u16 => OpGetlinkDoReply::GroIpv4MaxSize({
28352                    let res = parse_u32(next);
28353                    let Some(val) = res else { break };
28354                    val
28355                }),
28356                65u16 => OpGetlinkDoReply::DpllPin({
28357                    let res = Some(IterableLinkDpllPinAttrs::with_loc(next, self.orig_loc));
28358                    let Some(val) = res else { break };
28359                    val
28360                }),
28361                66u16 => OpGetlinkDoReply::MaxPacingOffloadHorizon({
28362                    let res = parse_u32(next);
28363                    let Some(val) = res else { break };
28364                    val
28365                }),
28366                67u16 => OpGetlinkDoReply::NetnsImmutable({
28367                    let res = parse_u8(next);
28368                    let Some(val) = res else { break };
28369                    val
28370                }),
28371                n => {
28372                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
28373                        break;
28374                    } else {
28375                        continue;
28376                    }
28377                }
28378            };
28379            return Some(Ok(res));
28380        }
28381        Some(Err(ErrorContext::new(
28382            "OpGetlinkDoReply",
28383            r#type.and_then(|t| OpGetlinkDoReply::attr_from_type(t)),
28384            self.orig_loc,
28385            self.buf.as_ptr().wrapping_add(pos) as usize,
28386        )))
28387    }
28388}
28389impl<'a> std::fmt::Debug for IterableOpGetlinkDoReply<'_> {
28390    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28391        let mut fmt = f.debug_struct("OpGetlinkDoReply");
28392        for attr in self.clone() {
28393            let attr = match attr {
28394                Ok(a) => a,
28395                Err(err) => {
28396                    fmt.finish()?;
28397                    f.write_str("Err(")?;
28398                    err.fmt(f)?;
28399                    return f.write_str(")");
28400                }
28401            };
28402            match attr {
28403                OpGetlinkDoReply::Address(val) => fmt.field("Address", &val),
28404                OpGetlinkDoReply::Broadcast(val) => fmt.field("Broadcast", &val),
28405                OpGetlinkDoReply::Ifname(val) => fmt.field("Ifname", &val),
28406                OpGetlinkDoReply::Mtu(val) => fmt.field("Mtu", &val),
28407                OpGetlinkDoReply::Link(val) => fmt.field("Link", &val),
28408                OpGetlinkDoReply::Qdisc(val) => fmt.field("Qdisc", &val),
28409                OpGetlinkDoReply::Stats(val) => fmt.field("Stats", &val),
28410                OpGetlinkDoReply::Cost(val) => fmt.field("Cost", &val),
28411                OpGetlinkDoReply::Priority(val) => fmt.field("Priority", &val),
28412                OpGetlinkDoReply::Master(val) => fmt.field("Master", &val),
28413                OpGetlinkDoReply::Wireless(val) => fmt.field("Wireless", &val),
28414                OpGetlinkDoReply::Protinfo(val) => fmt.field("Protinfo", &val),
28415                OpGetlinkDoReply::Txqlen(val) => fmt.field("Txqlen", &val),
28416                OpGetlinkDoReply::Map(val) => fmt.field("Map", &val),
28417                OpGetlinkDoReply::Weight(val) => fmt.field("Weight", &val),
28418                OpGetlinkDoReply::Operstate(val) => fmt.field("Operstate", &val),
28419                OpGetlinkDoReply::Linkmode(val) => fmt.field("Linkmode", &val),
28420                OpGetlinkDoReply::Linkinfo(val) => fmt.field("Linkinfo", &val),
28421                OpGetlinkDoReply::NetNsPid(val) => fmt.field("NetNsPid", &val),
28422                OpGetlinkDoReply::Ifalias(val) => fmt.field("Ifalias", &val),
28423                OpGetlinkDoReply::NumVf(val) => fmt.field("NumVf", &val),
28424                OpGetlinkDoReply::VfinfoList(val) => fmt.field("VfinfoList", &val),
28425                OpGetlinkDoReply::Stats64(val) => fmt.field("Stats64", &val),
28426                OpGetlinkDoReply::VfPorts(val) => fmt.field("VfPorts", &val),
28427                OpGetlinkDoReply::PortSelf(val) => fmt.field("PortSelf", &val),
28428                OpGetlinkDoReply::AfSpec(val) => fmt.field("AfSpec", &val),
28429                OpGetlinkDoReply::Group(val) => fmt.field("Group", &val),
28430                OpGetlinkDoReply::NetNsFd(val) => fmt.field("NetNsFd", &val),
28431                OpGetlinkDoReply::ExtMask(val) => {
28432                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
28433                }
28434                OpGetlinkDoReply::Promiscuity(val) => fmt.field("Promiscuity", &val),
28435                OpGetlinkDoReply::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
28436                OpGetlinkDoReply::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
28437                OpGetlinkDoReply::Carrier(val) => fmt.field("Carrier", &val),
28438                OpGetlinkDoReply::PhysPortId(val) => fmt.field("PhysPortId", &val),
28439                OpGetlinkDoReply::CarrierChanges(val) => fmt.field("CarrierChanges", &val),
28440                OpGetlinkDoReply::PhysSwitchId(val) => fmt.field("PhysSwitchId", &val),
28441                OpGetlinkDoReply::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
28442                OpGetlinkDoReply::PhysPortName(val) => fmt.field("PhysPortName", &val),
28443                OpGetlinkDoReply::ProtoDown(val) => fmt.field("ProtoDown", &val),
28444                OpGetlinkDoReply::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
28445                OpGetlinkDoReply::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
28446                OpGetlinkDoReply::Pad(val) => fmt.field("Pad", &val),
28447                OpGetlinkDoReply::Xdp(val) => fmt.field("Xdp", &val),
28448                OpGetlinkDoReply::Event(val) => fmt.field("Event", &val),
28449                OpGetlinkDoReply::NewNetnsid(val) => fmt.field("NewNetnsid", &val),
28450                OpGetlinkDoReply::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
28451                OpGetlinkDoReply::CarrierUpCount(val) => fmt.field("CarrierUpCount", &val),
28452                OpGetlinkDoReply::CarrierDownCount(val) => fmt.field("CarrierDownCount", &val),
28453                OpGetlinkDoReply::NewIfindex(val) => fmt.field("NewIfindex", &val),
28454                OpGetlinkDoReply::MinMtu(val) => fmt.field("MinMtu", &val),
28455                OpGetlinkDoReply::MaxMtu(val) => fmt.field("MaxMtu", &val),
28456                OpGetlinkDoReply::PropList(val) => fmt.field("PropList", &val),
28457                OpGetlinkDoReply::PermAddress(val) => fmt.field("PermAddress", &val),
28458                OpGetlinkDoReply::ProtoDownReason(val) => fmt.field("ProtoDownReason", &val),
28459                OpGetlinkDoReply::ParentDevName(val) => fmt.field("ParentDevName", &val),
28460                OpGetlinkDoReply::ParentDevBusName(val) => fmt.field("ParentDevBusName", &val),
28461                OpGetlinkDoReply::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
28462                OpGetlinkDoReply::TsoMaxSize(val) => fmt.field("TsoMaxSize", &val),
28463                OpGetlinkDoReply::TsoMaxSegs(val) => fmt.field("TsoMaxSegs", &val),
28464                OpGetlinkDoReply::Allmulti(val) => fmt.field("Allmulti", &val),
28465                OpGetlinkDoReply::DevlinkPort(val) => fmt.field("DevlinkPort", &val),
28466                OpGetlinkDoReply::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
28467                OpGetlinkDoReply::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
28468                OpGetlinkDoReply::DpllPin(val) => fmt.field("DpllPin", &val),
28469                OpGetlinkDoReply::MaxPacingOffloadHorizon(val) => {
28470                    fmt.field("MaxPacingOffloadHorizon", &val)
28471                }
28472                OpGetlinkDoReply::NetnsImmutable(val) => fmt.field("NetnsImmutable", &val),
28473            };
28474        }
28475        fmt.finish()
28476    }
28477}
28478impl IterableOpGetlinkDoReply<'_> {
28479    pub fn lookup_attr(
28480        &self,
28481        offset: usize,
28482        missing_type: Option<u16>,
28483    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
28484        let mut stack = Vec::new();
28485        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
28486        if cur == offset + PushIfinfomsg::len() {
28487            stack.push(("OpGetlinkDoReply", offset));
28488            return (
28489                stack,
28490                missing_type.and_then(|t| OpGetlinkDoReply::attr_from_type(t)),
28491            );
28492        }
28493        if cur > offset || cur + self.buf.len() < offset {
28494            return (stack, None);
28495        }
28496        let mut attrs = self.clone();
28497        let mut last_off = cur + attrs.pos;
28498        let mut missing = None;
28499        while let Some(attr) = attrs.next() {
28500            let Ok(attr) = attr else { break };
28501            match attr {
28502                OpGetlinkDoReply::Address(val) => {
28503                    if last_off == offset {
28504                        stack.push(("Address", last_off));
28505                        break;
28506                    }
28507                }
28508                OpGetlinkDoReply::Broadcast(val) => {
28509                    if last_off == offset {
28510                        stack.push(("Broadcast", last_off));
28511                        break;
28512                    }
28513                }
28514                OpGetlinkDoReply::Ifname(val) => {
28515                    if last_off == offset {
28516                        stack.push(("Ifname", last_off));
28517                        break;
28518                    }
28519                }
28520                OpGetlinkDoReply::Mtu(val) => {
28521                    if last_off == offset {
28522                        stack.push(("Mtu", last_off));
28523                        break;
28524                    }
28525                }
28526                OpGetlinkDoReply::Link(val) => {
28527                    if last_off == offset {
28528                        stack.push(("Link", last_off));
28529                        break;
28530                    }
28531                }
28532                OpGetlinkDoReply::Qdisc(val) => {
28533                    if last_off == offset {
28534                        stack.push(("Qdisc", last_off));
28535                        break;
28536                    }
28537                }
28538                OpGetlinkDoReply::Stats(val) => {
28539                    if last_off == offset {
28540                        stack.push(("Stats", last_off));
28541                        break;
28542                    }
28543                }
28544                OpGetlinkDoReply::Cost(val) => {
28545                    if last_off == offset {
28546                        stack.push(("Cost", last_off));
28547                        break;
28548                    }
28549                }
28550                OpGetlinkDoReply::Priority(val) => {
28551                    if last_off == offset {
28552                        stack.push(("Priority", last_off));
28553                        break;
28554                    }
28555                }
28556                OpGetlinkDoReply::Master(val) => {
28557                    if last_off == offset {
28558                        stack.push(("Master", last_off));
28559                        break;
28560                    }
28561                }
28562                OpGetlinkDoReply::Wireless(val) => {
28563                    if last_off == offset {
28564                        stack.push(("Wireless", last_off));
28565                        break;
28566                    }
28567                }
28568                OpGetlinkDoReply::Protinfo(val) => {
28569                    if last_off == offset {
28570                        stack.push(("Protinfo", last_off));
28571                        break;
28572                    }
28573                }
28574                OpGetlinkDoReply::Txqlen(val) => {
28575                    if last_off == offset {
28576                        stack.push(("Txqlen", last_off));
28577                        break;
28578                    }
28579                }
28580                OpGetlinkDoReply::Map(val) => {
28581                    if last_off == offset {
28582                        stack.push(("Map", last_off));
28583                        break;
28584                    }
28585                }
28586                OpGetlinkDoReply::Weight(val) => {
28587                    if last_off == offset {
28588                        stack.push(("Weight", last_off));
28589                        break;
28590                    }
28591                }
28592                OpGetlinkDoReply::Operstate(val) => {
28593                    if last_off == offset {
28594                        stack.push(("Operstate", last_off));
28595                        break;
28596                    }
28597                }
28598                OpGetlinkDoReply::Linkmode(val) => {
28599                    if last_off == offset {
28600                        stack.push(("Linkmode", last_off));
28601                        break;
28602                    }
28603                }
28604                OpGetlinkDoReply::Linkinfo(val) => {
28605                    (stack, missing) = val.lookup_attr(offset, missing_type);
28606                    if !stack.is_empty() {
28607                        break;
28608                    }
28609                }
28610                OpGetlinkDoReply::NetNsPid(val) => {
28611                    if last_off == offset {
28612                        stack.push(("NetNsPid", last_off));
28613                        break;
28614                    }
28615                }
28616                OpGetlinkDoReply::Ifalias(val) => {
28617                    if last_off == offset {
28618                        stack.push(("Ifalias", last_off));
28619                        break;
28620                    }
28621                }
28622                OpGetlinkDoReply::NumVf(val) => {
28623                    if last_off == offset {
28624                        stack.push(("NumVf", last_off));
28625                        break;
28626                    }
28627                }
28628                OpGetlinkDoReply::VfinfoList(val) => {
28629                    (stack, missing) = val.lookup_attr(offset, missing_type);
28630                    if !stack.is_empty() {
28631                        break;
28632                    }
28633                }
28634                OpGetlinkDoReply::Stats64(val) => {
28635                    if last_off == offset {
28636                        stack.push(("Stats64", last_off));
28637                        break;
28638                    }
28639                }
28640                OpGetlinkDoReply::VfPorts(val) => {
28641                    (stack, missing) = val.lookup_attr(offset, missing_type);
28642                    if !stack.is_empty() {
28643                        break;
28644                    }
28645                }
28646                OpGetlinkDoReply::PortSelf(val) => {
28647                    (stack, missing) = val.lookup_attr(offset, missing_type);
28648                    if !stack.is_empty() {
28649                        break;
28650                    }
28651                }
28652                OpGetlinkDoReply::AfSpec(val) => {
28653                    (stack, missing) = val.lookup_attr(offset, missing_type);
28654                    if !stack.is_empty() {
28655                        break;
28656                    }
28657                }
28658                OpGetlinkDoReply::Group(val) => {
28659                    if last_off == offset {
28660                        stack.push(("Group", last_off));
28661                        break;
28662                    }
28663                }
28664                OpGetlinkDoReply::NetNsFd(val) => {
28665                    if last_off == offset {
28666                        stack.push(("NetNsFd", last_off));
28667                        break;
28668                    }
28669                }
28670                OpGetlinkDoReply::ExtMask(val) => {
28671                    if last_off == offset {
28672                        stack.push(("ExtMask", last_off));
28673                        break;
28674                    }
28675                }
28676                OpGetlinkDoReply::Promiscuity(val) => {
28677                    if last_off == offset {
28678                        stack.push(("Promiscuity", last_off));
28679                        break;
28680                    }
28681                }
28682                OpGetlinkDoReply::NumTxQueues(val) => {
28683                    if last_off == offset {
28684                        stack.push(("NumTxQueues", last_off));
28685                        break;
28686                    }
28687                }
28688                OpGetlinkDoReply::NumRxQueues(val) => {
28689                    if last_off == offset {
28690                        stack.push(("NumRxQueues", last_off));
28691                        break;
28692                    }
28693                }
28694                OpGetlinkDoReply::Carrier(val) => {
28695                    if last_off == offset {
28696                        stack.push(("Carrier", last_off));
28697                        break;
28698                    }
28699                }
28700                OpGetlinkDoReply::PhysPortId(val) => {
28701                    if last_off == offset {
28702                        stack.push(("PhysPortId", last_off));
28703                        break;
28704                    }
28705                }
28706                OpGetlinkDoReply::CarrierChanges(val) => {
28707                    if last_off == offset {
28708                        stack.push(("CarrierChanges", last_off));
28709                        break;
28710                    }
28711                }
28712                OpGetlinkDoReply::PhysSwitchId(val) => {
28713                    if last_off == offset {
28714                        stack.push(("PhysSwitchId", last_off));
28715                        break;
28716                    }
28717                }
28718                OpGetlinkDoReply::LinkNetnsid(val) => {
28719                    if last_off == offset {
28720                        stack.push(("LinkNetnsid", last_off));
28721                        break;
28722                    }
28723                }
28724                OpGetlinkDoReply::PhysPortName(val) => {
28725                    if last_off == offset {
28726                        stack.push(("PhysPortName", last_off));
28727                        break;
28728                    }
28729                }
28730                OpGetlinkDoReply::ProtoDown(val) => {
28731                    if last_off == offset {
28732                        stack.push(("ProtoDown", last_off));
28733                        break;
28734                    }
28735                }
28736                OpGetlinkDoReply::GsoMaxSegs(val) => {
28737                    if last_off == offset {
28738                        stack.push(("GsoMaxSegs", last_off));
28739                        break;
28740                    }
28741                }
28742                OpGetlinkDoReply::GsoMaxSize(val) => {
28743                    if last_off == offset {
28744                        stack.push(("GsoMaxSize", last_off));
28745                        break;
28746                    }
28747                }
28748                OpGetlinkDoReply::Pad(val) => {
28749                    if last_off == offset {
28750                        stack.push(("Pad", last_off));
28751                        break;
28752                    }
28753                }
28754                OpGetlinkDoReply::Xdp(val) => {
28755                    (stack, missing) = val.lookup_attr(offset, missing_type);
28756                    if !stack.is_empty() {
28757                        break;
28758                    }
28759                }
28760                OpGetlinkDoReply::Event(val) => {
28761                    if last_off == offset {
28762                        stack.push(("Event", last_off));
28763                        break;
28764                    }
28765                }
28766                OpGetlinkDoReply::NewNetnsid(val) => {
28767                    if last_off == offset {
28768                        stack.push(("NewNetnsid", last_off));
28769                        break;
28770                    }
28771                }
28772                OpGetlinkDoReply::TargetNetnsid(val) => {
28773                    if last_off == offset {
28774                        stack.push(("TargetNetnsid", last_off));
28775                        break;
28776                    }
28777                }
28778                OpGetlinkDoReply::CarrierUpCount(val) => {
28779                    if last_off == offset {
28780                        stack.push(("CarrierUpCount", last_off));
28781                        break;
28782                    }
28783                }
28784                OpGetlinkDoReply::CarrierDownCount(val) => {
28785                    if last_off == offset {
28786                        stack.push(("CarrierDownCount", last_off));
28787                        break;
28788                    }
28789                }
28790                OpGetlinkDoReply::NewIfindex(val) => {
28791                    if last_off == offset {
28792                        stack.push(("NewIfindex", last_off));
28793                        break;
28794                    }
28795                }
28796                OpGetlinkDoReply::MinMtu(val) => {
28797                    if last_off == offset {
28798                        stack.push(("MinMtu", last_off));
28799                        break;
28800                    }
28801                }
28802                OpGetlinkDoReply::MaxMtu(val) => {
28803                    if last_off == offset {
28804                        stack.push(("MaxMtu", last_off));
28805                        break;
28806                    }
28807                }
28808                OpGetlinkDoReply::PropList(val) => {
28809                    (stack, missing) = val.lookup_attr(offset, missing_type);
28810                    if !stack.is_empty() {
28811                        break;
28812                    }
28813                }
28814                OpGetlinkDoReply::PermAddress(val) => {
28815                    if last_off == offset {
28816                        stack.push(("PermAddress", last_off));
28817                        break;
28818                    }
28819                }
28820                OpGetlinkDoReply::ProtoDownReason(val) => {
28821                    if last_off == offset {
28822                        stack.push(("ProtoDownReason", last_off));
28823                        break;
28824                    }
28825                }
28826                OpGetlinkDoReply::ParentDevName(val) => {
28827                    if last_off == offset {
28828                        stack.push(("ParentDevName", last_off));
28829                        break;
28830                    }
28831                }
28832                OpGetlinkDoReply::ParentDevBusName(val) => {
28833                    if last_off == offset {
28834                        stack.push(("ParentDevBusName", last_off));
28835                        break;
28836                    }
28837                }
28838                OpGetlinkDoReply::GroMaxSize(val) => {
28839                    if last_off == offset {
28840                        stack.push(("GroMaxSize", last_off));
28841                        break;
28842                    }
28843                }
28844                OpGetlinkDoReply::TsoMaxSize(val) => {
28845                    if last_off == offset {
28846                        stack.push(("TsoMaxSize", last_off));
28847                        break;
28848                    }
28849                }
28850                OpGetlinkDoReply::TsoMaxSegs(val) => {
28851                    if last_off == offset {
28852                        stack.push(("TsoMaxSegs", last_off));
28853                        break;
28854                    }
28855                }
28856                OpGetlinkDoReply::Allmulti(val) => {
28857                    if last_off == offset {
28858                        stack.push(("Allmulti", last_off));
28859                        break;
28860                    }
28861                }
28862                OpGetlinkDoReply::DevlinkPort(val) => {
28863                    if last_off == offset {
28864                        stack.push(("DevlinkPort", last_off));
28865                        break;
28866                    }
28867                }
28868                OpGetlinkDoReply::GsoIpv4MaxSize(val) => {
28869                    if last_off == offset {
28870                        stack.push(("GsoIpv4MaxSize", last_off));
28871                        break;
28872                    }
28873                }
28874                OpGetlinkDoReply::GroIpv4MaxSize(val) => {
28875                    if last_off == offset {
28876                        stack.push(("GroIpv4MaxSize", last_off));
28877                        break;
28878                    }
28879                }
28880                OpGetlinkDoReply::DpllPin(val) => {
28881                    (stack, missing) = val.lookup_attr(offset, missing_type);
28882                    if !stack.is_empty() {
28883                        break;
28884                    }
28885                }
28886                OpGetlinkDoReply::MaxPacingOffloadHorizon(val) => {
28887                    if last_off == offset {
28888                        stack.push(("MaxPacingOffloadHorizon", last_off));
28889                        break;
28890                    }
28891                }
28892                OpGetlinkDoReply::NetnsImmutable(val) => {
28893                    if last_off == offset {
28894                        stack.push(("NetnsImmutable", last_off));
28895                        break;
28896                    }
28897                }
28898                _ => {}
28899            };
28900            last_off = cur + attrs.pos;
28901        }
28902        if !stack.is_empty() {
28903            stack.push(("OpGetlinkDoReply", cur));
28904        }
28905        (stack, missing)
28906    }
28907}
28908#[derive(Debug)]
28909pub struct RequestOpGetlinkDoRequest<'r> {
28910    request: Request<'r>,
28911}
28912impl<'r> RequestOpGetlinkDoRequest<'r> {
28913    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
28914        PushOpGetlinkDoRequest::write_header(&mut request.buf_mut(), header);
28915        Self { request: request }
28916    }
28917    pub fn encode(&mut self) -> PushOpGetlinkDoRequest<&mut Vec<u8>> {
28918        PushOpGetlinkDoRequest::new_without_header(self.request.buf_mut())
28919    }
28920    pub fn into_encoder(self) -> PushOpGetlinkDoRequest<RequestBuf<'r>> {
28921        PushOpGetlinkDoRequest::new_without_header(self.request.buf)
28922    }
28923}
28924impl NetlinkRequest for RequestOpGetlinkDoRequest<'_> {
28925    type ReplyType<'buf> = (PushIfinfomsg, IterableOpGetlinkDoReply<'buf>);
28926    fn protocol(&self) -> Protocol {
28927        Protocol::Raw {
28928            protonum: 0u16,
28929            request_type: 18u16,
28930        }
28931    }
28932    fn flags(&self) -> u16 {
28933        self.request.flags
28934    }
28935    fn payload(&self) -> &[u8] {
28936        self.request.buf()
28937    }
28938    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
28939        OpGetlinkDoReply::new(buf)
28940    }
28941    fn lookup(
28942        buf: &[u8],
28943        offset: usize,
28944        missing_type: Option<u16>,
28945    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
28946        OpGetlinkDoRequest::new(buf)
28947            .1
28948            .lookup_attr(offset, missing_type)
28949    }
28950}
28951#[doc = "Set information about a link."]
28952pub struct PushOpSetlinkDoRequest<Prev: Rec> {
28953    pub(crate) prev: Option<Prev>,
28954    pub(crate) header_offset: Option<usize>,
28955}
28956impl<Prev: Rec> Rec for PushOpSetlinkDoRequest<Prev> {
28957    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
28958        self.prev.as_mut().unwrap().as_rec_mut()
28959    }
28960}
28961impl<Prev: Rec> PushOpSetlinkDoRequest<Prev> {
28962    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
28963        Self::write_header(&mut prev, header);
28964        Self::new_without_header(prev)
28965    }
28966    fn new_without_header(prev: Prev) -> Self {
28967        Self {
28968            prev: Some(prev),
28969            header_offset: None,
28970        }
28971    }
28972    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
28973        prev.as_rec_mut().extend(header.as_slice());
28974    }
28975    pub fn end_nested(mut self) -> Prev {
28976        let mut prev = self.prev.take().unwrap();
28977        if let Some(header_offset) = &self.header_offset {
28978            finalize_nested_header(prev.as_rec_mut(), *header_offset);
28979        }
28980        prev
28981    }
28982    pub fn push_address(mut self, value: &[u8]) -> Self {
28983        push_header(self.as_rec_mut(), 1u16, value.len() as u16);
28984        self.as_rec_mut().extend(value);
28985        self
28986    }
28987    pub fn push_broadcast(mut self, value: &[u8]) -> Self {
28988        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
28989        self.as_rec_mut().extend(value);
28990        self
28991    }
28992    pub fn push_ifname(mut self, value: &CStr) -> Self {
28993        push_header(
28994            self.as_rec_mut(),
28995            3u16,
28996            value.to_bytes_with_nul().len() as u16,
28997        );
28998        self.as_rec_mut().extend(value.to_bytes_with_nul());
28999        self
29000    }
29001    pub fn push_ifname_bytes(mut self, value: &[u8]) -> Self {
29002        push_header(self.as_rec_mut(), 3u16, (value.len() + 1) as u16);
29003        self.as_rec_mut().extend(value);
29004        self.as_rec_mut().push(0);
29005        self
29006    }
29007    pub fn push_mtu(mut self, value: u32) -> Self {
29008        push_header(self.as_rec_mut(), 4u16, 4 as u16);
29009        self.as_rec_mut().extend(value.to_ne_bytes());
29010        self
29011    }
29012    pub fn push_link(mut self, value: u32) -> Self {
29013        push_header(self.as_rec_mut(), 5u16, 4 as u16);
29014        self.as_rec_mut().extend(value.to_ne_bytes());
29015        self
29016    }
29017    pub fn push_qdisc(mut self, value: &CStr) -> Self {
29018        push_header(
29019            self.as_rec_mut(),
29020            6u16,
29021            value.to_bytes_with_nul().len() as u16,
29022        );
29023        self.as_rec_mut().extend(value.to_bytes_with_nul());
29024        self
29025    }
29026    pub fn push_qdisc_bytes(mut self, value: &[u8]) -> Self {
29027        push_header(self.as_rec_mut(), 6u16, (value.len() + 1) as u16);
29028        self.as_rec_mut().extend(value);
29029        self.as_rec_mut().push(0);
29030        self
29031    }
29032    pub fn push_stats(mut self, value: PushRtnlLinkStats) -> Self {
29033        push_header(self.as_rec_mut(), 7u16, value.as_slice().len() as u16);
29034        self.as_rec_mut().extend(value.as_slice());
29035        self
29036    }
29037    pub fn push_cost(mut self, value: &CStr) -> Self {
29038        push_header(
29039            self.as_rec_mut(),
29040            8u16,
29041            value.to_bytes_with_nul().len() as u16,
29042        );
29043        self.as_rec_mut().extend(value.to_bytes_with_nul());
29044        self
29045    }
29046    pub fn push_cost_bytes(mut self, value: &[u8]) -> Self {
29047        push_header(self.as_rec_mut(), 8u16, (value.len() + 1) as u16);
29048        self.as_rec_mut().extend(value);
29049        self.as_rec_mut().push(0);
29050        self
29051    }
29052    pub fn push_priority(mut self, value: &CStr) -> Self {
29053        push_header(
29054            self.as_rec_mut(),
29055            9u16,
29056            value.to_bytes_with_nul().len() as u16,
29057        );
29058        self.as_rec_mut().extend(value.to_bytes_with_nul());
29059        self
29060    }
29061    pub fn push_priority_bytes(mut self, value: &[u8]) -> Self {
29062        push_header(self.as_rec_mut(), 9u16, (value.len() + 1) as u16);
29063        self.as_rec_mut().extend(value);
29064        self.as_rec_mut().push(0);
29065        self
29066    }
29067    pub fn push_master(mut self, value: u32) -> Self {
29068        push_header(self.as_rec_mut(), 10u16, 4 as u16);
29069        self.as_rec_mut().extend(value.to_ne_bytes());
29070        self
29071    }
29072    pub fn push_wireless(mut self, value: &CStr) -> Self {
29073        push_header(
29074            self.as_rec_mut(),
29075            11u16,
29076            value.to_bytes_with_nul().len() as u16,
29077        );
29078        self.as_rec_mut().extend(value.to_bytes_with_nul());
29079        self
29080    }
29081    pub fn push_wireless_bytes(mut self, value: &[u8]) -> Self {
29082        push_header(self.as_rec_mut(), 11u16, (value.len() + 1) as u16);
29083        self.as_rec_mut().extend(value);
29084        self.as_rec_mut().push(0);
29085        self
29086    }
29087    pub fn push_protinfo(mut self, value: &CStr) -> Self {
29088        push_header(
29089            self.as_rec_mut(),
29090            12u16,
29091            value.to_bytes_with_nul().len() as u16,
29092        );
29093        self.as_rec_mut().extend(value.to_bytes_with_nul());
29094        self
29095    }
29096    pub fn push_protinfo_bytes(mut self, value: &[u8]) -> Self {
29097        push_header(self.as_rec_mut(), 12u16, (value.len() + 1) as u16);
29098        self.as_rec_mut().extend(value);
29099        self.as_rec_mut().push(0);
29100        self
29101    }
29102    pub fn push_txqlen(mut self, value: u32) -> Self {
29103        push_header(self.as_rec_mut(), 13u16, 4 as u16);
29104        self.as_rec_mut().extend(value.to_ne_bytes());
29105        self
29106    }
29107    pub fn push_map(mut self, value: PushRtnlLinkIfmap) -> Self {
29108        push_header(self.as_rec_mut(), 14u16, value.as_slice().len() as u16);
29109        self.as_rec_mut().extend(value.as_slice());
29110        self
29111    }
29112    pub fn push_weight(mut self, value: u32) -> Self {
29113        push_header(self.as_rec_mut(), 15u16, 4 as u16);
29114        self.as_rec_mut().extend(value.to_ne_bytes());
29115        self
29116    }
29117    pub fn push_operstate(mut self, value: u8) -> Self {
29118        push_header(self.as_rec_mut(), 16u16, 1 as u16);
29119        self.as_rec_mut().extend(value.to_ne_bytes());
29120        self
29121    }
29122    pub fn push_linkmode(mut self, value: u8) -> Self {
29123        push_header(self.as_rec_mut(), 17u16, 1 as u16);
29124        self.as_rec_mut().extend(value.to_ne_bytes());
29125        self
29126    }
29127    pub fn nested_linkinfo(mut self) -> PushLinkinfoAttrs<Self> {
29128        let header_offset = push_nested_header(self.as_rec_mut(), 18u16);
29129        PushLinkinfoAttrs {
29130            prev: Some(self),
29131            header_offset: Some(header_offset),
29132        }
29133    }
29134    pub fn push_net_ns_pid(mut self, value: u32) -> Self {
29135        push_header(self.as_rec_mut(), 19u16, 4 as u16);
29136        self.as_rec_mut().extend(value.to_ne_bytes());
29137        self
29138    }
29139    pub fn push_ifalias(mut self, value: &CStr) -> Self {
29140        push_header(
29141            self.as_rec_mut(),
29142            20u16,
29143            value.to_bytes_with_nul().len() as u16,
29144        );
29145        self.as_rec_mut().extend(value.to_bytes_with_nul());
29146        self
29147    }
29148    pub fn push_ifalias_bytes(mut self, value: &[u8]) -> Self {
29149        push_header(self.as_rec_mut(), 20u16, (value.len() + 1) as u16);
29150        self.as_rec_mut().extend(value);
29151        self.as_rec_mut().push(0);
29152        self
29153    }
29154    pub fn push_num_vf(mut self, value: u32) -> Self {
29155        push_header(self.as_rec_mut(), 21u16, 4 as u16);
29156        self.as_rec_mut().extend(value.to_ne_bytes());
29157        self
29158    }
29159    pub fn nested_vfinfo_list(mut self) -> PushVfinfoListAttrs<Self> {
29160        let header_offset = push_nested_header(self.as_rec_mut(), 22u16);
29161        PushVfinfoListAttrs {
29162            prev: Some(self),
29163            header_offset: Some(header_offset),
29164        }
29165    }
29166    pub fn push_stats64(mut self, value: PushRtnlLinkStats64) -> Self {
29167        push_header(self.as_rec_mut(), 23u16, value.as_slice().len() as u16);
29168        self.as_rec_mut().extend(value.as_slice());
29169        self
29170    }
29171    pub fn nested_vf_ports(mut self) -> PushVfPortsAttrs<Self> {
29172        let header_offset = push_nested_header(self.as_rec_mut(), 24u16);
29173        PushVfPortsAttrs {
29174            prev: Some(self),
29175            header_offset: Some(header_offset),
29176        }
29177    }
29178    pub fn nested_port_self(mut self) -> PushPortSelfAttrs<Self> {
29179        let header_offset = push_nested_header(self.as_rec_mut(), 25u16);
29180        PushPortSelfAttrs {
29181            prev: Some(self),
29182            header_offset: Some(header_offset),
29183        }
29184    }
29185    pub fn nested_af_spec(mut self) -> PushAfSpecAttrs<Self> {
29186        let header_offset = push_nested_header(self.as_rec_mut(), 26u16);
29187        PushAfSpecAttrs {
29188            prev: Some(self),
29189            header_offset: Some(header_offset),
29190        }
29191    }
29192    pub fn push_group(mut self, value: u32) -> Self {
29193        push_header(self.as_rec_mut(), 27u16, 4 as u16);
29194        self.as_rec_mut().extend(value.to_ne_bytes());
29195        self
29196    }
29197    pub fn push_net_ns_fd(mut self, value: u32) -> Self {
29198        push_header(self.as_rec_mut(), 28u16, 4 as u16);
29199        self.as_rec_mut().extend(value.to_ne_bytes());
29200        self
29201    }
29202    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
29203    pub fn push_ext_mask(mut self, value: u32) -> Self {
29204        push_header(self.as_rec_mut(), 29u16, 4 as u16);
29205        self.as_rec_mut().extend(value.to_ne_bytes());
29206        self
29207    }
29208    pub fn push_promiscuity(mut self, value: u32) -> Self {
29209        push_header(self.as_rec_mut(), 30u16, 4 as u16);
29210        self.as_rec_mut().extend(value.to_ne_bytes());
29211        self
29212    }
29213    pub fn push_num_tx_queues(mut self, value: u32) -> Self {
29214        push_header(self.as_rec_mut(), 31u16, 4 as u16);
29215        self.as_rec_mut().extend(value.to_ne_bytes());
29216        self
29217    }
29218    pub fn push_num_rx_queues(mut self, value: u32) -> Self {
29219        push_header(self.as_rec_mut(), 32u16, 4 as u16);
29220        self.as_rec_mut().extend(value.to_ne_bytes());
29221        self
29222    }
29223    pub fn push_carrier(mut self, value: u8) -> Self {
29224        push_header(self.as_rec_mut(), 33u16, 1 as u16);
29225        self.as_rec_mut().extend(value.to_ne_bytes());
29226        self
29227    }
29228    pub fn push_phys_port_id(mut self, value: &[u8]) -> Self {
29229        push_header(self.as_rec_mut(), 34u16, value.len() as u16);
29230        self.as_rec_mut().extend(value);
29231        self
29232    }
29233    pub fn push_carrier_changes(mut self, value: u32) -> Self {
29234        push_header(self.as_rec_mut(), 35u16, 4 as u16);
29235        self.as_rec_mut().extend(value.to_ne_bytes());
29236        self
29237    }
29238    pub fn push_phys_switch_id(mut self, value: &[u8]) -> Self {
29239        push_header(self.as_rec_mut(), 36u16, value.len() as u16);
29240        self.as_rec_mut().extend(value);
29241        self
29242    }
29243    pub fn push_link_netnsid(mut self, value: i32) -> Self {
29244        push_header(self.as_rec_mut(), 37u16, 4 as u16);
29245        self.as_rec_mut().extend(value.to_ne_bytes());
29246        self
29247    }
29248    pub fn push_phys_port_name(mut self, value: &CStr) -> Self {
29249        push_header(
29250            self.as_rec_mut(),
29251            38u16,
29252            value.to_bytes_with_nul().len() as u16,
29253        );
29254        self.as_rec_mut().extend(value.to_bytes_with_nul());
29255        self
29256    }
29257    pub fn push_phys_port_name_bytes(mut self, value: &[u8]) -> Self {
29258        push_header(self.as_rec_mut(), 38u16, (value.len() + 1) as u16);
29259        self.as_rec_mut().extend(value);
29260        self.as_rec_mut().push(0);
29261        self
29262    }
29263    pub fn push_proto_down(mut self, value: u8) -> Self {
29264        push_header(self.as_rec_mut(), 39u16, 1 as u16);
29265        self.as_rec_mut().extend(value.to_ne_bytes());
29266        self
29267    }
29268    pub fn push_gso_max_segs(mut self, value: u32) -> Self {
29269        push_header(self.as_rec_mut(), 40u16, 4 as u16);
29270        self.as_rec_mut().extend(value.to_ne_bytes());
29271        self
29272    }
29273    pub fn push_gso_max_size(mut self, value: u32) -> Self {
29274        push_header(self.as_rec_mut(), 41u16, 4 as u16);
29275        self.as_rec_mut().extend(value.to_ne_bytes());
29276        self
29277    }
29278    pub fn push_pad(mut self, value: &[u8]) -> Self {
29279        push_header(self.as_rec_mut(), 42u16, value.len() as u16);
29280        self.as_rec_mut().extend(value);
29281        self
29282    }
29283    pub fn nested_xdp(mut self) -> PushXdpAttrs<Self> {
29284        let header_offset = push_nested_header(self.as_rec_mut(), 43u16);
29285        PushXdpAttrs {
29286            prev: Some(self),
29287            header_offset: Some(header_offset),
29288        }
29289    }
29290    pub fn push_event(mut self, value: u32) -> Self {
29291        push_header(self.as_rec_mut(), 44u16, 4 as u16);
29292        self.as_rec_mut().extend(value.to_ne_bytes());
29293        self
29294    }
29295    pub fn push_new_netnsid(mut self, value: i32) -> Self {
29296        push_header(self.as_rec_mut(), 45u16, 4 as u16);
29297        self.as_rec_mut().extend(value.to_ne_bytes());
29298        self
29299    }
29300    pub fn push_target_netnsid(mut self, value: i32) -> Self {
29301        push_header(self.as_rec_mut(), 46u16, 4 as u16);
29302        self.as_rec_mut().extend(value.to_ne_bytes());
29303        self
29304    }
29305    pub fn push_carrier_up_count(mut self, value: u32) -> Self {
29306        push_header(self.as_rec_mut(), 47u16, 4 as u16);
29307        self.as_rec_mut().extend(value.to_ne_bytes());
29308        self
29309    }
29310    pub fn push_carrier_down_count(mut self, value: u32) -> Self {
29311        push_header(self.as_rec_mut(), 48u16, 4 as u16);
29312        self.as_rec_mut().extend(value.to_ne_bytes());
29313        self
29314    }
29315    pub fn push_new_ifindex(mut self, value: i32) -> Self {
29316        push_header(self.as_rec_mut(), 49u16, 4 as u16);
29317        self.as_rec_mut().extend(value.to_ne_bytes());
29318        self
29319    }
29320    pub fn push_min_mtu(mut self, value: u32) -> Self {
29321        push_header(self.as_rec_mut(), 50u16, 4 as u16);
29322        self.as_rec_mut().extend(value.to_ne_bytes());
29323        self
29324    }
29325    pub fn push_max_mtu(mut self, value: u32) -> Self {
29326        push_header(self.as_rec_mut(), 51u16, 4 as u16);
29327        self.as_rec_mut().extend(value.to_ne_bytes());
29328        self
29329    }
29330    pub fn nested_prop_list(mut self) -> PushPropListLinkAttrs<Self> {
29331        let header_offset = push_nested_header(self.as_rec_mut(), 52u16);
29332        PushPropListLinkAttrs {
29333            prev: Some(self),
29334            header_offset: Some(header_offset),
29335        }
29336    }
29337    pub fn push_perm_address(mut self, value: &[u8]) -> Self {
29338        push_header(self.as_rec_mut(), 54u16, value.len() as u16);
29339        self.as_rec_mut().extend(value);
29340        self
29341    }
29342    pub fn push_proto_down_reason(mut self, value: &CStr) -> Self {
29343        push_header(
29344            self.as_rec_mut(),
29345            55u16,
29346            value.to_bytes_with_nul().len() as u16,
29347        );
29348        self.as_rec_mut().extend(value.to_bytes_with_nul());
29349        self
29350    }
29351    pub fn push_proto_down_reason_bytes(mut self, value: &[u8]) -> Self {
29352        push_header(self.as_rec_mut(), 55u16, (value.len() + 1) as u16);
29353        self.as_rec_mut().extend(value);
29354        self.as_rec_mut().push(0);
29355        self
29356    }
29357    pub fn push_parent_dev_name(mut self, value: &CStr) -> Self {
29358        push_header(
29359            self.as_rec_mut(),
29360            56u16,
29361            value.to_bytes_with_nul().len() as u16,
29362        );
29363        self.as_rec_mut().extend(value.to_bytes_with_nul());
29364        self
29365    }
29366    pub fn push_parent_dev_name_bytes(mut self, value: &[u8]) -> Self {
29367        push_header(self.as_rec_mut(), 56u16, (value.len() + 1) as u16);
29368        self.as_rec_mut().extend(value);
29369        self.as_rec_mut().push(0);
29370        self
29371    }
29372    pub fn push_parent_dev_bus_name(mut self, value: &CStr) -> Self {
29373        push_header(
29374            self.as_rec_mut(),
29375            57u16,
29376            value.to_bytes_with_nul().len() as u16,
29377        );
29378        self.as_rec_mut().extend(value.to_bytes_with_nul());
29379        self
29380    }
29381    pub fn push_parent_dev_bus_name_bytes(mut self, value: &[u8]) -> Self {
29382        push_header(self.as_rec_mut(), 57u16, (value.len() + 1) as u16);
29383        self.as_rec_mut().extend(value);
29384        self.as_rec_mut().push(0);
29385        self
29386    }
29387    pub fn push_gro_max_size(mut self, value: u32) -> Self {
29388        push_header(self.as_rec_mut(), 58u16, 4 as u16);
29389        self.as_rec_mut().extend(value.to_ne_bytes());
29390        self
29391    }
29392    pub fn push_tso_max_size(mut self, value: u32) -> Self {
29393        push_header(self.as_rec_mut(), 59u16, 4 as u16);
29394        self.as_rec_mut().extend(value.to_ne_bytes());
29395        self
29396    }
29397    pub fn push_tso_max_segs(mut self, value: u32) -> Self {
29398        push_header(self.as_rec_mut(), 60u16, 4 as u16);
29399        self.as_rec_mut().extend(value.to_ne_bytes());
29400        self
29401    }
29402    pub fn push_allmulti(mut self, value: u32) -> Self {
29403        push_header(self.as_rec_mut(), 61u16, 4 as u16);
29404        self.as_rec_mut().extend(value.to_ne_bytes());
29405        self
29406    }
29407    pub fn push_devlink_port(mut self, value: &[u8]) -> Self {
29408        push_header(self.as_rec_mut(), 62u16, value.len() as u16);
29409        self.as_rec_mut().extend(value);
29410        self
29411    }
29412    pub fn push_gso_ipv4_max_size(mut self, value: u32) -> Self {
29413        push_header(self.as_rec_mut(), 63u16, 4 as u16);
29414        self.as_rec_mut().extend(value.to_ne_bytes());
29415        self
29416    }
29417    pub fn push_gro_ipv4_max_size(mut self, value: u32) -> Self {
29418        push_header(self.as_rec_mut(), 64u16, 4 as u16);
29419        self.as_rec_mut().extend(value.to_ne_bytes());
29420        self
29421    }
29422    pub fn nested_dpll_pin(mut self) -> PushLinkDpllPinAttrs<Self> {
29423        let header_offset = push_nested_header(self.as_rec_mut(), 65u16);
29424        PushLinkDpllPinAttrs {
29425            prev: Some(self),
29426            header_offset: Some(header_offset),
29427        }
29428    }
29429    #[doc = "EDT offload horizon supported by the device (in nsec)."]
29430    pub fn push_max_pacing_offload_horizon(mut self, value: u32) -> Self {
29431        push_header(self.as_rec_mut(), 66u16, 4 as u16);
29432        self.as_rec_mut().extend(value.to_ne_bytes());
29433        self
29434    }
29435    pub fn push_netns_immutable(mut self, value: u8) -> Self {
29436        push_header(self.as_rec_mut(), 67u16, 1 as u16);
29437        self.as_rec_mut().extend(value.to_ne_bytes());
29438        self
29439    }
29440}
29441impl<Prev: Rec> Drop for PushOpSetlinkDoRequest<Prev> {
29442    fn drop(&mut self) {
29443        if let Some(prev) = &mut self.prev {
29444            if let Some(header_offset) = &self.header_offset {
29445                finalize_nested_header(prev.as_rec_mut(), *header_offset);
29446            }
29447        }
29448    }
29449}
29450#[doc = "Set information about a link."]
29451#[derive(Clone)]
29452pub enum OpSetlinkDoRequest<'a> {
29453    Address(&'a [u8]),
29454    Broadcast(&'a [u8]),
29455    Ifname(&'a CStr),
29456    Mtu(u32),
29457    Link(u32),
29458    Qdisc(&'a CStr),
29459    Stats(PushRtnlLinkStats),
29460    Cost(&'a CStr),
29461    Priority(&'a CStr),
29462    Master(u32),
29463    Wireless(&'a CStr),
29464    Protinfo(&'a CStr),
29465    Txqlen(u32),
29466    Map(PushRtnlLinkIfmap),
29467    Weight(u32),
29468    Operstate(u8),
29469    Linkmode(u8),
29470    Linkinfo(IterableLinkinfoAttrs<'a>),
29471    NetNsPid(u32),
29472    Ifalias(&'a CStr),
29473    NumVf(u32),
29474    VfinfoList(IterableVfinfoListAttrs<'a>),
29475    Stats64(PushRtnlLinkStats64),
29476    VfPorts(IterableVfPortsAttrs<'a>),
29477    PortSelf(IterablePortSelfAttrs<'a>),
29478    AfSpec(IterableAfSpecAttrs<'a>),
29479    Group(u32),
29480    NetNsFd(u32),
29481    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
29482    ExtMask(u32),
29483    Promiscuity(u32),
29484    NumTxQueues(u32),
29485    NumRxQueues(u32),
29486    Carrier(u8),
29487    PhysPortId(&'a [u8]),
29488    CarrierChanges(u32),
29489    PhysSwitchId(&'a [u8]),
29490    LinkNetnsid(i32),
29491    PhysPortName(&'a CStr),
29492    ProtoDown(u8),
29493    GsoMaxSegs(u32),
29494    GsoMaxSize(u32),
29495    Pad(&'a [u8]),
29496    Xdp(IterableXdpAttrs<'a>),
29497    Event(u32),
29498    NewNetnsid(i32),
29499    TargetNetnsid(i32),
29500    CarrierUpCount(u32),
29501    CarrierDownCount(u32),
29502    NewIfindex(i32),
29503    MinMtu(u32),
29504    MaxMtu(u32),
29505    PropList(IterablePropListLinkAttrs<'a>),
29506    PermAddress(&'a [u8]),
29507    ProtoDownReason(&'a CStr),
29508    ParentDevName(&'a CStr),
29509    ParentDevBusName(&'a CStr),
29510    GroMaxSize(u32),
29511    TsoMaxSize(u32),
29512    TsoMaxSegs(u32),
29513    Allmulti(u32),
29514    DevlinkPort(&'a [u8]),
29515    GsoIpv4MaxSize(u32),
29516    GroIpv4MaxSize(u32),
29517    DpllPin(IterableLinkDpllPinAttrs<'a>),
29518    #[doc = "EDT offload horizon supported by the device (in nsec)."]
29519    MaxPacingOffloadHorizon(u32),
29520    NetnsImmutable(u8),
29521}
29522impl<'a> IterableOpSetlinkDoRequest<'a> {
29523    pub fn get_address(&self) -> Result<&'a [u8], ErrorContext> {
29524        let mut iter = self.clone();
29525        iter.pos = 0;
29526        for attr in iter {
29527            if let OpSetlinkDoRequest::Address(val) = attr? {
29528                return Ok(val);
29529            }
29530        }
29531        Err(ErrorContext::new_missing(
29532            "OpSetlinkDoRequest",
29533            "Address",
29534            self.orig_loc,
29535            self.buf.as_ptr() as usize,
29536        ))
29537    }
29538    pub fn get_broadcast(&self) -> Result<&'a [u8], ErrorContext> {
29539        let mut iter = self.clone();
29540        iter.pos = 0;
29541        for attr in iter {
29542            if let OpSetlinkDoRequest::Broadcast(val) = attr? {
29543                return Ok(val);
29544            }
29545        }
29546        Err(ErrorContext::new_missing(
29547            "OpSetlinkDoRequest",
29548            "Broadcast",
29549            self.orig_loc,
29550            self.buf.as_ptr() as usize,
29551        ))
29552    }
29553    pub fn get_ifname(&self) -> Result<&'a CStr, ErrorContext> {
29554        let mut iter = self.clone();
29555        iter.pos = 0;
29556        for attr in iter {
29557            if let OpSetlinkDoRequest::Ifname(val) = attr? {
29558                return Ok(val);
29559            }
29560        }
29561        Err(ErrorContext::new_missing(
29562            "OpSetlinkDoRequest",
29563            "Ifname",
29564            self.orig_loc,
29565            self.buf.as_ptr() as usize,
29566        ))
29567    }
29568    pub fn get_mtu(&self) -> Result<u32, ErrorContext> {
29569        let mut iter = self.clone();
29570        iter.pos = 0;
29571        for attr in iter {
29572            if let OpSetlinkDoRequest::Mtu(val) = attr? {
29573                return Ok(val);
29574            }
29575        }
29576        Err(ErrorContext::new_missing(
29577            "OpSetlinkDoRequest",
29578            "Mtu",
29579            self.orig_loc,
29580            self.buf.as_ptr() as usize,
29581        ))
29582    }
29583    pub fn get_link(&self) -> Result<u32, ErrorContext> {
29584        let mut iter = self.clone();
29585        iter.pos = 0;
29586        for attr in iter {
29587            if let OpSetlinkDoRequest::Link(val) = attr? {
29588                return Ok(val);
29589            }
29590        }
29591        Err(ErrorContext::new_missing(
29592            "OpSetlinkDoRequest",
29593            "Link",
29594            self.orig_loc,
29595            self.buf.as_ptr() as usize,
29596        ))
29597    }
29598    pub fn get_qdisc(&self) -> Result<&'a CStr, ErrorContext> {
29599        let mut iter = self.clone();
29600        iter.pos = 0;
29601        for attr in iter {
29602            if let OpSetlinkDoRequest::Qdisc(val) = attr? {
29603                return Ok(val);
29604            }
29605        }
29606        Err(ErrorContext::new_missing(
29607            "OpSetlinkDoRequest",
29608            "Qdisc",
29609            self.orig_loc,
29610            self.buf.as_ptr() as usize,
29611        ))
29612    }
29613    pub fn get_stats(&self) -> Result<PushRtnlLinkStats, ErrorContext> {
29614        let mut iter = self.clone();
29615        iter.pos = 0;
29616        for attr in iter {
29617            if let OpSetlinkDoRequest::Stats(val) = attr? {
29618                return Ok(val);
29619            }
29620        }
29621        Err(ErrorContext::new_missing(
29622            "OpSetlinkDoRequest",
29623            "Stats",
29624            self.orig_loc,
29625            self.buf.as_ptr() as usize,
29626        ))
29627    }
29628    pub fn get_cost(&self) -> Result<&'a CStr, ErrorContext> {
29629        let mut iter = self.clone();
29630        iter.pos = 0;
29631        for attr in iter {
29632            if let OpSetlinkDoRequest::Cost(val) = attr? {
29633                return Ok(val);
29634            }
29635        }
29636        Err(ErrorContext::new_missing(
29637            "OpSetlinkDoRequest",
29638            "Cost",
29639            self.orig_loc,
29640            self.buf.as_ptr() as usize,
29641        ))
29642    }
29643    pub fn get_priority(&self) -> Result<&'a CStr, ErrorContext> {
29644        let mut iter = self.clone();
29645        iter.pos = 0;
29646        for attr in iter {
29647            if let OpSetlinkDoRequest::Priority(val) = attr? {
29648                return Ok(val);
29649            }
29650        }
29651        Err(ErrorContext::new_missing(
29652            "OpSetlinkDoRequest",
29653            "Priority",
29654            self.orig_loc,
29655            self.buf.as_ptr() as usize,
29656        ))
29657    }
29658    pub fn get_master(&self) -> Result<u32, ErrorContext> {
29659        let mut iter = self.clone();
29660        iter.pos = 0;
29661        for attr in iter {
29662            if let OpSetlinkDoRequest::Master(val) = attr? {
29663                return Ok(val);
29664            }
29665        }
29666        Err(ErrorContext::new_missing(
29667            "OpSetlinkDoRequest",
29668            "Master",
29669            self.orig_loc,
29670            self.buf.as_ptr() as usize,
29671        ))
29672    }
29673    pub fn get_wireless(&self) -> Result<&'a CStr, ErrorContext> {
29674        let mut iter = self.clone();
29675        iter.pos = 0;
29676        for attr in iter {
29677            if let OpSetlinkDoRequest::Wireless(val) = attr? {
29678                return Ok(val);
29679            }
29680        }
29681        Err(ErrorContext::new_missing(
29682            "OpSetlinkDoRequest",
29683            "Wireless",
29684            self.orig_loc,
29685            self.buf.as_ptr() as usize,
29686        ))
29687    }
29688    pub fn get_protinfo(&self) -> Result<&'a CStr, ErrorContext> {
29689        let mut iter = self.clone();
29690        iter.pos = 0;
29691        for attr in iter {
29692            if let OpSetlinkDoRequest::Protinfo(val) = attr? {
29693                return Ok(val);
29694            }
29695        }
29696        Err(ErrorContext::new_missing(
29697            "OpSetlinkDoRequest",
29698            "Protinfo",
29699            self.orig_loc,
29700            self.buf.as_ptr() as usize,
29701        ))
29702    }
29703    pub fn get_txqlen(&self) -> Result<u32, ErrorContext> {
29704        let mut iter = self.clone();
29705        iter.pos = 0;
29706        for attr in iter {
29707            if let OpSetlinkDoRequest::Txqlen(val) = attr? {
29708                return Ok(val);
29709            }
29710        }
29711        Err(ErrorContext::new_missing(
29712            "OpSetlinkDoRequest",
29713            "Txqlen",
29714            self.orig_loc,
29715            self.buf.as_ptr() as usize,
29716        ))
29717    }
29718    pub fn get_map(&self) -> Result<PushRtnlLinkIfmap, ErrorContext> {
29719        let mut iter = self.clone();
29720        iter.pos = 0;
29721        for attr in iter {
29722            if let OpSetlinkDoRequest::Map(val) = attr? {
29723                return Ok(val);
29724            }
29725        }
29726        Err(ErrorContext::new_missing(
29727            "OpSetlinkDoRequest",
29728            "Map",
29729            self.orig_loc,
29730            self.buf.as_ptr() as usize,
29731        ))
29732    }
29733    pub fn get_weight(&self) -> Result<u32, ErrorContext> {
29734        let mut iter = self.clone();
29735        iter.pos = 0;
29736        for attr in iter {
29737            if let OpSetlinkDoRequest::Weight(val) = attr? {
29738                return Ok(val);
29739            }
29740        }
29741        Err(ErrorContext::new_missing(
29742            "OpSetlinkDoRequest",
29743            "Weight",
29744            self.orig_loc,
29745            self.buf.as_ptr() as usize,
29746        ))
29747    }
29748    pub fn get_operstate(&self) -> Result<u8, ErrorContext> {
29749        let mut iter = self.clone();
29750        iter.pos = 0;
29751        for attr in iter {
29752            if let OpSetlinkDoRequest::Operstate(val) = attr? {
29753                return Ok(val);
29754            }
29755        }
29756        Err(ErrorContext::new_missing(
29757            "OpSetlinkDoRequest",
29758            "Operstate",
29759            self.orig_loc,
29760            self.buf.as_ptr() as usize,
29761        ))
29762    }
29763    pub fn get_linkmode(&self) -> Result<u8, ErrorContext> {
29764        let mut iter = self.clone();
29765        iter.pos = 0;
29766        for attr in iter {
29767            if let OpSetlinkDoRequest::Linkmode(val) = attr? {
29768                return Ok(val);
29769            }
29770        }
29771        Err(ErrorContext::new_missing(
29772            "OpSetlinkDoRequest",
29773            "Linkmode",
29774            self.orig_loc,
29775            self.buf.as_ptr() as usize,
29776        ))
29777    }
29778    pub fn get_linkinfo(&self) -> Result<IterableLinkinfoAttrs<'a>, ErrorContext> {
29779        let mut iter = self.clone();
29780        iter.pos = 0;
29781        for attr in iter {
29782            if let OpSetlinkDoRequest::Linkinfo(val) = attr? {
29783                return Ok(val);
29784            }
29785        }
29786        Err(ErrorContext::new_missing(
29787            "OpSetlinkDoRequest",
29788            "Linkinfo",
29789            self.orig_loc,
29790            self.buf.as_ptr() as usize,
29791        ))
29792    }
29793    pub fn get_net_ns_pid(&self) -> Result<u32, ErrorContext> {
29794        let mut iter = self.clone();
29795        iter.pos = 0;
29796        for attr in iter {
29797            if let OpSetlinkDoRequest::NetNsPid(val) = attr? {
29798                return Ok(val);
29799            }
29800        }
29801        Err(ErrorContext::new_missing(
29802            "OpSetlinkDoRequest",
29803            "NetNsPid",
29804            self.orig_loc,
29805            self.buf.as_ptr() as usize,
29806        ))
29807    }
29808    pub fn get_ifalias(&self) -> Result<&'a CStr, ErrorContext> {
29809        let mut iter = self.clone();
29810        iter.pos = 0;
29811        for attr in iter {
29812            if let OpSetlinkDoRequest::Ifalias(val) = attr? {
29813                return Ok(val);
29814            }
29815        }
29816        Err(ErrorContext::new_missing(
29817            "OpSetlinkDoRequest",
29818            "Ifalias",
29819            self.orig_loc,
29820            self.buf.as_ptr() as usize,
29821        ))
29822    }
29823    pub fn get_num_vf(&self) -> Result<u32, ErrorContext> {
29824        let mut iter = self.clone();
29825        iter.pos = 0;
29826        for attr in iter {
29827            if let OpSetlinkDoRequest::NumVf(val) = attr? {
29828                return Ok(val);
29829            }
29830        }
29831        Err(ErrorContext::new_missing(
29832            "OpSetlinkDoRequest",
29833            "NumVf",
29834            self.orig_loc,
29835            self.buf.as_ptr() as usize,
29836        ))
29837    }
29838    pub fn get_vfinfo_list(&self) -> Result<IterableVfinfoListAttrs<'a>, ErrorContext> {
29839        let mut iter = self.clone();
29840        iter.pos = 0;
29841        for attr in iter {
29842            if let OpSetlinkDoRequest::VfinfoList(val) = attr? {
29843                return Ok(val);
29844            }
29845        }
29846        Err(ErrorContext::new_missing(
29847            "OpSetlinkDoRequest",
29848            "VfinfoList",
29849            self.orig_loc,
29850            self.buf.as_ptr() as usize,
29851        ))
29852    }
29853    pub fn get_stats64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
29854        let mut iter = self.clone();
29855        iter.pos = 0;
29856        for attr in iter {
29857            if let OpSetlinkDoRequest::Stats64(val) = attr? {
29858                return Ok(val);
29859            }
29860        }
29861        Err(ErrorContext::new_missing(
29862            "OpSetlinkDoRequest",
29863            "Stats64",
29864            self.orig_loc,
29865            self.buf.as_ptr() as usize,
29866        ))
29867    }
29868    pub fn get_vf_ports(&self) -> Result<IterableVfPortsAttrs<'a>, ErrorContext> {
29869        let mut iter = self.clone();
29870        iter.pos = 0;
29871        for attr in iter {
29872            if let OpSetlinkDoRequest::VfPorts(val) = attr? {
29873                return Ok(val);
29874            }
29875        }
29876        Err(ErrorContext::new_missing(
29877            "OpSetlinkDoRequest",
29878            "VfPorts",
29879            self.orig_loc,
29880            self.buf.as_ptr() as usize,
29881        ))
29882    }
29883    pub fn get_port_self(&self) -> Result<IterablePortSelfAttrs<'a>, ErrorContext> {
29884        let mut iter = self.clone();
29885        iter.pos = 0;
29886        for attr in iter {
29887            if let OpSetlinkDoRequest::PortSelf(val) = attr? {
29888                return Ok(val);
29889            }
29890        }
29891        Err(ErrorContext::new_missing(
29892            "OpSetlinkDoRequest",
29893            "PortSelf",
29894            self.orig_loc,
29895            self.buf.as_ptr() as usize,
29896        ))
29897    }
29898    pub fn get_af_spec(&self) -> Result<IterableAfSpecAttrs<'a>, ErrorContext> {
29899        let mut iter = self.clone();
29900        iter.pos = 0;
29901        for attr in iter {
29902            if let OpSetlinkDoRequest::AfSpec(val) = attr? {
29903                return Ok(val);
29904            }
29905        }
29906        Err(ErrorContext::new_missing(
29907            "OpSetlinkDoRequest",
29908            "AfSpec",
29909            self.orig_loc,
29910            self.buf.as_ptr() as usize,
29911        ))
29912    }
29913    pub fn get_group(&self) -> Result<u32, ErrorContext> {
29914        let mut iter = self.clone();
29915        iter.pos = 0;
29916        for attr in iter {
29917            if let OpSetlinkDoRequest::Group(val) = attr? {
29918                return Ok(val);
29919            }
29920        }
29921        Err(ErrorContext::new_missing(
29922            "OpSetlinkDoRequest",
29923            "Group",
29924            self.orig_loc,
29925            self.buf.as_ptr() as usize,
29926        ))
29927    }
29928    pub fn get_net_ns_fd(&self) -> Result<u32, ErrorContext> {
29929        let mut iter = self.clone();
29930        iter.pos = 0;
29931        for attr in iter {
29932            if let OpSetlinkDoRequest::NetNsFd(val) = attr? {
29933                return Ok(val);
29934            }
29935        }
29936        Err(ErrorContext::new_missing(
29937            "OpSetlinkDoRequest",
29938            "NetNsFd",
29939            self.orig_loc,
29940            self.buf.as_ptr() as usize,
29941        ))
29942    }
29943    #[doc = "Associated type: \"RtextFilter\" (1 bit per enumeration)"]
29944    pub fn get_ext_mask(&self) -> Result<u32, ErrorContext> {
29945        let mut iter = self.clone();
29946        iter.pos = 0;
29947        for attr in iter {
29948            if let OpSetlinkDoRequest::ExtMask(val) = attr? {
29949                return Ok(val);
29950            }
29951        }
29952        Err(ErrorContext::new_missing(
29953            "OpSetlinkDoRequest",
29954            "ExtMask",
29955            self.orig_loc,
29956            self.buf.as_ptr() as usize,
29957        ))
29958    }
29959    pub fn get_promiscuity(&self) -> Result<u32, ErrorContext> {
29960        let mut iter = self.clone();
29961        iter.pos = 0;
29962        for attr in iter {
29963            if let OpSetlinkDoRequest::Promiscuity(val) = attr? {
29964                return Ok(val);
29965            }
29966        }
29967        Err(ErrorContext::new_missing(
29968            "OpSetlinkDoRequest",
29969            "Promiscuity",
29970            self.orig_loc,
29971            self.buf.as_ptr() as usize,
29972        ))
29973    }
29974    pub fn get_num_tx_queues(&self) -> Result<u32, ErrorContext> {
29975        let mut iter = self.clone();
29976        iter.pos = 0;
29977        for attr in iter {
29978            if let OpSetlinkDoRequest::NumTxQueues(val) = attr? {
29979                return Ok(val);
29980            }
29981        }
29982        Err(ErrorContext::new_missing(
29983            "OpSetlinkDoRequest",
29984            "NumTxQueues",
29985            self.orig_loc,
29986            self.buf.as_ptr() as usize,
29987        ))
29988    }
29989    pub fn get_num_rx_queues(&self) -> Result<u32, ErrorContext> {
29990        let mut iter = self.clone();
29991        iter.pos = 0;
29992        for attr in iter {
29993            if let OpSetlinkDoRequest::NumRxQueues(val) = attr? {
29994                return Ok(val);
29995            }
29996        }
29997        Err(ErrorContext::new_missing(
29998            "OpSetlinkDoRequest",
29999            "NumRxQueues",
30000            self.orig_loc,
30001            self.buf.as_ptr() as usize,
30002        ))
30003    }
30004    pub fn get_carrier(&self) -> Result<u8, ErrorContext> {
30005        let mut iter = self.clone();
30006        iter.pos = 0;
30007        for attr in iter {
30008            if let OpSetlinkDoRequest::Carrier(val) = attr? {
30009                return Ok(val);
30010            }
30011        }
30012        Err(ErrorContext::new_missing(
30013            "OpSetlinkDoRequest",
30014            "Carrier",
30015            self.orig_loc,
30016            self.buf.as_ptr() as usize,
30017        ))
30018    }
30019    pub fn get_phys_port_id(&self) -> Result<&'a [u8], ErrorContext> {
30020        let mut iter = self.clone();
30021        iter.pos = 0;
30022        for attr in iter {
30023            if let OpSetlinkDoRequest::PhysPortId(val) = attr? {
30024                return Ok(val);
30025            }
30026        }
30027        Err(ErrorContext::new_missing(
30028            "OpSetlinkDoRequest",
30029            "PhysPortId",
30030            self.orig_loc,
30031            self.buf.as_ptr() as usize,
30032        ))
30033    }
30034    pub fn get_carrier_changes(&self) -> Result<u32, ErrorContext> {
30035        let mut iter = self.clone();
30036        iter.pos = 0;
30037        for attr in iter {
30038            if let OpSetlinkDoRequest::CarrierChanges(val) = attr? {
30039                return Ok(val);
30040            }
30041        }
30042        Err(ErrorContext::new_missing(
30043            "OpSetlinkDoRequest",
30044            "CarrierChanges",
30045            self.orig_loc,
30046            self.buf.as_ptr() as usize,
30047        ))
30048    }
30049    pub fn get_phys_switch_id(&self) -> Result<&'a [u8], ErrorContext> {
30050        let mut iter = self.clone();
30051        iter.pos = 0;
30052        for attr in iter {
30053            if let OpSetlinkDoRequest::PhysSwitchId(val) = attr? {
30054                return Ok(val);
30055            }
30056        }
30057        Err(ErrorContext::new_missing(
30058            "OpSetlinkDoRequest",
30059            "PhysSwitchId",
30060            self.orig_loc,
30061            self.buf.as_ptr() as usize,
30062        ))
30063    }
30064    pub fn get_link_netnsid(&self) -> Result<i32, ErrorContext> {
30065        let mut iter = self.clone();
30066        iter.pos = 0;
30067        for attr in iter {
30068            if let OpSetlinkDoRequest::LinkNetnsid(val) = attr? {
30069                return Ok(val);
30070            }
30071        }
30072        Err(ErrorContext::new_missing(
30073            "OpSetlinkDoRequest",
30074            "LinkNetnsid",
30075            self.orig_loc,
30076            self.buf.as_ptr() as usize,
30077        ))
30078    }
30079    pub fn get_phys_port_name(&self) -> Result<&'a CStr, ErrorContext> {
30080        let mut iter = self.clone();
30081        iter.pos = 0;
30082        for attr in iter {
30083            if let OpSetlinkDoRequest::PhysPortName(val) = attr? {
30084                return Ok(val);
30085            }
30086        }
30087        Err(ErrorContext::new_missing(
30088            "OpSetlinkDoRequest",
30089            "PhysPortName",
30090            self.orig_loc,
30091            self.buf.as_ptr() as usize,
30092        ))
30093    }
30094    pub fn get_proto_down(&self) -> Result<u8, ErrorContext> {
30095        let mut iter = self.clone();
30096        iter.pos = 0;
30097        for attr in iter {
30098            if let OpSetlinkDoRequest::ProtoDown(val) = attr? {
30099                return Ok(val);
30100            }
30101        }
30102        Err(ErrorContext::new_missing(
30103            "OpSetlinkDoRequest",
30104            "ProtoDown",
30105            self.orig_loc,
30106            self.buf.as_ptr() as usize,
30107        ))
30108    }
30109    pub fn get_gso_max_segs(&self) -> Result<u32, ErrorContext> {
30110        let mut iter = self.clone();
30111        iter.pos = 0;
30112        for attr in iter {
30113            if let OpSetlinkDoRequest::GsoMaxSegs(val) = attr? {
30114                return Ok(val);
30115            }
30116        }
30117        Err(ErrorContext::new_missing(
30118            "OpSetlinkDoRequest",
30119            "GsoMaxSegs",
30120            self.orig_loc,
30121            self.buf.as_ptr() as usize,
30122        ))
30123    }
30124    pub fn get_gso_max_size(&self) -> Result<u32, ErrorContext> {
30125        let mut iter = self.clone();
30126        iter.pos = 0;
30127        for attr in iter {
30128            if let OpSetlinkDoRequest::GsoMaxSize(val) = attr? {
30129                return Ok(val);
30130            }
30131        }
30132        Err(ErrorContext::new_missing(
30133            "OpSetlinkDoRequest",
30134            "GsoMaxSize",
30135            self.orig_loc,
30136            self.buf.as_ptr() as usize,
30137        ))
30138    }
30139    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
30140        let mut iter = self.clone();
30141        iter.pos = 0;
30142        for attr in iter {
30143            if let OpSetlinkDoRequest::Pad(val) = attr? {
30144                return Ok(val);
30145            }
30146        }
30147        Err(ErrorContext::new_missing(
30148            "OpSetlinkDoRequest",
30149            "Pad",
30150            self.orig_loc,
30151            self.buf.as_ptr() as usize,
30152        ))
30153    }
30154    pub fn get_xdp(&self) -> Result<IterableXdpAttrs<'a>, ErrorContext> {
30155        let mut iter = self.clone();
30156        iter.pos = 0;
30157        for attr in iter {
30158            if let OpSetlinkDoRequest::Xdp(val) = attr? {
30159                return Ok(val);
30160            }
30161        }
30162        Err(ErrorContext::new_missing(
30163            "OpSetlinkDoRequest",
30164            "Xdp",
30165            self.orig_loc,
30166            self.buf.as_ptr() as usize,
30167        ))
30168    }
30169    pub fn get_event(&self) -> Result<u32, ErrorContext> {
30170        let mut iter = self.clone();
30171        iter.pos = 0;
30172        for attr in iter {
30173            if let OpSetlinkDoRequest::Event(val) = attr? {
30174                return Ok(val);
30175            }
30176        }
30177        Err(ErrorContext::new_missing(
30178            "OpSetlinkDoRequest",
30179            "Event",
30180            self.orig_loc,
30181            self.buf.as_ptr() as usize,
30182        ))
30183    }
30184    pub fn get_new_netnsid(&self) -> Result<i32, ErrorContext> {
30185        let mut iter = self.clone();
30186        iter.pos = 0;
30187        for attr in iter {
30188            if let OpSetlinkDoRequest::NewNetnsid(val) = attr? {
30189                return Ok(val);
30190            }
30191        }
30192        Err(ErrorContext::new_missing(
30193            "OpSetlinkDoRequest",
30194            "NewNetnsid",
30195            self.orig_loc,
30196            self.buf.as_ptr() as usize,
30197        ))
30198    }
30199    pub fn get_target_netnsid(&self) -> Result<i32, ErrorContext> {
30200        let mut iter = self.clone();
30201        iter.pos = 0;
30202        for attr in iter {
30203            if let OpSetlinkDoRequest::TargetNetnsid(val) = attr? {
30204                return Ok(val);
30205            }
30206        }
30207        Err(ErrorContext::new_missing(
30208            "OpSetlinkDoRequest",
30209            "TargetNetnsid",
30210            self.orig_loc,
30211            self.buf.as_ptr() as usize,
30212        ))
30213    }
30214    pub fn get_carrier_up_count(&self) -> Result<u32, ErrorContext> {
30215        let mut iter = self.clone();
30216        iter.pos = 0;
30217        for attr in iter {
30218            if let OpSetlinkDoRequest::CarrierUpCount(val) = attr? {
30219                return Ok(val);
30220            }
30221        }
30222        Err(ErrorContext::new_missing(
30223            "OpSetlinkDoRequest",
30224            "CarrierUpCount",
30225            self.orig_loc,
30226            self.buf.as_ptr() as usize,
30227        ))
30228    }
30229    pub fn get_carrier_down_count(&self) -> Result<u32, ErrorContext> {
30230        let mut iter = self.clone();
30231        iter.pos = 0;
30232        for attr in iter {
30233            if let OpSetlinkDoRequest::CarrierDownCount(val) = attr? {
30234                return Ok(val);
30235            }
30236        }
30237        Err(ErrorContext::new_missing(
30238            "OpSetlinkDoRequest",
30239            "CarrierDownCount",
30240            self.orig_loc,
30241            self.buf.as_ptr() as usize,
30242        ))
30243    }
30244    pub fn get_new_ifindex(&self) -> Result<i32, ErrorContext> {
30245        let mut iter = self.clone();
30246        iter.pos = 0;
30247        for attr in iter {
30248            if let OpSetlinkDoRequest::NewIfindex(val) = attr? {
30249                return Ok(val);
30250            }
30251        }
30252        Err(ErrorContext::new_missing(
30253            "OpSetlinkDoRequest",
30254            "NewIfindex",
30255            self.orig_loc,
30256            self.buf.as_ptr() as usize,
30257        ))
30258    }
30259    pub fn get_min_mtu(&self) -> Result<u32, ErrorContext> {
30260        let mut iter = self.clone();
30261        iter.pos = 0;
30262        for attr in iter {
30263            if let OpSetlinkDoRequest::MinMtu(val) = attr? {
30264                return Ok(val);
30265            }
30266        }
30267        Err(ErrorContext::new_missing(
30268            "OpSetlinkDoRequest",
30269            "MinMtu",
30270            self.orig_loc,
30271            self.buf.as_ptr() as usize,
30272        ))
30273    }
30274    pub fn get_max_mtu(&self) -> Result<u32, ErrorContext> {
30275        let mut iter = self.clone();
30276        iter.pos = 0;
30277        for attr in iter {
30278            if let OpSetlinkDoRequest::MaxMtu(val) = attr? {
30279                return Ok(val);
30280            }
30281        }
30282        Err(ErrorContext::new_missing(
30283            "OpSetlinkDoRequest",
30284            "MaxMtu",
30285            self.orig_loc,
30286            self.buf.as_ptr() as usize,
30287        ))
30288    }
30289    pub fn get_prop_list(&self) -> Result<IterablePropListLinkAttrs<'a>, ErrorContext> {
30290        let mut iter = self.clone();
30291        iter.pos = 0;
30292        for attr in iter {
30293            if let OpSetlinkDoRequest::PropList(val) = attr? {
30294                return Ok(val);
30295            }
30296        }
30297        Err(ErrorContext::new_missing(
30298            "OpSetlinkDoRequest",
30299            "PropList",
30300            self.orig_loc,
30301            self.buf.as_ptr() as usize,
30302        ))
30303    }
30304    pub fn get_perm_address(&self) -> Result<&'a [u8], ErrorContext> {
30305        let mut iter = self.clone();
30306        iter.pos = 0;
30307        for attr in iter {
30308            if let OpSetlinkDoRequest::PermAddress(val) = attr? {
30309                return Ok(val);
30310            }
30311        }
30312        Err(ErrorContext::new_missing(
30313            "OpSetlinkDoRequest",
30314            "PermAddress",
30315            self.orig_loc,
30316            self.buf.as_ptr() as usize,
30317        ))
30318    }
30319    pub fn get_proto_down_reason(&self) -> Result<&'a CStr, ErrorContext> {
30320        let mut iter = self.clone();
30321        iter.pos = 0;
30322        for attr in iter {
30323            if let OpSetlinkDoRequest::ProtoDownReason(val) = attr? {
30324                return Ok(val);
30325            }
30326        }
30327        Err(ErrorContext::new_missing(
30328            "OpSetlinkDoRequest",
30329            "ProtoDownReason",
30330            self.orig_loc,
30331            self.buf.as_ptr() as usize,
30332        ))
30333    }
30334    pub fn get_parent_dev_name(&self) -> Result<&'a CStr, ErrorContext> {
30335        let mut iter = self.clone();
30336        iter.pos = 0;
30337        for attr in iter {
30338            if let OpSetlinkDoRequest::ParentDevName(val) = attr? {
30339                return Ok(val);
30340            }
30341        }
30342        Err(ErrorContext::new_missing(
30343            "OpSetlinkDoRequest",
30344            "ParentDevName",
30345            self.orig_loc,
30346            self.buf.as_ptr() as usize,
30347        ))
30348    }
30349    pub fn get_parent_dev_bus_name(&self) -> Result<&'a CStr, ErrorContext> {
30350        let mut iter = self.clone();
30351        iter.pos = 0;
30352        for attr in iter {
30353            if let OpSetlinkDoRequest::ParentDevBusName(val) = attr? {
30354                return Ok(val);
30355            }
30356        }
30357        Err(ErrorContext::new_missing(
30358            "OpSetlinkDoRequest",
30359            "ParentDevBusName",
30360            self.orig_loc,
30361            self.buf.as_ptr() as usize,
30362        ))
30363    }
30364    pub fn get_gro_max_size(&self) -> Result<u32, ErrorContext> {
30365        let mut iter = self.clone();
30366        iter.pos = 0;
30367        for attr in iter {
30368            if let OpSetlinkDoRequest::GroMaxSize(val) = attr? {
30369                return Ok(val);
30370            }
30371        }
30372        Err(ErrorContext::new_missing(
30373            "OpSetlinkDoRequest",
30374            "GroMaxSize",
30375            self.orig_loc,
30376            self.buf.as_ptr() as usize,
30377        ))
30378    }
30379    pub fn get_tso_max_size(&self) -> Result<u32, ErrorContext> {
30380        let mut iter = self.clone();
30381        iter.pos = 0;
30382        for attr in iter {
30383            if let OpSetlinkDoRequest::TsoMaxSize(val) = attr? {
30384                return Ok(val);
30385            }
30386        }
30387        Err(ErrorContext::new_missing(
30388            "OpSetlinkDoRequest",
30389            "TsoMaxSize",
30390            self.orig_loc,
30391            self.buf.as_ptr() as usize,
30392        ))
30393    }
30394    pub fn get_tso_max_segs(&self) -> Result<u32, ErrorContext> {
30395        let mut iter = self.clone();
30396        iter.pos = 0;
30397        for attr in iter {
30398            if let OpSetlinkDoRequest::TsoMaxSegs(val) = attr? {
30399                return Ok(val);
30400            }
30401        }
30402        Err(ErrorContext::new_missing(
30403            "OpSetlinkDoRequest",
30404            "TsoMaxSegs",
30405            self.orig_loc,
30406            self.buf.as_ptr() as usize,
30407        ))
30408    }
30409    pub fn get_allmulti(&self) -> Result<u32, ErrorContext> {
30410        let mut iter = self.clone();
30411        iter.pos = 0;
30412        for attr in iter {
30413            if let OpSetlinkDoRequest::Allmulti(val) = attr? {
30414                return Ok(val);
30415            }
30416        }
30417        Err(ErrorContext::new_missing(
30418            "OpSetlinkDoRequest",
30419            "Allmulti",
30420            self.orig_loc,
30421            self.buf.as_ptr() as usize,
30422        ))
30423    }
30424    pub fn get_devlink_port(&self) -> Result<&'a [u8], ErrorContext> {
30425        let mut iter = self.clone();
30426        iter.pos = 0;
30427        for attr in iter {
30428            if let OpSetlinkDoRequest::DevlinkPort(val) = attr? {
30429                return Ok(val);
30430            }
30431        }
30432        Err(ErrorContext::new_missing(
30433            "OpSetlinkDoRequest",
30434            "DevlinkPort",
30435            self.orig_loc,
30436            self.buf.as_ptr() as usize,
30437        ))
30438    }
30439    pub fn get_gso_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
30440        let mut iter = self.clone();
30441        iter.pos = 0;
30442        for attr in iter {
30443            if let OpSetlinkDoRequest::GsoIpv4MaxSize(val) = attr? {
30444                return Ok(val);
30445            }
30446        }
30447        Err(ErrorContext::new_missing(
30448            "OpSetlinkDoRequest",
30449            "GsoIpv4MaxSize",
30450            self.orig_loc,
30451            self.buf.as_ptr() as usize,
30452        ))
30453    }
30454    pub fn get_gro_ipv4_max_size(&self) -> Result<u32, ErrorContext> {
30455        let mut iter = self.clone();
30456        iter.pos = 0;
30457        for attr in iter {
30458            if let OpSetlinkDoRequest::GroIpv4MaxSize(val) = attr? {
30459                return Ok(val);
30460            }
30461        }
30462        Err(ErrorContext::new_missing(
30463            "OpSetlinkDoRequest",
30464            "GroIpv4MaxSize",
30465            self.orig_loc,
30466            self.buf.as_ptr() as usize,
30467        ))
30468    }
30469    pub fn get_dpll_pin(&self) -> Result<IterableLinkDpllPinAttrs<'a>, ErrorContext> {
30470        let mut iter = self.clone();
30471        iter.pos = 0;
30472        for attr in iter {
30473            if let OpSetlinkDoRequest::DpllPin(val) = attr? {
30474                return Ok(val);
30475            }
30476        }
30477        Err(ErrorContext::new_missing(
30478            "OpSetlinkDoRequest",
30479            "DpllPin",
30480            self.orig_loc,
30481            self.buf.as_ptr() as usize,
30482        ))
30483    }
30484    #[doc = "EDT offload horizon supported by the device (in nsec)."]
30485    pub fn get_max_pacing_offload_horizon(&self) -> Result<u32, ErrorContext> {
30486        let mut iter = self.clone();
30487        iter.pos = 0;
30488        for attr in iter {
30489            if let OpSetlinkDoRequest::MaxPacingOffloadHorizon(val) = attr? {
30490                return Ok(val);
30491            }
30492        }
30493        Err(ErrorContext::new_missing(
30494            "OpSetlinkDoRequest",
30495            "MaxPacingOffloadHorizon",
30496            self.orig_loc,
30497            self.buf.as_ptr() as usize,
30498        ))
30499    }
30500    pub fn get_netns_immutable(&self) -> Result<u8, ErrorContext> {
30501        let mut iter = self.clone();
30502        iter.pos = 0;
30503        for attr in iter {
30504            if let OpSetlinkDoRequest::NetnsImmutable(val) = attr? {
30505                return Ok(val);
30506            }
30507        }
30508        Err(ErrorContext::new_missing(
30509            "OpSetlinkDoRequest",
30510            "NetnsImmutable",
30511            self.orig_loc,
30512            self.buf.as_ptr() as usize,
30513        ))
30514    }
30515}
30516impl<'a> OpSetlinkDoRequest<'a> {
30517    pub fn new(buf: &'a [u8]) -> (PushIfinfomsg, IterableOpSetlinkDoRequest<'a>) {
30518        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
30519        (
30520            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
30521            IterableOpSetlinkDoRequest::with_loc(attrs, buf.as_ptr() as usize),
30522        )
30523    }
30524    fn attr_from_type(r#type: u16) -> Option<&'static str> {
30525        LinkAttrs::attr_from_type(r#type)
30526    }
30527}
30528#[derive(Clone, Copy, Default)]
30529pub struct IterableOpSetlinkDoRequest<'a> {
30530    buf: &'a [u8],
30531    pos: usize,
30532    orig_loc: usize,
30533}
30534impl<'a> IterableOpSetlinkDoRequest<'a> {
30535    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
30536        Self {
30537            buf,
30538            pos: 0,
30539            orig_loc,
30540        }
30541    }
30542    pub fn get_buf(&self) -> &'a [u8] {
30543        self.buf
30544    }
30545}
30546impl<'a> Iterator for IterableOpSetlinkDoRequest<'a> {
30547    type Item = Result<OpSetlinkDoRequest<'a>, ErrorContext>;
30548    fn next(&mut self) -> Option<Self::Item> {
30549        if self.buf.len() == self.pos {
30550            return None;
30551        }
30552        let pos = self.pos;
30553        let mut r#type = None;
30554        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
30555            r#type = Some(header.r#type);
30556            let res = match header.r#type {
30557                1u16 => OpSetlinkDoRequest::Address({
30558                    let res = Some(next);
30559                    let Some(val) = res else { break };
30560                    val
30561                }),
30562                2u16 => OpSetlinkDoRequest::Broadcast({
30563                    let res = Some(next);
30564                    let Some(val) = res else { break };
30565                    val
30566                }),
30567                3u16 => OpSetlinkDoRequest::Ifname({
30568                    let res = CStr::from_bytes_with_nul(next).ok();
30569                    let Some(val) = res else { break };
30570                    val
30571                }),
30572                4u16 => OpSetlinkDoRequest::Mtu({
30573                    let res = parse_u32(next);
30574                    let Some(val) = res else { break };
30575                    val
30576                }),
30577                5u16 => OpSetlinkDoRequest::Link({
30578                    let res = parse_u32(next);
30579                    let Some(val) = res else { break };
30580                    val
30581                }),
30582                6u16 => OpSetlinkDoRequest::Qdisc({
30583                    let res = CStr::from_bytes_with_nul(next).ok();
30584                    let Some(val) = res else { break };
30585                    val
30586                }),
30587                7u16 => OpSetlinkDoRequest::Stats({
30588                    let res = PushRtnlLinkStats::new_from_slice(next);
30589                    let Some(val) = res else { break };
30590                    val
30591                }),
30592                8u16 => OpSetlinkDoRequest::Cost({
30593                    let res = CStr::from_bytes_with_nul(next).ok();
30594                    let Some(val) = res else { break };
30595                    val
30596                }),
30597                9u16 => OpSetlinkDoRequest::Priority({
30598                    let res = CStr::from_bytes_with_nul(next).ok();
30599                    let Some(val) = res else { break };
30600                    val
30601                }),
30602                10u16 => OpSetlinkDoRequest::Master({
30603                    let res = parse_u32(next);
30604                    let Some(val) = res else { break };
30605                    val
30606                }),
30607                11u16 => OpSetlinkDoRequest::Wireless({
30608                    let res = CStr::from_bytes_with_nul(next).ok();
30609                    let Some(val) = res else { break };
30610                    val
30611                }),
30612                12u16 => OpSetlinkDoRequest::Protinfo({
30613                    let res = CStr::from_bytes_with_nul(next).ok();
30614                    let Some(val) = res else { break };
30615                    val
30616                }),
30617                13u16 => OpSetlinkDoRequest::Txqlen({
30618                    let res = parse_u32(next);
30619                    let Some(val) = res else { break };
30620                    val
30621                }),
30622                14u16 => OpSetlinkDoRequest::Map({
30623                    let res = PushRtnlLinkIfmap::new_from_slice(next);
30624                    let Some(val) = res else { break };
30625                    val
30626                }),
30627                15u16 => OpSetlinkDoRequest::Weight({
30628                    let res = parse_u32(next);
30629                    let Some(val) = res else { break };
30630                    val
30631                }),
30632                16u16 => OpSetlinkDoRequest::Operstate({
30633                    let res = parse_u8(next);
30634                    let Some(val) = res else { break };
30635                    val
30636                }),
30637                17u16 => OpSetlinkDoRequest::Linkmode({
30638                    let res = parse_u8(next);
30639                    let Some(val) = res else { break };
30640                    val
30641                }),
30642                18u16 => OpSetlinkDoRequest::Linkinfo({
30643                    let res = Some(IterableLinkinfoAttrs::with_loc(next, self.orig_loc));
30644                    let Some(val) = res else { break };
30645                    val
30646                }),
30647                19u16 => OpSetlinkDoRequest::NetNsPid({
30648                    let res = parse_u32(next);
30649                    let Some(val) = res else { break };
30650                    val
30651                }),
30652                20u16 => OpSetlinkDoRequest::Ifalias({
30653                    let res = CStr::from_bytes_with_nul(next).ok();
30654                    let Some(val) = res else { break };
30655                    val
30656                }),
30657                21u16 => OpSetlinkDoRequest::NumVf({
30658                    let res = parse_u32(next);
30659                    let Some(val) = res else { break };
30660                    val
30661                }),
30662                22u16 => OpSetlinkDoRequest::VfinfoList({
30663                    let res = Some(IterableVfinfoListAttrs::with_loc(next, self.orig_loc));
30664                    let Some(val) = res else { break };
30665                    val
30666                }),
30667                23u16 => OpSetlinkDoRequest::Stats64({
30668                    let res = PushRtnlLinkStats64::new_from_slice(next);
30669                    let Some(val) = res else { break };
30670                    val
30671                }),
30672                24u16 => OpSetlinkDoRequest::VfPorts({
30673                    let res = Some(IterableVfPortsAttrs::with_loc(next, self.orig_loc));
30674                    let Some(val) = res else { break };
30675                    val
30676                }),
30677                25u16 => OpSetlinkDoRequest::PortSelf({
30678                    let res = Some(IterablePortSelfAttrs::with_loc(next, self.orig_loc));
30679                    let Some(val) = res else { break };
30680                    val
30681                }),
30682                26u16 => OpSetlinkDoRequest::AfSpec({
30683                    let res = Some(IterableAfSpecAttrs::with_loc(next, self.orig_loc));
30684                    let Some(val) = res else { break };
30685                    val
30686                }),
30687                27u16 => OpSetlinkDoRequest::Group({
30688                    let res = parse_u32(next);
30689                    let Some(val) = res else { break };
30690                    val
30691                }),
30692                28u16 => OpSetlinkDoRequest::NetNsFd({
30693                    let res = parse_u32(next);
30694                    let Some(val) = res else { break };
30695                    val
30696                }),
30697                29u16 => OpSetlinkDoRequest::ExtMask({
30698                    let res = parse_u32(next);
30699                    let Some(val) = res else { break };
30700                    val
30701                }),
30702                30u16 => OpSetlinkDoRequest::Promiscuity({
30703                    let res = parse_u32(next);
30704                    let Some(val) = res else { break };
30705                    val
30706                }),
30707                31u16 => OpSetlinkDoRequest::NumTxQueues({
30708                    let res = parse_u32(next);
30709                    let Some(val) = res else { break };
30710                    val
30711                }),
30712                32u16 => OpSetlinkDoRequest::NumRxQueues({
30713                    let res = parse_u32(next);
30714                    let Some(val) = res else { break };
30715                    val
30716                }),
30717                33u16 => OpSetlinkDoRequest::Carrier({
30718                    let res = parse_u8(next);
30719                    let Some(val) = res else { break };
30720                    val
30721                }),
30722                34u16 => OpSetlinkDoRequest::PhysPortId({
30723                    let res = Some(next);
30724                    let Some(val) = res else { break };
30725                    val
30726                }),
30727                35u16 => OpSetlinkDoRequest::CarrierChanges({
30728                    let res = parse_u32(next);
30729                    let Some(val) = res else { break };
30730                    val
30731                }),
30732                36u16 => OpSetlinkDoRequest::PhysSwitchId({
30733                    let res = Some(next);
30734                    let Some(val) = res else { break };
30735                    val
30736                }),
30737                37u16 => OpSetlinkDoRequest::LinkNetnsid({
30738                    let res = parse_i32(next);
30739                    let Some(val) = res else { break };
30740                    val
30741                }),
30742                38u16 => OpSetlinkDoRequest::PhysPortName({
30743                    let res = CStr::from_bytes_with_nul(next).ok();
30744                    let Some(val) = res else { break };
30745                    val
30746                }),
30747                39u16 => OpSetlinkDoRequest::ProtoDown({
30748                    let res = parse_u8(next);
30749                    let Some(val) = res else { break };
30750                    val
30751                }),
30752                40u16 => OpSetlinkDoRequest::GsoMaxSegs({
30753                    let res = parse_u32(next);
30754                    let Some(val) = res else { break };
30755                    val
30756                }),
30757                41u16 => OpSetlinkDoRequest::GsoMaxSize({
30758                    let res = parse_u32(next);
30759                    let Some(val) = res else { break };
30760                    val
30761                }),
30762                42u16 => OpSetlinkDoRequest::Pad({
30763                    let res = Some(next);
30764                    let Some(val) = res else { break };
30765                    val
30766                }),
30767                43u16 => OpSetlinkDoRequest::Xdp({
30768                    let res = Some(IterableXdpAttrs::with_loc(next, self.orig_loc));
30769                    let Some(val) = res else { break };
30770                    val
30771                }),
30772                44u16 => OpSetlinkDoRequest::Event({
30773                    let res = parse_u32(next);
30774                    let Some(val) = res else { break };
30775                    val
30776                }),
30777                45u16 => OpSetlinkDoRequest::NewNetnsid({
30778                    let res = parse_i32(next);
30779                    let Some(val) = res else { break };
30780                    val
30781                }),
30782                46u16 => OpSetlinkDoRequest::TargetNetnsid({
30783                    let res = parse_i32(next);
30784                    let Some(val) = res else { break };
30785                    val
30786                }),
30787                47u16 => OpSetlinkDoRequest::CarrierUpCount({
30788                    let res = parse_u32(next);
30789                    let Some(val) = res else { break };
30790                    val
30791                }),
30792                48u16 => OpSetlinkDoRequest::CarrierDownCount({
30793                    let res = parse_u32(next);
30794                    let Some(val) = res else { break };
30795                    val
30796                }),
30797                49u16 => OpSetlinkDoRequest::NewIfindex({
30798                    let res = parse_i32(next);
30799                    let Some(val) = res else { break };
30800                    val
30801                }),
30802                50u16 => OpSetlinkDoRequest::MinMtu({
30803                    let res = parse_u32(next);
30804                    let Some(val) = res else { break };
30805                    val
30806                }),
30807                51u16 => OpSetlinkDoRequest::MaxMtu({
30808                    let res = parse_u32(next);
30809                    let Some(val) = res else { break };
30810                    val
30811                }),
30812                52u16 => OpSetlinkDoRequest::PropList({
30813                    let res = Some(IterablePropListLinkAttrs::with_loc(next, self.orig_loc));
30814                    let Some(val) = res else { break };
30815                    val
30816                }),
30817                54u16 => OpSetlinkDoRequest::PermAddress({
30818                    let res = Some(next);
30819                    let Some(val) = res else { break };
30820                    val
30821                }),
30822                55u16 => OpSetlinkDoRequest::ProtoDownReason({
30823                    let res = CStr::from_bytes_with_nul(next).ok();
30824                    let Some(val) = res else { break };
30825                    val
30826                }),
30827                56u16 => OpSetlinkDoRequest::ParentDevName({
30828                    let res = CStr::from_bytes_with_nul(next).ok();
30829                    let Some(val) = res else { break };
30830                    val
30831                }),
30832                57u16 => OpSetlinkDoRequest::ParentDevBusName({
30833                    let res = CStr::from_bytes_with_nul(next).ok();
30834                    let Some(val) = res else { break };
30835                    val
30836                }),
30837                58u16 => OpSetlinkDoRequest::GroMaxSize({
30838                    let res = parse_u32(next);
30839                    let Some(val) = res else { break };
30840                    val
30841                }),
30842                59u16 => OpSetlinkDoRequest::TsoMaxSize({
30843                    let res = parse_u32(next);
30844                    let Some(val) = res else { break };
30845                    val
30846                }),
30847                60u16 => OpSetlinkDoRequest::TsoMaxSegs({
30848                    let res = parse_u32(next);
30849                    let Some(val) = res else { break };
30850                    val
30851                }),
30852                61u16 => OpSetlinkDoRequest::Allmulti({
30853                    let res = parse_u32(next);
30854                    let Some(val) = res else { break };
30855                    val
30856                }),
30857                62u16 => OpSetlinkDoRequest::DevlinkPort({
30858                    let res = Some(next);
30859                    let Some(val) = res else { break };
30860                    val
30861                }),
30862                63u16 => OpSetlinkDoRequest::GsoIpv4MaxSize({
30863                    let res = parse_u32(next);
30864                    let Some(val) = res else { break };
30865                    val
30866                }),
30867                64u16 => OpSetlinkDoRequest::GroIpv4MaxSize({
30868                    let res = parse_u32(next);
30869                    let Some(val) = res else { break };
30870                    val
30871                }),
30872                65u16 => OpSetlinkDoRequest::DpllPin({
30873                    let res = Some(IterableLinkDpllPinAttrs::with_loc(next, self.orig_loc));
30874                    let Some(val) = res else { break };
30875                    val
30876                }),
30877                66u16 => OpSetlinkDoRequest::MaxPacingOffloadHorizon({
30878                    let res = parse_u32(next);
30879                    let Some(val) = res else { break };
30880                    val
30881                }),
30882                67u16 => OpSetlinkDoRequest::NetnsImmutable({
30883                    let res = parse_u8(next);
30884                    let Some(val) = res else { break };
30885                    val
30886                }),
30887                n => {
30888                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
30889                        break;
30890                    } else {
30891                        continue;
30892                    }
30893                }
30894            };
30895            return Some(Ok(res));
30896        }
30897        Some(Err(ErrorContext::new(
30898            "OpSetlinkDoRequest",
30899            r#type.and_then(|t| OpSetlinkDoRequest::attr_from_type(t)),
30900            self.orig_loc,
30901            self.buf.as_ptr().wrapping_add(pos) as usize,
30902        )))
30903    }
30904}
30905impl<'a> std::fmt::Debug for IterableOpSetlinkDoRequest<'_> {
30906    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30907        let mut fmt = f.debug_struct("OpSetlinkDoRequest");
30908        for attr in self.clone() {
30909            let attr = match attr {
30910                Ok(a) => a,
30911                Err(err) => {
30912                    fmt.finish()?;
30913                    f.write_str("Err(")?;
30914                    err.fmt(f)?;
30915                    return f.write_str(")");
30916                }
30917            };
30918            match attr {
30919                OpSetlinkDoRequest::Address(val) => fmt.field("Address", &val),
30920                OpSetlinkDoRequest::Broadcast(val) => fmt.field("Broadcast", &val),
30921                OpSetlinkDoRequest::Ifname(val) => fmt.field("Ifname", &val),
30922                OpSetlinkDoRequest::Mtu(val) => fmt.field("Mtu", &val),
30923                OpSetlinkDoRequest::Link(val) => fmt.field("Link", &val),
30924                OpSetlinkDoRequest::Qdisc(val) => fmt.field("Qdisc", &val),
30925                OpSetlinkDoRequest::Stats(val) => fmt.field("Stats", &val),
30926                OpSetlinkDoRequest::Cost(val) => fmt.field("Cost", &val),
30927                OpSetlinkDoRequest::Priority(val) => fmt.field("Priority", &val),
30928                OpSetlinkDoRequest::Master(val) => fmt.field("Master", &val),
30929                OpSetlinkDoRequest::Wireless(val) => fmt.field("Wireless", &val),
30930                OpSetlinkDoRequest::Protinfo(val) => fmt.field("Protinfo", &val),
30931                OpSetlinkDoRequest::Txqlen(val) => fmt.field("Txqlen", &val),
30932                OpSetlinkDoRequest::Map(val) => fmt.field("Map", &val),
30933                OpSetlinkDoRequest::Weight(val) => fmt.field("Weight", &val),
30934                OpSetlinkDoRequest::Operstate(val) => fmt.field("Operstate", &val),
30935                OpSetlinkDoRequest::Linkmode(val) => fmt.field("Linkmode", &val),
30936                OpSetlinkDoRequest::Linkinfo(val) => fmt.field("Linkinfo", &val),
30937                OpSetlinkDoRequest::NetNsPid(val) => fmt.field("NetNsPid", &val),
30938                OpSetlinkDoRequest::Ifalias(val) => fmt.field("Ifalias", &val),
30939                OpSetlinkDoRequest::NumVf(val) => fmt.field("NumVf", &val),
30940                OpSetlinkDoRequest::VfinfoList(val) => fmt.field("VfinfoList", &val),
30941                OpSetlinkDoRequest::Stats64(val) => fmt.field("Stats64", &val),
30942                OpSetlinkDoRequest::VfPorts(val) => fmt.field("VfPorts", &val),
30943                OpSetlinkDoRequest::PortSelf(val) => fmt.field("PortSelf", &val),
30944                OpSetlinkDoRequest::AfSpec(val) => fmt.field("AfSpec", &val),
30945                OpSetlinkDoRequest::Group(val) => fmt.field("Group", &val),
30946                OpSetlinkDoRequest::NetNsFd(val) => fmt.field("NetNsFd", &val),
30947                OpSetlinkDoRequest::ExtMask(val) => {
30948                    fmt.field("ExtMask", &FormatFlags(val.into(), RtextFilter::from_value))
30949                }
30950                OpSetlinkDoRequest::Promiscuity(val) => fmt.field("Promiscuity", &val),
30951                OpSetlinkDoRequest::NumTxQueues(val) => fmt.field("NumTxQueues", &val),
30952                OpSetlinkDoRequest::NumRxQueues(val) => fmt.field("NumRxQueues", &val),
30953                OpSetlinkDoRequest::Carrier(val) => fmt.field("Carrier", &val),
30954                OpSetlinkDoRequest::PhysPortId(val) => fmt.field("PhysPortId", &val),
30955                OpSetlinkDoRequest::CarrierChanges(val) => fmt.field("CarrierChanges", &val),
30956                OpSetlinkDoRequest::PhysSwitchId(val) => fmt.field("PhysSwitchId", &val),
30957                OpSetlinkDoRequest::LinkNetnsid(val) => fmt.field("LinkNetnsid", &val),
30958                OpSetlinkDoRequest::PhysPortName(val) => fmt.field("PhysPortName", &val),
30959                OpSetlinkDoRequest::ProtoDown(val) => fmt.field("ProtoDown", &val),
30960                OpSetlinkDoRequest::GsoMaxSegs(val) => fmt.field("GsoMaxSegs", &val),
30961                OpSetlinkDoRequest::GsoMaxSize(val) => fmt.field("GsoMaxSize", &val),
30962                OpSetlinkDoRequest::Pad(val) => fmt.field("Pad", &val),
30963                OpSetlinkDoRequest::Xdp(val) => fmt.field("Xdp", &val),
30964                OpSetlinkDoRequest::Event(val) => fmt.field("Event", &val),
30965                OpSetlinkDoRequest::NewNetnsid(val) => fmt.field("NewNetnsid", &val),
30966                OpSetlinkDoRequest::TargetNetnsid(val) => fmt.field("TargetNetnsid", &val),
30967                OpSetlinkDoRequest::CarrierUpCount(val) => fmt.field("CarrierUpCount", &val),
30968                OpSetlinkDoRequest::CarrierDownCount(val) => fmt.field("CarrierDownCount", &val),
30969                OpSetlinkDoRequest::NewIfindex(val) => fmt.field("NewIfindex", &val),
30970                OpSetlinkDoRequest::MinMtu(val) => fmt.field("MinMtu", &val),
30971                OpSetlinkDoRequest::MaxMtu(val) => fmt.field("MaxMtu", &val),
30972                OpSetlinkDoRequest::PropList(val) => fmt.field("PropList", &val),
30973                OpSetlinkDoRequest::PermAddress(val) => fmt.field("PermAddress", &val),
30974                OpSetlinkDoRequest::ProtoDownReason(val) => fmt.field("ProtoDownReason", &val),
30975                OpSetlinkDoRequest::ParentDevName(val) => fmt.field("ParentDevName", &val),
30976                OpSetlinkDoRequest::ParentDevBusName(val) => fmt.field("ParentDevBusName", &val),
30977                OpSetlinkDoRequest::GroMaxSize(val) => fmt.field("GroMaxSize", &val),
30978                OpSetlinkDoRequest::TsoMaxSize(val) => fmt.field("TsoMaxSize", &val),
30979                OpSetlinkDoRequest::TsoMaxSegs(val) => fmt.field("TsoMaxSegs", &val),
30980                OpSetlinkDoRequest::Allmulti(val) => fmt.field("Allmulti", &val),
30981                OpSetlinkDoRequest::DevlinkPort(val) => fmt.field("DevlinkPort", &val),
30982                OpSetlinkDoRequest::GsoIpv4MaxSize(val) => fmt.field("GsoIpv4MaxSize", &val),
30983                OpSetlinkDoRequest::GroIpv4MaxSize(val) => fmt.field("GroIpv4MaxSize", &val),
30984                OpSetlinkDoRequest::DpllPin(val) => fmt.field("DpllPin", &val),
30985                OpSetlinkDoRequest::MaxPacingOffloadHorizon(val) => {
30986                    fmt.field("MaxPacingOffloadHorizon", &val)
30987                }
30988                OpSetlinkDoRequest::NetnsImmutable(val) => fmt.field("NetnsImmutable", &val),
30989            };
30990        }
30991        fmt.finish()
30992    }
30993}
30994impl IterableOpSetlinkDoRequest<'_> {
30995    pub fn lookup_attr(
30996        &self,
30997        offset: usize,
30998        missing_type: Option<u16>,
30999    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
31000        let mut stack = Vec::new();
31001        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
31002        if cur == offset + PushIfinfomsg::len() {
31003            stack.push(("OpSetlinkDoRequest", offset));
31004            return (
31005                stack,
31006                missing_type.and_then(|t| OpSetlinkDoRequest::attr_from_type(t)),
31007            );
31008        }
31009        if cur > offset || cur + self.buf.len() < offset {
31010            return (stack, None);
31011        }
31012        let mut attrs = self.clone();
31013        let mut last_off = cur + attrs.pos;
31014        let mut missing = None;
31015        while let Some(attr) = attrs.next() {
31016            let Ok(attr) = attr else { break };
31017            match attr {
31018                OpSetlinkDoRequest::Address(val) => {
31019                    if last_off == offset {
31020                        stack.push(("Address", last_off));
31021                        break;
31022                    }
31023                }
31024                OpSetlinkDoRequest::Broadcast(val) => {
31025                    if last_off == offset {
31026                        stack.push(("Broadcast", last_off));
31027                        break;
31028                    }
31029                }
31030                OpSetlinkDoRequest::Ifname(val) => {
31031                    if last_off == offset {
31032                        stack.push(("Ifname", last_off));
31033                        break;
31034                    }
31035                }
31036                OpSetlinkDoRequest::Mtu(val) => {
31037                    if last_off == offset {
31038                        stack.push(("Mtu", last_off));
31039                        break;
31040                    }
31041                }
31042                OpSetlinkDoRequest::Link(val) => {
31043                    if last_off == offset {
31044                        stack.push(("Link", last_off));
31045                        break;
31046                    }
31047                }
31048                OpSetlinkDoRequest::Qdisc(val) => {
31049                    if last_off == offset {
31050                        stack.push(("Qdisc", last_off));
31051                        break;
31052                    }
31053                }
31054                OpSetlinkDoRequest::Stats(val) => {
31055                    if last_off == offset {
31056                        stack.push(("Stats", last_off));
31057                        break;
31058                    }
31059                }
31060                OpSetlinkDoRequest::Cost(val) => {
31061                    if last_off == offset {
31062                        stack.push(("Cost", last_off));
31063                        break;
31064                    }
31065                }
31066                OpSetlinkDoRequest::Priority(val) => {
31067                    if last_off == offset {
31068                        stack.push(("Priority", last_off));
31069                        break;
31070                    }
31071                }
31072                OpSetlinkDoRequest::Master(val) => {
31073                    if last_off == offset {
31074                        stack.push(("Master", last_off));
31075                        break;
31076                    }
31077                }
31078                OpSetlinkDoRequest::Wireless(val) => {
31079                    if last_off == offset {
31080                        stack.push(("Wireless", last_off));
31081                        break;
31082                    }
31083                }
31084                OpSetlinkDoRequest::Protinfo(val) => {
31085                    if last_off == offset {
31086                        stack.push(("Protinfo", last_off));
31087                        break;
31088                    }
31089                }
31090                OpSetlinkDoRequest::Txqlen(val) => {
31091                    if last_off == offset {
31092                        stack.push(("Txqlen", last_off));
31093                        break;
31094                    }
31095                }
31096                OpSetlinkDoRequest::Map(val) => {
31097                    if last_off == offset {
31098                        stack.push(("Map", last_off));
31099                        break;
31100                    }
31101                }
31102                OpSetlinkDoRequest::Weight(val) => {
31103                    if last_off == offset {
31104                        stack.push(("Weight", last_off));
31105                        break;
31106                    }
31107                }
31108                OpSetlinkDoRequest::Operstate(val) => {
31109                    if last_off == offset {
31110                        stack.push(("Operstate", last_off));
31111                        break;
31112                    }
31113                }
31114                OpSetlinkDoRequest::Linkmode(val) => {
31115                    if last_off == offset {
31116                        stack.push(("Linkmode", last_off));
31117                        break;
31118                    }
31119                }
31120                OpSetlinkDoRequest::Linkinfo(val) => {
31121                    (stack, missing) = val.lookup_attr(offset, missing_type);
31122                    if !stack.is_empty() {
31123                        break;
31124                    }
31125                }
31126                OpSetlinkDoRequest::NetNsPid(val) => {
31127                    if last_off == offset {
31128                        stack.push(("NetNsPid", last_off));
31129                        break;
31130                    }
31131                }
31132                OpSetlinkDoRequest::Ifalias(val) => {
31133                    if last_off == offset {
31134                        stack.push(("Ifalias", last_off));
31135                        break;
31136                    }
31137                }
31138                OpSetlinkDoRequest::NumVf(val) => {
31139                    if last_off == offset {
31140                        stack.push(("NumVf", last_off));
31141                        break;
31142                    }
31143                }
31144                OpSetlinkDoRequest::VfinfoList(val) => {
31145                    (stack, missing) = val.lookup_attr(offset, missing_type);
31146                    if !stack.is_empty() {
31147                        break;
31148                    }
31149                }
31150                OpSetlinkDoRequest::Stats64(val) => {
31151                    if last_off == offset {
31152                        stack.push(("Stats64", last_off));
31153                        break;
31154                    }
31155                }
31156                OpSetlinkDoRequest::VfPorts(val) => {
31157                    (stack, missing) = val.lookup_attr(offset, missing_type);
31158                    if !stack.is_empty() {
31159                        break;
31160                    }
31161                }
31162                OpSetlinkDoRequest::PortSelf(val) => {
31163                    (stack, missing) = val.lookup_attr(offset, missing_type);
31164                    if !stack.is_empty() {
31165                        break;
31166                    }
31167                }
31168                OpSetlinkDoRequest::AfSpec(val) => {
31169                    (stack, missing) = val.lookup_attr(offset, missing_type);
31170                    if !stack.is_empty() {
31171                        break;
31172                    }
31173                }
31174                OpSetlinkDoRequest::Group(val) => {
31175                    if last_off == offset {
31176                        stack.push(("Group", last_off));
31177                        break;
31178                    }
31179                }
31180                OpSetlinkDoRequest::NetNsFd(val) => {
31181                    if last_off == offset {
31182                        stack.push(("NetNsFd", last_off));
31183                        break;
31184                    }
31185                }
31186                OpSetlinkDoRequest::ExtMask(val) => {
31187                    if last_off == offset {
31188                        stack.push(("ExtMask", last_off));
31189                        break;
31190                    }
31191                }
31192                OpSetlinkDoRequest::Promiscuity(val) => {
31193                    if last_off == offset {
31194                        stack.push(("Promiscuity", last_off));
31195                        break;
31196                    }
31197                }
31198                OpSetlinkDoRequest::NumTxQueues(val) => {
31199                    if last_off == offset {
31200                        stack.push(("NumTxQueues", last_off));
31201                        break;
31202                    }
31203                }
31204                OpSetlinkDoRequest::NumRxQueues(val) => {
31205                    if last_off == offset {
31206                        stack.push(("NumRxQueues", last_off));
31207                        break;
31208                    }
31209                }
31210                OpSetlinkDoRequest::Carrier(val) => {
31211                    if last_off == offset {
31212                        stack.push(("Carrier", last_off));
31213                        break;
31214                    }
31215                }
31216                OpSetlinkDoRequest::PhysPortId(val) => {
31217                    if last_off == offset {
31218                        stack.push(("PhysPortId", last_off));
31219                        break;
31220                    }
31221                }
31222                OpSetlinkDoRequest::CarrierChanges(val) => {
31223                    if last_off == offset {
31224                        stack.push(("CarrierChanges", last_off));
31225                        break;
31226                    }
31227                }
31228                OpSetlinkDoRequest::PhysSwitchId(val) => {
31229                    if last_off == offset {
31230                        stack.push(("PhysSwitchId", last_off));
31231                        break;
31232                    }
31233                }
31234                OpSetlinkDoRequest::LinkNetnsid(val) => {
31235                    if last_off == offset {
31236                        stack.push(("LinkNetnsid", last_off));
31237                        break;
31238                    }
31239                }
31240                OpSetlinkDoRequest::PhysPortName(val) => {
31241                    if last_off == offset {
31242                        stack.push(("PhysPortName", last_off));
31243                        break;
31244                    }
31245                }
31246                OpSetlinkDoRequest::ProtoDown(val) => {
31247                    if last_off == offset {
31248                        stack.push(("ProtoDown", last_off));
31249                        break;
31250                    }
31251                }
31252                OpSetlinkDoRequest::GsoMaxSegs(val) => {
31253                    if last_off == offset {
31254                        stack.push(("GsoMaxSegs", last_off));
31255                        break;
31256                    }
31257                }
31258                OpSetlinkDoRequest::GsoMaxSize(val) => {
31259                    if last_off == offset {
31260                        stack.push(("GsoMaxSize", last_off));
31261                        break;
31262                    }
31263                }
31264                OpSetlinkDoRequest::Pad(val) => {
31265                    if last_off == offset {
31266                        stack.push(("Pad", last_off));
31267                        break;
31268                    }
31269                }
31270                OpSetlinkDoRequest::Xdp(val) => {
31271                    (stack, missing) = val.lookup_attr(offset, missing_type);
31272                    if !stack.is_empty() {
31273                        break;
31274                    }
31275                }
31276                OpSetlinkDoRequest::Event(val) => {
31277                    if last_off == offset {
31278                        stack.push(("Event", last_off));
31279                        break;
31280                    }
31281                }
31282                OpSetlinkDoRequest::NewNetnsid(val) => {
31283                    if last_off == offset {
31284                        stack.push(("NewNetnsid", last_off));
31285                        break;
31286                    }
31287                }
31288                OpSetlinkDoRequest::TargetNetnsid(val) => {
31289                    if last_off == offset {
31290                        stack.push(("TargetNetnsid", last_off));
31291                        break;
31292                    }
31293                }
31294                OpSetlinkDoRequest::CarrierUpCount(val) => {
31295                    if last_off == offset {
31296                        stack.push(("CarrierUpCount", last_off));
31297                        break;
31298                    }
31299                }
31300                OpSetlinkDoRequest::CarrierDownCount(val) => {
31301                    if last_off == offset {
31302                        stack.push(("CarrierDownCount", last_off));
31303                        break;
31304                    }
31305                }
31306                OpSetlinkDoRequest::NewIfindex(val) => {
31307                    if last_off == offset {
31308                        stack.push(("NewIfindex", last_off));
31309                        break;
31310                    }
31311                }
31312                OpSetlinkDoRequest::MinMtu(val) => {
31313                    if last_off == offset {
31314                        stack.push(("MinMtu", last_off));
31315                        break;
31316                    }
31317                }
31318                OpSetlinkDoRequest::MaxMtu(val) => {
31319                    if last_off == offset {
31320                        stack.push(("MaxMtu", last_off));
31321                        break;
31322                    }
31323                }
31324                OpSetlinkDoRequest::PropList(val) => {
31325                    (stack, missing) = val.lookup_attr(offset, missing_type);
31326                    if !stack.is_empty() {
31327                        break;
31328                    }
31329                }
31330                OpSetlinkDoRequest::PermAddress(val) => {
31331                    if last_off == offset {
31332                        stack.push(("PermAddress", last_off));
31333                        break;
31334                    }
31335                }
31336                OpSetlinkDoRequest::ProtoDownReason(val) => {
31337                    if last_off == offset {
31338                        stack.push(("ProtoDownReason", last_off));
31339                        break;
31340                    }
31341                }
31342                OpSetlinkDoRequest::ParentDevName(val) => {
31343                    if last_off == offset {
31344                        stack.push(("ParentDevName", last_off));
31345                        break;
31346                    }
31347                }
31348                OpSetlinkDoRequest::ParentDevBusName(val) => {
31349                    if last_off == offset {
31350                        stack.push(("ParentDevBusName", last_off));
31351                        break;
31352                    }
31353                }
31354                OpSetlinkDoRequest::GroMaxSize(val) => {
31355                    if last_off == offset {
31356                        stack.push(("GroMaxSize", last_off));
31357                        break;
31358                    }
31359                }
31360                OpSetlinkDoRequest::TsoMaxSize(val) => {
31361                    if last_off == offset {
31362                        stack.push(("TsoMaxSize", last_off));
31363                        break;
31364                    }
31365                }
31366                OpSetlinkDoRequest::TsoMaxSegs(val) => {
31367                    if last_off == offset {
31368                        stack.push(("TsoMaxSegs", last_off));
31369                        break;
31370                    }
31371                }
31372                OpSetlinkDoRequest::Allmulti(val) => {
31373                    if last_off == offset {
31374                        stack.push(("Allmulti", last_off));
31375                        break;
31376                    }
31377                }
31378                OpSetlinkDoRequest::DevlinkPort(val) => {
31379                    if last_off == offset {
31380                        stack.push(("DevlinkPort", last_off));
31381                        break;
31382                    }
31383                }
31384                OpSetlinkDoRequest::GsoIpv4MaxSize(val) => {
31385                    if last_off == offset {
31386                        stack.push(("GsoIpv4MaxSize", last_off));
31387                        break;
31388                    }
31389                }
31390                OpSetlinkDoRequest::GroIpv4MaxSize(val) => {
31391                    if last_off == offset {
31392                        stack.push(("GroIpv4MaxSize", last_off));
31393                        break;
31394                    }
31395                }
31396                OpSetlinkDoRequest::DpllPin(val) => {
31397                    (stack, missing) = val.lookup_attr(offset, missing_type);
31398                    if !stack.is_empty() {
31399                        break;
31400                    }
31401                }
31402                OpSetlinkDoRequest::MaxPacingOffloadHorizon(val) => {
31403                    if last_off == offset {
31404                        stack.push(("MaxPacingOffloadHorizon", last_off));
31405                        break;
31406                    }
31407                }
31408                OpSetlinkDoRequest::NetnsImmutable(val) => {
31409                    if last_off == offset {
31410                        stack.push(("NetnsImmutable", last_off));
31411                        break;
31412                    }
31413                }
31414                _ => {}
31415            };
31416            last_off = cur + attrs.pos;
31417        }
31418        if !stack.is_empty() {
31419            stack.push(("OpSetlinkDoRequest", cur));
31420        }
31421        (stack, missing)
31422    }
31423}
31424#[doc = "Set information about a link."]
31425pub struct PushOpSetlinkDoReply<Prev: Rec> {
31426    pub(crate) prev: Option<Prev>,
31427    pub(crate) header_offset: Option<usize>,
31428}
31429impl<Prev: Rec> Rec for PushOpSetlinkDoReply<Prev> {
31430    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31431        self.prev.as_mut().unwrap().as_rec_mut()
31432    }
31433}
31434impl<Prev: Rec> PushOpSetlinkDoReply<Prev> {
31435    pub fn new(mut prev: Prev, header: &PushIfinfomsg) -> Self {
31436        Self::write_header(&mut prev, header);
31437        Self::new_without_header(prev)
31438    }
31439    fn new_without_header(prev: Prev) -> Self {
31440        Self {
31441            prev: Some(prev),
31442            header_offset: None,
31443        }
31444    }
31445    fn write_header(prev: &mut Prev, header: &PushIfinfomsg) {
31446        prev.as_rec_mut().extend(header.as_slice());
31447    }
31448    pub fn end_nested(mut self) -> Prev {
31449        let mut prev = self.prev.take().unwrap();
31450        if let Some(header_offset) = &self.header_offset {
31451            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31452        }
31453        prev
31454    }
31455}
31456impl<Prev: Rec> Drop for PushOpSetlinkDoReply<Prev> {
31457    fn drop(&mut self) {
31458        if let Some(prev) = &mut self.prev {
31459            if let Some(header_offset) = &self.header_offset {
31460                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31461            }
31462        }
31463    }
31464}
31465#[doc = "Set information about a link."]
31466#[derive(Clone)]
31467pub enum OpSetlinkDoReply {}
31468impl<'a> IterableOpSetlinkDoReply<'a> {}
31469impl OpSetlinkDoReply {
31470    pub fn new(buf: &'_ [u8]) -> (PushIfinfomsg, IterableOpSetlinkDoReply<'_>) {
31471        let (header, attrs) = buf.split_at(buf.len().min(PushIfinfomsg::len()));
31472        (
31473            PushIfinfomsg::new_from_slice(header).unwrap_or_default(),
31474            IterableOpSetlinkDoReply::with_loc(attrs, buf.as_ptr() as usize),
31475        )
31476    }
31477    fn attr_from_type(r#type: u16) -> Option<&'static str> {
31478        LinkAttrs::attr_from_type(r#type)
31479    }
31480}
31481#[derive(Clone, Copy, Default)]
31482pub struct IterableOpSetlinkDoReply<'a> {
31483    buf: &'a [u8],
31484    pos: usize,
31485    orig_loc: usize,
31486}
31487impl<'a> IterableOpSetlinkDoReply<'a> {
31488    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
31489        Self {
31490            buf,
31491            pos: 0,
31492            orig_loc,
31493        }
31494    }
31495    pub fn get_buf(&self) -> &'a [u8] {
31496        self.buf
31497    }
31498}
31499impl<'a> Iterator for IterableOpSetlinkDoReply<'a> {
31500    type Item = Result<OpSetlinkDoReply, ErrorContext>;
31501    fn next(&mut self) -> Option<Self::Item> {
31502        if self.buf.len() == self.pos {
31503            return None;
31504        }
31505        let pos = self.pos;
31506        let mut r#type = None;
31507        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
31508            r#type = Some(header.r#type);
31509            let res = match header.r#type {
31510                n => {
31511                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
31512                        break;
31513                    } else {
31514                        continue;
31515                    }
31516                }
31517            };
31518            return Some(Ok(res));
31519        }
31520        Some(Err(ErrorContext::new(
31521            "OpSetlinkDoReply",
31522            r#type.and_then(|t| OpSetlinkDoReply::attr_from_type(t)),
31523            self.orig_loc,
31524            self.buf.as_ptr().wrapping_add(pos) as usize,
31525        )))
31526    }
31527}
31528impl std::fmt::Debug for IterableOpSetlinkDoReply<'_> {
31529    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31530        let mut fmt = f.debug_struct("OpSetlinkDoReply");
31531        for attr in self.clone() {
31532            let attr = match attr {
31533                Ok(a) => a,
31534                Err(err) => {
31535                    fmt.finish()?;
31536                    f.write_str("Err(")?;
31537                    err.fmt(f)?;
31538                    return f.write_str(")");
31539                }
31540            };
31541            match attr {};
31542        }
31543        fmt.finish()
31544    }
31545}
31546impl IterableOpSetlinkDoReply<'_> {
31547    pub fn lookup_attr(
31548        &self,
31549        offset: usize,
31550        missing_type: Option<u16>,
31551    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
31552        let mut stack = Vec::new();
31553        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
31554        if cur == offset + PushIfinfomsg::len() {
31555            stack.push(("OpSetlinkDoReply", offset));
31556            return (
31557                stack,
31558                missing_type.and_then(|t| OpSetlinkDoReply::attr_from_type(t)),
31559            );
31560        }
31561        (stack, None)
31562    }
31563}
31564#[derive(Debug)]
31565pub struct RequestOpSetlinkDoRequest<'r> {
31566    request: Request<'r>,
31567}
31568impl<'r> RequestOpSetlinkDoRequest<'r> {
31569    pub fn new(mut request: Request<'r>, header: &PushIfinfomsg) -> Self {
31570        PushOpSetlinkDoRequest::write_header(&mut request.buf_mut(), header);
31571        Self { request: request }
31572    }
31573    pub fn encode(&mut self) -> PushOpSetlinkDoRequest<&mut Vec<u8>> {
31574        PushOpSetlinkDoRequest::new_without_header(self.request.buf_mut())
31575    }
31576    pub fn into_encoder(self) -> PushOpSetlinkDoRequest<RequestBuf<'r>> {
31577        PushOpSetlinkDoRequest::new_without_header(self.request.buf)
31578    }
31579}
31580impl NetlinkRequest for RequestOpSetlinkDoRequest<'_> {
31581    type ReplyType<'buf> = (PushIfinfomsg, IterableOpSetlinkDoReply<'buf>);
31582    fn protocol(&self) -> Protocol {
31583        Protocol::Raw {
31584            protonum: 0u16,
31585            request_type: 19u16,
31586        }
31587    }
31588    fn flags(&self) -> u16 {
31589        self.request.flags
31590    }
31591    fn payload(&self) -> &[u8] {
31592        self.request.buf()
31593    }
31594    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
31595        OpSetlinkDoReply::new(buf)
31596    }
31597    fn lookup(
31598        buf: &[u8],
31599        offset: usize,
31600        missing_type: Option<u16>,
31601    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
31602        OpSetlinkDoRequest::new(buf)
31603            .1
31604            .lookup_attr(offset, missing_type)
31605    }
31606}
31607#[doc = "Get / dump link stats."]
31608pub struct PushOpGetstatsDumpRequest<Prev: Rec> {
31609    pub(crate) prev: Option<Prev>,
31610    pub(crate) header_offset: Option<usize>,
31611}
31612impl<Prev: Rec> Rec for PushOpGetstatsDumpRequest<Prev> {
31613    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31614        self.prev.as_mut().unwrap().as_rec_mut()
31615    }
31616}
31617impl<Prev: Rec> PushOpGetstatsDumpRequest<Prev> {
31618    pub fn new(mut prev: Prev, header: &PushIfStatsMsg) -> Self {
31619        Self::write_header(&mut prev, header);
31620        Self::new_without_header(prev)
31621    }
31622    fn new_without_header(prev: Prev) -> Self {
31623        Self {
31624            prev: Some(prev),
31625            header_offset: None,
31626        }
31627    }
31628    fn write_header(prev: &mut Prev, header: &PushIfStatsMsg) {
31629        prev.as_rec_mut().extend(header.as_slice());
31630    }
31631    pub fn end_nested(mut self) -> Prev {
31632        let mut prev = self.prev.take().unwrap();
31633        if let Some(header_offset) = &self.header_offset {
31634            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31635        }
31636        prev
31637    }
31638}
31639impl<Prev: Rec> Drop for PushOpGetstatsDumpRequest<Prev> {
31640    fn drop(&mut self) {
31641        if let Some(prev) = &mut self.prev {
31642            if let Some(header_offset) = &self.header_offset {
31643                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31644            }
31645        }
31646    }
31647}
31648#[doc = "Get / dump link stats."]
31649#[derive(Clone)]
31650pub enum OpGetstatsDumpRequest {}
31651impl<'a> IterableOpGetstatsDumpRequest<'a> {}
31652impl OpGetstatsDumpRequest {
31653    pub fn new(buf: &'_ [u8]) -> (PushIfStatsMsg, IterableOpGetstatsDumpRequest<'_>) {
31654        let (header, attrs) = buf.split_at(buf.len().min(PushIfStatsMsg::len()));
31655        (
31656            PushIfStatsMsg::new_from_slice(header).unwrap_or_default(),
31657            IterableOpGetstatsDumpRequest::with_loc(attrs, buf.as_ptr() as usize),
31658        )
31659    }
31660    fn attr_from_type(r#type: u16) -> Option<&'static str> {
31661        StatsAttrs::attr_from_type(r#type)
31662    }
31663}
31664#[derive(Clone, Copy, Default)]
31665pub struct IterableOpGetstatsDumpRequest<'a> {
31666    buf: &'a [u8],
31667    pos: usize,
31668    orig_loc: usize,
31669}
31670impl<'a> IterableOpGetstatsDumpRequest<'a> {
31671    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
31672        Self {
31673            buf,
31674            pos: 0,
31675            orig_loc,
31676        }
31677    }
31678    pub fn get_buf(&self) -> &'a [u8] {
31679        self.buf
31680    }
31681}
31682impl<'a> Iterator for IterableOpGetstatsDumpRequest<'a> {
31683    type Item = Result<OpGetstatsDumpRequest, ErrorContext>;
31684    fn next(&mut self) -> Option<Self::Item> {
31685        if self.buf.len() == self.pos {
31686            return None;
31687        }
31688        let pos = self.pos;
31689        let mut r#type = None;
31690        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
31691            r#type = Some(header.r#type);
31692            let res = match header.r#type {
31693                n => {
31694                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
31695                        break;
31696                    } else {
31697                        continue;
31698                    }
31699                }
31700            };
31701            return Some(Ok(res));
31702        }
31703        Some(Err(ErrorContext::new(
31704            "OpGetstatsDumpRequest",
31705            r#type.and_then(|t| OpGetstatsDumpRequest::attr_from_type(t)),
31706            self.orig_loc,
31707            self.buf.as_ptr().wrapping_add(pos) as usize,
31708        )))
31709    }
31710}
31711impl std::fmt::Debug for IterableOpGetstatsDumpRequest<'_> {
31712    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31713        let mut fmt = f.debug_struct("OpGetstatsDumpRequest");
31714        for attr in self.clone() {
31715            let attr = match attr {
31716                Ok(a) => a,
31717                Err(err) => {
31718                    fmt.finish()?;
31719                    f.write_str("Err(")?;
31720                    err.fmt(f)?;
31721                    return f.write_str(")");
31722                }
31723            };
31724            match attr {};
31725        }
31726        fmt.finish()
31727    }
31728}
31729impl IterableOpGetstatsDumpRequest<'_> {
31730    pub fn lookup_attr(
31731        &self,
31732        offset: usize,
31733        missing_type: Option<u16>,
31734    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
31735        let mut stack = Vec::new();
31736        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
31737        if cur == offset + PushIfStatsMsg::len() {
31738            stack.push(("OpGetstatsDumpRequest", offset));
31739            return (
31740                stack,
31741                missing_type.and_then(|t| OpGetstatsDumpRequest::attr_from_type(t)),
31742            );
31743        }
31744        (stack, None)
31745    }
31746}
31747#[doc = "Get / dump link stats."]
31748pub struct PushOpGetstatsDumpReply<Prev: Rec> {
31749    pub(crate) prev: Option<Prev>,
31750    pub(crate) header_offset: Option<usize>,
31751}
31752impl<Prev: Rec> Rec for PushOpGetstatsDumpReply<Prev> {
31753    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
31754        self.prev.as_mut().unwrap().as_rec_mut()
31755    }
31756}
31757impl<Prev: Rec> PushOpGetstatsDumpReply<Prev> {
31758    pub fn new(mut prev: Prev, header: &PushIfStatsMsg) -> Self {
31759        Self::write_header(&mut prev, header);
31760        Self::new_without_header(prev)
31761    }
31762    fn new_without_header(prev: Prev) -> Self {
31763        Self {
31764            prev: Some(prev),
31765            header_offset: None,
31766        }
31767    }
31768    fn write_header(prev: &mut Prev, header: &PushIfStatsMsg) {
31769        prev.as_rec_mut().extend(header.as_slice());
31770    }
31771    pub fn end_nested(mut self) -> Prev {
31772        let mut prev = self.prev.take().unwrap();
31773        if let Some(header_offset) = &self.header_offset {
31774            finalize_nested_header(prev.as_rec_mut(), *header_offset);
31775        }
31776        prev
31777    }
31778    pub fn push_link_64(mut self, value: PushRtnlLinkStats64) -> Self {
31779        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
31780        self.as_rec_mut().extend(value.as_slice());
31781        self
31782    }
31783    pub fn push_link_xstats(mut self, value: &[u8]) -> Self {
31784        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
31785        self.as_rec_mut().extend(value);
31786        self
31787    }
31788    pub fn push_link_xstats_slave(mut self, value: &[u8]) -> Self {
31789        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
31790        self.as_rec_mut().extend(value);
31791        self
31792    }
31793    pub fn nested_link_offload_xstats(mut self) -> PushLinkOffloadXstats<Self> {
31794        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
31795        PushLinkOffloadXstats {
31796            prev: Some(self),
31797            header_offset: Some(header_offset),
31798        }
31799    }
31800    pub fn push_af_spec(mut self, value: &[u8]) -> Self {
31801        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
31802        self.as_rec_mut().extend(value);
31803        self
31804    }
31805}
31806impl<Prev: Rec> Drop for PushOpGetstatsDumpReply<Prev> {
31807    fn drop(&mut self) {
31808        if let Some(prev) = &mut self.prev {
31809            if let Some(header_offset) = &self.header_offset {
31810                finalize_nested_header(prev.as_rec_mut(), *header_offset);
31811            }
31812        }
31813    }
31814}
31815#[doc = "Get / dump link stats."]
31816#[derive(Clone)]
31817pub enum OpGetstatsDumpReply<'a> {
31818    Link64(PushRtnlLinkStats64),
31819    LinkXstats(&'a [u8]),
31820    LinkXstatsSlave(&'a [u8]),
31821    LinkOffloadXstats(IterableLinkOffloadXstats<'a>),
31822    AfSpec(&'a [u8]),
31823}
31824impl<'a> IterableOpGetstatsDumpReply<'a> {
31825    pub fn get_link_64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
31826        let mut iter = self.clone();
31827        iter.pos = 0;
31828        for attr in iter {
31829            if let OpGetstatsDumpReply::Link64(val) = attr? {
31830                return Ok(val);
31831            }
31832        }
31833        Err(ErrorContext::new_missing(
31834            "OpGetstatsDumpReply",
31835            "Link64",
31836            self.orig_loc,
31837            self.buf.as_ptr() as usize,
31838        ))
31839    }
31840    pub fn get_link_xstats(&self) -> Result<&'a [u8], ErrorContext> {
31841        let mut iter = self.clone();
31842        iter.pos = 0;
31843        for attr in iter {
31844            if let OpGetstatsDumpReply::LinkXstats(val) = attr? {
31845                return Ok(val);
31846            }
31847        }
31848        Err(ErrorContext::new_missing(
31849            "OpGetstatsDumpReply",
31850            "LinkXstats",
31851            self.orig_loc,
31852            self.buf.as_ptr() as usize,
31853        ))
31854    }
31855    pub fn get_link_xstats_slave(&self) -> Result<&'a [u8], ErrorContext> {
31856        let mut iter = self.clone();
31857        iter.pos = 0;
31858        for attr in iter {
31859            if let OpGetstatsDumpReply::LinkXstatsSlave(val) = attr? {
31860                return Ok(val);
31861            }
31862        }
31863        Err(ErrorContext::new_missing(
31864            "OpGetstatsDumpReply",
31865            "LinkXstatsSlave",
31866            self.orig_loc,
31867            self.buf.as_ptr() as usize,
31868        ))
31869    }
31870    pub fn get_link_offload_xstats(&self) -> Result<IterableLinkOffloadXstats<'a>, ErrorContext> {
31871        let mut iter = self.clone();
31872        iter.pos = 0;
31873        for attr in iter {
31874            if let OpGetstatsDumpReply::LinkOffloadXstats(val) = attr? {
31875                return Ok(val);
31876            }
31877        }
31878        Err(ErrorContext::new_missing(
31879            "OpGetstatsDumpReply",
31880            "LinkOffloadXstats",
31881            self.orig_loc,
31882            self.buf.as_ptr() as usize,
31883        ))
31884    }
31885    pub fn get_af_spec(&self) -> Result<&'a [u8], ErrorContext> {
31886        let mut iter = self.clone();
31887        iter.pos = 0;
31888        for attr in iter {
31889            if let OpGetstatsDumpReply::AfSpec(val) = attr? {
31890                return Ok(val);
31891            }
31892        }
31893        Err(ErrorContext::new_missing(
31894            "OpGetstatsDumpReply",
31895            "AfSpec",
31896            self.orig_loc,
31897            self.buf.as_ptr() as usize,
31898        ))
31899    }
31900}
31901impl<'a> OpGetstatsDumpReply<'a> {
31902    pub fn new(buf: &'a [u8]) -> (PushIfStatsMsg, IterableOpGetstatsDumpReply<'a>) {
31903        let (header, attrs) = buf.split_at(buf.len().min(PushIfStatsMsg::len()));
31904        (
31905            PushIfStatsMsg::new_from_slice(header).unwrap_or_default(),
31906            IterableOpGetstatsDumpReply::with_loc(attrs, buf.as_ptr() as usize),
31907        )
31908    }
31909    fn attr_from_type(r#type: u16) -> Option<&'static str> {
31910        StatsAttrs::attr_from_type(r#type)
31911    }
31912}
31913#[derive(Clone, Copy, Default)]
31914pub struct IterableOpGetstatsDumpReply<'a> {
31915    buf: &'a [u8],
31916    pos: usize,
31917    orig_loc: usize,
31918}
31919impl<'a> IterableOpGetstatsDumpReply<'a> {
31920    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
31921        Self {
31922            buf,
31923            pos: 0,
31924            orig_loc,
31925        }
31926    }
31927    pub fn get_buf(&self) -> &'a [u8] {
31928        self.buf
31929    }
31930}
31931impl<'a> Iterator for IterableOpGetstatsDumpReply<'a> {
31932    type Item = Result<OpGetstatsDumpReply<'a>, ErrorContext>;
31933    fn next(&mut self) -> Option<Self::Item> {
31934        if self.buf.len() == self.pos {
31935            return None;
31936        }
31937        let pos = self.pos;
31938        let mut r#type = None;
31939        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
31940            r#type = Some(header.r#type);
31941            let res = match header.r#type {
31942                1u16 => OpGetstatsDumpReply::Link64({
31943                    let res = PushRtnlLinkStats64::new_from_slice(next);
31944                    let Some(val) = res else { break };
31945                    val
31946                }),
31947                2u16 => OpGetstatsDumpReply::LinkXstats({
31948                    let res = Some(next);
31949                    let Some(val) = res else { break };
31950                    val
31951                }),
31952                3u16 => OpGetstatsDumpReply::LinkXstatsSlave({
31953                    let res = Some(next);
31954                    let Some(val) = res else { break };
31955                    val
31956                }),
31957                4u16 => OpGetstatsDumpReply::LinkOffloadXstats({
31958                    let res = Some(IterableLinkOffloadXstats::with_loc(next, self.orig_loc));
31959                    let Some(val) = res else { break };
31960                    val
31961                }),
31962                5u16 => OpGetstatsDumpReply::AfSpec({
31963                    let res = Some(next);
31964                    let Some(val) = res else { break };
31965                    val
31966                }),
31967                n => {
31968                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
31969                        break;
31970                    } else {
31971                        continue;
31972                    }
31973                }
31974            };
31975            return Some(Ok(res));
31976        }
31977        Some(Err(ErrorContext::new(
31978            "OpGetstatsDumpReply",
31979            r#type.and_then(|t| OpGetstatsDumpReply::attr_from_type(t)),
31980            self.orig_loc,
31981            self.buf.as_ptr().wrapping_add(pos) as usize,
31982        )))
31983    }
31984}
31985impl<'a> std::fmt::Debug for IterableOpGetstatsDumpReply<'_> {
31986    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31987        let mut fmt = f.debug_struct("OpGetstatsDumpReply");
31988        for attr in self.clone() {
31989            let attr = match attr {
31990                Ok(a) => a,
31991                Err(err) => {
31992                    fmt.finish()?;
31993                    f.write_str("Err(")?;
31994                    err.fmt(f)?;
31995                    return f.write_str(")");
31996                }
31997            };
31998            match attr {
31999                OpGetstatsDumpReply::Link64(val) => fmt.field("Link64", &val),
32000                OpGetstatsDumpReply::LinkXstats(val) => fmt.field("LinkXstats", &val),
32001                OpGetstatsDumpReply::LinkXstatsSlave(val) => fmt.field("LinkXstatsSlave", &val),
32002                OpGetstatsDumpReply::LinkOffloadXstats(val) => fmt.field("LinkOffloadXstats", &val),
32003                OpGetstatsDumpReply::AfSpec(val) => fmt.field("AfSpec", &val),
32004            };
32005        }
32006        fmt.finish()
32007    }
32008}
32009impl IterableOpGetstatsDumpReply<'_> {
32010    pub fn lookup_attr(
32011        &self,
32012        offset: usize,
32013        missing_type: Option<u16>,
32014    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32015        let mut stack = Vec::new();
32016        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
32017        if cur == offset + PushIfStatsMsg::len() {
32018            stack.push(("OpGetstatsDumpReply", offset));
32019            return (
32020                stack,
32021                missing_type.and_then(|t| OpGetstatsDumpReply::attr_from_type(t)),
32022            );
32023        }
32024        if cur > offset || cur + self.buf.len() < offset {
32025            return (stack, None);
32026        }
32027        let mut attrs = self.clone();
32028        let mut last_off = cur + attrs.pos;
32029        let mut missing = None;
32030        while let Some(attr) = attrs.next() {
32031            let Ok(attr) = attr else { break };
32032            match attr {
32033                OpGetstatsDumpReply::Link64(val) => {
32034                    if last_off == offset {
32035                        stack.push(("Link64", last_off));
32036                        break;
32037                    }
32038                }
32039                OpGetstatsDumpReply::LinkXstats(val) => {
32040                    if last_off == offset {
32041                        stack.push(("LinkXstats", last_off));
32042                        break;
32043                    }
32044                }
32045                OpGetstatsDumpReply::LinkXstatsSlave(val) => {
32046                    if last_off == offset {
32047                        stack.push(("LinkXstatsSlave", last_off));
32048                        break;
32049                    }
32050                }
32051                OpGetstatsDumpReply::LinkOffloadXstats(val) => {
32052                    (stack, missing) = val.lookup_attr(offset, missing_type);
32053                    if !stack.is_empty() {
32054                        break;
32055                    }
32056                }
32057                OpGetstatsDumpReply::AfSpec(val) => {
32058                    if last_off == offset {
32059                        stack.push(("AfSpec", last_off));
32060                        break;
32061                    }
32062                }
32063                _ => {}
32064            };
32065            last_off = cur + attrs.pos;
32066        }
32067        if !stack.is_empty() {
32068            stack.push(("OpGetstatsDumpReply", cur));
32069        }
32070        (stack, missing)
32071    }
32072}
32073#[derive(Debug)]
32074pub struct RequestOpGetstatsDumpRequest<'r> {
32075    request: Request<'r>,
32076}
32077impl<'r> RequestOpGetstatsDumpRequest<'r> {
32078    pub fn new(mut request: Request<'r>, header: &PushIfStatsMsg) -> Self {
32079        PushOpGetstatsDumpRequest::write_header(&mut request.buf_mut(), header);
32080        Self {
32081            request: request.set_dump(),
32082        }
32083    }
32084    pub fn encode(&mut self) -> PushOpGetstatsDumpRequest<&mut Vec<u8>> {
32085        PushOpGetstatsDumpRequest::new_without_header(self.request.buf_mut())
32086    }
32087    pub fn into_encoder(self) -> PushOpGetstatsDumpRequest<RequestBuf<'r>> {
32088        PushOpGetstatsDumpRequest::new_without_header(self.request.buf)
32089    }
32090}
32091impl NetlinkRequest for RequestOpGetstatsDumpRequest<'_> {
32092    type ReplyType<'buf> = (PushIfStatsMsg, IterableOpGetstatsDumpReply<'buf>);
32093    fn protocol(&self) -> Protocol {
32094        Protocol::Raw {
32095            protonum: 0u16,
32096            request_type: 94u16,
32097        }
32098    }
32099    fn flags(&self) -> u16 {
32100        self.request.flags
32101    }
32102    fn payload(&self) -> &[u8] {
32103        self.request.buf()
32104    }
32105    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
32106        OpGetstatsDumpReply::new(buf)
32107    }
32108    fn lookup(
32109        buf: &[u8],
32110        offset: usize,
32111        missing_type: Option<u16>,
32112    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32113        OpGetstatsDumpRequest::new(buf)
32114            .1
32115            .lookup_attr(offset, missing_type)
32116    }
32117}
32118#[doc = "Get / dump link stats."]
32119pub struct PushOpGetstatsDoRequest<Prev: Rec> {
32120    pub(crate) prev: Option<Prev>,
32121    pub(crate) header_offset: Option<usize>,
32122}
32123impl<Prev: Rec> Rec for PushOpGetstatsDoRequest<Prev> {
32124    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32125        self.prev.as_mut().unwrap().as_rec_mut()
32126    }
32127}
32128impl<Prev: Rec> PushOpGetstatsDoRequest<Prev> {
32129    pub fn new(mut prev: Prev, header: &PushIfStatsMsg) -> Self {
32130        Self::write_header(&mut prev, header);
32131        Self::new_without_header(prev)
32132    }
32133    fn new_without_header(prev: Prev) -> Self {
32134        Self {
32135            prev: Some(prev),
32136            header_offset: None,
32137        }
32138    }
32139    fn write_header(prev: &mut Prev, header: &PushIfStatsMsg) {
32140        prev.as_rec_mut().extend(header.as_slice());
32141    }
32142    pub fn end_nested(mut self) -> Prev {
32143        let mut prev = self.prev.take().unwrap();
32144        if let Some(header_offset) = &self.header_offset {
32145            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32146        }
32147        prev
32148    }
32149}
32150impl<Prev: Rec> Drop for PushOpGetstatsDoRequest<Prev> {
32151    fn drop(&mut self) {
32152        if let Some(prev) = &mut self.prev {
32153            if let Some(header_offset) = &self.header_offset {
32154                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32155            }
32156        }
32157    }
32158}
32159#[doc = "Get / dump link stats."]
32160#[derive(Clone)]
32161pub enum OpGetstatsDoRequest {}
32162impl<'a> IterableOpGetstatsDoRequest<'a> {}
32163impl OpGetstatsDoRequest {
32164    pub fn new(buf: &'_ [u8]) -> (PushIfStatsMsg, IterableOpGetstatsDoRequest<'_>) {
32165        let (header, attrs) = buf.split_at(buf.len().min(PushIfStatsMsg::len()));
32166        (
32167            PushIfStatsMsg::new_from_slice(header).unwrap_or_default(),
32168            IterableOpGetstatsDoRequest::with_loc(attrs, buf.as_ptr() as usize),
32169        )
32170    }
32171    fn attr_from_type(r#type: u16) -> Option<&'static str> {
32172        StatsAttrs::attr_from_type(r#type)
32173    }
32174}
32175#[derive(Clone, Copy, Default)]
32176pub struct IterableOpGetstatsDoRequest<'a> {
32177    buf: &'a [u8],
32178    pos: usize,
32179    orig_loc: usize,
32180}
32181impl<'a> IterableOpGetstatsDoRequest<'a> {
32182    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
32183        Self {
32184            buf,
32185            pos: 0,
32186            orig_loc,
32187        }
32188    }
32189    pub fn get_buf(&self) -> &'a [u8] {
32190        self.buf
32191    }
32192}
32193impl<'a> Iterator for IterableOpGetstatsDoRequest<'a> {
32194    type Item = Result<OpGetstatsDoRequest, ErrorContext>;
32195    fn next(&mut self) -> Option<Self::Item> {
32196        if self.buf.len() == self.pos {
32197            return None;
32198        }
32199        let pos = self.pos;
32200        let mut r#type = None;
32201        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
32202            r#type = Some(header.r#type);
32203            let res = match header.r#type {
32204                n => {
32205                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
32206                        break;
32207                    } else {
32208                        continue;
32209                    }
32210                }
32211            };
32212            return Some(Ok(res));
32213        }
32214        Some(Err(ErrorContext::new(
32215            "OpGetstatsDoRequest",
32216            r#type.and_then(|t| OpGetstatsDoRequest::attr_from_type(t)),
32217            self.orig_loc,
32218            self.buf.as_ptr().wrapping_add(pos) as usize,
32219        )))
32220    }
32221}
32222impl std::fmt::Debug for IterableOpGetstatsDoRequest<'_> {
32223    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32224        let mut fmt = f.debug_struct("OpGetstatsDoRequest");
32225        for attr in self.clone() {
32226            let attr = match attr {
32227                Ok(a) => a,
32228                Err(err) => {
32229                    fmt.finish()?;
32230                    f.write_str("Err(")?;
32231                    err.fmt(f)?;
32232                    return f.write_str(")");
32233                }
32234            };
32235            match attr {};
32236        }
32237        fmt.finish()
32238    }
32239}
32240impl IterableOpGetstatsDoRequest<'_> {
32241    pub fn lookup_attr(
32242        &self,
32243        offset: usize,
32244        missing_type: Option<u16>,
32245    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32246        let mut stack = Vec::new();
32247        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
32248        if cur == offset + PushIfStatsMsg::len() {
32249            stack.push(("OpGetstatsDoRequest", offset));
32250            return (
32251                stack,
32252                missing_type.and_then(|t| OpGetstatsDoRequest::attr_from_type(t)),
32253            );
32254        }
32255        (stack, None)
32256    }
32257}
32258#[doc = "Get / dump link stats."]
32259pub struct PushOpGetstatsDoReply<Prev: Rec> {
32260    pub(crate) prev: Option<Prev>,
32261    pub(crate) header_offset: Option<usize>,
32262}
32263impl<Prev: Rec> Rec for PushOpGetstatsDoReply<Prev> {
32264    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
32265        self.prev.as_mut().unwrap().as_rec_mut()
32266    }
32267}
32268impl<Prev: Rec> PushOpGetstatsDoReply<Prev> {
32269    pub fn new(mut prev: Prev, header: &PushIfStatsMsg) -> Self {
32270        Self::write_header(&mut prev, header);
32271        Self::new_without_header(prev)
32272    }
32273    fn new_without_header(prev: Prev) -> Self {
32274        Self {
32275            prev: Some(prev),
32276            header_offset: None,
32277        }
32278    }
32279    fn write_header(prev: &mut Prev, header: &PushIfStatsMsg) {
32280        prev.as_rec_mut().extend(header.as_slice());
32281    }
32282    pub fn end_nested(mut self) -> Prev {
32283        let mut prev = self.prev.take().unwrap();
32284        if let Some(header_offset) = &self.header_offset {
32285            finalize_nested_header(prev.as_rec_mut(), *header_offset);
32286        }
32287        prev
32288    }
32289    pub fn push_link_64(mut self, value: PushRtnlLinkStats64) -> Self {
32290        push_header(self.as_rec_mut(), 1u16, value.as_slice().len() as u16);
32291        self.as_rec_mut().extend(value.as_slice());
32292        self
32293    }
32294    pub fn push_link_xstats(mut self, value: &[u8]) -> Self {
32295        push_header(self.as_rec_mut(), 2u16, value.len() as u16);
32296        self.as_rec_mut().extend(value);
32297        self
32298    }
32299    pub fn push_link_xstats_slave(mut self, value: &[u8]) -> Self {
32300        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
32301        self.as_rec_mut().extend(value);
32302        self
32303    }
32304    pub fn nested_link_offload_xstats(mut self) -> PushLinkOffloadXstats<Self> {
32305        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
32306        PushLinkOffloadXstats {
32307            prev: Some(self),
32308            header_offset: Some(header_offset),
32309        }
32310    }
32311    pub fn push_af_spec(mut self, value: &[u8]) -> Self {
32312        push_header(self.as_rec_mut(), 5u16, value.len() as u16);
32313        self.as_rec_mut().extend(value);
32314        self
32315    }
32316}
32317impl<Prev: Rec> Drop for PushOpGetstatsDoReply<Prev> {
32318    fn drop(&mut self) {
32319        if let Some(prev) = &mut self.prev {
32320            if let Some(header_offset) = &self.header_offset {
32321                finalize_nested_header(prev.as_rec_mut(), *header_offset);
32322            }
32323        }
32324    }
32325}
32326#[doc = "Get / dump link stats."]
32327#[derive(Clone)]
32328pub enum OpGetstatsDoReply<'a> {
32329    Link64(PushRtnlLinkStats64),
32330    LinkXstats(&'a [u8]),
32331    LinkXstatsSlave(&'a [u8]),
32332    LinkOffloadXstats(IterableLinkOffloadXstats<'a>),
32333    AfSpec(&'a [u8]),
32334}
32335impl<'a> IterableOpGetstatsDoReply<'a> {
32336    pub fn get_link_64(&self) -> Result<PushRtnlLinkStats64, ErrorContext> {
32337        let mut iter = self.clone();
32338        iter.pos = 0;
32339        for attr in iter {
32340            if let OpGetstatsDoReply::Link64(val) = attr? {
32341                return Ok(val);
32342            }
32343        }
32344        Err(ErrorContext::new_missing(
32345            "OpGetstatsDoReply",
32346            "Link64",
32347            self.orig_loc,
32348            self.buf.as_ptr() as usize,
32349        ))
32350    }
32351    pub fn get_link_xstats(&self) -> Result<&'a [u8], ErrorContext> {
32352        let mut iter = self.clone();
32353        iter.pos = 0;
32354        for attr in iter {
32355            if let OpGetstatsDoReply::LinkXstats(val) = attr? {
32356                return Ok(val);
32357            }
32358        }
32359        Err(ErrorContext::new_missing(
32360            "OpGetstatsDoReply",
32361            "LinkXstats",
32362            self.orig_loc,
32363            self.buf.as_ptr() as usize,
32364        ))
32365    }
32366    pub fn get_link_xstats_slave(&self) -> Result<&'a [u8], ErrorContext> {
32367        let mut iter = self.clone();
32368        iter.pos = 0;
32369        for attr in iter {
32370            if let OpGetstatsDoReply::LinkXstatsSlave(val) = attr? {
32371                return Ok(val);
32372            }
32373        }
32374        Err(ErrorContext::new_missing(
32375            "OpGetstatsDoReply",
32376            "LinkXstatsSlave",
32377            self.orig_loc,
32378            self.buf.as_ptr() as usize,
32379        ))
32380    }
32381    pub fn get_link_offload_xstats(&self) -> Result<IterableLinkOffloadXstats<'a>, ErrorContext> {
32382        let mut iter = self.clone();
32383        iter.pos = 0;
32384        for attr in iter {
32385            if let OpGetstatsDoReply::LinkOffloadXstats(val) = attr? {
32386                return Ok(val);
32387            }
32388        }
32389        Err(ErrorContext::new_missing(
32390            "OpGetstatsDoReply",
32391            "LinkOffloadXstats",
32392            self.orig_loc,
32393            self.buf.as_ptr() as usize,
32394        ))
32395    }
32396    pub fn get_af_spec(&self) -> Result<&'a [u8], ErrorContext> {
32397        let mut iter = self.clone();
32398        iter.pos = 0;
32399        for attr in iter {
32400            if let OpGetstatsDoReply::AfSpec(val) = attr? {
32401                return Ok(val);
32402            }
32403        }
32404        Err(ErrorContext::new_missing(
32405            "OpGetstatsDoReply",
32406            "AfSpec",
32407            self.orig_loc,
32408            self.buf.as_ptr() as usize,
32409        ))
32410    }
32411}
32412impl<'a> OpGetstatsDoReply<'a> {
32413    pub fn new(buf: &'a [u8]) -> (PushIfStatsMsg, IterableOpGetstatsDoReply<'a>) {
32414        let (header, attrs) = buf.split_at(buf.len().min(PushIfStatsMsg::len()));
32415        (
32416            PushIfStatsMsg::new_from_slice(header).unwrap_or_default(),
32417            IterableOpGetstatsDoReply::with_loc(attrs, buf.as_ptr() as usize),
32418        )
32419    }
32420    fn attr_from_type(r#type: u16) -> Option<&'static str> {
32421        StatsAttrs::attr_from_type(r#type)
32422    }
32423}
32424#[derive(Clone, Copy, Default)]
32425pub struct IterableOpGetstatsDoReply<'a> {
32426    buf: &'a [u8],
32427    pos: usize,
32428    orig_loc: usize,
32429}
32430impl<'a> IterableOpGetstatsDoReply<'a> {
32431    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
32432        Self {
32433            buf,
32434            pos: 0,
32435            orig_loc,
32436        }
32437    }
32438    pub fn get_buf(&self) -> &'a [u8] {
32439        self.buf
32440    }
32441}
32442impl<'a> Iterator for IterableOpGetstatsDoReply<'a> {
32443    type Item = Result<OpGetstatsDoReply<'a>, ErrorContext>;
32444    fn next(&mut self) -> Option<Self::Item> {
32445        if self.buf.len() == self.pos {
32446            return None;
32447        }
32448        let pos = self.pos;
32449        let mut r#type = None;
32450        while let Some((header, next)) = chop_header(self.buf, &mut self.pos) {
32451            r#type = Some(header.r#type);
32452            let res = match header.r#type {
32453                1u16 => OpGetstatsDoReply::Link64({
32454                    let res = PushRtnlLinkStats64::new_from_slice(next);
32455                    let Some(val) = res else { break };
32456                    val
32457                }),
32458                2u16 => OpGetstatsDoReply::LinkXstats({
32459                    let res = Some(next);
32460                    let Some(val) = res else { break };
32461                    val
32462                }),
32463                3u16 => OpGetstatsDoReply::LinkXstatsSlave({
32464                    let res = Some(next);
32465                    let Some(val) = res else { break };
32466                    val
32467                }),
32468                4u16 => OpGetstatsDoReply::LinkOffloadXstats({
32469                    let res = Some(IterableLinkOffloadXstats::with_loc(next, self.orig_loc));
32470                    let Some(val) = res else { break };
32471                    val
32472                }),
32473                5u16 => OpGetstatsDoReply::AfSpec({
32474                    let res = Some(next);
32475                    let Some(val) = res else { break };
32476                    val
32477                }),
32478                n => {
32479                    if cfg!(any(test, feature = "deny-unknown-attrs")) {
32480                        break;
32481                    } else {
32482                        continue;
32483                    }
32484                }
32485            };
32486            return Some(Ok(res));
32487        }
32488        Some(Err(ErrorContext::new(
32489            "OpGetstatsDoReply",
32490            r#type.and_then(|t| OpGetstatsDoReply::attr_from_type(t)),
32491            self.orig_loc,
32492            self.buf.as_ptr().wrapping_add(pos) as usize,
32493        )))
32494    }
32495}
32496impl<'a> std::fmt::Debug for IterableOpGetstatsDoReply<'_> {
32497    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32498        let mut fmt = f.debug_struct("OpGetstatsDoReply");
32499        for attr in self.clone() {
32500            let attr = match attr {
32501                Ok(a) => a,
32502                Err(err) => {
32503                    fmt.finish()?;
32504                    f.write_str("Err(")?;
32505                    err.fmt(f)?;
32506                    return f.write_str(")");
32507                }
32508            };
32509            match attr {
32510                OpGetstatsDoReply::Link64(val) => fmt.field("Link64", &val),
32511                OpGetstatsDoReply::LinkXstats(val) => fmt.field("LinkXstats", &val),
32512                OpGetstatsDoReply::LinkXstatsSlave(val) => fmt.field("LinkXstatsSlave", &val),
32513                OpGetstatsDoReply::LinkOffloadXstats(val) => fmt.field("LinkOffloadXstats", &val),
32514                OpGetstatsDoReply::AfSpec(val) => fmt.field("AfSpec", &val),
32515            };
32516        }
32517        fmt.finish()
32518    }
32519}
32520impl IterableOpGetstatsDoReply<'_> {
32521    pub fn lookup_attr(
32522        &self,
32523        offset: usize,
32524        missing_type: Option<u16>,
32525    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32526        let mut stack = Vec::new();
32527        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
32528        if cur == offset + PushIfStatsMsg::len() {
32529            stack.push(("OpGetstatsDoReply", offset));
32530            return (
32531                stack,
32532                missing_type.and_then(|t| OpGetstatsDoReply::attr_from_type(t)),
32533            );
32534        }
32535        if cur > offset || cur + self.buf.len() < offset {
32536            return (stack, None);
32537        }
32538        let mut attrs = self.clone();
32539        let mut last_off = cur + attrs.pos;
32540        let mut missing = None;
32541        while let Some(attr) = attrs.next() {
32542            let Ok(attr) = attr else { break };
32543            match attr {
32544                OpGetstatsDoReply::Link64(val) => {
32545                    if last_off == offset {
32546                        stack.push(("Link64", last_off));
32547                        break;
32548                    }
32549                }
32550                OpGetstatsDoReply::LinkXstats(val) => {
32551                    if last_off == offset {
32552                        stack.push(("LinkXstats", last_off));
32553                        break;
32554                    }
32555                }
32556                OpGetstatsDoReply::LinkXstatsSlave(val) => {
32557                    if last_off == offset {
32558                        stack.push(("LinkXstatsSlave", last_off));
32559                        break;
32560                    }
32561                }
32562                OpGetstatsDoReply::LinkOffloadXstats(val) => {
32563                    (stack, missing) = val.lookup_attr(offset, missing_type);
32564                    if !stack.is_empty() {
32565                        break;
32566                    }
32567                }
32568                OpGetstatsDoReply::AfSpec(val) => {
32569                    if last_off == offset {
32570                        stack.push(("AfSpec", last_off));
32571                        break;
32572                    }
32573                }
32574                _ => {}
32575            };
32576            last_off = cur + attrs.pos;
32577        }
32578        if !stack.is_empty() {
32579            stack.push(("OpGetstatsDoReply", cur));
32580        }
32581        (stack, missing)
32582    }
32583}
32584#[derive(Debug)]
32585pub struct RequestOpGetstatsDoRequest<'r> {
32586    request: Request<'r>,
32587}
32588impl<'r> RequestOpGetstatsDoRequest<'r> {
32589    pub fn new(mut request: Request<'r>, header: &PushIfStatsMsg) -> Self {
32590        PushOpGetstatsDoRequest::write_header(&mut request.buf_mut(), header);
32591        Self { request: request }
32592    }
32593    pub fn encode(&mut self) -> PushOpGetstatsDoRequest<&mut Vec<u8>> {
32594        PushOpGetstatsDoRequest::new_without_header(self.request.buf_mut())
32595    }
32596    pub fn into_encoder(self) -> PushOpGetstatsDoRequest<RequestBuf<'r>> {
32597        PushOpGetstatsDoRequest::new_without_header(self.request.buf)
32598    }
32599}
32600impl NetlinkRequest for RequestOpGetstatsDoRequest<'_> {
32601    type ReplyType<'buf> = (PushIfStatsMsg, IterableOpGetstatsDoReply<'buf>);
32602    fn protocol(&self) -> Protocol {
32603        Protocol::Raw {
32604            protonum: 0u16,
32605            request_type: 94u16,
32606        }
32607    }
32608    fn flags(&self) -> u16 {
32609        self.request.flags
32610    }
32611    fn payload(&self) -> &[u8] {
32612        self.request.buf()
32613    }
32614    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
32615        OpGetstatsDoReply::new(buf)
32616    }
32617    fn lookup(
32618        buf: &[u8],
32619        offset: usize,
32620        missing_type: Option<u16>,
32621    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
32622        OpGetstatsDoRequest::new(buf)
32623            .1
32624            .lookup_attr(offset, missing_type)
32625    }
32626}
32627#[derive(Debug)]
32628pub struct ChainedFinal<'a> {
32629    inner: Chained<'a>,
32630}
32631#[derive(Debug)]
32632pub struct Chained<'a> {
32633    buf: RequestBuf<'a>,
32634    first_seq: u32,
32635    lookups: Vec<(&'static str, LookupFn)>,
32636    last_header_offset: usize,
32637    last_kind: Option<RequestInfo>,
32638}
32639impl<'a> ChainedFinal<'a> {
32640    pub fn into_chained(self) -> Chained<'a> {
32641        self.inner
32642    }
32643    pub fn buf(&self) -> &Vec<u8> {
32644        self.inner.buf()
32645    }
32646    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
32647        self.inner.buf_mut()
32648    }
32649    fn get_index(&self, seq: u32) -> Option<u32> {
32650        let min = self.inner.first_seq;
32651        let max = min.wrapping_add(self.inner.lookups.len() as u32);
32652        return if min <= max {
32653            (min..max).contains(&seq).then(|| seq - min)
32654        } else if min <= seq {
32655            Some(seq - min)
32656        } else if seq < max {
32657            Some(u32::MAX - min + seq)
32658        } else {
32659            None
32660        };
32661    }
32662}
32663impl crate::traits::NetlinkChained for ChainedFinal<'_> {
32664    fn protonum(&self) -> u16 {
32665        PROTONUM
32666    }
32667    fn payload(&self) -> &[u8] {
32668        self.buf()
32669    }
32670    fn chain_len(&self) -> usize {
32671        self.inner.lookups.len()
32672    }
32673    fn get_index(&self, seq: u32) -> Option<usize> {
32674        self.get_index(seq).map(|n| n as usize)
32675    }
32676    fn name(&self, index: usize) -> &'static str {
32677        self.inner.lookups[index].0
32678    }
32679    fn lookup(&self, index: usize) -> LookupFn {
32680        self.inner.lookups[index].1
32681    }
32682}
32683impl Chained<'static> {
32684    pub fn new(first_seq: u32) -> Self {
32685        Self::new_from_buf(Vec::new(), first_seq)
32686    }
32687    pub fn new_from_buf(buf: Vec<u8>, first_seq: u32) -> Self {
32688        Self {
32689            buf: RequestBuf::Own(buf),
32690            first_seq,
32691            lookups: Vec::new(),
32692            last_header_offset: 0,
32693            last_kind: None,
32694        }
32695    }
32696    pub fn into_buf(self) -> Vec<u8> {
32697        match self.buf {
32698            RequestBuf::Own(buf) => buf,
32699            _ => unreachable!(),
32700        }
32701    }
32702}
32703impl<'a> Chained<'a> {
32704    pub fn new_with_buf(buf: &'a mut Vec<u8>, first_seq: u32) -> Self {
32705        Self {
32706            buf: RequestBuf::Ref(buf),
32707            first_seq,
32708            lookups: Vec::new(),
32709            last_header_offset: 0,
32710            last_kind: None,
32711        }
32712    }
32713    pub fn finalize(mut self) -> ChainedFinal<'a> {
32714        self.update_header();
32715        ChainedFinal { inner: self }
32716    }
32717    pub fn request(&mut self) -> Request<'_> {
32718        self.update_header();
32719        self.last_header_offset = self.buf().len();
32720        self.buf_mut()
32721            .extend_from_slice(PushNlmsghdr::new().as_slice());
32722        let mut request = Request::new_extend(self.buf.buf_mut());
32723        self.last_kind = None;
32724        request.writeback = Some(&mut self.last_kind);
32725        request
32726    }
32727    pub fn buf(&self) -> &Vec<u8> {
32728        self.buf.buf()
32729    }
32730    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
32731        self.buf.buf_mut()
32732    }
32733    fn update_header(&mut self) {
32734        let Some(RequestInfo {
32735            protocol,
32736            flags,
32737            name,
32738            lookup,
32739        }) = self.last_kind
32740        else {
32741            if !self.buf().is_empty() {
32742                assert_eq!(
32743                    self.last_header_offset + PushNlmsghdr::len(),
32744                    self.buf().len()
32745                );
32746                self.buf.buf_mut().truncate(self.last_header_offset);
32747            }
32748            return;
32749        };
32750        let header_offset = self.last_header_offset;
32751        let request_type = match protocol {
32752            Protocol::Raw { request_type, .. } => request_type,
32753            Protocol::Generic(_) => unreachable!(),
32754        };
32755        let index = self.lookups.len();
32756        let seq = self.first_seq.wrapping_add(index as u32);
32757        self.lookups.push((name, lookup));
32758        let buf = self.buf_mut();
32759        align(buf);
32760        let mut header = PushNlmsghdr::new();
32761        header.set_len((buf.len() - header_offset) as u32);
32762        header.set_type(request_type);
32763        header.set_flags(flags | consts::NLM_F_REQUEST as u16 | consts::NLM_F_ACK as u16);
32764        header.set_seq(seq);
32765        buf[header_offset..(header_offset + 16)].clone_from_slice(header.as_slice());
32766    }
32767}
32768use crate::traits::LookupFn;
32769use crate::utils::RequestBuf;
32770#[derive(Debug)]
32771pub struct Request<'buf> {
32772    buf: RequestBuf<'buf>,
32773    flags: u16,
32774    writeback: Option<&'buf mut Option<RequestInfo>>,
32775}
32776#[allow(unused)]
32777#[derive(Debug, Clone)]
32778pub struct RequestInfo {
32779    protocol: Protocol,
32780    flags: u16,
32781    name: &'static str,
32782    lookup: LookupFn,
32783}
32784impl Request<'static> {
32785    pub fn new() -> Self {
32786        Self::new_from_buf(Vec::new())
32787    }
32788    pub fn new_from_buf(buf: Vec<u8>) -> Self {
32789        Self {
32790            flags: 0,
32791            buf: RequestBuf::Own(buf),
32792            writeback: None,
32793        }
32794    }
32795    pub fn into_buf(self) -> Vec<u8> {
32796        match self.buf {
32797            RequestBuf::Own(buf) => buf,
32798            _ => unreachable!(),
32799        }
32800    }
32801}
32802impl<'buf> Request<'buf> {
32803    pub fn new_with_buf(buf: &'buf mut Vec<u8>) -> Self {
32804        buf.clear();
32805        Self::new_extend(buf)
32806    }
32807    pub fn new_extend(buf: &'buf mut Vec<u8>) -> Self {
32808        Self {
32809            flags: 0,
32810            buf: RequestBuf::Ref(buf),
32811            writeback: None,
32812        }
32813    }
32814    fn do_writeback(&mut self, protocol: Protocol, name: &'static str, lookup: LookupFn) {
32815        let Some(writeback) = &mut self.writeback else {
32816            return;
32817        };
32818        **writeback = Some(RequestInfo {
32819            protocol,
32820            flags: self.flags,
32821            name,
32822            lookup,
32823        })
32824    }
32825    pub fn buf(&self) -> &Vec<u8> {
32826        self.buf.buf()
32827    }
32828    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
32829        self.buf.buf_mut()
32830    }
32831    #[doc = "Set `NLM_F_CREATE` flag"]
32832    pub fn set_create(mut self) -> Self {
32833        self.flags |= consts::NLM_F_CREATE as u16;
32834        self
32835    }
32836    #[doc = "Set `NLM_F_EXCL` flag"]
32837    pub fn set_excl(mut self) -> Self {
32838        self.flags |= consts::NLM_F_EXCL as u16;
32839        self
32840    }
32841    #[doc = "Set `NLM_F_REPLACE` flag"]
32842    pub fn set_replace(mut self) -> Self {
32843        self.flags |= consts::NLM_F_REPLACE as u16;
32844        self
32845    }
32846    #[doc = "Set `NLM_F_CREATE` and `NLM_F_REPLACE` flag"]
32847    pub fn set_change(self) -> Self {
32848        self.set_create().set_replace()
32849    }
32850    #[doc = "Set `NLM_F_APPEND` flag"]
32851    pub fn set_append(mut self) -> Self {
32852        self.flags |= consts::NLM_F_APPEND as u16;
32853        self
32854    }
32855    #[doc = "Set `NLM_F_DUMP` flag"]
32856    fn set_dump(mut self) -> Self {
32857        self.flags |= consts::NLM_F_DUMP as u16;
32858        self
32859    }
32860    pub fn op_newlink_do_request(self, header: &PushIfinfomsg) -> RequestOpNewlinkDoRequest<'buf> {
32861        let mut res = RequestOpNewlinkDoRequest::new(self, header);
32862        res.request.do_writeback(
32863            res.protocol(),
32864            "op-newlink-do-request",
32865            RequestOpNewlinkDoRequest::lookup,
32866        );
32867        res
32868    }
32869    pub fn op_dellink_do_request(self, header: &PushIfinfomsg) -> RequestOpDellinkDoRequest<'buf> {
32870        let mut res = RequestOpDellinkDoRequest::new(self, header);
32871        res.request.do_writeback(
32872            res.protocol(),
32873            "op-dellink-do-request",
32874            RequestOpDellinkDoRequest::lookup,
32875        );
32876        res
32877    }
32878    pub fn op_getlink_dump_request(
32879        self,
32880        header: &PushIfinfomsg,
32881    ) -> RequestOpGetlinkDumpRequest<'buf> {
32882        let mut res = RequestOpGetlinkDumpRequest::new(self, header);
32883        res.request.do_writeback(
32884            res.protocol(),
32885            "op-getlink-dump-request",
32886            RequestOpGetlinkDumpRequest::lookup,
32887        );
32888        res
32889    }
32890    pub fn op_getlink_do_request(self, header: &PushIfinfomsg) -> RequestOpGetlinkDoRequest<'buf> {
32891        let mut res = RequestOpGetlinkDoRequest::new(self, header);
32892        res.request.do_writeback(
32893            res.protocol(),
32894            "op-getlink-do-request",
32895            RequestOpGetlinkDoRequest::lookup,
32896        );
32897        res
32898    }
32899    pub fn op_setlink_do_request(self, header: &PushIfinfomsg) -> RequestOpSetlinkDoRequest<'buf> {
32900        let mut res = RequestOpSetlinkDoRequest::new(self, header);
32901        res.request.do_writeback(
32902            res.protocol(),
32903            "op-setlink-do-request",
32904            RequestOpSetlinkDoRequest::lookup,
32905        );
32906        res
32907    }
32908    pub fn op_getstats_dump_request(
32909        self,
32910        header: &PushIfStatsMsg,
32911    ) -> RequestOpGetstatsDumpRequest<'buf> {
32912        let mut res = RequestOpGetstatsDumpRequest::new(self, header);
32913        res.request.do_writeback(
32914            res.protocol(),
32915            "op-getstats-dump-request",
32916            RequestOpGetstatsDumpRequest::lookup,
32917        );
32918        res
32919    }
32920    pub fn op_getstats_do_request(
32921        self,
32922        header: &PushIfStatsMsg,
32923    ) -> RequestOpGetstatsDoRequest<'buf> {
32924        let mut res = RequestOpGetstatsDoRequest::new(self, header);
32925        res.request.do_writeback(
32926            res.protocol(),
32927            "op-getstats-do-request",
32928            RequestOpGetstatsDoRequest::lookup,
32929        );
32930        res
32931    }
32932}