Skip to main content

netlink_bindings/builtin/
mod.rs

1#![doc = "Auxilary types not porovided by any particular family\n"]
2#![allow(clippy::all)]
3#![allow(unused_imports)]
4#![allow(unused_assignments)]
5#![allow(non_snake_case)]
6#![allow(unused_variables)]
7#![allow(irrefutable_let_patterns)]
8#![allow(unreachable_code)]
9#![allow(unreachable_patterns)]
10#[cfg(test)]
11mod tests;
12use crate::{
13    consts,
14    traits::{NetlinkRequest, Protocol},
15    utils::*,
16};
17pub const PROTONAME: &CStr = c"builtin";
18#[doc = "Generic family header"]
19#[doc = "Wrapper for bitfield32 type"]
20#[doc = "Header of a Netlink message"]
21#[derive(Clone)]
22pub enum Dummy {}
23impl<'a> IterableDummy<'a> {}
24impl Dummy {
25    pub fn new<'a>(buf: &'a [u8]) -> IterableDummy<'a> {
26        IterableDummy::with_loc(buf, buf.as_ptr() as usize)
27    }
28    fn attr_from_type(r#type: u16) -> Option<&'static str> {
29        None
30    }
31}
32#[derive(Clone, Copy, Default)]
33pub struct IterableDummy<'a> {
34    buf: &'a [u8],
35    pos: usize,
36    orig_loc: usize,
37}
38impl<'a> IterableDummy<'a> {
39    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
40        Self {
41            buf,
42            pos: 0,
43            orig_loc,
44        }
45    }
46    pub fn get_buf(&self) -> &'a [u8] {
47        self.buf
48    }
49}
50impl<'a> Iterator for IterableDummy<'a> {
51    type Item = Result<Dummy, ErrorContext>;
52    fn next(&mut self) -> Option<Self::Item> {
53        let pos = self.pos;
54        let mut r#type;
55        loop {
56            r#type = None;
57            if self.buf.len() == self.pos {
58                return None;
59            }
60            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
61                break;
62            };
63            r#type = Some(header.r#type);
64            let res = match header.r#type {
65                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
66                n => continue,
67            };
68            return Some(Ok(res));
69        }
70        Some(Err(ErrorContext::new(
71            "Dummy",
72            r#type.and_then(|t| Dummy::attr_from_type(t)),
73            self.orig_loc,
74            self.buf.as_ptr().wrapping_add(pos) as usize,
75        )))
76    }
77}
78impl std::fmt::Debug for IterableDummy<'_> {
79    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
80        let mut fmt = f.debug_struct("Dummy");
81        for attr in self.clone() {
82            let attr = match attr {
83                Ok(a) => a,
84                Err(err) => {
85                    fmt.finish()?;
86                    f.write_str("Err(")?;
87                    err.fmt(f)?;
88                    return f.write_str(")");
89                }
90            };
91            match attr {};
92        }
93        fmt.finish()
94    }
95}
96impl IterableDummy<'_> {
97    pub fn lookup_attr(
98        &self,
99        offset: usize,
100        missing_type: Option<u16>,
101    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
102        let mut stack = Vec::new();
103        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
104        if cur == offset {
105            stack.push(("Dummy", offset));
106            return (stack, missing_type.and_then(|t| Dummy::attr_from_type(t)));
107        }
108        (stack, None)
109    }
110}
111#[derive(Clone)]
112pub enum NlmsgerrAttrs<'a> {
113    #[doc = "error message string (string)"]
114    Msg(&'a CStr),
115    #[doc = "offset of the invalid attribute in the original message, counting from the beginning of the header (u32)"]
116    Offset(u32),
117    #[doc = "arbitrary subsystem specific cookie to be used - in the success case - to identify a created object or operation or similar (binary)"]
118    Cookie(&'a [u8]),
119    #[doc = "policy for a rejected attribute"]
120    Policy(IterablePolicyTypeAttrs<'a>),
121    #[doc = "type of a missing required attribute, NLMSGERR_ATTR_MISS_NEST will not be present if the attribute was missing at the message level"]
122    MissingType(u16),
123    #[doc = "offset of the nest where attribute was missing"]
124    MissingNest(u32),
125}
126impl<'a> IterableNlmsgerrAttrs<'a> {
127    #[doc = "error message string (string)"]
128    pub fn get_msg(&self) -> Result<&'a CStr, ErrorContext> {
129        let mut iter = self.clone();
130        iter.pos = 0;
131        for attr in iter {
132            if let NlmsgerrAttrs::Msg(val) = attr? {
133                return Ok(val);
134            }
135        }
136        Err(ErrorContext::new_missing(
137            "NlmsgerrAttrs",
138            "Msg",
139            self.orig_loc,
140            self.buf.as_ptr() as usize,
141        ))
142    }
143    #[doc = "offset of the invalid attribute in the original message, counting from the beginning of the header (u32)"]
144    pub fn get_offset(&self) -> Result<u32, ErrorContext> {
145        let mut iter = self.clone();
146        iter.pos = 0;
147        for attr in iter {
148            if let NlmsgerrAttrs::Offset(val) = attr? {
149                return Ok(val);
150            }
151        }
152        Err(ErrorContext::new_missing(
153            "NlmsgerrAttrs",
154            "Offset",
155            self.orig_loc,
156            self.buf.as_ptr() as usize,
157        ))
158    }
159    #[doc = "arbitrary subsystem specific cookie to be used - in the success case - to identify a created object or operation or similar (binary)"]
160    pub fn get_cookie(&self) -> Result<&'a [u8], ErrorContext> {
161        let mut iter = self.clone();
162        iter.pos = 0;
163        for attr in iter {
164            if let NlmsgerrAttrs::Cookie(val) = attr? {
165                return Ok(val);
166            }
167        }
168        Err(ErrorContext::new_missing(
169            "NlmsgerrAttrs",
170            "Cookie",
171            self.orig_loc,
172            self.buf.as_ptr() as usize,
173        ))
174    }
175    #[doc = "policy for a rejected attribute"]
176    pub fn get_policy(&self) -> Result<IterablePolicyTypeAttrs<'a>, ErrorContext> {
177        let mut iter = self.clone();
178        iter.pos = 0;
179        for attr in iter {
180            if let NlmsgerrAttrs::Policy(val) = attr? {
181                return Ok(val);
182            }
183        }
184        Err(ErrorContext::new_missing(
185            "NlmsgerrAttrs",
186            "Policy",
187            self.orig_loc,
188            self.buf.as_ptr() as usize,
189        ))
190    }
191    #[doc = "type of a missing required attribute, NLMSGERR_ATTR_MISS_NEST will not be present if the attribute was missing at the message level"]
192    pub fn get_missing_type(&self) -> Result<u16, ErrorContext> {
193        let mut iter = self.clone();
194        iter.pos = 0;
195        for attr in iter {
196            if let NlmsgerrAttrs::MissingType(val) = attr? {
197                return Ok(val);
198            }
199        }
200        Err(ErrorContext::new_missing(
201            "NlmsgerrAttrs",
202            "MissingType",
203            self.orig_loc,
204            self.buf.as_ptr() as usize,
205        ))
206    }
207    #[doc = "offset of the nest where attribute was missing"]
208    pub fn get_missing_nest(&self) -> Result<u32, ErrorContext> {
209        let mut iter = self.clone();
210        iter.pos = 0;
211        for attr in iter {
212            if let NlmsgerrAttrs::MissingNest(val) = attr? {
213                return Ok(val);
214            }
215        }
216        Err(ErrorContext::new_missing(
217            "NlmsgerrAttrs",
218            "MissingNest",
219            self.orig_loc,
220            self.buf.as_ptr() as usize,
221        ))
222    }
223}
224impl NlmsgerrAttrs<'_> {
225    pub fn new<'a>(buf: &'a [u8]) -> IterableNlmsgerrAttrs<'a> {
226        IterableNlmsgerrAttrs::with_loc(buf, buf.as_ptr() as usize)
227    }
228    fn attr_from_type(r#type: u16) -> Option<&'static str> {
229        let res = match r#type {
230            0u16 => "Unused",
231            1u16 => "Msg",
232            2u16 => "Offset",
233            3u16 => "Cookie",
234            4u16 => "Policy",
235            5u16 => "MissingType",
236            6u16 => "MissingNest",
237            _ => return None,
238        };
239        Some(res)
240    }
241}
242#[derive(Clone, Copy, Default)]
243pub struct IterableNlmsgerrAttrs<'a> {
244    buf: &'a [u8],
245    pos: usize,
246    orig_loc: usize,
247}
248impl<'a> IterableNlmsgerrAttrs<'a> {
249    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
250        Self {
251            buf,
252            pos: 0,
253            orig_loc,
254        }
255    }
256    pub fn get_buf(&self) -> &'a [u8] {
257        self.buf
258    }
259}
260impl<'a> Iterator for IterableNlmsgerrAttrs<'a> {
261    type Item = Result<NlmsgerrAttrs<'a>, ErrorContext>;
262    fn next(&mut self) -> Option<Self::Item> {
263        let pos = self.pos;
264        let mut r#type;
265        loop {
266            r#type = None;
267            if self.buf.len() == self.pos {
268                return None;
269            }
270            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
271                break;
272            };
273            r#type = Some(header.r#type);
274            let res = match header.r#type {
275                1u16 => NlmsgerrAttrs::Msg({
276                    let res = CStr::from_bytes_with_nul(next).ok();
277                    let Some(val) = res else { break };
278                    val
279                }),
280                2u16 => NlmsgerrAttrs::Offset({
281                    let res = parse_u32(next);
282                    let Some(val) = res else { break };
283                    val
284                }),
285                3u16 => NlmsgerrAttrs::Cookie({
286                    let res = Some(next);
287                    let Some(val) = res else { break };
288                    val
289                }),
290                4u16 => NlmsgerrAttrs::Policy({
291                    let res = Some(IterablePolicyTypeAttrs::with_loc(next, self.orig_loc));
292                    let Some(val) = res else { break };
293                    val
294                }),
295                5u16 => NlmsgerrAttrs::MissingType({
296                    let res = parse_u16(next);
297                    let Some(val) = res else { break };
298                    val
299                }),
300                6u16 => NlmsgerrAttrs::MissingNest({
301                    let res = parse_u32(next);
302                    let Some(val) = res else { break };
303                    val
304                }),
305                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
306                n => continue,
307            };
308            return Some(Ok(res));
309        }
310        Some(Err(ErrorContext::new(
311            "NlmsgerrAttrs",
312            r#type.and_then(|t| NlmsgerrAttrs::attr_from_type(t)),
313            self.orig_loc,
314            self.buf.as_ptr().wrapping_add(pos) as usize,
315        )))
316    }
317}
318impl<'a> std::fmt::Debug for IterableNlmsgerrAttrs<'_> {
319    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
320        let mut fmt = f.debug_struct("NlmsgerrAttrs");
321        for attr in self.clone() {
322            let attr = match attr {
323                Ok(a) => a,
324                Err(err) => {
325                    fmt.finish()?;
326                    f.write_str("Err(")?;
327                    err.fmt(f)?;
328                    return f.write_str(")");
329                }
330            };
331            match attr {
332                NlmsgerrAttrs::Msg(val) => fmt.field("Msg", &val),
333                NlmsgerrAttrs::Offset(val) => fmt.field("Offset", &val),
334                NlmsgerrAttrs::Cookie(val) => fmt.field("Cookie", &val),
335                NlmsgerrAttrs::Policy(val) => fmt.field("Policy", &val),
336                NlmsgerrAttrs::MissingType(val) => fmt.field("MissingType", &val),
337                NlmsgerrAttrs::MissingNest(val) => fmt.field("MissingNest", &val),
338            };
339        }
340        fmt.finish()
341    }
342}
343impl IterableNlmsgerrAttrs<'_> {
344    pub fn lookup_attr(
345        &self,
346        offset: usize,
347        missing_type: Option<u16>,
348    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
349        let mut stack = Vec::new();
350        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
351        if cur == offset {
352            stack.push(("NlmsgerrAttrs", offset));
353            return (
354                stack,
355                missing_type.and_then(|t| NlmsgerrAttrs::attr_from_type(t)),
356            );
357        }
358        if cur > offset || cur + self.buf.len() < offset {
359            return (stack, None);
360        }
361        let mut attrs = self.clone();
362        let mut last_off = cur + attrs.pos;
363        let mut missing = None;
364        while let Some(attr) = attrs.next() {
365            let Ok(attr) = attr else { break };
366            match attr {
367                NlmsgerrAttrs::Msg(val) => {
368                    if last_off == offset {
369                        stack.push(("Msg", last_off));
370                        break;
371                    }
372                }
373                NlmsgerrAttrs::Offset(val) => {
374                    if last_off == offset {
375                        stack.push(("Offset", last_off));
376                        break;
377                    }
378                }
379                NlmsgerrAttrs::Cookie(val) => {
380                    if last_off == offset {
381                        stack.push(("Cookie", last_off));
382                        break;
383                    }
384                }
385                NlmsgerrAttrs::Policy(val) => {
386                    (stack, missing) = val.lookup_attr(offset, missing_type);
387                    if !stack.is_empty() {
388                        break;
389                    }
390                }
391                NlmsgerrAttrs::MissingType(val) => {
392                    if last_off == offset {
393                        stack.push(("MissingType", last_off));
394                        break;
395                    }
396                }
397                NlmsgerrAttrs::MissingNest(val) => {
398                    if last_off == offset {
399                        stack.push(("MissingNest", last_off));
400                        break;
401                    }
402                }
403                _ => {}
404            };
405            last_off = cur + attrs.pos;
406        }
407        if !stack.is_empty() {
408            stack.push(("NlmsgerrAttrs", cur));
409        }
410        (stack, missing)
411    }
412}
413#[derive(Clone)]
414pub enum PolicyTypeAttrs<'a> {
415    #[doc = "type of the attribute, enum netlink_attribute_type (U32)"]
416    Type(u32),
417    #[doc = "minimum value for signed integers (S64)"]
418    MinValueSigned(i64),
419    #[doc = "maximum value for signed integers (S64)"]
420    MaxValueSigned(i64),
421    #[doc = "minimum value for unsigned integers (U64)"]
422    MinValueU(u64),
423    #[doc = "maximum value for unsigned integers (U64)"]
424    MaxValueU(u64),
425    #[doc = "minimum length for binary attributes, no minimum if not given (U32)"]
426    MinLength(u32),
427    #[doc = "maximum length for binary attributes, no maximum if not given (U32)"]
428    MaxLength(u32),
429    #[doc = "sub policy for nested and nested array types (U32)"]
430    PolicyIdx(u32),
431    #[doc = "maximum sub policy attribute for nested and nested array types, this can in theory be < the size of the policy pointed to by the index, if limited inside the nesting (U32)"]
432    PolicyMaxtype(u32),
433    #[doc = "valid mask for the bitfield32 type (U32)"]
434    Bitfield32Mask(u32),
435    #[doc = "pad attribute for 64-bit alignment"]
436    Pad(&'a [u8]),
437    #[doc = "mask of valid bits for unsigned integers (U64)"]
438    Mask(u64),
439}
440impl<'a> IterablePolicyTypeAttrs<'a> {
441    #[doc = "type of the attribute, enum netlink_attribute_type (U32)"]
442    pub fn get_type(&self) -> Result<u32, ErrorContext> {
443        let mut iter = self.clone();
444        iter.pos = 0;
445        for attr in iter {
446            if let PolicyTypeAttrs::Type(val) = attr? {
447                return Ok(val);
448            }
449        }
450        Err(ErrorContext::new_missing(
451            "PolicyTypeAttrs",
452            "Type",
453            self.orig_loc,
454            self.buf.as_ptr() as usize,
455        ))
456    }
457    #[doc = "minimum value for signed integers (S64)"]
458    pub fn get_min_value_signed(&self) -> Result<i64, ErrorContext> {
459        let mut iter = self.clone();
460        iter.pos = 0;
461        for attr in iter {
462            if let PolicyTypeAttrs::MinValueSigned(val) = attr? {
463                return Ok(val);
464            }
465        }
466        Err(ErrorContext::new_missing(
467            "PolicyTypeAttrs",
468            "MinValueSigned",
469            self.orig_loc,
470            self.buf.as_ptr() as usize,
471        ))
472    }
473    #[doc = "maximum value for signed integers (S64)"]
474    pub fn get_max_value_signed(&self) -> Result<i64, ErrorContext> {
475        let mut iter = self.clone();
476        iter.pos = 0;
477        for attr in iter {
478            if let PolicyTypeAttrs::MaxValueSigned(val) = attr? {
479                return Ok(val);
480            }
481        }
482        Err(ErrorContext::new_missing(
483            "PolicyTypeAttrs",
484            "MaxValueSigned",
485            self.orig_loc,
486            self.buf.as_ptr() as usize,
487        ))
488    }
489    #[doc = "minimum value for unsigned integers (U64)"]
490    pub fn get_min_value_u(&self) -> Result<u64, ErrorContext> {
491        let mut iter = self.clone();
492        iter.pos = 0;
493        for attr in iter {
494            if let PolicyTypeAttrs::MinValueU(val) = attr? {
495                return Ok(val);
496            }
497        }
498        Err(ErrorContext::new_missing(
499            "PolicyTypeAttrs",
500            "MinValueU",
501            self.orig_loc,
502            self.buf.as_ptr() as usize,
503        ))
504    }
505    #[doc = "maximum value for unsigned integers (U64)"]
506    pub fn get_max_value_u(&self) -> Result<u64, ErrorContext> {
507        let mut iter = self.clone();
508        iter.pos = 0;
509        for attr in iter {
510            if let PolicyTypeAttrs::MaxValueU(val) = attr? {
511                return Ok(val);
512            }
513        }
514        Err(ErrorContext::new_missing(
515            "PolicyTypeAttrs",
516            "MaxValueU",
517            self.orig_loc,
518            self.buf.as_ptr() as usize,
519        ))
520    }
521    #[doc = "minimum length for binary attributes, no minimum if not given (U32)"]
522    pub fn get_min_length(&self) -> Result<u32, ErrorContext> {
523        let mut iter = self.clone();
524        iter.pos = 0;
525        for attr in iter {
526            if let PolicyTypeAttrs::MinLength(val) = attr? {
527                return Ok(val);
528            }
529        }
530        Err(ErrorContext::new_missing(
531            "PolicyTypeAttrs",
532            "MinLength",
533            self.orig_loc,
534            self.buf.as_ptr() as usize,
535        ))
536    }
537    #[doc = "maximum length for binary attributes, no maximum if not given (U32)"]
538    pub fn get_max_length(&self) -> Result<u32, ErrorContext> {
539        let mut iter = self.clone();
540        iter.pos = 0;
541        for attr in iter {
542            if let PolicyTypeAttrs::MaxLength(val) = attr? {
543                return Ok(val);
544            }
545        }
546        Err(ErrorContext::new_missing(
547            "PolicyTypeAttrs",
548            "MaxLength",
549            self.orig_loc,
550            self.buf.as_ptr() as usize,
551        ))
552    }
553    #[doc = "sub policy for nested and nested array types (U32)"]
554    pub fn get_policy_idx(&self) -> Result<u32, ErrorContext> {
555        let mut iter = self.clone();
556        iter.pos = 0;
557        for attr in iter {
558            if let PolicyTypeAttrs::PolicyIdx(val) = attr? {
559                return Ok(val);
560            }
561        }
562        Err(ErrorContext::new_missing(
563            "PolicyTypeAttrs",
564            "PolicyIdx",
565            self.orig_loc,
566            self.buf.as_ptr() as usize,
567        ))
568    }
569    #[doc = "maximum sub policy attribute for nested and nested array types, this can in theory be < the size of the policy pointed to by the index, if limited inside the nesting (U32)"]
570    pub fn get_policy_maxtype(&self) -> Result<u32, ErrorContext> {
571        let mut iter = self.clone();
572        iter.pos = 0;
573        for attr in iter {
574            if let PolicyTypeAttrs::PolicyMaxtype(val) = attr? {
575                return Ok(val);
576            }
577        }
578        Err(ErrorContext::new_missing(
579            "PolicyTypeAttrs",
580            "PolicyMaxtype",
581            self.orig_loc,
582            self.buf.as_ptr() as usize,
583        ))
584    }
585    #[doc = "valid mask for the bitfield32 type (U32)"]
586    pub fn get_bitfield32_mask(&self) -> Result<u32, ErrorContext> {
587        let mut iter = self.clone();
588        iter.pos = 0;
589        for attr in iter {
590            if let PolicyTypeAttrs::Bitfield32Mask(val) = attr? {
591                return Ok(val);
592            }
593        }
594        Err(ErrorContext::new_missing(
595            "PolicyTypeAttrs",
596            "Bitfield32Mask",
597            self.orig_loc,
598            self.buf.as_ptr() as usize,
599        ))
600    }
601    #[doc = "pad attribute for 64-bit alignment"]
602    pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
603        let mut iter = self.clone();
604        iter.pos = 0;
605        for attr in iter {
606            if let PolicyTypeAttrs::Pad(val) = attr? {
607                return Ok(val);
608            }
609        }
610        Err(ErrorContext::new_missing(
611            "PolicyTypeAttrs",
612            "Pad",
613            self.orig_loc,
614            self.buf.as_ptr() as usize,
615        ))
616    }
617    #[doc = "mask of valid bits for unsigned integers (U64)"]
618    pub fn get_mask(&self) -> Result<u64, ErrorContext> {
619        let mut iter = self.clone();
620        iter.pos = 0;
621        for attr in iter {
622            if let PolicyTypeAttrs::Mask(val) = attr? {
623                return Ok(val);
624            }
625        }
626        Err(ErrorContext::new_missing(
627            "PolicyTypeAttrs",
628            "Mask",
629            self.orig_loc,
630            self.buf.as_ptr() as usize,
631        ))
632    }
633}
634impl PolicyTypeAttrs<'_> {
635    pub fn new<'a>(buf: &'a [u8]) -> IterablePolicyTypeAttrs<'a> {
636        IterablePolicyTypeAttrs::with_loc(buf, buf.as_ptr() as usize)
637    }
638    fn attr_from_type(r#type: u16) -> Option<&'static str> {
639        let res = match r#type {
640            0u16 => "Unspec",
641            1u16 => "Type",
642            2u16 => "MinValueSigned",
643            3u16 => "MaxValueSigned",
644            4u16 => "MinValueU",
645            5u16 => "MaxValueU",
646            6u16 => "MinLength",
647            7u16 => "MaxLength",
648            8u16 => "PolicyIdx",
649            9u16 => "PolicyMaxtype",
650            10u16 => "Bitfield32Mask",
651            11u16 => "Pad",
652            12u16 => "Mask",
653            _ => return None,
654        };
655        Some(res)
656    }
657}
658#[derive(Clone, Copy, Default)]
659pub struct IterablePolicyTypeAttrs<'a> {
660    buf: &'a [u8],
661    pos: usize,
662    orig_loc: usize,
663}
664impl<'a> IterablePolicyTypeAttrs<'a> {
665    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
666        Self {
667            buf,
668            pos: 0,
669            orig_loc,
670        }
671    }
672    pub fn get_buf(&self) -> &'a [u8] {
673        self.buf
674    }
675}
676impl<'a> Iterator for IterablePolicyTypeAttrs<'a> {
677    type Item = Result<PolicyTypeAttrs<'a>, ErrorContext>;
678    fn next(&mut self) -> Option<Self::Item> {
679        let pos = self.pos;
680        let mut r#type;
681        loop {
682            r#type = None;
683            if self.buf.len() == self.pos {
684                return None;
685            }
686            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
687                break;
688            };
689            r#type = Some(header.r#type);
690            let res = match header.r#type {
691                1u16 => PolicyTypeAttrs::Type({
692                    let res = parse_u32(next);
693                    let Some(val) = res else { break };
694                    val
695                }),
696                2u16 => PolicyTypeAttrs::MinValueSigned({
697                    let res = parse_i64(next);
698                    let Some(val) = res else { break };
699                    val
700                }),
701                3u16 => PolicyTypeAttrs::MaxValueSigned({
702                    let res = parse_i64(next);
703                    let Some(val) = res else { break };
704                    val
705                }),
706                4u16 => PolicyTypeAttrs::MinValueU({
707                    let res = parse_u64(next);
708                    let Some(val) = res else { break };
709                    val
710                }),
711                5u16 => PolicyTypeAttrs::MaxValueU({
712                    let res = parse_u64(next);
713                    let Some(val) = res else { break };
714                    val
715                }),
716                6u16 => PolicyTypeAttrs::MinLength({
717                    let res = parse_u32(next);
718                    let Some(val) = res else { break };
719                    val
720                }),
721                7u16 => PolicyTypeAttrs::MaxLength({
722                    let res = parse_u32(next);
723                    let Some(val) = res else { break };
724                    val
725                }),
726                8u16 => PolicyTypeAttrs::PolicyIdx({
727                    let res = parse_u32(next);
728                    let Some(val) = res else { break };
729                    val
730                }),
731                9u16 => PolicyTypeAttrs::PolicyMaxtype({
732                    let res = parse_u32(next);
733                    let Some(val) = res else { break };
734                    val
735                }),
736                10u16 => PolicyTypeAttrs::Bitfield32Mask({
737                    let res = parse_u32(next);
738                    let Some(val) = res else { break };
739                    val
740                }),
741                11u16 => PolicyTypeAttrs::Pad({
742                    let res = Some(next);
743                    let Some(val) = res else { break };
744                    val
745                }),
746                12u16 => PolicyTypeAttrs::Mask({
747                    let res = parse_u64(next);
748                    let Some(val) = res else { break };
749                    val
750                }),
751                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
752                n => continue,
753            };
754            return Some(Ok(res));
755        }
756        Some(Err(ErrorContext::new(
757            "PolicyTypeAttrs",
758            r#type.and_then(|t| PolicyTypeAttrs::attr_from_type(t)),
759            self.orig_loc,
760            self.buf.as_ptr().wrapping_add(pos) as usize,
761        )))
762    }
763}
764impl<'a> std::fmt::Debug for IterablePolicyTypeAttrs<'_> {
765    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
766        let mut fmt = f.debug_struct("PolicyTypeAttrs");
767        for attr in self.clone() {
768            let attr = match attr {
769                Ok(a) => a,
770                Err(err) => {
771                    fmt.finish()?;
772                    f.write_str("Err(")?;
773                    err.fmt(f)?;
774                    return f.write_str(")");
775                }
776            };
777            match attr {
778                PolicyTypeAttrs::Type(val) => fmt.field("Type", &val),
779                PolicyTypeAttrs::MinValueSigned(val) => fmt.field("MinValueSigned", &val),
780                PolicyTypeAttrs::MaxValueSigned(val) => fmt.field("MaxValueSigned", &val),
781                PolicyTypeAttrs::MinValueU(val) => fmt.field("MinValueU", &val),
782                PolicyTypeAttrs::MaxValueU(val) => fmt.field("MaxValueU", &val),
783                PolicyTypeAttrs::MinLength(val) => fmt.field("MinLength", &val),
784                PolicyTypeAttrs::MaxLength(val) => fmt.field("MaxLength", &val),
785                PolicyTypeAttrs::PolicyIdx(val) => fmt.field("PolicyIdx", &val),
786                PolicyTypeAttrs::PolicyMaxtype(val) => fmt.field("PolicyMaxtype", &val),
787                PolicyTypeAttrs::Bitfield32Mask(val) => fmt.field("Bitfield32Mask", &val),
788                PolicyTypeAttrs::Pad(val) => fmt.field("Pad", &val),
789                PolicyTypeAttrs::Mask(val) => fmt.field("Mask", &val),
790            };
791        }
792        fmt.finish()
793    }
794}
795impl IterablePolicyTypeAttrs<'_> {
796    pub fn lookup_attr(
797        &self,
798        offset: usize,
799        missing_type: Option<u16>,
800    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
801        let mut stack = Vec::new();
802        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
803        if cur == offset {
804            stack.push(("PolicyTypeAttrs", offset));
805            return (
806                stack,
807                missing_type.and_then(|t| PolicyTypeAttrs::attr_from_type(t)),
808            );
809        }
810        if cur > offset || cur + self.buf.len() < offset {
811            return (stack, None);
812        }
813        let mut attrs = self.clone();
814        let mut last_off = cur + attrs.pos;
815        while let Some(attr) = attrs.next() {
816            let Ok(attr) = attr else { break };
817            match attr {
818                PolicyTypeAttrs::Type(val) => {
819                    if last_off == offset {
820                        stack.push(("Type", last_off));
821                        break;
822                    }
823                }
824                PolicyTypeAttrs::MinValueSigned(val) => {
825                    if last_off == offset {
826                        stack.push(("MinValueSigned", last_off));
827                        break;
828                    }
829                }
830                PolicyTypeAttrs::MaxValueSigned(val) => {
831                    if last_off == offset {
832                        stack.push(("MaxValueSigned", last_off));
833                        break;
834                    }
835                }
836                PolicyTypeAttrs::MinValueU(val) => {
837                    if last_off == offset {
838                        stack.push(("MinValueU", last_off));
839                        break;
840                    }
841                }
842                PolicyTypeAttrs::MaxValueU(val) => {
843                    if last_off == offset {
844                        stack.push(("MaxValueU", last_off));
845                        break;
846                    }
847                }
848                PolicyTypeAttrs::MinLength(val) => {
849                    if last_off == offset {
850                        stack.push(("MinLength", last_off));
851                        break;
852                    }
853                }
854                PolicyTypeAttrs::MaxLength(val) => {
855                    if last_off == offset {
856                        stack.push(("MaxLength", last_off));
857                        break;
858                    }
859                }
860                PolicyTypeAttrs::PolicyIdx(val) => {
861                    if last_off == offset {
862                        stack.push(("PolicyIdx", last_off));
863                        break;
864                    }
865                }
866                PolicyTypeAttrs::PolicyMaxtype(val) => {
867                    if last_off == offset {
868                        stack.push(("PolicyMaxtype", last_off));
869                        break;
870                    }
871                }
872                PolicyTypeAttrs::Bitfield32Mask(val) => {
873                    if last_off == offset {
874                        stack.push(("Bitfield32Mask", last_off));
875                        break;
876                    }
877                }
878                PolicyTypeAttrs::Pad(val) => {
879                    if last_off == offset {
880                        stack.push(("Pad", last_off));
881                        break;
882                    }
883                }
884                PolicyTypeAttrs::Mask(val) => {
885                    if last_off == offset {
886                        stack.push(("Mask", last_off));
887                        break;
888                    }
889                }
890                _ => {}
891            };
892            last_off = cur + attrs.pos;
893        }
894        if !stack.is_empty() {
895            stack.push(("PolicyTypeAttrs", cur));
896        }
897        (stack, None)
898    }
899}
900pub struct PushDummy<Prev: Rec> {
901    pub(crate) prev: Option<Prev>,
902    pub(crate) header_offset: Option<usize>,
903}
904impl<Prev: Rec> Rec for PushDummy<Prev> {
905    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
906        self.prev.as_mut().unwrap().as_rec_mut()
907    }
908    fn as_rec(&self) -> &Vec<u8> {
909        self.prev.as_ref().unwrap().as_rec()
910    }
911}
912impl<Prev: Rec> PushDummy<Prev> {
913    pub fn new(prev: Prev) -> Self {
914        Self {
915            prev: Some(prev),
916            header_offset: None,
917        }
918    }
919    pub fn end_nested(mut self) -> Prev {
920        let mut prev = self.prev.take().unwrap();
921        if let Some(header_offset) = &self.header_offset {
922            finalize_nested_header(prev.as_rec_mut(), *header_offset);
923        }
924        prev
925    }
926}
927impl<Prev: Rec> Drop for PushDummy<Prev> {
928    fn drop(&mut self) {
929        if let Some(prev) = &mut self.prev {
930            if let Some(header_offset) = &self.header_offset {
931                finalize_nested_header(prev.as_rec_mut(), *header_offset);
932            }
933        }
934    }
935}
936pub struct PushNlmsgerrAttrs<Prev: Rec> {
937    pub(crate) prev: Option<Prev>,
938    pub(crate) header_offset: Option<usize>,
939}
940impl<Prev: Rec> Rec for PushNlmsgerrAttrs<Prev> {
941    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
942        self.prev.as_mut().unwrap().as_rec_mut()
943    }
944    fn as_rec(&self) -> &Vec<u8> {
945        self.prev.as_ref().unwrap().as_rec()
946    }
947}
948impl<Prev: Rec> PushNlmsgerrAttrs<Prev> {
949    pub fn new(prev: Prev) -> Self {
950        Self {
951            prev: Some(prev),
952            header_offset: None,
953        }
954    }
955    pub fn end_nested(mut self) -> Prev {
956        let mut prev = self.prev.take().unwrap();
957        if let Some(header_offset) = &self.header_offset {
958            finalize_nested_header(prev.as_rec_mut(), *header_offset);
959        }
960        prev
961    }
962    #[doc = "error message string (string)"]
963    pub fn push_msg(mut self, value: &CStr) -> Self {
964        push_header(
965            self.as_rec_mut(),
966            1u16,
967            value.to_bytes_with_nul().len() as u16,
968        );
969        self.as_rec_mut().extend(value.to_bytes_with_nul());
970        self
971    }
972    #[doc = "error message string (string)"]
973    pub fn push_msg_bytes(mut self, value: &[u8]) -> Self {
974        push_header(self.as_rec_mut(), 1u16, (value.len() + 1) as u16);
975        self.as_rec_mut().extend(value);
976        self.as_rec_mut().push(0);
977        self
978    }
979    #[doc = "offset of the invalid attribute in the original message, counting from the beginning of the header (u32)"]
980    pub fn push_offset(mut self, value: u32) -> Self {
981        push_header(self.as_rec_mut(), 2u16, 4 as u16);
982        self.as_rec_mut().extend(value.to_ne_bytes());
983        self
984    }
985    #[doc = "arbitrary subsystem specific cookie to be used - in the success case - to identify a created object or operation or similar (binary)"]
986    pub fn push_cookie(mut self, value: &[u8]) -> Self {
987        push_header(self.as_rec_mut(), 3u16, value.len() as u16);
988        self.as_rec_mut().extend(value);
989        self
990    }
991    #[doc = "policy for a rejected attribute"]
992    pub fn nested_policy(mut self) -> PushPolicyTypeAttrs<Self> {
993        let header_offset = push_nested_header(self.as_rec_mut(), 4u16);
994        PushPolicyTypeAttrs {
995            prev: Some(self),
996            header_offset: Some(header_offset),
997        }
998    }
999    #[doc = "type of a missing required attribute, NLMSGERR_ATTR_MISS_NEST will not be present if the attribute was missing at the message level"]
1000    pub fn push_missing_type(mut self, value: u16) -> Self {
1001        push_header(self.as_rec_mut(), 5u16, 2 as u16);
1002        self.as_rec_mut().extend(value.to_ne_bytes());
1003        self
1004    }
1005    #[doc = "offset of the nest where attribute was missing"]
1006    pub fn push_missing_nest(mut self, value: u32) -> Self {
1007        push_header(self.as_rec_mut(), 6u16, 4 as u16);
1008        self.as_rec_mut().extend(value.to_ne_bytes());
1009        self
1010    }
1011}
1012impl<Prev: Rec> Drop for PushNlmsgerrAttrs<Prev> {
1013    fn drop(&mut self) {
1014        if let Some(prev) = &mut self.prev {
1015            if let Some(header_offset) = &self.header_offset {
1016                finalize_nested_header(prev.as_rec_mut(), *header_offset);
1017            }
1018        }
1019    }
1020}
1021pub struct PushPolicyTypeAttrs<Prev: Rec> {
1022    pub(crate) prev: Option<Prev>,
1023    pub(crate) header_offset: Option<usize>,
1024}
1025impl<Prev: Rec> Rec for PushPolicyTypeAttrs<Prev> {
1026    fn as_rec_mut(&mut self) -> &mut Vec<u8> {
1027        self.prev.as_mut().unwrap().as_rec_mut()
1028    }
1029    fn as_rec(&self) -> &Vec<u8> {
1030        self.prev.as_ref().unwrap().as_rec()
1031    }
1032}
1033impl<Prev: Rec> PushPolicyTypeAttrs<Prev> {
1034    pub fn new(prev: Prev) -> Self {
1035        Self {
1036            prev: Some(prev),
1037            header_offset: None,
1038        }
1039    }
1040    pub fn end_nested(mut self) -> Prev {
1041        let mut prev = self.prev.take().unwrap();
1042        if let Some(header_offset) = &self.header_offset {
1043            finalize_nested_header(prev.as_rec_mut(), *header_offset);
1044        }
1045        prev
1046    }
1047    #[doc = "type of the attribute, enum netlink_attribute_type (U32)"]
1048    pub fn push_type(mut self, value: u32) -> Self {
1049        push_header(self.as_rec_mut(), 1u16, 4 as u16);
1050        self.as_rec_mut().extend(value.to_ne_bytes());
1051        self
1052    }
1053    #[doc = "minimum value for signed integers (S64)"]
1054    pub fn push_min_value_signed(mut self, value: i64) -> Self {
1055        push_header(self.as_rec_mut(), 2u16, 8 as u16);
1056        self.as_rec_mut().extend(value.to_ne_bytes());
1057        self
1058    }
1059    #[doc = "maximum value for signed integers (S64)"]
1060    pub fn push_max_value_signed(mut self, value: i64) -> Self {
1061        push_header(self.as_rec_mut(), 3u16, 8 as u16);
1062        self.as_rec_mut().extend(value.to_ne_bytes());
1063        self
1064    }
1065    #[doc = "minimum value for unsigned integers (U64)"]
1066    pub fn push_min_value_u(mut self, value: u64) -> Self {
1067        push_header(self.as_rec_mut(), 4u16, 8 as u16);
1068        self.as_rec_mut().extend(value.to_ne_bytes());
1069        self
1070    }
1071    #[doc = "maximum value for unsigned integers (U64)"]
1072    pub fn push_max_value_u(mut self, value: u64) -> Self {
1073        push_header(self.as_rec_mut(), 5u16, 8 as u16);
1074        self.as_rec_mut().extend(value.to_ne_bytes());
1075        self
1076    }
1077    #[doc = "minimum length for binary attributes, no minimum if not given (U32)"]
1078    pub fn push_min_length(mut self, value: u32) -> Self {
1079        push_header(self.as_rec_mut(), 6u16, 4 as u16);
1080        self.as_rec_mut().extend(value.to_ne_bytes());
1081        self
1082    }
1083    #[doc = "maximum length for binary attributes, no maximum if not given (U32)"]
1084    pub fn push_max_length(mut self, value: u32) -> Self {
1085        push_header(self.as_rec_mut(), 7u16, 4 as u16);
1086        self.as_rec_mut().extend(value.to_ne_bytes());
1087        self
1088    }
1089    #[doc = "sub policy for nested and nested array types (U32)"]
1090    pub fn push_policy_idx(mut self, value: u32) -> Self {
1091        push_header(self.as_rec_mut(), 8u16, 4 as u16);
1092        self.as_rec_mut().extend(value.to_ne_bytes());
1093        self
1094    }
1095    #[doc = "maximum sub policy attribute for nested and nested array types, this can in theory be < the size of the policy pointed to by the index, if limited inside the nesting (U32)"]
1096    pub fn push_policy_maxtype(mut self, value: u32) -> Self {
1097        push_header(self.as_rec_mut(), 9u16, 4 as u16);
1098        self.as_rec_mut().extend(value.to_ne_bytes());
1099        self
1100    }
1101    #[doc = "valid mask for the bitfield32 type (U32)"]
1102    pub fn push_bitfield32_mask(mut self, value: u32) -> Self {
1103        push_header(self.as_rec_mut(), 10u16, 4 as u16);
1104        self.as_rec_mut().extend(value.to_ne_bytes());
1105        self
1106    }
1107    #[doc = "pad attribute for 64-bit alignment"]
1108    pub fn push_pad(mut self, value: &[u8]) -> Self {
1109        push_header(self.as_rec_mut(), 11u16, value.len() as u16);
1110        self.as_rec_mut().extend(value);
1111        self
1112    }
1113    #[doc = "mask of valid bits for unsigned integers (U64)"]
1114    pub fn push_mask(mut self, value: u64) -> Self {
1115        push_header(self.as_rec_mut(), 12u16, 8 as u16);
1116        self.as_rec_mut().extend(value.to_ne_bytes());
1117        self
1118    }
1119}
1120impl<Prev: Rec> Drop for PushPolicyTypeAttrs<Prev> {
1121    fn drop(&mut self) {
1122        if let Some(prev) = &mut self.prev {
1123            if let Some(header_offset) = &self.header_offset {
1124                finalize_nested_header(prev.as_rec_mut(), *header_offset);
1125            }
1126        }
1127    }
1128}
1129#[derive(Clone)]
1130pub struct PushBuiltinNfgenmsg {
1131    pub(crate) buf: [u8; 4usize],
1132}
1133#[doc = "Create zero-initialized struct"]
1134impl Default for PushBuiltinNfgenmsg {
1135    fn default() -> Self {
1136        Self { buf: [0u8; 4usize] }
1137    }
1138}
1139impl PushBuiltinNfgenmsg {
1140    #[doc = "Create zero-initialized struct"]
1141    pub fn new() -> Self {
1142        Default::default()
1143    }
1144    #[doc = "Copy from contents from other slice"]
1145    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1146        if other.len() != Self::len() {
1147            return None;
1148        }
1149        let mut buf = [0u8; Self::len()];
1150        buf.clone_from_slice(other);
1151        Some(Self { buf })
1152    }
1153    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1154    pub fn new_from_zeroed(other: &[u8]) -> Self {
1155        let mut buf = [0u8; Self::len()];
1156        let len = buf.len().min(other.len());
1157        buf[..len].clone_from_slice(&other[..len]);
1158        Self { buf }
1159    }
1160    pub fn as_slice(&self) -> &[u8] {
1161        &self.buf
1162    }
1163    pub fn as_mut_slice(&mut self) -> &mut [u8] {
1164        &mut self.buf
1165    }
1166    pub const fn len() -> usize {
1167        4usize
1168    }
1169    pub fn cmd(&self) -> u8 {
1170        parse_u8(&self.buf[0usize..1usize]).unwrap()
1171    }
1172    pub fn set_cmd(&mut self, value: u8) {
1173        self.buf[0usize..1usize].copy_from_slice(&value.to_ne_bytes())
1174    }
1175    pub fn version(&self) -> u8 {
1176        parse_u8(&self.buf[1usize..2usize]).unwrap()
1177    }
1178    pub fn set_version(&mut self, value: u8) {
1179        self.buf[1usize..2usize].copy_from_slice(&value.to_ne_bytes())
1180    }
1181    pub fn reserved(&self) -> u16 {
1182        parse_u16(&self.buf[2usize..4usize]).unwrap()
1183    }
1184    pub fn set_reserved(&mut self, value: u16) {
1185        self.buf[2usize..4usize].copy_from_slice(&value.to_ne_bytes())
1186    }
1187}
1188impl std::fmt::Debug for PushBuiltinNfgenmsg {
1189    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1190        fmt.debug_struct("BuiltinNfgenmsg")
1191            .field("cmd", &self.cmd())
1192            .field("version", &self.version())
1193            .field("reserved", &self.reserved())
1194            .finish()
1195    }
1196}
1197#[derive(Clone)]
1198pub struct PushBuiltinBitfield32 {
1199    pub(crate) buf: [u8; 8usize],
1200}
1201#[doc = "Create zero-initialized struct"]
1202impl Default for PushBuiltinBitfield32 {
1203    fn default() -> Self {
1204        Self { buf: [0u8; 8usize] }
1205    }
1206}
1207impl PushBuiltinBitfield32 {
1208    #[doc = "Create zero-initialized struct"]
1209    pub fn new() -> Self {
1210        Default::default()
1211    }
1212    #[doc = "Copy from contents from other slice"]
1213    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1214        if other.len() != Self::len() {
1215            return None;
1216        }
1217        let mut buf = [0u8; Self::len()];
1218        buf.clone_from_slice(other);
1219        Some(Self { buf })
1220    }
1221    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1222    pub fn new_from_zeroed(other: &[u8]) -> Self {
1223        let mut buf = [0u8; Self::len()];
1224        let len = buf.len().min(other.len());
1225        buf[..len].clone_from_slice(&other[..len]);
1226        Self { buf }
1227    }
1228    pub fn as_slice(&self) -> &[u8] {
1229        &self.buf
1230    }
1231    pub fn as_mut_slice(&mut self) -> &mut [u8] {
1232        &mut self.buf
1233    }
1234    pub const fn len() -> usize {
1235        8usize
1236    }
1237    pub fn value(&self) -> u32 {
1238        parse_u32(&self.buf[0usize..4usize]).unwrap()
1239    }
1240    pub fn set_value(&mut self, value: u32) {
1241        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
1242    }
1243    pub fn selector(&self) -> u32 {
1244        parse_u32(&self.buf[4usize..8usize]).unwrap()
1245    }
1246    pub fn set_selector(&mut self, value: u32) {
1247        self.buf[4usize..8usize].copy_from_slice(&value.to_ne_bytes())
1248    }
1249}
1250impl std::fmt::Debug for PushBuiltinBitfield32 {
1251    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1252        fmt.debug_struct("BuiltinBitfield32")
1253            .field("value", &self.value())
1254            .field("selector", &self.selector())
1255            .finish()
1256    }
1257}
1258#[derive(Clone)]
1259pub struct PushNlmsghdr {
1260    pub(crate) buf: [u8; 16usize],
1261}
1262#[doc = "Create zero-initialized struct"]
1263impl Default for PushNlmsghdr {
1264    fn default() -> Self {
1265        Self {
1266            buf: [0u8; 16usize],
1267        }
1268    }
1269}
1270impl PushNlmsghdr {
1271    #[doc = "Create zero-initialized struct"]
1272    pub fn new() -> Self {
1273        Default::default()
1274    }
1275    #[doc = "Copy from contents from other slice"]
1276    pub fn new_from_slice(other: &[u8]) -> Option<Self> {
1277        if other.len() != Self::len() {
1278            return None;
1279        }
1280        let mut buf = [0u8; Self::len()];
1281        buf.clone_from_slice(other);
1282        Some(Self { buf })
1283    }
1284    #[doc = "Copy from contents from another slice, padding with zeros or truncating when needed"]
1285    pub fn new_from_zeroed(other: &[u8]) -> Self {
1286        let mut buf = [0u8; Self::len()];
1287        let len = buf.len().min(other.len());
1288        buf[..len].clone_from_slice(&other[..len]);
1289        Self { buf }
1290    }
1291    pub fn as_slice(&self) -> &[u8] {
1292        &self.buf
1293    }
1294    pub fn as_mut_slice(&mut self) -> &mut [u8] {
1295        &mut self.buf
1296    }
1297    pub const fn len() -> usize {
1298        16usize
1299    }
1300    pub fn get_len(&self) -> u32 {
1301        parse_u32(&self.buf[0usize..4usize]).unwrap()
1302    }
1303    pub fn set_len(&mut self, value: u32) {
1304        self.buf[0usize..4usize].copy_from_slice(&value.to_ne_bytes())
1305    }
1306    pub fn get_type(&self) -> u16 {
1307        parse_u16(&self.buf[4usize..6usize]).unwrap()
1308    }
1309    pub fn set_type(&mut self, value: u16) {
1310        self.buf[4usize..6usize].copy_from_slice(&value.to_ne_bytes())
1311    }
1312    pub fn flags(&self) -> u16 {
1313        parse_u16(&self.buf[6usize..8usize]).unwrap()
1314    }
1315    pub fn set_flags(&mut self, value: u16) {
1316        self.buf[6usize..8usize].copy_from_slice(&value.to_ne_bytes())
1317    }
1318    pub fn seq(&self) -> u32 {
1319        parse_u32(&self.buf[8usize..12usize]).unwrap()
1320    }
1321    pub fn set_seq(&mut self, value: u32) {
1322        self.buf[8usize..12usize].copy_from_slice(&value.to_ne_bytes())
1323    }
1324    pub fn pid(&self) -> u32 {
1325        parse_u32(&self.buf[12usize..16usize]).unwrap()
1326    }
1327    pub fn set_pid(&mut self, value: u32) {
1328        self.buf[12usize..16usize].copy_from_slice(&value.to_ne_bytes())
1329    }
1330}
1331impl std::fmt::Debug for PushNlmsghdr {
1332    fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1333        fmt.debug_struct("Nlmsghdr")
1334            .field("len", &self.get_len())
1335            .field("type", &self.get_type())
1336            .field("flags", &self.flags())
1337            .field("seq", &self.seq())
1338            .field("pid", &self.pid())
1339            .finish()
1340    }
1341}