Skip to main content

netlink_bindings/ovpn/
mod.rs

1#![doc = "Netlink protocol to control OpenVPN network devices\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)]
10use crate::builtin::{BuiltinBitfield32, BuiltinNfgenmsg, Nlmsghdr, PushDummy};
11use crate::{
12    consts,
13    traits::{NetlinkRequest, Protocol},
14    utils::*,
15};
16pub const PROTONAME: &str = "ovpn";
17pub const PROTONAME_CSTR: &CStr = c"ovpn";
18pub const NONCE_TAIL_SIZE: u64 = 8u64;
19#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
20#[derive(Debug, Clone, Copy)]
21pub enum CipherAlg {
22    None = 0,
23    AesGcm = 1,
24    Chacha20Poly1305 = 2,
25}
26impl CipherAlg {
27    pub fn from_value(value: u64) -> Option<Self> {
28        Some(match value {
29            0 => Self::None,
30            1 => Self::AesGcm,
31            2 => Self::Chacha20Poly1305,
32            _ => return None,
33        })
34    }
35}
36#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
37#[derive(Debug, Clone, Copy)]
38pub enum DelPeerReason {
39    Teardown = 0,
40    Userspace = 1,
41    Expired = 2,
42    TransportError = 3,
43    TransportDisconnect = 4,
44}
45impl DelPeerReason {
46    pub fn from_value(value: u64) -> Option<Self> {
47        Some(match value {
48            0 => Self::Teardown,
49            1 => Self::Userspace,
50            2 => Self::Expired,
51            3 => Self::TransportError,
52            4 => Self::TransportDisconnect,
53            _ => return None,
54        })
55    }
56}
57#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
58#[derive(Debug, Clone, Copy)]
59pub enum KeySlot {
60    Primary = 0,
61    Secondary = 1,
62}
63impl KeySlot {
64    pub fn from_value(value: u64) -> Option<Self> {
65        Some(match value {
66            0 => Self::Primary,
67            1 => Self::Secondary,
68            _ => return None,
69        })
70    }
71}
72#[derive(Clone)]
73pub enum Peer<'a> {
74    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
75    Id(u32),
76    #[doc = "The remote IPv4 address of the peer\n"]
77    RemoteIpv4(std::net::Ipv4Addr),
78    #[doc = "The remote IPv6 address of the peer\n"]
79    RemoteIpv6(&'a [u8]),
80    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
81    RemoteIpv6ScopeId(u32),
82    #[doc = "The remote port of the peer\n"]
83    RemotePort(u16),
84    #[doc = "The socket to be used to communicate with the peer\n"]
85    Socket(u32),
86    #[doc = "The ID of the netns the socket assigned to this peer lives in\n"]
87    SocketNetnsid(i32),
88    #[doc = "The IPv4 address assigned to the peer by the server\n"]
89    VpnIpv4(std::net::Ipv4Addr),
90    #[doc = "The IPv6 address assigned to the peer by the server\n"]
91    VpnIpv6(&'a [u8]),
92    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
93    LocalIpv4(std::net::Ipv4Addr),
94    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
95    LocalIpv6(&'a [u8]),
96    #[doc = "The local port to be used to send packets to the peer (UDP only)\n"]
97    LocalPort(u16),
98    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
99    KeepaliveInterval(u32),
100    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
101    KeepaliveTimeout(u32),
102    #[doc = "The reason why a peer was deleted\n\nAssociated type: [`DelPeerReason`] (enum)"]
103    DelReason(u32),
104    #[doc = "Number of bytes received over the tunnel\n"]
105    VpnRxBytes(u32),
106    #[doc = "Number of bytes transmitted over the tunnel\n"]
107    VpnTxBytes(u32),
108    #[doc = "Number of packets received over the tunnel\n"]
109    VpnRxPackets(u32),
110    #[doc = "Number of packets transmitted over the tunnel\n"]
111    VpnTxPackets(u32),
112    #[doc = "Number of bytes received at the transport level\n"]
113    LinkRxBytes(u32),
114    #[doc = "Number of bytes transmitted at the transport level\n"]
115    LinkTxBytes(u32),
116    #[doc = "Number of packets received at the transport level\n"]
117    LinkRxPackets(u32),
118    #[doc = "Number of packets transmitted at the transport level\n"]
119    LinkTxPackets(u32),
120    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
121    TxId(u32),
122}
123impl<'a> IterablePeer<'a> {
124    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
125    pub fn get_id(&self) -> Result<u32, ErrorContext> {
126        let mut iter = self.clone();
127        iter.pos = 0;
128        for attr in iter {
129            if let Ok(Peer::Id(val)) = attr {
130                return Ok(val);
131            }
132        }
133        Err(ErrorContext::new_missing(
134            "Peer",
135            "Id",
136            self.orig_loc,
137            self.buf.as_ptr() as usize,
138        ))
139    }
140    #[doc = "The remote IPv4 address of the peer\n"]
141    pub fn get_remote_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
142        let mut iter = self.clone();
143        iter.pos = 0;
144        for attr in iter {
145            if let Ok(Peer::RemoteIpv4(val)) = attr {
146                return Ok(val);
147            }
148        }
149        Err(ErrorContext::new_missing(
150            "Peer",
151            "RemoteIpv4",
152            self.orig_loc,
153            self.buf.as_ptr() as usize,
154        ))
155    }
156    #[doc = "The remote IPv6 address of the peer\n"]
157    pub fn get_remote_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
158        let mut iter = self.clone();
159        iter.pos = 0;
160        for attr in iter {
161            if let Ok(Peer::RemoteIpv6(val)) = attr {
162                return Ok(val);
163            }
164        }
165        Err(ErrorContext::new_missing(
166            "Peer",
167            "RemoteIpv6",
168            self.orig_loc,
169            self.buf.as_ptr() as usize,
170        ))
171    }
172    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
173    pub fn get_remote_ipv6_scope_id(&self) -> Result<u32, ErrorContext> {
174        let mut iter = self.clone();
175        iter.pos = 0;
176        for attr in iter {
177            if let Ok(Peer::RemoteIpv6ScopeId(val)) = attr {
178                return Ok(val);
179            }
180        }
181        Err(ErrorContext::new_missing(
182            "Peer",
183            "RemoteIpv6ScopeId",
184            self.orig_loc,
185            self.buf.as_ptr() as usize,
186        ))
187    }
188    #[doc = "The remote port of the peer\n"]
189    pub fn get_remote_port(&self) -> Result<u16, ErrorContext> {
190        let mut iter = self.clone();
191        iter.pos = 0;
192        for attr in iter {
193            if let Ok(Peer::RemotePort(val)) = attr {
194                return Ok(val);
195            }
196        }
197        Err(ErrorContext::new_missing(
198            "Peer",
199            "RemotePort",
200            self.orig_loc,
201            self.buf.as_ptr() as usize,
202        ))
203    }
204    #[doc = "The socket to be used to communicate with the peer\n"]
205    pub fn get_socket(&self) -> Result<u32, ErrorContext> {
206        let mut iter = self.clone();
207        iter.pos = 0;
208        for attr in iter {
209            if let Ok(Peer::Socket(val)) = attr {
210                return Ok(val);
211            }
212        }
213        Err(ErrorContext::new_missing(
214            "Peer",
215            "Socket",
216            self.orig_loc,
217            self.buf.as_ptr() as usize,
218        ))
219    }
220    #[doc = "The ID of the netns the socket assigned to this peer lives in\n"]
221    pub fn get_socket_netnsid(&self) -> Result<i32, ErrorContext> {
222        let mut iter = self.clone();
223        iter.pos = 0;
224        for attr in iter {
225            if let Ok(Peer::SocketNetnsid(val)) = attr {
226                return Ok(val);
227            }
228        }
229        Err(ErrorContext::new_missing(
230            "Peer",
231            "SocketNetnsid",
232            self.orig_loc,
233            self.buf.as_ptr() as usize,
234        ))
235    }
236    #[doc = "The IPv4 address assigned to the peer by the server\n"]
237    pub fn get_vpn_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
238        let mut iter = self.clone();
239        iter.pos = 0;
240        for attr in iter {
241            if let Ok(Peer::VpnIpv4(val)) = attr {
242                return Ok(val);
243            }
244        }
245        Err(ErrorContext::new_missing(
246            "Peer",
247            "VpnIpv4",
248            self.orig_loc,
249            self.buf.as_ptr() as usize,
250        ))
251    }
252    #[doc = "The IPv6 address assigned to the peer by the server\n"]
253    pub fn get_vpn_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
254        let mut iter = self.clone();
255        iter.pos = 0;
256        for attr in iter {
257            if let Ok(Peer::VpnIpv6(val)) = attr {
258                return Ok(val);
259            }
260        }
261        Err(ErrorContext::new_missing(
262            "Peer",
263            "VpnIpv6",
264            self.orig_loc,
265            self.buf.as_ptr() as usize,
266        ))
267    }
268    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
269    pub fn get_local_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
270        let mut iter = self.clone();
271        iter.pos = 0;
272        for attr in iter {
273            if let Ok(Peer::LocalIpv4(val)) = attr {
274                return Ok(val);
275            }
276        }
277        Err(ErrorContext::new_missing(
278            "Peer",
279            "LocalIpv4",
280            self.orig_loc,
281            self.buf.as_ptr() as usize,
282        ))
283    }
284    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
285    pub fn get_local_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
286        let mut iter = self.clone();
287        iter.pos = 0;
288        for attr in iter {
289            if let Ok(Peer::LocalIpv6(val)) = attr {
290                return Ok(val);
291            }
292        }
293        Err(ErrorContext::new_missing(
294            "Peer",
295            "LocalIpv6",
296            self.orig_loc,
297            self.buf.as_ptr() as usize,
298        ))
299    }
300    #[doc = "The local port to be used to send packets to the peer (UDP only)\n"]
301    pub fn get_local_port(&self) -> Result<u16, ErrorContext> {
302        let mut iter = self.clone();
303        iter.pos = 0;
304        for attr in iter {
305            if let Ok(Peer::LocalPort(val)) = attr {
306                return Ok(val);
307            }
308        }
309        Err(ErrorContext::new_missing(
310            "Peer",
311            "LocalPort",
312            self.orig_loc,
313            self.buf.as_ptr() as usize,
314        ))
315    }
316    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
317    pub fn get_keepalive_interval(&self) -> Result<u32, ErrorContext> {
318        let mut iter = self.clone();
319        iter.pos = 0;
320        for attr in iter {
321            if let Ok(Peer::KeepaliveInterval(val)) = attr {
322                return Ok(val);
323            }
324        }
325        Err(ErrorContext::new_missing(
326            "Peer",
327            "KeepaliveInterval",
328            self.orig_loc,
329            self.buf.as_ptr() as usize,
330        ))
331    }
332    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
333    pub fn get_keepalive_timeout(&self) -> Result<u32, ErrorContext> {
334        let mut iter = self.clone();
335        iter.pos = 0;
336        for attr in iter {
337            if let Ok(Peer::KeepaliveTimeout(val)) = attr {
338                return Ok(val);
339            }
340        }
341        Err(ErrorContext::new_missing(
342            "Peer",
343            "KeepaliveTimeout",
344            self.orig_loc,
345            self.buf.as_ptr() as usize,
346        ))
347    }
348    #[doc = "The reason why a peer was deleted\n\nAssociated type: [`DelPeerReason`] (enum)"]
349    pub fn get_del_reason(&self) -> Result<u32, ErrorContext> {
350        let mut iter = self.clone();
351        iter.pos = 0;
352        for attr in iter {
353            if let Ok(Peer::DelReason(val)) = attr {
354                return Ok(val);
355            }
356        }
357        Err(ErrorContext::new_missing(
358            "Peer",
359            "DelReason",
360            self.orig_loc,
361            self.buf.as_ptr() as usize,
362        ))
363    }
364    #[doc = "Number of bytes received over the tunnel\n"]
365    pub fn get_vpn_rx_bytes(&self) -> Result<u32, ErrorContext> {
366        let mut iter = self.clone();
367        iter.pos = 0;
368        for attr in iter {
369            if let Ok(Peer::VpnRxBytes(val)) = attr {
370                return Ok(val);
371            }
372        }
373        Err(ErrorContext::new_missing(
374            "Peer",
375            "VpnRxBytes",
376            self.orig_loc,
377            self.buf.as_ptr() as usize,
378        ))
379    }
380    #[doc = "Number of bytes transmitted over the tunnel\n"]
381    pub fn get_vpn_tx_bytes(&self) -> Result<u32, ErrorContext> {
382        let mut iter = self.clone();
383        iter.pos = 0;
384        for attr in iter {
385            if let Ok(Peer::VpnTxBytes(val)) = attr {
386                return Ok(val);
387            }
388        }
389        Err(ErrorContext::new_missing(
390            "Peer",
391            "VpnTxBytes",
392            self.orig_loc,
393            self.buf.as_ptr() as usize,
394        ))
395    }
396    #[doc = "Number of packets received over the tunnel\n"]
397    pub fn get_vpn_rx_packets(&self) -> Result<u32, ErrorContext> {
398        let mut iter = self.clone();
399        iter.pos = 0;
400        for attr in iter {
401            if let Ok(Peer::VpnRxPackets(val)) = attr {
402                return Ok(val);
403            }
404        }
405        Err(ErrorContext::new_missing(
406            "Peer",
407            "VpnRxPackets",
408            self.orig_loc,
409            self.buf.as_ptr() as usize,
410        ))
411    }
412    #[doc = "Number of packets transmitted over the tunnel\n"]
413    pub fn get_vpn_tx_packets(&self) -> Result<u32, ErrorContext> {
414        let mut iter = self.clone();
415        iter.pos = 0;
416        for attr in iter {
417            if let Ok(Peer::VpnTxPackets(val)) = attr {
418                return Ok(val);
419            }
420        }
421        Err(ErrorContext::new_missing(
422            "Peer",
423            "VpnTxPackets",
424            self.orig_loc,
425            self.buf.as_ptr() as usize,
426        ))
427    }
428    #[doc = "Number of bytes received at the transport level\n"]
429    pub fn get_link_rx_bytes(&self) -> Result<u32, ErrorContext> {
430        let mut iter = self.clone();
431        iter.pos = 0;
432        for attr in iter {
433            if let Ok(Peer::LinkRxBytes(val)) = attr {
434                return Ok(val);
435            }
436        }
437        Err(ErrorContext::new_missing(
438            "Peer",
439            "LinkRxBytes",
440            self.orig_loc,
441            self.buf.as_ptr() as usize,
442        ))
443    }
444    #[doc = "Number of bytes transmitted at the transport level\n"]
445    pub fn get_link_tx_bytes(&self) -> Result<u32, ErrorContext> {
446        let mut iter = self.clone();
447        iter.pos = 0;
448        for attr in iter {
449            if let Ok(Peer::LinkTxBytes(val)) = attr {
450                return Ok(val);
451            }
452        }
453        Err(ErrorContext::new_missing(
454            "Peer",
455            "LinkTxBytes",
456            self.orig_loc,
457            self.buf.as_ptr() as usize,
458        ))
459    }
460    #[doc = "Number of packets received at the transport level\n"]
461    pub fn get_link_rx_packets(&self) -> Result<u32, ErrorContext> {
462        let mut iter = self.clone();
463        iter.pos = 0;
464        for attr in iter {
465            if let Ok(Peer::LinkRxPackets(val)) = attr {
466                return Ok(val);
467            }
468        }
469        Err(ErrorContext::new_missing(
470            "Peer",
471            "LinkRxPackets",
472            self.orig_loc,
473            self.buf.as_ptr() as usize,
474        ))
475    }
476    #[doc = "Number of packets transmitted at the transport level\n"]
477    pub fn get_link_tx_packets(&self) -> Result<u32, ErrorContext> {
478        let mut iter = self.clone();
479        iter.pos = 0;
480        for attr in iter {
481            if let Ok(Peer::LinkTxPackets(val)) = attr {
482                return Ok(val);
483            }
484        }
485        Err(ErrorContext::new_missing(
486            "Peer",
487            "LinkTxPackets",
488            self.orig_loc,
489            self.buf.as_ptr() as usize,
490        ))
491    }
492    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
493    pub fn get_tx_id(&self) -> Result<u32, ErrorContext> {
494        let mut iter = self.clone();
495        iter.pos = 0;
496        for attr in iter {
497            if let Ok(Peer::TxId(val)) = attr {
498                return Ok(val);
499            }
500        }
501        Err(ErrorContext::new_missing(
502            "Peer",
503            "TxId",
504            self.orig_loc,
505            self.buf.as_ptr() as usize,
506        ))
507    }
508}
509impl Peer<'_> {
510    pub fn new<'a>(buf: &'a [u8]) -> IterablePeer<'a> {
511        IterablePeer::with_loc(buf, buf.as_ptr() as usize)
512    }
513    fn attr_from_type(r#type: u16) -> Option<&'static str> {
514        let res = match r#type {
515            1u16 => "Id",
516            2u16 => "RemoteIpv4",
517            3u16 => "RemoteIpv6",
518            4u16 => "RemoteIpv6ScopeId",
519            5u16 => "RemotePort",
520            6u16 => "Socket",
521            7u16 => "SocketNetnsid",
522            8u16 => "VpnIpv4",
523            9u16 => "VpnIpv6",
524            10u16 => "LocalIpv4",
525            11u16 => "LocalIpv6",
526            12u16 => "LocalPort",
527            13u16 => "KeepaliveInterval",
528            14u16 => "KeepaliveTimeout",
529            15u16 => "DelReason",
530            16u16 => "VpnRxBytes",
531            17u16 => "VpnTxBytes",
532            18u16 => "VpnRxPackets",
533            19u16 => "VpnTxPackets",
534            20u16 => "LinkRxBytes",
535            21u16 => "LinkTxBytes",
536            22u16 => "LinkRxPackets",
537            23u16 => "LinkTxPackets",
538            24u16 => "TxId",
539            _ => return None,
540        };
541        Some(res)
542    }
543}
544#[derive(Clone, Copy, Default)]
545pub struct IterablePeer<'a> {
546    buf: &'a [u8],
547    pos: usize,
548    orig_loc: usize,
549}
550impl<'a> IterablePeer<'a> {
551    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
552        Self {
553            buf,
554            pos: 0,
555            orig_loc,
556        }
557    }
558    pub fn get_buf(&self) -> &'a [u8] {
559        self.buf
560    }
561}
562impl<'a> Iterator for IterablePeer<'a> {
563    type Item = Result<Peer<'a>, ErrorContext>;
564    fn next(&mut self) -> Option<Self::Item> {
565        let mut pos;
566        let mut r#type;
567        loop {
568            pos = self.pos;
569            r#type = None;
570            if self.buf.len() == self.pos {
571                return None;
572            }
573            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
574                self.pos = self.buf.len();
575                break;
576            };
577            r#type = Some(header.r#type);
578            let res = match header.r#type {
579                1u16 => Peer::Id({
580                    let res = parse_u32(next);
581                    let Some(val) = res else { break };
582                    val
583                }),
584                2u16 => Peer::RemoteIpv4({
585                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
586                    let Some(val) = res else { break };
587                    val
588                }),
589                3u16 => Peer::RemoteIpv6({
590                    let res = Some(next);
591                    let Some(val) = res else { break };
592                    val
593                }),
594                4u16 => Peer::RemoteIpv6ScopeId({
595                    let res = parse_u32(next);
596                    let Some(val) = res else { break };
597                    val
598                }),
599                5u16 => Peer::RemotePort({
600                    let res = parse_be_u16(next);
601                    let Some(val) = res else { break };
602                    val
603                }),
604                6u16 => Peer::Socket({
605                    let res = parse_u32(next);
606                    let Some(val) = res else { break };
607                    val
608                }),
609                7u16 => Peer::SocketNetnsid({
610                    let res = parse_i32(next);
611                    let Some(val) = res else { break };
612                    val
613                }),
614                8u16 => Peer::VpnIpv4({
615                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
616                    let Some(val) = res else { break };
617                    val
618                }),
619                9u16 => Peer::VpnIpv6({
620                    let res = Some(next);
621                    let Some(val) = res else { break };
622                    val
623                }),
624                10u16 => Peer::LocalIpv4({
625                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
626                    let Some(val) = res else { break };
627                    val
628                }),
629                11u16 => Peer::LocalIpv6({
630                    let res = Some(next);
631                    let Some(val) = res else { break };
632                    val
633                }),
634                12u16 => Peer::LocalPort({
635                    let res = parse_be_u16(next);
636                    let Some(val) = res else { break };
637                    val
638                }),
639                13u16 => Peer::KeepaliveInterval({
640                    let res = parse_u32(next);
641                    let Some(val) = res else { break };
642                    val
643                }),
644                14u16 => Peer::KeepaliveTimeout({
645                    let res = parse_u32(next);
646                    let Some(val) = res else { break };
647                    val
648                }),
649                15u16 => Peer::DelReason({
650                    let res = parse_u32(next);
651                    let Some(val) = res else { break };
652                    val
653                }),
654                16u16 => Peer::VpnRxBytes({
655                    let res = parse_u32(next);
656                    let Some(val) = res else { break };
657                    val
658                }),
659                17u16 => Peer::VpnTxBytes({
660                    let res = parse_u32(next);
661                    let Some(val) = res else { break };
662                    val
663                }),
664                18u16 => Peer::VpnRxPackets({
665                    let res = parse_u32(next);
666                    let Some(val) = res else { break };
667                    val
668                }),
669                19u16 => Peer::VpnTxPackets({
670                    let res = parse_u32(next);
671                    let Some(val) = res else { break };
672                    val
673                }),
674                20u16 => Peer::LinkRxBytes({
675                    let res = parse_u32(next);
676                    let Some(val) = res else { break };
677                    val
678                }),
679                21u16 => Peer::LinkTxBytes({
680                    let res = parse_u32(next);
681                    let Some(val) = res else { break };
682                    val
683                }),
684                22u16 => Peer::LinkRxPackets({
685                    let res = parse_u32(next);
686                    let Some(val) = res else { break };
687                    val
688                }),
689                23u16 => Peer::LinkTxPackets({
690                    let res = parse_u32(next);
691                    let Some(val) = res else { break };
692                    val
693                }),
694                24u16 => Peer::TxId({
695                    let res = parse_u32(next);
696                    let Some(val) = res else { break };
697                    val
698                }),
699                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
700                n => continue,
701            };
702            return Some(Ok(res));
703        }
704        Some(Err(ErrorContext::new(
705            "Peer",
706            r#type.and_then(|t| Peer::attr_from_type(t)),
707            self.orig_loc,
708            self.buf.as_ptr().wrapping_add(pos) as usize,
709        )))
710    }
711}
712impl<'a> std::fmt::Debug for IterablePeer<'_> {
713    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
714        let mut fmt = f.debug_struct("Peer");
715        for attr in self.clone() {
716            let attr = match attr {
717                Ok(a) => a,
718                Err(err) => {
719                    fmt.finish()?;
720                    f.write_str("Err(")?;
721                    err.fmt(f)?;
722                    return f.write_str(")");
723                }
724            };
725            match attr {
726                Peer::Id(val) => fmt.field("Id", &val),
727                Peer::RemoteIpv4(val) => fmt.field("RemoteIpv4", &val),
728                Peer::RemoteIpv6(val) => fmt.field("RemoteIpv6", &val),
729                Peer::RemoteIpv6ScopeId(val) => fmt.field("RemoteIpv6ScopeId", &val),
730                Peer::RemotePort(val) => fmt.field("RemotePort", &val),
731                Peer::Socket(val) => fmt.field("Socket", &val),
732                Peer::SocketNetnsid(val) => fmt.field("SocketNetnsid", &val),
733                Peer::VpnIpv4(val) => fmt.field("VpnIpv4", &val),
734                Peer::VpnIpv6(val) => fmt.field("VpnIpv6", &val),
735                Peer::LocalIpv4(val) => fmt.field("LocalIpv4", &val),
736                Peer::LocalIpv6(val) => fmt.field("LocalIpv6", &val),
737                Peer::LocalPort(val) => fmt.field("LocalPort", &val),
738                Peer::KeepaliveInterval(val) => fmt.field("KeepaliveInterval", &val),
739                Peer::KeepaliveTimeout(val) => fmt.field("KeepaliveTimeout", &val),
740                Peer::DelReason(val) => fmt.field(
741                    "DelReason",
742                    &FormatEnum(val.into(), DelPeerReason::from_value),
743                ),
744                Peer::VpnRxBytes(val) => fmt.field("VpnRxBytes", &val),
745                Peer::VpnTxBytes(val) => fmt.field("VpnTxBytes", &val),
746                Peer::VpnRxPackets(val) => fmt.field("VpnRxPackets", &val),
747                Peer::VpnTxPackets(val) => fmt.field("VpnTxPackets", &val),
748                Peer::LinkRxBytes(val) => fmt.field("LinkRxBytes", &val),
749                Peer::LinkTxBytes(val) => fmt.field("LinkTxBytes", &val),
750                Peer::LinkRxPackets(val) => fmt.field("LinkRxPackets", &val),
751                Peer::LinkTxPackets(val) => fmt.field("LinkTxPackets", &val),
752                Peer::TxId(val) => fmt.field("TxId", &val),
753            };
754        }
755        fmt.finish()
756    }
757}
758impl IterablePeer<'_> {
759    pub fn lookup_attr(
760        &self,
761        offset: usize,
762        missing_type: Option<u16>,
763    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
764        let mut stack = Vec::new();
765        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
766        if missing_type.is_some() && cur == offset {
767            stack.push(("Peer", offset));
768            return (stack, missing_type.and_then(|t| Peer::attr_from_type(t)));
769        }
770        if cur > offset || cur + self.buf.len() < offset {
771            return (stack, None);
772        }
773        let mut attrs = self.clone();
774        let mut last_off = cur + attrs.pos;
775        while let Some(attr) = attrs.next() {
776            let Ok(attr) = attr else { break };
777            match attr {
778                Peer::Id(val) => {
779                    if last_off == offset {
780                        stack.push(("Id", last_off));
781                        break;
782                    }
783                }
784                Peer::RemoteIpv4(val) => {
785                    if last_off == offset {
786                        stack.push(("RemoteIpv4", last_off));
787                        break;
788                    }
789                }
790                Peer::RemoteIpv6(val) => {
791                    if last_off == offset {
792                        stack.push(("RemoteIpv6", last_off));
793                        break;
794                    }
795                }
796                Peer::RemoteIpv6ScopeId(val) => {
797                    if last_off == offset {
798                        stack.push(("RemoteIpv6ScopeId", last_off));
799                        break;
800                    }
801                }
802                Peer::RemotePort(val) => {
803                    if last_off == offset {
804                        stack.push(("RemotePort", last_off));
805                        break;
806                    }
807                }
808                Peer::Socket(val) => {
809                    if last_off == offset {
810                        stack.push(("Socket", last_off));
811                        break;
812                    }
813                }
814                Peer::SocketNetnsid(val) => {
815                    if last_off == offset {
816                        stack.push(("SocketNetnsid", last_off));
817                        break;
818                    }
819                }
820                Peer::VpnIpv4(val) => {
821                    if last_off == offset {
822                        stack.push(("VpnIpv4", last_off));
823                        break;
824                    }
825                }
826                Peer::VpnIpv6(val) => {
827                    if last_off == offset {
828                        stack.push(("VpnIpv6", last_off));
829                        break;
830                    }
831                }
832                Peer::LocalIpv4(val) => {
833                    if last_off == offset {
834                        stack.push(("LocalIpv4", last_off));
835                        break;
836                    }
837                }
838                Peer::LocalIpv6(val) => {
839                    if last_off == offset {
840                        stack.push(("LocalIpv6", last_off));
841                        break;
842                    }
843                }
844                Peer::LocalPort(val) => {
845                    if last_off == offset {
846                        stack.push(("LocalPort", last_off));
847                        break;
848                    }
849                }
850                Peer::KeepaliveInterval(val) => {
851                    if last_off == offset {
852                        stack.push(("KeepaliveInterval", last_off));
853                        break;
854                    }
855                }
856                Peer::KeepaliveTimeout(val) => {
857                    if last_off == offset {
858                        stack.push(("KeepaliveTimeout", last_off));
859                        break;
860                    }
861                }
862                Peer::DelReason(val) => {
863                    if last_off == offset {
864                        stack.push(("DelReason", last_off));
865                        break;
866                    }
867                }
868                Peer::VpnRxBytes(val) => {
869                    if last_off == offset {
870                        stack.push(("VpnRxBytes", last_off));
871                        break;
872                    }
873                }
874                Peer::VpnTxBytes(val) => {
875                    if last_off == offset {
876                        stack.push(("VpnTxBytes", last_off));
877                        break;
878                    }
879                }
880                Peer::VpnRxPackets(val) => {
881                    if last_off == offset {
882                        stack.push(("VpnRxPackets", last_off));
883                        break;
884                    }
885                }
886                Peer::VpnTxPackets(val) => {
887                    if last_off == offset {
888                        stack.push(("VpnTxPackets", last_off));
889                        break;
890                    }
891                }
892                Peer::LinkRxBytes(val) => {
893                    if last_off == offset {
894                        stack.push(("LinkRxBytes", last_off));
895                        break;
896                    }
897                }
898                Peer::LinkTxBytes(val) => {
899                    if last_off == offset {
900                        stack.push(("LinkTxBytes", last_off));
901                        break;
902                    }
903                }
904                Peer::LinkRxPackets(val) => {
905                    if last_off == offset {
906                        stack.push(("LinkRxPackets", last_off));
907                        break;
908                    }
909                }
910                Peer::LinkTxPackets(val) => {
911                    if last_off == offset {
912                        stack.push(("LinkTxPackets", last_off));
913                        break;
914                    }
915                }
916                Peer::TxId(val) => {
917                    if last_off == offset {
918                        stack.push(("TxId", last_off));
919                        break;
920                    }
921                }
922                _ => {}
923            };
924            last_off = cur + attrs.pos;
925        }
926        if !stack.is_empty() {
927            stack.push(("Peer", cur));
928        }
929        (stack, None)
930    }
931}
932#[derive(Clone)]
933pub enum PeerNewInput<'a> {
934    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
935    Id(u32),
936    #[doc = "The remote IPv4 address of the peer\n"]
937    RemoteIpv4(std::net::Ipv4Addr),
938    #[doc = "The remote IPv6 address of the peer\n"]
939    RemoteIpv6(&'a [u8]),
940    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
941    RemoteIpv6ScopeId(u32),
942    #[doc = "The remote port of the peer\n"]
943    RemotePort(u16),
944    #[doc = "The socket to be used to communicate with the peer\n"]
945    Socket(u32),
946    #[doc = "The IPv4 address assigned to the peer by the server\n"]
947    VpnIpv4(std::net::Ipv4Addr),
948    #[doc = "The IPv6 address assigned to the peer by the server\n"]
949    VpnIpv6(&'a [u8]),
950    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
951    LocalIpv4(std::net::Ipv4Addr),
952    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
953    LocalIpv6(&'a [u8]),
954    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
955    KeepaliveInterval(u32),
956    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
957    KeepaliveTimeout(u32),
958    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
959    TxId(u32),
960}
961impl<'a> IterablePeerNewInput<'a> {
962    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
963    pub fn get_id(&self) -> Result<u32, ErrorContext> {
964        let mut iter = self.clone();
965        iter.pos = 0;
966        for attr in iter {
967            if let Ok(PeerNewInput::Id(val)) = attr {
968                return Ok(val);
969            }
970        }
971        Err(ErrorContext::new_missing(
972            "PeerNewInput",
973            "Id",
974            self.orig_loc,
975            self.buf.as_ptr() as usize,
976        ))
977    }
978    #[doc = "The remote IPv4 address of the peer\n"]
979    pub fn get_remote_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
980        let mut iter = self.clone();
981        iter.pos = 0;
982        for attr in iter {
983            if let Ok(PeerNewInput::RemoteIpv4(val)) = attr {
984                return Ok(val);
985            }
986        }
987        Err(ErrorContext::new_missing(
988            "PeerNewInput",
989            "RemoteIpv4",
990            self.orig_loc,
991            self.buf.as_ptr() as usize,
992        ))
993    }
994    #[doc = "The remote IPv6 address of the peer\n"]
995    pub fn get_remote_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
996        let mut iter = self.clone();
997        iter.pos = 0;
998        for attr in iter {
999            if let Ok(PeerNewInput::RemoteIpv6(val)) = attr {
1000                return Ok(val);
1001            }
1002        }
1003        Err(ErrorContext::new_missing(
1004            "PeerNewInput",
1005            "RemoteIpv6",
1006            self.orig_loc,
1007            self.buf.as_ptr() as usize,
1008        ))
1009    }
1010    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
1011    pub fn get_remote_ipv6_scope_id(&self) -> Result<u32, ErrorContext> {
1012        let mut iter = self.clone();
1013        iter.pos = 0;
1014        for attr in iter {
1015            if let Ok(PeerNewInput::RemoteIpv6ScopeId(val)) = attr {
1016                return Ok(val);
1017            }
1018        }
1019        Err(ErrorContext::new_missing(
1020            "PeerNewInput",
1021            "RemoteIpv6ScopeId",
1022            self.orig_loc,
1023            self.buf.as_ptr() as usize,
1024        ))
1025    }
1026    #[doc = "The remote port of the peer\n"]
1027    pub fn get_remote_port(&self) -> Result<u16, ErrorContext> {
1028        let mut iter = self.clone();
1029        iter.pos = 0;
1030        for attr in iter {
1031            if let Ok(PeerNewInput::RemotePort(val)) = attr {
1032                return Ok(val);
1033            }
1034        }
1035        Err(ErrorContext::new_missing(
1036            "PeerNewInput",
1037            "RemotePort",
1038            self.orig_loc,
1039            self.buf.as_ptr() as usize,
1040        ))
1041    }
1042    #[doc = "The socket to be used to communicate with the peer\n"]
1043    pub fn get_socket(&self) -> Result<u32, ErrorContext> {
1044        let mut iter = self.clone();
1045        iter.pos = 0;
1046        for attr in iter {
1047            if let Ok(PeerNewInput::Socket(val)) = attr {
1048                return Ok(val);
1049            }
1050        }
1051        Err(ErrorContext::new_missing(
1052            "PeerNewInput",
1053            "Socket",
1054            self.orig_loc,
1055            self.buf.as_ptr() as usize,
1056        ))
1057    }
1058    #[doc = "The IPv4 address assigned to the peer by the server\n"]
1059    pub fn get_vpn_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
1060        let mut iter = self.clone();
1061        iter.pos = 0;
1062        for attr in iter {
1063            if let Ok(PeerNewInput::VpnIpv4(val)) = attr {
1064                return Ok(val);
1065            }
1066        }
1067        Err(ErrorContext::new_missing(
1068            "PeerNewInput",
1069            "VpnIpv4",
1070            self.orig_loc,
1071            self.buf.as_ptr() as usize,
1072        ))
1073    }
1074    #[doc = "The IPv6 address assigned to the peer by the server\n"]
1075    pub fn get_vpn_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
1076        let mut iter = self.clone();
1077        iter.pos = 0;
1078        for attr in iter {
1079            if let Ok(PeerNewInput::VpnIpv6(val)) = attr {
1080                return Ok(val);
1081            }
1082        }
1083        Err(ErrorContext::new_missing(
1084            "PeerNewInput",
1085            "VpnIpv6",
1086            self.orig_loc,
1087            self.buf.as_ptr() as usize,
1088        ))
1089    }
1090    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
1091    pub fn get_local_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
1092        let mut iter = self.clone();
1093        iter.pos = 0;
1094        for attr in iter {
1095            if let Ok(PeerNewInput::LocalIpv4(val)) = attr {
1096                return Ok(val);
1097            }
1098        }
1099        Err(ErrorContext::new_missing(
1100            "PeerNewInput",
1101            "LocalIpv4",
1102            self.orig_loc,
1103            self.buf.as_ptr() as usize,
1104        ))
1105    }
1106    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
1107    pub fn get_local_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
1108        let mut iter = self.clone();
1109        iter.pos = 0;
1110        for attr in iter {
1111            if let Ok(PeerNewInput::LocalIpv6(val)) = attr {
1112                return Ok(val);
1113            }
1114        }
1115        Err(ErrorContext::new_missing(
1116            "PeerNewInput",
1117            "LocalIpv6",
1118            self.orig_loc,
1119            self.buf.as_ptr() as usize,
1120        ))
1121    }
1122    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
1123    pub fn get_keepalive_interval(&self) -> Result<u32, ErrorContext> {
1124        let mut iter = self.clone();
1125        iter.pos = 0;
1126        for attr in iter {
1127            if let Ok(PeerNewInput::KeepaliveInterval(val)) = attr {
1128                return Ok(val);
1129            }
1130        }
1131        Err(ErrorContext::new_missing(
1132            "PeerNewInput",
1133            "KeepaliveInterval",
1134            self.orig_loc,
1135            self.buf.as_ptr() as usize,
1136        ))
1137    }
1138    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
1139    pub fn get_keepalive_timeout(&self) -> Result<u32, ErrorContext> {
1140        let mut iter = self.clone();
1141        iter.pos = 0;
1142        for attr in iter {
1143            if let Ok(PeerNewInput::KeepaliveTimeout(val)) = attr {
1144                return Ok(val);
1145            }
1146        }
1147        Err(ErrorContext::new_missing(
1148            "PeerNewInput",
1149            "KeepaliveTimeout",
1150            self.orig_loc,
1151            self.buf.as_ptr() as usize,
1152        ))
1153    }
1154    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
1155    pub fn get_tx_id(&self) -> Result<u32, ErrorContext> {
1156        let mut iter = self.clone();
1157        iter.pos = 0;
1158        for attr in iter {
1159            if let Ok(PeerNewInput::TxId(val)) = attr {
1160                return Ok(val);
1161            }
1162        }
1163        Err(ErrorContext::new_missing(
1164            "PeerNewInput",
1165            "TxId",
1166            self.orig_loc,
1167            self.buf.as_ptr() as usize,
1168        ))
1169    }
1170}
1171impl PeerNewInput<'_> {
1172    pub fn new<'a>(buf: &'a [u8]) -> IterablePeerNewInput<'a> {
1173        IterablePeerNewInput::with_loc(buf, buf.as_ptr() as usize)
1174    }
1175    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1176        Peer::attr_from_type(r#type)
1177    }
1178}
1179#[derive(Clone, Copy, Default)]
1180pub struct IterablePeerNewInput<'a> {
1181    buf: &'a [u8],
1182    pos: usize,
1183    orig_loc: usize,
1184}
1185impl<'a> IterablePeerNewInput<'a> {
1186    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1187        Self {
1188            buf,
1189            pos: 0,
1190            orig_loc,
1191        }
1192    }
1193    pub fn get_buf(&self) -> &'a [u8] {
1194        self.buf
1195    }
1196}
1197impl<'a> Iterator for IterablePeerNewInput<'a> {
1198    type Item = Result<PeerNewInput<'a>, ErrorContext>;
1199    fn next(&mut self) -> Option<Self::Item> {
1200        let mut pos;
1201        let mut r#type;
1202        loop {
1203            pos = self.pos;
1204            r#type = None;
1205            if self.buf.len() == self.pos {
1206                return None;
1207            }
1208            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1209                self.pos = self.buf.len();
1210                break;
1211            };
1212            r#type = Some(header.r#type);
1213            let res = match header.r#type {
1214                1u16 => PeerNewInput::Id({
1215                    let res = parse_u32(next);
1216                    let Some(val) = res else { break };
1217                    val
1218                }),
1219                2u16 => PeerNewInput::RemoteIpv4({
1220                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
1221                    let Some(val) = res else { break };
1222                    val
1223                }),
1224                3u16 => PeerNewInput::RemoteIpv6({
1225                    let res = Some(next);
1226                    let Some(val) = res else { break };
1227                    val
1228                }),
1229                4u16 => PeerNewInput::RemoteIpv6ScopeId({
1230                    let res = parse_u32(next);
1231                    let Some(val) = res else { break };
1232                    val
1233                }),
1234                5u16 => PeerNewInput::RemotePort({
1235                    let res = parse_be_u16(next);
1236                    let Some(val) = res else { break };
1237                    val
1238                }),
1239                6u16 => PeerNewInput::Socket({
1240                    let res = parse_u32(next);
1241                    let Some(val) = res else { break };
1242                    val
1243                }),
1244                8u16 => PeerNewInput::VpnIpv4({
1245                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
1246                    let Some(val) = res else { break };
1247                    val
1248                }),
1249                9u16 => PeerNewInput::VpnIpv6({
1250                    let res = Some(next);
1251                    let Some(val) = res else { break };
1252                    val
1253                }),
1254                10u16 => PeerNewInput::LocalIpv4({
1255                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
1256                    let Some(val) = res else { break };
1257                    val
1258                }),
1259                11u16 => PeerNewInput::LocalIpv6({
1260                    let res = Some(next);
1261                    let Some(val) = res else { break };
1262                    val
1263                }),
1264                13u16 => PeerNewInput::KeepaliveInterval({
1265                    let res = parse_u32(next);
1266                    let Some(val) = res else { break };
1267                    val
1268                }),
1269                14u16 => PeerNewInput::KeepaliveTimeout({
1270                    let res = parse_u32(next);
1271                    let Some(val) = res else { break };
1272                    val
1273                }),
1274                24u16 => PeerNewInput::TxId({
1275                    let res = parse_u32(next);
1276                    let Some(val) = res else { break };
1277                    val
1278                }),
1279                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1280                n => continue,
1281            };
1282            return Some(Ok(res));
1283        }
1284        Some(Err(ErrorContext::new(
1285            "PeerNewInput",
1286            r#type.and_then(|t| PeerNewInput::attr_from_type(t)),
1287            self.orig_loc,
1288            self.buf.as_ptr().wrapping_add(pos) as usize,
1289        )))
1290    }
1291}
1292impl<'a> std::fmt::Debug for IterablePeerNewInput<'_> {
1293    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1294        let mut fmt = f.debug_struct("PeerNewInput");
1295        for attr in self.clone() {
1296            let attr = match attr {
1297                Ok(a) => a,
1298                Err(err) => {
1299                    fmt.finish()?;
1300                    f.write_str("Err(")?;
1301                    err.fmt(f)?;
1302                    return f.write_str(")");
1303                }
1304            };
1305            match attr {
1306                PeerNewInput::Id(val) => fmt.field("Id", &val),
1307                PeerNewInput::RemoteIpv4(val) => fmt.field("RemoteIpv4", &val),
1308                PeerNewInput::RemoteIpv6(val) => fmt.field("RemoteIpv6", &val),
1309                PeerNewInput::RemoteIpv6ScopeId(val) => fmt.field("RemoteIpv6ScopeId", &val),
1310                PeerNewInput::RemotePort(val) => fmt.field("RemotePort", &val),
1311                PeerNewInput::Socket(val) => fmt.field("Socket", &val),
1312                PeerNewInput::VpnIpv4(val) => fmt.field("VpnIpv4", &val),
1313                PeerNewInput::VpnIpv6(val) => fmt.field("VpnIpv6", &val),
1314                PeerNewInput::LocalIpv4(val) => fmt.field("LocalIpv4", &val),
1315                PeerNewInput::LocalIpv6(val) => fmt.field("LocalIpv6", &val),
1316                PeerNewInput::KeepaliveInterval(val) => fmt.field("KeepaliveInterval", &val),
1317                PeerNewInput::KeepaliveTimeout(val) => fmt.field("KeepaliveTimeout", &val),
1318                PeerNewInput::TxId(val) => fmt.field("TxId", &val),
1319            };
1320        }
1321        fmt.finish()
1322    }
1323}
1324impl IterablePeerNewInput<'_> {
1325    pub fn lookup_attr(
1326        &self,
1327        offset: usize,
1328        missing_type: Option<u16>,
1329    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
1330        let mut stack = Vec::new();
1331        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
1332        if missing_type.is_some() && cur == offset {
1333            stack.push(("PeerNewInput", offset));
1334            return (
1335                stack,
1336                missing_type.and_then(|t| PeerNewInput::attr_from_type(t)),
1337            );
1338        }
1339        if cur > offset || cur + self.buf.len() < offset {
1340            return (stack, None);
1341        }
1342        let mut attrs = self.clone();
1343        let mut last_off = cur + attrs.pos;
1344        while let Some(attr) = attrs.next() {
1345            let Ok(attr) = attr else { break };
1346            match attr {
1347                PeerNewInput::Id(val) => {
1348                    if last_off == offset {
1349                        stack.push(("Id", last_off));
1350                        break;
1351                    }
1352                }
1353                PeerNewInput::RemoteIpv4(val) => {
1354                    if last_off == offset {
1355                        stack.push(("RemoteIpv4", last_off));
1356                        break;
1357                    }
1358                }
1359                PeerNewInput::RemoteIpv6(val) => {
1360                    if last_off == offset {
1361                        stack.push(("RemoteIpv6", last_off));
1362                        break;
1363                    }
1364                }
1365                PeerNewInput::RemoteIpv6ScopeId(val) => {
1366                    if last_off == offset {
1367                        stack.push(("RemoteIpv6ScopeId", last_off));
1368                        break;
1369                    }
1370                }
1371                PeerNewInput::RemotePort(val) => {
1372                    if last_off == offset {
1373                        stack.push(("RemotePort", last_off));
1374                        break;
1375                    }
1376                }
1377                PeerNewInput::Socket(val) => {
1378                    if last_off == offset {
1379                        stack.push(("Socket", last_off));
1380                        break;
1381                    }
1382                }
1383                PeerNewInput::VpnIpv4(val) => {
1384                    if last_off == offset {
1385                        stack.push(("VpnIpv4", last_off));
1386                        break;
1387                    }
1388                }
1389                PeerNewInput::VpnIpv6(val) => {
1390                    if last_off == offset {
1391                        stack.push(("VpnIpv6", last_off));
1392                        break;
1393                    }
1394                }
1395                PeerNewInput::LocalIpv4(val) => {
1396                    if last_off == offset {
1397                        stack.push(("LocalIpv4", last_off));
1398                        break;
1399                    }
1400                }
1401                PeerNewInput::LocalIpv6(val) => {
1402                    if last_off == offset {
1403                        stack.push(("LocalIpv6", last_off));
1404                        break;
1405                    }
1406                }
1407                PeerNewInput::KeepaliveInterval(val) => {
1408                    if last_off == offset {
1409                        stack.push(("KeepaliveInterval", last_off));
1410                        break;
1411                    }
1412                }
1413                PeerNewInput::KeepaliveTimeout(val) => {
1414                    if last_off == offset {
1415                        stack.push(("KeepaliveTimeout", last_off));
1416                        break;
1417                    }
1418                }
1419                PeerNewInput::TxId(val) => {
1420                    if last_off == offset {
1421                        stack.push(("TxId", last_off));
1422                        break;
1423                    }
1424                }
1425                _ => {}
1426            };
1427            last_off = cur + attrs.pos;
1428        }
1429        if !stack.is_empty() {
1430            stack.push(("PeerNewInput", cur));
1431        }
1432        (stack, None)
1433    }
1434}
1435#[derive(Clone)]
1436pub enum PeerSetInput<'a> {
1437    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
1438    Id(u32),
1439    #[doc = "The remote IPv4 address of the peer\n"]
1440    RemoteIpv4(std::net::Ipv4Addr),
1441    #[doc = "The remote IPv6 address of the peer\n"]
1442    RemoteIpv6(&'a [u8]),
1443    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
1444    RemoteIpv6ScopeId(u32),
1445    #[doc = "The remote port of the peer\n"]
1446    RemotePort(u16),
1447    #[doc = "The IPv4 address assigned to the peer by the server\n"]
1448    VpnIpv4(std::net::Ipv4Addr),
1449    #[doc = "The IPv6 address assigned to the peer by the server\n"]
1450    VpnIpv6(&'a [u8]),
1451    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
1452    LocalIpv4(std::net::Ipv4Addr),
1453    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
1454    LocalIpv6(&'a [u8]),
1455    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
1456    KeepaliveInterval(u32),
1457    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
1458    KeepaliveTimeout(u32),
1459    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
1460    TxId(u32),
1461}
1462impl<'a> IterablePeerSetInput<'a> {
1463    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
1464    pub fn get_id(&self) -> Result<u32, ErrorContext> {
1465        let mut iter = self.clone();
1466        iter.pos = 0;
1467        for attr in iter {
1468            if let Ok(PeerSetInput::Id(val)) = attr {
1469                return Ok(val);
1470            }
1471        }
1472        Err(ErrorContext::new_missing(
1473            "PeerSetInput",
1474            "Id",
1475            self.orig_loc,
1476            self.buf.as_ptr() as usize,
1477        ))
1478    }
1479    #[doc = "The remote IPv4 address of the peer\n"]
1480    pub fn get_remote_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
1481        let mut iter = self.clone();
1482        iter.pos = 0;
1483        for attr in iter {
1484            if let Ok(PeerSetInput::RemoteIpv4(val)) = attr {
1485                return Ok(val);
1486            }
1487        }
1488        Err(ErrorContext::new_missing(
1489            "PeerSetInput",
1490            "RemoteIpv4",
1491            self.orig_loc,
1492            self.buf.as_ptr() as usize,
1493        ))
1494    }
1495    #[doc = "The remote IPv6 address of the peer\n"]
1496    pub fn get_remote_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
1497        let mut iter = self.clone();
1498        iter.pos = 0;
1499        for attr in iter {
1500            if let Ok(PeerSetInput::RemoteIpv6(val)) = attr {
1501                return Ok(val);
1502            }
1503        }
1504        Err(ErrorContext::new_missing(
1505            "PeerSetInput",
1506            "RemoteIpv6",
1507            self.orig_loc,
1508            self.buf.as_ptr() as usize,
1509        ))
1510    }
1511    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
1512    pub fn get_remote_ipv6_scope_id(&self) -> Result<u32, ErrorContext> {
1513        let mut iter = self.clone();
1514        iter.pos = 0;
1515        for attr in iter {
1516            if let Ok(PeerSetInput::RemoteIpv6ScopeId(val)) = attr {
1517                return Ok(val);
1518            }
1519        }
1520        Err(ErrorContext::new_missing(
1521            "PeerSetInput",
1522            "RemoteIpv6ScopeId",
1523            self.orig_loc,
1524            self.buf.as_ptr() as usize,
1525        ))
1526    }
1527    #[doc = "The remote port of the peer\n"]
1528    pub fn get_remote_port(&self) -> Result<u16, ErrorContext> {
1529        let mut iter = self.clone();
1530        iter.pos = 0;
1531        for attr in iter {
1532            if let Ok(PeerSetInput::RemotePort(val)) = attr {
1533                return Ok(val);
1534            }
1535        }
1536        Err(ErrorContext::new_missing(
1537            "PeerSetInput",
1538            "RemotePort",
1539            self.orig_loc,
1540            self.buf.as_ptr() as usize,
1541        ))
1542    }
1543    #[doc = "The IPv4 address assigned to the peer by the server\n"]
1544    pub fn get_vpn_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
1545        let mut iter = self.clone();
1546        iter.pos = 0;
1547        for attr in iter {
1548            if let Ok(PeerSetInput::VpnIpv4(val)) = attr {
1549                return Ok(val);
1550            }
1551        }
1552        Err(ErrorContext::new_missing(
1553            "PeerSetInput",
1554            "VpnIpv4",
1555            self.orig_loc,
1556            self.buf.as_ptr() as usize,
1557        ))
1558    }
1559    #[doc = "The IPv6 address assigned to the peer by the server\n"]
1560    pub fn get_vpn_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
1561        let mut iter = self.clone();
1562        iter.pos = 0;
1563        for attr in iter {
1564            if let Ok(PeerSetInput::VpnIpv6(val)) = attr {
1565                return Ok(val);
1566            }
1567        }
1568        Err(ErrorContext::new_missing(
1569            "PeerSetInput",
1570            "VpnIpv6",
1571            self.orig_loc,
1572            self.buf.as_ptr() as usize,
1573        ))
1574    }
1575    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
1576    pub fn get_local_ipv4(&self) -> Result<std::net::Ipv4Addr, ErrorContext> {
1577        let mut iter = self.clone();
1578        iter.pos = 0;
1579        for attr in iter {
1580            if let Ok(PeerSetInput::LocalIpv4(val)) = attr {
1581                return Ok(val);
1582            }
1583        }
1584        Err(ErrorContext::new_missing(
1585            "PeerSetInput",
1586            "LocalIpv4",
1587            self.orig_loc,
1588            self.buf.as_ptr() as usize,
1589        ))
1590    }
1591    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
1592    pub fn get_local_ipv6(&self) -> Result<&'a [u8], ErrorContext> {
1593        let mut iter = self.clone();
1594        iter.pos = 0;
1595        for attr in iter {
1596            if let Ok(PeerSetInput::LocalIpv6(val)) = attr {
1597                return Ok(val);
1598            }
1599        }
1600        Err(ErrorContext::new_missing(
1601            "PeerSetInput",
1602            "LocalIpv6",
1603            self.orig_loc,
1604            self.buf.as_ptr() as usize,
1605        ))
1606    }
1607    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
1608    pub fn get_keepalive_interval(&self) -> Result<u32, ErrorContext> {
1609        let mut iter = self.clone();
1610        iter.pos = 0;
1611        for attr in iter {
1612            if let Ok(PeerSetInput::KeepaliveInterval(val)) = attr {
1613                return Ok(val);
1614            }
1615        }
1616        Err(ErrorContext::new_missing(
1617            "PeerSetInput",
1618            "KeepaliveInterval",
1619            self.orig_loc,
1620            self.buf.as_ptr() as usize,
1621        ))
1622    }
1623    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
1624    pub fn get_keepalive_timeout(&self) -> Result<u32, ErrorContext> {
1625        let mut iter = self.clone();
1626        iter.pos = 0;
1627        for attr in iter {
1628            if let Ok(PeerSetInput::KeepaliveTimeout(val)) = attr {
1629                return Ok(val);
1630            }
1631        }
1632        Err(ErrorContext::new_missing(
1633            "PeerSetInput",
1634            "KeepaliveTimeout",
1635            self.orig_loc,
1636            self.buf.as_ptr() as usize,
1637        ))
1638    }
1639    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
1640    pub fn get_tx_id(&self) -> Result<u32, ErrorContext> {
1641        let mut iter = self.clone();
1642        iter.pos = 0;
1643        for attr in iter {
1644            if let Ok(PeerSetInput::TxId(val)) = attr {
1645                return Ok(val);
1646            }
1647        }
1648        Err(ErrorContext::new_missing(
1649            "PeerSetInput",
1650            "TxId",
1651            self.orig_loc,
1652            self.buf.as_ptr() as usize,
1653        ))
1654    }
1655}
1656impl PeerSetInput<'_> {
1657    pub fn new<'a>(buf: &'a [u8]) -> IterablePeerSetInput<'a> {
1658        IterablePeerSetInput::with_loc(buf, buf.as_ptr() as usize)
1659    }
1660    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1661        Peer::attr_from_type(r#type)
1662    }
1663}
1664#[derive(Clone, Copy, Default)]
1665pub struct IterablePeerSetInput<'a> {
1666    buf: &'a [u8],
1667    pos: usize,
1668    orig_loc: usize,
1669}
1670impl<'a> IterablePeerSetInput<'a> {
1671    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1672        Self {
1673            buf,
1674            pos: 0,
1675            orig_loc,
1676        }
1677    }
1678    pub fn get_buf(&self) -> &'a [u8] {
1679        self.buf
1680    }
1681}
1682impl<'a> Iterator for IterablePeerSetInput<'a> {
1683    type Item = Result<PeerSetInput<'a>, ErrorContext>;
1684    fn next(&mut self) -> Option<Self::Item> {
1685        let mut pos;
1686        let mut r#type;
1687        loop {
1688            pos = self.pos;
1689            r#type = None;
1690            if self.buf.len() == self.pos {
1691                return None;
1692            }
1693            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1694                self.pos = self.buf.len();
1695                break;
1696            };
1697            r#type = Some(header.r#type);
1698            let res = match header.r#type {
1699                1u16 => PeerSetInput::Id({
1700                    let res = parse_u32(next);
1701                    let Some(val) = res else { break };
1702                    val
1703                }),
1704                2u16 => PeerSetInput::RemoteIpv4({
1705                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
1706                    let Some(val) = res else { break };
1707                    val
1708                }),
1709                3u16 => PeerSetInput::RemoteIpv6({
1710                    let res = Some(next);
1711                    let Some(val) = res else { break };
1712                    val
1713                }),
1714                4u16 => PeerSetInput::RemoteIpv6ScopeId({
1715                    let res = parse_u32(next);
1716                    let Some(val) = res else { break };
1717                    val
1718                }),
1719                5u16 => PeerSetInput::RemotePort({
1720                    let res = parse_be_u16(next);
1721                    let Some(val) = res else { break };
1722                    val
1723                }),
1724                8u16 => PeerSetInput::VpnIpv4({
1725                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
1726                    let Some(val) = res else { break };
1727                    val
1728                }),
1729                9u16 => PeerSetInput::VpnIpv6({
1730                    let res = Some(next);
1731                    let Some(val) = res else { break };
1732                    val
1733                }),
1734                10u16 => PeerSetInput::LocalIpv4({
1735                    let res = parse_be_u32(next).map(Ipv4Addr::from_bits);
1736                    let Some(val) = res else { break };
1737                    val
1738                }),
1739                11u16 => PeerSetInput::LocalIpv6({
1740                    let res = Some(next);
1741                    let Some(val) = res else { break };
1742                    val
1743                }),
1744                13u16 => PeerSetInput::KeepaliveInterval({
1745                    let res = parse_u32(next);
1746                    let Some(val) = res else { break };
1747                    val
1748                }),
1749                14u16 => PeerSetInput::KeepaliveTimeout({
1750                    let res = parse_u32(next);
1751                    let Some(val) = res else { break };
1752                    val
1753                }),
1754                24u16 => PeerSetInput::TxId({
1755                    let res = parse_u32(next);
1756                    let Some(val) = res else { break };
1757                    val
1758                }),
1759                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1760                n => continue,
1761            };
1762            return Some(Ok(res));
1763        }
1764        Some(Err(ErrorContext::new(
1765            "PeerSetInput",
1766            r#type.and_then(|t| PeerSetInput::attr_from_type(t)),
1767            self.orig_loc,
1768            self.buf.as_ptr().wrapping_add(pos) as usize,
1769        )))
1770    }
1771}
1772impl<'a> std::fmt::Debug for IterablePeerSetInput<'_> {
1773    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1774        let mut fmt = f.debug_struct("PeerSetInput");
1775        for attr in self.clone() {
1776            let attr = match attr {
1777                Ok(a) => a,
1778                Err(err) => {
1779                    fmt.finish()?;
1780                    f.write_str("Err(")?;
1781                    err.fmt(f)?;
1782                    return f.write_str(")");
1783                }
1784            };
1785            match attr {
1786                PeerSetInput::Id(val) => fmt.field("Id", &val),
1787                PeerSetInput::RemoteIpv4(val) => fmt.field("RemoteIpv4", &val),
1788                PeerSetInput::RemoteIpv6(val) => fmt.field("RemoteIpv6", &val),
1789                PeerSetInput::RemoteIpv6ScopeId(val) => fmt.field("RemoteIpv6ScopeId", &val),
1790                PeerSetInput::RemotePort(val) => fmt.field("RemotePort", &val),
1791                PeerSetInput::VpnIpv4(val) => fmt.field("VpnIpv4", &val),
1792                PeerSetInput::VpnIpv6(val) => fmt.field("VpnIpv6", &val),
1793                PeerSetInput::LocalIpv4(val) => fmt.field("LocalIpv4", &val),
1794                PeerSetInput::LocalIpv6(val) => fmt.field("LocalIpv6", &val),
1795                PeerSetInput::KeepaliveInterval(val) => fmt.field("KeepaliveInterval", &val),
1796                PeerSetInput::KeepaliveTimeout(val) => fmt.field("KeepaliveTimeout", &val),
1797                PeerSetInput::TxId(val) => fmt.field("TxId", &val),
1798            };
1799        }
1800        fmt.finish()
1801    }
1802}
1803impl IterablePeerSetInput<'_> {
1804    pub fn lookup_attr(
1805        &self,
1806        offset: usize,
1807        missing_type: Option<u16>,
1808    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
1809        let mut stack = Vec::new();
1810        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
1811        if missing_type.is_some() && cur == offset {
1812            stack.push(("PeerSetInput", offset));
1813            return (
1814                stack,
1815                missing_type.and_then(|t| PeerSetInput::attr_from_type(t)),
1816            );
1817        }
1818        if cur > offset || cur + self.buf.len() < offset {
1819            return (stack, None);
1820        }
1821        let mut attrs = self.clone();
1822        let mut last_off = cur + attrs.pos;
1823        while let Some(attr) = attrs.next() {
1824            let Ok(attr) = attr else { break };
1825            match attr {
1826                PeerSetInput::Id(val) => {
1827                    if last_off == offset {
1828                        stack.push(("Id", last_off));
1829                        break;
1830                    }
1831                }
1832                PeerSetInput::RemoteIpv4(val) => {
1833                    if last_off == offset {
1834                        stack.push(("RemoteIpv4", last_off));
1835                        break;
1836                    }
1837                }
1838                PeerSetInput::RemoteIpv6(val) => {
1839                    if last_off == offset {
1840                        stack.push(("RemoteIpv6", last_off));
1841                        break;
1842                    }
1843                }
1844                PeerSetInput::RemoteIpv6ScopeId(val) => {
1845                    if last_off == offset {
1846                        stack.push(("RemoteIpv6ScopeId", last_off));
1847                        break;
1848                    }
1849                }
1850                PeerSetInput::RemotePort(val) => {
1851                    if last_off == offset {
1852                        stack.push(("RemotePort", last_off));
1853                        break;
1854                    }
1855                }
1856                PeerSetInput::VpnIpv4(val) => {
1857                    if last_off == offset {
1858                        stack.push(("VpnIpv4", last_off));
1859                        break;
1860                    }
1861                }
1862                PeerSetInput::VpnIpv6(val) => {
1863                    if last_off == offset {
1864                        stack.push(("VpnIpv6", last_off));
1865                        break;
1866                    }
1867                }
1868                PeerSetInput::LocalIpv4(val) => {
1869                    if last_off == offset {
1870                        stack.push(("LocalIpv4", last_off));
1871                        break;
1872                    }
1873                }
1874                PeerSetInput::LocalIpv6(val) => {
1875                    if last_off == offset {
1876                        stack.push(("LocalIpv6", last_off));
1877                        break;
1878                    }
1879                }
1880                PeerSetInput::KeepaliveInterval(val) => {
1881                    if last_off == offset {
1882                        stack.push(("KeepaliveInterval", last_off));
1883                        break;
1884                    }
1885                }
1886                PeerSetInput::KeepaliveTimeout(val) => {
1887                    if last_off == offset {
1888                        stack.push(("KeepaliveTimeout", last_off));
1889                        break;
1890                    }
1891                }
1892                PeerSetInput::TxId(val) => {
1893                    if last_off == offset {
1894                        stack.push(("TxId", last_off));
1895                        break;
1896                    }
1897                }
1898                _ => {}
1899            };
1900            last_off = cur + attrs.pos;
1901        }
1902        if !stack.is_empty() {
1903            stack.push(("PeerSetInput", cur));
1904        }
1905        (stack, None)
1906    }
1907}
1908#[derive(Clone)]
1909pub enum PeerDelInput {
1910    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
1911    Id(u32),
1912}
1913impl<'a> IterablePeerDelInput<'a> {
1914    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
1915    pub fn get_id(&self) -> Result<u32, ErrorContext> {
1916        let mut iter = self.clone();
1917        iter.pos = 0;
1918        for attr in iter {
1919            if let Ok(PeerDelInput::Id(val)) = attr {
1920                return Ok(val);
1921            }
1922        }
1923        Err(ErrorContext::new_missing(
1924            "PeerDelInput",
1925            "Id",
1926            self.orig_loc,
1927            self.buf.as_ptr() as usize,
1928        ))
1929    }
1930}
1931impl PeerDelInput {
1932    pub fn new<'a>(buf: &'a [u8]) -> IterablePeerDelInput<'a> {
1933        IterablePeerDelInput::with_loc(buf, buf.as_ptr() as usize)
1934    }
1935    fn attr_from_type(r#type: u16) -> Option<&'static str> {
1936        Peer::attr_from_type(r#type)
1937    }
1938}
1939#[derive(Clone, Copy, Default)]
1940pub struct IterablePeerDelInput<'a> {
1941    buf: &'a [u8],
1942    pos: usize,
1943    orig_loc: usize,
1944}
1945impl<'a> IterablePeerDelInput<'a> {
1946    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1947        Self {
1948            buf,
1949            pos: 0,
1950            orig_loc,
1951        }
1952    }
1953    pub fn get_buf(&self) -> &'a [u8] {
1954        self.buf
1955    }
1956}
1957impl<'a> Iterator for IterablePeerDelInput<'a> {
1958    type Item = Result<PeerDelInput, ErrorContext>;
1959    fn next(&mut self) -> Option<Self::Item> {
1960        let mut pos;
1961        let mut r#type;
1962        loop {
1963            pos = self.pos;
1964            r#type = None;
1965            if self.buf.len() == self.pos {
1966                return None;
1967            }
1968            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1969                self.pos = self.buf.len();
1970                break;
1971            };
1972            r#type = Some(header.r#type);
1973            let res = match header.r#type {
1974                1u16 => PeerDelInput::Id({
1975                    let res = parse_u32(next);
1976                    let Some(val) = res else { break };
1977                    val
1978                }),
1979                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1980                n => continue,
1981            };
1982            return Some(Ok(res));
1983        }
1984        Some(Err(ErrorContext::new(
1985            "PeerDelInput",
1986            r#type.and_then(|t| PeerDelInput::attr_from_type(t)),
1987            self.orig_loc,
1988            self.buf.as_ptr().wrapping_add(pos) as usize,
1989        )))
1990    }
1991}
1992impl std::fmt::Debug for IterablePeerDelInput<'_> {
1993    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1994        let mut fmt = f.debug_struct("PeerDelInput");
1995        for attr in self.clone() {
1996            let attr = match attr {
1997                Ok(a) => a,
1998                Err(err) => {
1999                    fmt.finish()?;
2000                    f.write_str("Err(")?;
2001                    err.fmt(f)?;
2002                    return f.write_str(")");
2003                }
2004            };
2005            match attr {
2006                PeerDelInput::Id(val) => fmt.field("Id", &val),
2007            };
2008        }
2009        fmt.finish()
2010    }
2011}
2012impl IterablePeerDelInput<'_> {
2013    pub fn lookup_attr(
2014        &self,
2015        offset: usize,
2016        missing_type: Option<u16>,
2017    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2018        let mut stack = Vec::new();
2019        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2020        if missing_type.is_some() && cur == offset {
2021            stack.push(("PeerDelInput", offset));
2022            return (
2023                stack,
2024                missing_type.and_then(|t| PeerDelInput::attr_from_type(t)),
2025            );
2026        }
2027        if cur > offset || cur + self.buf.len() < offset {
2028            return (stack, None);
2029        }
2030        let mut attrs = self.clone();
2031        let mut last_off = cur + attrs.pos;
2032        while let Some(attr) = attrs.next() {
2033            let Ok(attr) = attr else { break };
2034            match attr {
2035                PeerDelInput::Id(val) => {
2036                    if last_off == offset {
2037                        stack.push(("Id", last_off));
2038                        break;
2039                    }
2040                }
2041                _ => {}
2042            };
2043            last_off = cur + attrs.pos;
2044        }
2045        if !stack.is_empty() {
2046            stack.push(("PeerDelInput", cur));
2047        }
2048        (stack, None)
2049    }
2050}
2051#[derive(Clone)]
2052pub enum Keyconf<'a> {
2053    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
2054    PeerId(u32),
2055    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
2056    Slot(u32),
2057    #[doc = "The unique ID of the key in the peer context. Used to fetch the correct\nkey upon decryption\n"]
2058    KeyId(u32),
2059    #[doc = "The cipher to be used when communicating with the peer\n\nAssociated type: [`CipherAlg`] (enum)"]
2060    CipherAlg(u32),
2061    #[doc = "Key material for encrypt direction\n"]
2062    EncryptDir(IterableKeydir<'a>),
2063    #[doc = "Key material for decrypt direction\n"]
2064    DecryptDir(IterableKeydir<'a>),
2065}
2066impl<'a> IterableKeyconf<'a> {
2067    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
2068    pub fn get_peer_id(&self) -> Result<u32, ErrorContext> {
2069        let mut iter = self.clone();
2070        iter.pos = 0;
2071        for attr in iter {
2072            if let Ok(Keyconf::PeerId(val)) = attr {
2073                return Ok(val);
2074            }
2075        }
2076        Err(ErrorContext::new_missing(
2077            "Keyconf",
2078            "PeerId",
2079            self.orig_loc,
2080            self.buf.as_ptr() as usize,
2081        ))
2082    }
2083    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
2084    pub fn get_slot(&self) -> Result<u32, ErrorContext> {
2085        let mut iter = self.clone();
2086        iter.pos = 0;
2087        for attr in iter {
2088            if let Ok(Keyconf::Slot(val)) = attr {
2089                return Ok(val);
2090            }
2091        }
2092        Err(ErrorContext::new_missing(
2093            "Keyconf",
2094            "Slot",
2095            self.orig_loc,
2096            self.buf.as_ptr() as usize,
2097        ))
2098    }
2099    #[doc = "The unique ID of the key in the peer context. Used to fetch the correct\nkey upon decryption\n"]
2100    pub fn get_key_id(&self) -> Result<u32, ErrorContext> {
2101        let mut iter = self.clone();
2102        iter.pos = 0;
2103        for attr in iter {
2104            if let Ok(Keyconf::KeyId(val)) = attr {
2105                return Ok(val);
2106            }
2107        }
2108        Err(ErrorContext::new_missing(
2109            "Keyconf",
2110            "KeyId",
2111            self.orig_loc,
2112            self.buf.as_ptr() as usize,
2113        ))
2114    }
2115    #[doc = "The cipher to be used when communicating with the peer\n\nAssociated type: [`CipherAlg`] (enum)"]
2116    pub fn get_cipher_alg(&self) -> Result<u32, ErrorContext> {
2117        let mut iter = self.clone();
2118        iter.pos = 0;
2119        for attr in iter {
2120            if let Ok(Keyconf::CipherAlg(val)) = attr {
2121                return Ok(val);
2122            }
2123        }
2124        Err(ErrorContext::new_missing(
2125            "Keyconf",
2126            "CipherAlg",
2127            self.orig_loc,
2128            self.buf.as_ptr() as usize,
2129        ))
2130    }
2131    #[doc = "Key material for encrypt direction\n"]
2132    pub fn get_encrypt_dir(&self) -> Result<IterableKeydir<'a>, ErrorContext> {
2133        let mut iter = self.clone();
2134        iter.pos = 0;
2135        for attr in iter {
2136            if let Ok(Keyconf::EncryptDir(val)) = attr {
2137                return Ok(val);
2138            }
2139        }
2140        Err(ErrorContext::new_missing(
2141            "Keyconf",
2142            "EncryptDir",
2143            self.orig_loc,
2144            self.buf.as_ptr() as usize,
2145        ))
2146    }
2147    #[doc = "Key material for decrypt direction\n"]
2148    pub fn get_decrypt_dir(&self) -> Result<IterableKeydir<'a>, ErrorContext> {
2149        let mut iter = self.clone();
2150        iter.pos = 0;
2151        for attr in iter {
2152            if let Ok(Keyconf::DecryptDir(val)) = attr {
2153                return Ok(val);
2154            }
2155        }
2156        Err(ErrorContext::new_missing(
2157            "Keyconf",
2158            "DecryptDir",
2159            self.orig_loc,
2160            self.buf.as_ptr() as usize,
2161        ))
2162    }
2163}
2164impl Keyconf<'_> {
2165    pub fn new<'a>(buf: &'a [u8]) -> IterableKeyconf<'a> {
2166        IterableKeyconf::with_loc(buf, buf.as_ptr() as usize)
2167    }
2168    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2169        let res = match r#type {
2170            1u16 => "PeerId",
2171            2u16 => "Slot",
2172            3u16 => "KeyId",
2173            4u16 => "CipherAlg",
2174            5u16 => "EncryptDir",
2175            6u16 => "DecryptDir",
2176            _ => return None,
2177        };
2178        Some(res)
2179    }
2180}
2181#[derive(Clone, Copy, Default)]
2182pub struct IterableKeyconf<'a> {
2183    buf: &'a [u8],
2184    pos: usize,
2185    orig_loc: usize,
2186}
2187impl<'a> IterableKeyconf<'a> {
2188    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2189        Self {
2190            buf,
2191            pos: 0,
2192            orig_loc,
2193        }
2194    }
2195    pub fn get_buf(&self) -> &'a [u8] {
2196        self.buf
2197    }
2198}
2199impl<'a> Iterator for IterableKeyconf<'a> {
2200    type Item = Result<Keyconf<'a>, ErrorContext>;
2201    fn next(&mut self) -> Option<Self::Item> {
2202        let mut pos;
2203        let mut r#type;
2204        loop {
2205            pos = self.pos;
2206            r#type = None;
2207            if self.buf.len() == self.pos {
2208                return None;
2209            }
2210            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2211                self.pos = self.buf.len();
2212                break;
2213            };
2214            r#type = Some(header.r#type);
2215            let res = match header.r#type {
2216                1u16 => Keyconf::PeerId({
2217                    let res = parse_u32(next);
2218                    let Some(val) = res else { break };
2219                    val
2220                }),
2221                2u16 => Keyconf::Slot({
2222                    let res = parse_u32(next);
2223                    let Some(val) = res else { break };
2224                    val
2225                }),
2226                3u16 => Keyconf::KeyId({
2227                    let res = parse_u32(next);
2228                    let Some(val) = res else { break };
2229                    val
2230                }),
2231                4u16 => Keyconf::CipherAlg({
2232                    let res = parse_u32(next);
2233                    let Some(val) = res else { break };
2234                    val
2235                }),
2236                5u16 => Keyconf::EncryptDir({
2237                    let res = Some(IterableKeydir::with_loc(next, self.orig_loc));
2238                    let Some(val) = res else { break };
2239                    val
2240                }),
2241                6u16 => Keyconf::DecryptDir({
2242                    let res = Some(IterableKeydir::with_loc(next, self.orig_loc));
2243                    let Some(val) = res else { break };
2244                    val
2245                }),
2246                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2247                n => continue,
2248            };
2249            return Some(Ok(res));
2250        }
2251        Some(Err(ErrorContext::new(
2252            "Keyconf",
2253            r#type.and_then(|t| Keyconf::attr_from_type(t)),
2254            self.orig_loc,
2255            self.buf.as_ptr().wrapping_add(pos) as usize,
2256        )))
2257    }
2258}
2259impl<'a> std::fmt::Debug for IterableKeyconf<'_> {
2260    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2261        let mut fmt = f.debug_struct("Keyconf");
2262        for attr in self.clone() {
2263            let attr = match attr {
2264                Ok(a) => a,
2265                Err(err) => {
2266                    fmt.finish()?;
2267                    f.write_str("Err(")?;
2268                    err.fmt(f)?;
2269                    return f.write_str(")");
2270                }
2271            };
2272            match attr {
2273                Keyconf::PeerId(val) => fmt.field("PeerId", &val),
2274                Keyconf::Slot(val) => {
2275                    fmt.field("Slot", &FormatEnum(val.into(), KeySlot::from_value))
2276                }
2277                Keyconf::KeyId(val) => fmt.field("KeyId", &val),
2278                Keyconf::CipherAlg(val) => {
2279                    fmt.field("CipherAlg", &FormatEnum(val.into(), CipherAlg::from_value))
2280                }
2281                Keyconf::EncryptDir(val) => fmt.field("EncryptDir", &val),
2282                Keyconf::DecryptDir(val) => fmt.field("DecryptDir", &val),
2283            };
2284        }
2285        fmt.finish()
2286    }
2287}
2288impl IterableKeyconf<'_> {
2289    pub fn lookup_attr(
2290        &self,
2291        offset: usize,
2292        missing_type: Option<u16>,
2293    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2294        let mut stack = Vec::new();
2295        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2296        if missing_type.is_some() && cur == offset {
2297            stack.push(("Keyconf", offset));
2298            return (stack, missing_type.and_then(|t| Keyconf::attr_from_type(t)));
2299        }
2300        if cur > offset || cur + self.buf.len() < offset {
2301            return (stack, None);
2302        }
2303        let mut attrs = self.clone();
2304        let mut last_off = cur + attrs.pos;
2305        let mut missing = None;
2306        while let Some(attr) = attrs.next() {
2307            let Ok(attr) = attr else { break };
2308            match attr {
2309                Keyconf::PeerId(val) => {
2310                    if last_off == offset {
2311                        stack.push(("PeerId", last_off));
2312                        break;
2313                    }
2314                }
2315                Keyconf::Slot(val) => {
2316                    if last_off == offset {
2317                        stack.push(("Slot", last_off));
2318                        break;
2319                    }
2320                }
2321                Keyconf::KeyId(val) => {
2322                    if last_off == offset {
2323                        stack.push(("KeyId", last_off));
2324                        break;
2325                    }
2326                }
2327                Keyconf::CipherAlg(val) => {
2328                    if last_off == offset {
2329                        stack.push(("CipherAlg", last_off));
2330                        break;
2331                    }
2332                }
2333                Keyconf::EncryptDir(val) => {
2334                    (stack, missing) = val.lookup_attr(offset, missing_type);
2335                    if !stack.is_empty() {
2336                        break;
2337                    }
2338                }
2339                Keyconf::DecryptDir(val) => {
2340                    (stack, missing) = val.lookup_attr(offset, missing_type);
2341                    if !stack.is_empty() {
2342                        break;
2343                    }
2344                }
2345                _ => {}
2346            };
2347            last_off = cur + attrs.pos;
2348        }
2349        if !stack.is_empty() {
2350            stack.push(("Keyconf", cur));
2351        }
2352        (stack, missing)
2353    }
2354}
2355#[derive(Clone)]
2356pub enum Keydir<'a> {
2357    #[doc = "The actual key to be used by the cipher\n"]
2358    CipherKey(&'a [u8]),
2359    #[doc = "Random nonce to be concatenated to the packet ID, in order to obtain the\nactual cipher IV\n"]
2360    NonceTail(&'a [u8]),
2361}
2362impl<'a> IterableKeydir<'a> {
2363    #[doc = "The actual key to be used by the cipher\n"]
2364    pub fn get_cipher_key(&self) -> Result<&'a [u8], ErrorContext> {
2365        let mut iter = self.clone();
2366        iter.pos = 0;
2367        for attr in iter {
2368            if let Ok(Keydir::CipherKey(val)) = attr {
2369                return Ok(val);
2370            }
2371        }
2372        Err(ErrorContext::new_missing(
2373            "Keydir",
2374            "CipherKey",
2375            self.orig_loc,
2376            self.buf.as_ptr() as usize,
2377        ))
2378    }
2379    #[doc = "Random nonce to be concatenated to the packet ID, in order to obtain the\nactual cipher IV\n"]
2380    pub fn get_nonce_tail(&self) -> Result<&'a [u8], ErrorContext> {
2381        let mut iter = self.clone();
2382        iter.pos = 0;
2383        for attr in iter {
2384            if let Ok(Keydir::NonceTail(val)) = attr {
2385                return Ok(val);
2386            }
2387        }
2388        Err(ErrorContext::new_missing(
2389            "Keydir",
2390            "NonceTail",
2391            self.orig_loc,
2392            self.buf.as_ptr() as usize,
2393        ))
2394    }
2395}
2396impl Keydir<'_> {
2397    pub fn new<'a>(buf: &'a [u8]) -> IterableKeydir<'a> {
2398        IterableKeydir::with_loc(buf, buf.as_ptr() as usize)
2399    }
2400    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2401        let res = match r#type {
2402            1u16 => "CipherKey",
2403            2u16 => "NonceTail",
2404            _ => return None,
2405        };
2406        Some(res)
2407    }
2408}
2409#[derive(Clone, Copy, Default)]
2410pub struct IterableKeydir<'a> {
2411    buf: &'a [u8],
2412    pos: usize,
2413    orig_loc: usize,
2414}
2415impl<'a> IterableKeydir<'a> {
2416    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2417        Self {
2418            buf,
2419            pos: 0,
2420            orig_loc,
2421        }
2422    }
2423    pub fn get_buf(&self) -> &'a [u8] {
2424        self.buf
2425    }
2426}
2427impl<'a> Iterator for IterableKeydir<'a> {
2428    type Item = Result<Keydir<'a>, ErrorContext>;
2429    fn next(&mut self) -> Option<Self::Item> {
2430        let mut pos;
2431        let mut r#type;
2432        loop {
2433            pos = self.pos;
2434            r#type = None;
2435            if self.buf.len() == self.pos {
2436                return None;
2437            }
2438            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2439                self.pos = self.buf.len();
2440                break;
2441            };
2442            r#type = Some(header.r#type);
2443            let res = match header.r#type {
2444                1u16 => Keydir::CipherKey({
2445                    let res = Some(next);
2446                    let Some(val) = res else { break };
2447                    val
2448                }),
2449                2u16 => Keydir::NonceTail({
2450                    let res = Some(next);
2451                    let Some(val) = res else { break };
2452                    val
2453                }),
2454                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2455                n => continue,
2456            };
2457            return Some(Ok(res));
2458        }
2459        Some(Err(ErrorContext::new(
2460            "Keydir",
2461            r#type.and_then(|t| Keydir::attr_from_type(t)),
2462            self.orig_loc,
2463            self.buf.as_ptr().wrapping_add(pos) as usize,
2464        )))
2465    }
2466}
2467impl<'a> std::fmt::Debug for IterableKeydir<'_> {
2468    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2469        let mut fmt = f.debug_struct("Keydir");
2470        for attr in self.clone() {
2471            let attr = match attr {
2472                Ok(a) => a,
2473                Err(err) => {
2474                    fmt.finish()?;
2475                    f.write_str("Err(")?;
2476                    err.fmt(f)?;
2477                    return f.write_str(")");
2478                }
2479            };
2480            match attr {
2481                Keydir::CipherKey(val) => fmt.field("CipherKey", &val),
2482                Keydir::NonceTail(val) => fmt.field("NonceTail", &val),
2483            };
2484        }
2485        fmt.finish()
2486    }
2487}
2488impl IterableKeydir<'_> {
2489    pub fn lookup_attr(
2490        &self,
2491        offset: usize,
2492        missing_type: Option<u16>,
2493    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2494        let mut stack = Vec::new();
2495        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2496        if missing_type.is_some() && cur == offset {
2497            stack.push(("Keydir", offset));
2498            return (stack, missing_type.and_then(|t| Keydir::attr_from_type(t)));
2499        }
2500        if cur > offset || cur + self.buf.len() < offset {
2501            return (stack, None);
2502        }
2503        let mut attrs = self.clone();
2504        let mut last_off = cur + attrs.pos;
2505        while let Some(attr) = attrs.next() {
2506            let Ok(attr) = attr else { break };
2507            match attr {
2508                Keydir::CipherKey(val) => {
2509                    if last_off == offset {
2510                        stack.push(("CipherKey", last_off));
2511                        break;
2512                    }
2513                }
2514                Keydir::NonceTail(val) => {
2515                    if last_off == offset {
2516                        stack.push(("NonceTail", last_off));
2517                        break;
2518                    }
2519                }
2520                _ => {}
2521            };
2522            last_off = cur + attrs.pos;
2523        }
2524        if !stack.is_empty() {
2525            stack.push(("Keydir", cur));
2526        }
2527        (stack, None)
2528    }
2529}
2530#[derive(Clone)]
2531pub enum KeyconfGet {
2532    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
2533    PeerId(u32),
2534    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
2535    Slot(u32),
2536    #[doc = "The unique ID of the key in the peer context. Used to fetch the correct\nkey upon decryption\n"]
2537    KeyId(u32),
2538    #[doc = "The cipher to be used when communicating with the peer\n\nAssociated type: [`CipherAlg`] (enum)"]
2539    CipherAlg(u32),
2540}
2541impl<'a> IterableKeyconfGet<'a> {
2542    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
2543    pub fn get_peer_id(&self) -> Result<u32, ErrorContext> {
2544        let mut iter = self.clone();
2545        iter.pos = 0;
2546        for attr in iter {
2547            if let Ok(KeyconfGet::PeerId(val)) = attr {
2548                return Ok(val);
2549            }
2550        }
2551        Err(ErrorContext::new_missing(
2552            "KeyconfGet",
2553            "PeerId",
2554            self.orig_loc,
2555            self.buf.as_ptr() as usize,
2556        ))
2557    }
2558    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
2559    pub fn get_slot(&self) -> Result<u32, ErrorContext> {
2560        let mut iter = self.clone();
2561        iter.pos = 0;
2562        for attr in iter {
2563            if let Ok(KeyconfGet::Slot(val)) = attr {
2564                return Ok(val);
2565            }
2566        }
2567        Err(ErrorContext::new_missing(
2568            "KeyconfGet",
2569            "Slot",
2570            self.orig_loc,
2571            self.buf.as_ptr() as usize,
2572        ))
2573    }
2574    #[doc = "The unique ID of the key in the peer context. Used to fetch the correct\nkey upon decryption\n"]
2575    pub fn get_key_id(&self) -> Result<u32, ErrorContext> {
2576        let mut iter = self.clone();
2577        iter.pos = 0;
2578        for attr in iter {
2579            if let Ok(KeyconfGet::KeyId(val)) = attr {
2580                return Ok(val);
2581            }
2582        }
2583        Err(ErrorContext::new_missing(
2584            "KeyconfGet",
2585            "KeyId",
2586            self.orig_loc,
2587            self.buf.as_ptr() as usize,
2588        ))
2589    }
2590    #[doc = "The cipher to be used when communicating with the peer\n\nAssociated type: [`CipherAlg`] (enum)"]
2591    pub fn get_cipher_alg(&self) -> Result<u32, ErrorContext> {
2592        let mut iter = self.clone();
2593        iter.pos = 0;
2594        for attr in iter {
2595            if let Ok(KeyconfGet::CipherAlg(val)) = attr {
2596                return Ok(val);
2597            }
2598        }
2599        Err(ErrorContext::new_missing(
2600            "KeyconfGet",
2601            "CipherAlg",
2602            self.orig_loc,
2603            self.buf.as_ptr() as usize,
2604        ))
2605    }
2606}
2607impl KeyconfGet {
2608    pub fn new<'a>(buf: &'a [u8]) -> IterableKeyconfGet<'a> {
2609        IterableKeyconfGet::with_loc(buf, buf.as_ptr() as usize)
2610    }
2611    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2612        Keyconf::attr_from_type(r#type)
2613    }
2614}
2615#[derive(Clone, Copy, Default)]
2616pub struct IterableKeyconfGet<'a> {
2617    buf: &'a [u8],
2618    pos: usize,
2619    orig_loc: usize,
2620}
2621impl<'a> IterableKeyconfGet<'a> {
2622    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2623        Self {
2624            buf,
2625            pos: 0,
2626            orig_loc,
2627        }
2628    }
2629    pub fn get_buf(&self) -> &'a [u8] {
2630        self.buf
2631    }
2632}
2633impl<'a> Iterator for IterableKeyconfGet<'a> {
2634    type Item = Result<KeyconfGet, ErrorContext>;
2635    fn next(&mut self) -> Option<Self::Item> {
2636        let mut pos;
2637        let mut r#type;
2638        loop {
2639            pos = self.pos;
2640            r#type = None;
2641            if self.buf.len() == self.pos {
2642                return None;
2643            }
2644            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2645                self.pos = self.buf.len();
2646                break;
2647            };
2648            r#type = Some(header.r#type);
2649            let res = match header.r#type {
2650                1u16 => KeyconfGet::PeerId({
2651                    let res = parse_u32(next);
2652                    let Some(val) = res else { break };
2653                    val
2654                }),
2655                2u16 => KeyconfGet::Slot({
2656                    let res = parse_u32(next);
2657                    let Some(val) = res else { break };
2658                    val
2659                }),
2660                3u16 => KeyconfGet::KeyId({
2661                    let res = parse_u32(next);
2662                    let Some(val) = res else { break };
2663                    val
2664                }),
2665                4u16 => KeyconfGet::CipherAlg({
2666                    let res = parse_u32(next);
2667                    let Some(val) = res else { break };
2668                    val
2669                }),
2670                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2671                n => continue,
2672            };
2673            return Some(Ok(res));
2674        }
2675        Some(Err(ErrorContext::new(
2676            "KeyconfGet",
2677            r#type.and_then(|t| KeyconfGet::attr_from_type(t)),
2678            self.orig_loc,
2679            self.buf.as_ptr().wrapping_add(pos) as usize,
2680        )))
2681    }
2682}
2683impl std::fmt::Debug for IterableKeyconfGet<'_> {
2684    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2685        let mut fmt = f.debug_struct("KeyconfGet");
2686        for attr in self.clone() {
2687            let attr = match attr {
2688                Ok(a) => a,
2689                Err(err) => {
2690                    fmt.finish()?;
2691                    f.write_str("Err(")?;
2692                    err.fmt(f)?;
2693                    return f.write_str(")");
2694                }
2695            };
2696            match attr {
2697                KeyconfGet::PeerId(val) => fmt.field("PeerId", &val),
2698                KeyconfGet::Slot(val) => {
2699                    fmt.field("Slot", &FormatEnum(val.into(), KeySlot::from_value))
2700                }
2701                KeyconfGet::KeyId(val) => fmt.field("KeyId", &val),
2702                KeyconfGet::CipherAlg(val) => {
2703                    fmt.field("CipherAlg", &FormatEnum(val.into(), CipherAlg::from_value))
2704                }
2705            };
2706        }
2707        fmt.finish()
2708    }
2709}
2710impl IterableKeyconfGet<'_> {
2711    pub fn lookup_attr(
2712        &self,
2713        offset: usize,
2714        missing_type: Option<u16>,
2715    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2716        let mut stack = Vec::new();
2717        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2718        if missing_type.is_some() && cur == offset {
2719            stack.push(("KeyconfGet", offset));
2720            return (
2721                stack,
2722                missing_type.and_then(|t| KeyconfGet::attr_from_type(t)),
2723            );
2724        }
2725        if cur > offset || cur + self.buf.len() < offset {
2726            return (stack, None);
2727        }
2728        let mut attrs = self.clone();
2729        let mut last_off = cur + attrs.pos;
2730        while let Some(attr) = attrs.next() {
2731            let Ok(attr) = attr else { break };
2732            match attr {
2733                KeyconfGet::PeerId(val) => {
2734                    if last_off == offset {
2735                        stack.push(("PeerId", last_off));
2736                        break;
2737                    }
2738                }
2739                KeyconfGet::Slot(val) => {
2740                    if last_off == offset {
2741                        stack.push(("Slot", last_off));
2742                        break;
2743                    }
2744                }
2745                KeyconfGet::KeyId(val) => {
2746                    if last_off == offset {
2747                        stack.push(("KeyId", last_off));
2748                        break;
2749                    }
2750                }
2751                KeyconfGet::CipherAlg(val) => {
2752                    if last_off == offset {
2753                        stack.push(("CipherAlg", last_off));
2754                        break;
2755                    }
2756                }
2757                _ => {}
2758            };
2759            last_off = cur + attrs.pos;
2760        }
2761        if !stack.is_empty() {
2762            stack.push(("KeyconfGet", cur));
2763        }
2764        (stack, None)
2765    }
2766}
2767#[derive(Clone)]
2768pub enum KeyconfSwapInput {
2769    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
2770    PeerId(u32),
2771}
2772impl<'a> IterableKeyconfSwapInput<'a> {
2773    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
2774    pub fn get_peer_id(&self) -> Result<u32, ErrorContext> {
2775        let mut iter = self.clone();
2776        iter.pos = 0;
2777        for attr in iter {
2778            if let Ok(KeyconfSwapInput::PeerId(val)) = attr {
2779                return Ok(val);
2780            }
2781        }
2782        Err(ErrorContext::new_missing(
2783            "KeyconfSwapInput",
2784            "PeerId",
2785            self.orig_loc,
2786            self.buf.as_ptr() as usize,
2787        ))
2788    }
2789}
2790impl KeyconfSwapInput {
2791    pub fn new<'a>(buf: &'a [u8]) -> IterableKeyconfSwapInput<'a> {
2792        IterableKeyconfSwapInput::with_loc(buf, buf.as_ptr() as usize)
2793    }
2794    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2795        Keyconf::attr_from_type(r#type)
2796    }
2797}
2798#[derive(Clone, Copy, Default)]
2799pub struct IterableKeyconfSwapInput<'a> {
2800    buf: &'a [u8],
2801    pos: usize,
2802    orig_loc: usize,
2803}
2804impl<'a> IterableKeyconfSwapInput<'a> {
2805    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2806        Self {
2807            buf,
2808            pos: 0,
2809            orig_loc,
2810        }
2811    }
2812    pub fn get_buf(&self) -> &'a [u8] {
2813        self.buf
2814    }
2815}
2816impl<'a> Iterator for IterableKeyconfSwapInput<'a> {
2817    type Item = Result<KeyconfSwapInput, ErrorContext>;
2818    fn next(&mut self) -> Option<Self::Item> {
2819        let mut pos;
2820        let mut r#type;
2821        loop {
2822            pos = self.pos;
2823            r#type = None;
2824            if self.buf.len() == self.pos {
2825                return None;
2826            }
2827            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2828                self.pos = self.buf.len();
2829                break;
2830            };
2831            r#type = Some(header.r#type);
2832            let res = match header.r#type {
2833                1u16 => KeyconfSwapInput::PeerId({
2834                    let res = parse_u32(next);
2835                    let Some(val) = res else { break };
2836                    val
2837                }),
2838                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2839                n => continue,
2840            };
2841            return Some(Ok(res));
2842        }
2843        Some(Err(ErrorContext::new(
2844            "KeyconfSwapInput",
2845            r#type.and_then(|t| KeyconfSwapInput::attr_from_type(t)),
2846            self.orig_loc,
2847            self.buf.as_ptr().wrapping_add(pos) as usize,
2848        )))
2849    }
2850}
2851impl std::fmt::Debug for IterableKeyconfSwapInput<'_> {
2852    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2853        let mut fmt = f.debug_struct("KeyconfSwapInput");
2854        for attr in self.clone() {
2855            let attr = match attr {
2856                Ok(a) => a,
2857                Err(err) => {
2858                    fmt.finish()?;
2859                    f.write_str("Err(")?;
2860                    err.fmt(f)?;
2861                    return f.write_str(")");
2862                }
2863            };
2864            match attr {
2865                KeyconfSwapInput::PeerId(val) => fmt.field("PeerId", &val),
2866            };
2867        }
2868        fmt.finish()
2869    }
2870}
2871impl IterableKeyconfSwapInput<'_> {
2872    pub fn lookup_attr(
2873        &self,
2874        offset: usize,
2875        missing_type: Option<u16>,
2876    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2877        let mut stack = Vec::new();
2878        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2879        if missing_type.is_some() && cur == offset {
2880            stack.push(("KeyconfSwapInput", offset));
2881            return (
2882                stack,
2883                missing_type.and_then(|t| KeyconfSwapInput::attr_from_type(t)),
2884            );
2885        }
2886        if cur > offset || cur + self.buf.len() < offset {
2887            return (stack, None);
2888        }
2889        let mut attrs = self.clone();
2890        let mut last_off = cur + attrs.pos;
2891        while let Some(attr) = attrs.next() {
2892            let Ok(attr) = attr else { break };
2893            match attr {
2894                KeyconfSwapInput::PeerId(val) => {
2895                    if last_off == offset {
2896                        stack.push(("PeerId", last_off));
2897                        break;
2898                    }
2899                }
2900                _ => {}
2901            };
2902            last_off = cur + attrs.pos;
2903        }
2904        if !stack.is_empty() {
2905            stack.push(("KeyconfSwapInput", cur));
2906        }
2907        (stack, None)
2908    }
2909}
2910#[derive(Clone)]
2911pub enum KeyconfDelInput {
2912    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
2913    PeerId(u32),
2914    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
2915    Slot(u32),
2916}
2917impl<'a> IterableKeyconfDelInput<'a> {
2918    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
2919    pub fn get_peer_id(&self) -> Result<u32, ErrorContext> {
2920        let mut iter = self.clone();
2921        iter.pos = 0;
2922        for attr in iter {
2923            if let Ok(KeyconfDelInput::PeerId(val)) = attr {
2924                return Ok(val);
2925            }
2926        }
2927        Err(ErrorContext::new_missing(
2928            "KeyconfDelInput",
2929            "PeerId",
2930            self.orig_loc,
2931            self.buf.as_ptr() as usize,
2932        ))
2933    }
2934    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
2935    pub fn get_slot(&self) -> Result<u32, ErrorContext> {
2936        let mut iter = self.clone();
2937        iter.pos = 0;
2938        for attr in iter {
2939            if let Ok(KeyconfDelInput::Slot(val)) = attr {
2940                return Ok(val);
2941            }
2942        }
2943        Err(ErrorContext::new_missing(
2944            "KeyconfDelInput",
2945            "Slot",
2946            self.orig_loc,
2947            self.buf.as_ptr() as usize,
2948        ))
2949    }
2950}
2951impl KeyconfDelInput {
2952    pub fn new<'a>(buf: &'a [u8]) -> IterableKeyconfDelInput<'a> {
2953        IterableKeyconfDelInput::with_loc(buf, buf.as_ptr() as usize)
2954    }
2955    fn attr_from_type(r#type: u16) -> Option<&'static str> {
2956        Keyconf::attr_from_type(r#type)
2957    }
2958}
2959#[derive(Clone, Copy, Default)]
2960pub struct IterableKeyconfDelInput<'a> {
2961    buf: &'a [u8],
2962    pos: usize,
2963    orig_loc: usize,
2964}
2965impl<'a> IterableKeyconfDelInput<'a> {
2966    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2967        Self {
2968            buf,
2969            pos: 0,
2970            orig_loc,
2971        }
2972    }
2973    pub fn get_buf(&self) -> &'a [u8] {
2974        self.buf
2975    }
2976}
2977impl<'a> Iterator for IterableKeyconfDelInput<'a> {
2978    type Item = Result<KeyconfDelInput, ErrorContext>;
2979    fn next(&mut self) -> Option<Self::Item> {
2980        let mut pos;
2981        let mut r#type;
2982        loop {
2983            pos = self.pos;
2984            r#type = None;
2985            if self.buf.len() == self.pos {
2986                return None;
2987            }
2988            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2989                self.pos = self.buf.len();
2990                break;
2991            };
2992            r#type = Some(header.r#type);
2993            let res = match header.r#type {
2994                1u16 => KeyconfDelInput::PeerId({
2995                    let res = parse_u32(next);
2996                    let Some(val) = res else { break };
2997                    val
2998                }),
2999                2u16 => KeyconfDelInput::Slot({
3000                    let res = parse_u32(next);
3001                    let Some(val) = res else { break };
3002                    val
3003                }),
3004                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3005                n => continue,
3006            };
3007            return Some(Ok(res));
3008        }
3009        Some(Err(ErrorContext::new(
3010            "KeyconfDelInput",
3011            r#type.and_then(|t| KeyconfDelInput::attr_from_type(t)),
3012            self.orig_loc,
3013            self.buf.as_ptr().wrapping_add(pos) as usize,
3014        )))
3015    }
3016}
3017impl std::fmt::Debug for IterableKeyconfDelInput<'_> {
3018    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3019        let mut fmt = f.debug_struct("KeyconfDelInput");
3020        for attr in self.clone() {
3021            let attr = match attr {
3022                Ok(a) => a,
3023                Err(err) => {
3024                    fmt.finish()?;
3025                    f.write_str("Err(")?;
3026                    err.fmt(f)?;
3027                    return f.write_str(")");
3028                }
3029            };
3030            match attr {
3031                KeyconfDelInput::PeerId(val) => fmt.field("PeerId", &val),
3032                KeyconfDelInput::Slot(val) => {
3033                    fmt.field("Slot", &FormatEnum(val.into(), KeySlot::from_value))
3034                }
3035            };
3036        }
3037        fmt.finish()
3038    }
3039}
3040impl IterableKeyconfDelInput<'_> {
3041    pub fn lookup_attr(
3042        &self,
3043        offset: usize,
3044        missing_type: Option<u16>,
3045    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3046        let mut stack = Vec::new();
3047        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3048        if missing_type.is_some() && cur == offset {
3049            stack.push(("KeyconfDelInput", offset));
3050            return (
3051                stack,
3052                missing_type.and_then(|t| KeyconfDelInput::attr_from_type(t)),
3053            );
3054        }
3055        if cur > offset || cur + self.buf.len() < offset {
3056            return (stack, None);
3057        }
3058        let mut attrs = self.clone();
3059        let mut last_off = cur + attrs.pos;
3060        while let Some(attr) = attrs.next() {
3061            let Ok(attr) = attr else { break };
3062            match attr {
3063                KeyconfDelInput::PeerId(val) => {
3064                    if last_off == offset {
3065                        stack.push(("PeerId", last_off));
3066                        break;
3067                    }
3068                }
3069                KeyconfDelInput::Slot(val) => {
3070                    if last_off == offset {
3071                        stack.push(("Slot", last_off));
3072                        break;
3073                    }
3074                }
3075                _ => {}
3076            };
3077            last_off = cur + attrs.pos;
3078        }
3079        if !stack.is_empty() {
3080            stack.push(("KeyconfDelInput", cur));
3081        }
3082        (stack, None)
3083    }
3084}
3085#[derive(Clone)]
3086pub enum Ovpn<'a> {
3087    #[doc = "Index of the ovpn interface to operate on\n"]
3088    Ifindex(u32),
3089    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
3090    Peer(IterablePeer<'a>),
3091    #[doc = "Peer specific cipher configuration\n"]
3092    Keyconf(IterableKeyconf<'a>),
3093}
3094impl<'a> IterableOvpn<'a> {
3095    #[doc = "Index of the ovpn interface to operate on\n"]
3096    pub fn get_ifindex(&self) -> Result<u32, ErrorContext> {
3097        let mut iter = self.clone();
3098        iter.pos = 0;
3099        for attr in iter {
3100            if let Ok(Ovpn::Ifindex(val)) = attr {
3101                return Ok(val);
3102            }
3103        }
3104        Err(ErrorContext::new_missing(
3105            "Ovpn",
3106            "Ifindex",
3107            self.orig_loc,
3108            self.buf.as_ptr() as usize,
3109        ))
3110    }
3111    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
3112    pub fn get_peer(&self) -> Result<IterablePeer<'a>, ErrorContext> {
3113        let mut iter = self.clone();
3114        iter.pos = 0;
3115        for attr in iter {
3116            if let Ok(Ovpn::Peer(val)) = attr {
3117                return Ok(val);
3118            }
3119        }
3120        Err(ErrorContext::new_missing(
3121            "Ovpn",
3122            "Peer",
3123            self.orig_loc,
3124            self.buf.as_ptr() as usize,
3125        ))
3126    }
3127    #[doc = "Peer specific cipher configuration\n"]
3128    pub fn get_keyconf(&self) -> Result<IterableKeyconf<'a>, ErrorContext> {
3129        let mut iter = self.clone();
3130        iter.pos = 0;
3131        for attr in iter {
3132            if let Ok(Ovpn::Keyconf(val)) = attr {
3133                return Ok(val);
3134            }
3135        }
3136        Err(ErrorContext::new_missing(
3137            "Ovpn",
3138            "Keyconf",
3139            self.orig_loc,
3140            self.buf.as_ptr() as usize,
3141        ))
3142    }
3143}
3144impl Ovpn<'_> {
3145    pub fn new<'a>(buf: &'a [u8]) -> IterableOvpn<'a> {
3146        IterableOvpn::with_loc(buf, buf.as_ptr() as usize)
3147    }
3148    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3149        let res = match r#type {
3150            1u16 => "Ifindex",
3151            2u16 => "Peer",
3152            3u16 => "Keyconf",
3153            _ => return None,
3154        };
3155        Some(res)
3156    }
3157}
3158#[derive(Clone, Copy, Default)]
3159pub struct IterableOvpn<'a> {
3160    buf: &'a [u8],
3161    pos: usize,
3162    orig_loc: usize,
3163}
3164impl<'a> IterableOvpn<'a> {
3165    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3166        Self {
3167            buf,
3168            pos: 0,
3169            orig_loc,
3170        }
3171    }
3172    pub fn get_buf(&self) -> &'a [u8] {
3173        self.buf
3174    }
3175}
3176impl<'a> Iterator for IterableOvpn<'a> {
3177    type Item = Result<Ovpn<'a>, ErrorContext>;
3178    fn next(&mut self) -> Option<Self::Item> {
3179        let mut pos;
3180        let mut r#type;
3181        loop {
3182            pos = self.pos;
3183            r#type = None;
3184            if self.buf.len() == self.pos {
3185                return None;
3186            }
3187            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3188                self.pos = self.buf.len();
3189                break;
3190            };
3191            r#type = Some(header.r#type);
3192            let res = match header.r#type {
3193                1u16 => Ovpn::Ifindex({
3194                    let res = parse_u32(next);
3195                    let Some(val) = res else { break };
3196                    val
3197                }),
3198                2u16 => Ovpn::Peer({
3199                    let res = Some(IterablePeer::with_loc(next, self.orig_loc));
3200                    let Some(val) = res else { break };
3201                    val
3202                }),
3203                3u16 => Ovpn::Keyconf({
3204                    let res = Some(IterableKeyconf::with_loc(next, self.orig_loc));
3205                    let Some(val) = res else { break };
3206                    val
3207                }),
3208                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3209                n => continue,
3210            };
3211            return Some(Ok(res));
3212        }
3213        Some(Err(ErrorContext::new(
3214            "Ovpn",
3215            r#type.and_then(|t| Ovpn::attr_from_type(t)),
3216            self.orig_loc,
3217            self.buf.as_ptr().wrapping_add(pos) as usize,
3218        )))
3219    }
3220}
3221impl<'a> std::fmt::Debug for IterableOvpn<'_> {
3222    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3223        let mut fmt = f.debug_struct("Ovpn");
3224        for attr in self.clone() {
3225            let attr = match attr {
3226                Ok(a) => a,
3227                Err(err) => {
3228                    fmt.finish()?;
3229                    f.write_str("Err(")?;
3230                    err.fmt(f)?;
3231                    return f.write_str(")");
3232                }
3233            };
3234            match attr {
3235                Ovpn::Ifindex(val) => fmt.field("Ifindex", &val),
3236                Ovpn::Peer(val) => fmt.field("Peer", &val),
3237                Ovpn::Keyconf(val) => fmt.field("Keyconf", &val),
3238            };
3239        }
3240        fmt.finish()
3241    }
3242}
3243impl IterableOvpn<'_> {
3244    pub fn lookup_attr(
3245        &self,
3246        offset: usize,
3247        missing_type: Option<u16>,
3248    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3249        let mut stack = Vec::new();
3250        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3251        if missing_type.is_some() && cur == offset {
3252            stack.push(("Ovpn", offset));
3253            return (stack, missing_type.and_then(|t| Ovpn::attr_from_type(t)));
3254        }
3255        if cur > offset || cur + self.buf.len() < offset {
3256            return (stack, None);
3257        }
3258        let mut attrs = self.clone();
3259        let mut last_off = cur + attrs.pos;
3260        let mut missing = None;
3261        while let Some(attr) = attrs.next() {
3262            let Ok(attr) = attr else { break };
3263            match attr {
3264                Ovpn::Ifindex(val) => {
3265                    if last_off == offset {
3266                        stack.push(("Ifindex", last_off));
3267                        break;
3268                    }
3269                }
3270                Ovpn::Peer(val) => {
3271                    (stack, missing) = val.lookup_attr(offset, missing_type);
3272                    if !stack.is_empty() {
3273                        break;
3274                    }
3275                }
3276                Ovpn::Keyconf(val) => {
3277                    (stack, missing) = val.lookup_attr(offset, missing_type);
3278                    if !stack.is_empty() {
3279                        break;
3280                    }
3281                }
3282                _ => {}
3283            };
3284            last_off = cur + attrs.pos;
3285        }
3286        if !stack.is_empty() {
3287            stack.push(("Ovpn", cur));
3288        }
3289        (stack, missing)
3290    }
3291}
3292#[derive(Clone)]
3293pub enum OvpnPeerNewInput<'a> {
3294    #[doc = "Index of the ovpn interface to operate on\n"]
3295    Ifindex(u32),
3296    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
3297    Peer(IterablePeerNewInput<'a>),
3298}
3299impl<'a> IterableOvpnPeerNewInput<'a> {
3300    #[doc = "Index of the ovpn interface to operate on\n"]
3301    pub fn get_ifindex(&self) -> Result<u32, ErrorContext> {
3302        let mut iter = self.clone();
3303        iter.pos = 0;
3304        for attr in iter {
3305            if let Ok(OvpnPeerNewInput::Ifindex(val)) = attr {
3306                return Ok(val);
3307            }
3308        }
3309        Err(ErrorContext::new_missing(
3310            "OvpnPeerNewInput",
3311            "Ifindex",
3312            self.orig_loc,
3313            self.buf.as_ptr() as usize,
3314        ))
3315    }
3316    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
3317    pub fn get_peer(&self) -> Result<IterablePeerNewInput<'a>, ErrorContext> {
3318        let mut iter = self.clone();
3319        iter.pos = 0;
3320        for attr in iter {
3321            if let Ok(OvpnPeerNewInput::Peer(val)) = attr {
3322                return Ok(val);
3323            }
3324        }
3325        Err(ErrorContext::new_missing(
3326            "OvpnPeerNewInput",
3327            "Peer",
3328            self.orig_loc,
3329            self.buf.as_ptr() as usize,
3330        ))
3331    }
3332}
3333impl OvpnPeerNewInput<'_> {
3334    pub fn new<'a>(buf: &'a [u8]) -> IterableOvpnPeerNewInput<'a> {
3335        IterableOvpnPeerNewInput::with_loc(buf, buf.as_ptr() as usize)
3336    }
3337    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3338        Ovpn::attr_from_type(r#type)
3339    }
3340}
3341#[derive(Clone, Copy, Default)]
3342pub struct IterableOvpnPeerNewInput<'a> {
3343    buf: &'a [u8],
3344    pos: usize,
3345    orig_loc: usize,
3346}
3347impl<'a> IterableOvpnPeerNewInput<'a> {
3348    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3349        Self {
3350            buf,
3351            pos: 0,
3352            orig_loc,
3353        }
3354    }
3355    pub fn get_buf(&self) -> &'a [u8] {
3356        self.buf
3357    }
3358}
3359impl<'a> Iterator for IterableOvpnPeerNewInput<'a> {
3360    type Item = Result<OvpnPeerNewInput<'a>, ErrorContext>;
3361    fn next(&mut self) -> Option<Self::Item> {
3362        let mut pos;
3363        let mut r#type;
3364        loop {
3365            pos = self.pos;
3366            r#type = None;
3367            if self.buf.len() == self.pos {
3368                return None;
3369            }
3370            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3371                self.pos = self.buf.len();
3372                break;
3373            };
3374            r#type = Some(header.r#type);
3375            let res = match header.r#type {
3376                1u16 => OvpnPeerNewInput::Ifindex({
3377                    let res = parse_u32(next);
3378                    let Some(val) = res else { break };
3379                    val
3380                }),
3381                2u16 => OvpnPeerNewInput::Peer({
3382                    let res = Some(IterablePeerNewInput::with_loc(next, self.orig_loc));
3383                    let Some(val) = res else { break };
3384                    val
3385                }),
3386                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3387                n => continue,
3388            };
3389            return Some(Ok(res));
3390        }
3391        Some(Err(ErrorContext::new(
3392            "OvpnPeerNewInput",
3393            r#type.and_then(|t| OvpnPeerNewInput::attr_from_type(t)),
3394            self.orig_loc,
3395            self.buf.as_ptr().wrapping_add(pos) as usize,
3396        )))
3397    }
3398}
3399impl<'a> std::fmt::Debug for IterableOvpnPeerNewInput<'_> {
3400    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3401        let mut fmt = f.debug_struct("OvpnPeerNewInput");
3402        for attr in self.clone() {
3403            let attr = match attr {
3404                Ok(a) => a,
3405                Err(err) => {
3406                    fmt.finish()?;
3407                    f.write_str("Err(")?;
3408                    err.fmt(f)?;
3409                    return f.write_str(")");
3410                }
3411            };
3412            match attr {
3413                OvpnPeerNewInput::Ifindex(val) => fmt.field("Ifindex", &val),
3414                OvpnPeerNewInput::Peer(val) => fmt.field("Peer", &val),
3415            };
3416        }
3417        fmt.finish()
3418    }
3419}
3420impl IterableOvpnPeerNewInput<'_> {
3421    pub fn lookup_attr(
3422        &self,
3423        offset: usize,
3424        missing_type: Option<u16>,
3425    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3426        let mut stack = Vec::new();
3427        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3428        if missing_type.is_some() && cur == offset {
3429            stack.push(("OvpnPeerNewInput", offset));
3430            return (
3431                stack,
3432                missing_type.and_then(|t| OvpnPeerNewInput::attr_from_type(t)),
3433            );
3434        }
3435        if cur > offset || cur + self.buf.len() < offset {
3436            return (stack, None);
3437        }
3438        let mut attrs = self.clone();
3439        let mut last_off = cur + attrs.pos;
3440        let mut missing = None;
3441        while let Some(attr) = attrs.next() {
3442            let Ok(attr) = attr else { break };
3443            match attr {
3444                OvpnPeerNewInput::Ifindex(val) => {
3445                    if last_off == offset {
3446                        stack.push(("Ifindex", last_off));
3447                        break;
3448                    }
3449                }
3450                OvpnPeerNewInput::Peer(val) => {
3451                    (stack, missing) = val.lookup_attr(offset, missing_type);
3452                    if !stack.is_empty() {
3453                        break;
3454                    }
3455                }
3456                _ => {}
3457            };
3458            last_off = cur + attrs.pos;
3459        }
3460        if !stack.is_empty() {
3461            stack.push(("OvpnPeerNewInput", cur));
3462        }
3463        (stack, missing)
3464    }
3465}
3466#[derive(Clone)]
3467pub enum OvpnPeerSetInput<'a> {
3468    #[doc = "Index of the ovpn interface to operate on\n"]
3469    Ifindex(u32),
3470    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
3471    Peer(IterablePeerSetInput<'a>),
3472}
3473impl<'a> IterableOvpnPeerSetInput<'a> {
3474    #[doc = "Index of the ovpn interface to operate on\n"]
3475    pub fn get_ifindex(&self) -> Result<u32, ErrorContext> {
3476        let mut iter = self.clone();
3477        iter.pos = 0;
3478        for attr in iter {
3479            if let Ok(OvpnPeerSetInput::Ifindex(val)) = attr {
3480                return Ok(val);
3481            }
3482        }
3483        Err(ErrorContext::new_missing(
3484            "OvpnPeerSetInput",
3485            "Ifindex",
3486            self.orig_loc,
3487            self.buf.as_ptr() as usize,
3488        ))
3489    }
3490    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
3491    pub fn get_peer(&self) -> Result<IterablePeerSetInput<'a>, ErrorContext> {
3492        let mut iter = self.clone();
3493        iter.pos = 0;
3494        for attr in iter {
3495            if let Ok(OvpnPeerSetInput::Peer(val)) = attr {
3496                return Ok(val);
3497            }
3498        }
3499        Err(ErrorContext::new_missing(
3500            "OvpnPeerSetInput",
3501            "Peer",
3502            self.orig_loc,
3503            self.buf.as_ptr() as usize,
3504        ))
3505    }
3506}
3507impl OvpnPeerSetInput<'_> {
3508    pub fn new<'a>(buf: &'a [u8]) -> IterableOvpnPeerSetInput<'a> {
3509        IterableOvpnPeerSetInput::with_loc(buf, buf.as_ptr() as usize)
3510    }
3511    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3512        Ovpn::attr_from_type(r#type)
3513    }
3514}
3515#[derive(Clone, Copy, Default)]
3516pub struct IterableOvpnPeerSetInput<'a> {
3517    buf: &'a [u8],
3518    pos: usize,
3519    orig_loc: usize,
3520}
3521impl<'a> IterableOvpnPeerSetInput<'a> {
3522    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3523        Self {
3524            buf,
3525            pos: 0,
3526            orig_loc,
3527        }
3528    }
3529    pub fn get_buf(&self) -> &'a [u8] {
3530        self.buf
3531    }
3532}
3533impl<'a> Iterator for IterableOvpnPeerSetInput<'a> {
3534    type Item = Result<OvpnPeerSetInput<'a>, ErrorContext>;
3535    fn next(&mut self) -> Option<Self::Item> {
3536        let mut pos;
3537        let mut r#type;
3538        loop {
3539            pos = self.pos;
3540            r#type = None;
3541            if self.buf.len() == self.pos {
3542                return None;
3543            }
3544            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3545                self.pos = self.buf.len();
3546                break;
3547            };
3548            r#type = Some(header.r#type);
3549            let res = match header.r#type {
3550                1u16 => OvpnPeerSetInput::Ifindex({
3551                    let res = parse_u32(next);
3552                    let Some(val) = res else { break };
3553                    val
3554                }),
3555                2u16 => OvpnPeerSetInput::Peer({
3556                    let res = Some(IterablePeerSetInput::with_loc(next, self.orig_loc));
3557                    let Some(val) = res else { break };
3558                    val
3559                }),
3560                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3561                n => continue,
3562            };
3563            return Some(Ok(res));
3564        }
3565        Some(Err(ErrorContext::new(
3566            "OvpnPeerSetInput",
3567            r#type.and_then(|t| OvpnPeerSetInput::attr_from_type(t)),
3568            self.orig_loc,
3569            self.buf.as_ptr().wrapping_add(pos) as usize,
3570        )))
3571    }
3572}
3573impl<'a> std::fmt::Debug for IterableOvpnPeerSetInput<'_> {
3574    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3575        let mut fmt = f.debug_struct("OvpnPeerSetInput");
3576        for attr in self.clone() {
3577            let attr = match attr {
3578                Ok(a) => a,
3579                Err(err) => {
3580                    fmt.finish()?;
3581                    f.write_str("Err(")?;
3582                    err.fmt(f)?;
3583                    return f.write_str(")");
3584                }
3585            };
3586            match attr {
3587                OvpnPeerSetInput::Ifindex(val) => fmt.field("Ifindex", &val),
3588                OvpnPeerSetInput::Peer(val) => fmt.field("Peer", &val),
3589            };
3590        }
3591        fmt.finish()
3592    }
3593}
3594impl IterableOvpnPeerSetInput<'_> {
3595    pub fn lookup_attr(
3596        &self,
3597        offset: usize,
3598        missing_type: Option<u16>,
3599    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3600        let mut stack = Vec::new();
3601        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3602        if missing_type.is_some() && cur == offset {
3603            stack.push(("OvpnPeerSetInput", offset));
3604            return (
3605                stack,
3606                missing_type.and_then(|t| OvpnPeerSetInput::attr_from_type(t)),
3607            );
3608        }
3609        if cur > offset || cur + self.buf.len() < offset {
3610            return (stack, None);
3611        }
3612        let mut attrs = self.clone();
3613        let mut last_off = cur + attrs.pos;
3614        let mut missing = None;
3615        while let Some(attr) = attrs.next() {
3616            let Ok(attr) = attr else { break };
3617            match attr {
3618                OvpnPeerSetInput::Ifindex(val) => {
3619                    if last_off == offset {
3620                        stack.push(("Ifindex", last_off));
3621                        break;
3622                    }
3623                }
3624                OvpnPeerSetInput::Peer(val) => {
3625                    (stack, missing) = val.lookup_attr(offset, missing_type);
3626                    if !stack.is_empty() {
3627                        break;
3628                    }
3629                }
3630                _ => {}
3631            };
3632            last_off = cur + attrs.pos;
3633        }
3634        if !stack.is_empty() {
3635            stack.push(("OvpnPeerSetInput", cur));
3636        }
3637        (stack, missing)
3638    }
3639}
3640#[derive(Clone)]
3641pub enum OvpnPeerDelInput<'a> {
3642    #[doc = "Index of the ovpn interface to operate on\n"]
3643    Ifindex(u32),
3644    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
3645    Peer(IterablePeerDelInput<'a>),
3646}
3647impl<'a> IterableOvpnPeerDelInput<'a> {
3648    #[doc = "Index of the ovpn interface to operate on\n"]
3649    pub fn get_ifindex(&self) -> Result<u32, ErrorContext> {
3650        let mut iter = self.clone();
3651        iter.pos = 0;
3652        for attr in iter {
3653            if let Ok(OvpnPeerDelInput::Ifindex(val)) = attr {
3654                return Ok(val);
3655            }
3656        }
3657        Err(ErrorContext::new_missing(
3658            "OvpnPeerDelInput",
3659            "Ifindex",
3660            self.orig_loc,
3661            self.buf.as_ptr() as usize,
3662        ))
3663    }
3664    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
3665    pub fn get_peer(&self) -> Result<IterablePeerDelInput<'a>, ErrorContext> {
3666        let mut iter = self.clone();
3667        iter.pos = 0;
3668        for attr in iter {
3669            if let Ok(OvpnPeerDelInput::Peer(val)) = attr {
3670                return Ok(val);
3671            }
3672        }
3673        Err(ErrorContext::new_missing(
3674            "OvpnPeerDelInput",
3675            "Peer",
3676            self.orig_loc,
3677            self.buf.as_ptr() as usize,
3678        ))
3679    }
3680}
3681impl OvpnPeerDelInput<'_> {
3682    pub fn new<'a>(buf: &'a [u8]) -> IterableOvpnPeerDelInput<'a> {
3683        IterableOvpnPeerDelInput::with_loc(buf, buf.as_ptr() as usize)
3684    }
3685    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3686        Ovpn::attr_from_type(r#type)
3687    }
3688}
3689#[derive(Clone, Copy, Default)]
3690pub struct IterableOvpnPeerDelInput<'a> {
3691    buf: &'a [u8],
3692    pos: usize,
3693    orig_loc: usize,
3694}
3695impl<'a> IterableOvpnPeerDelInput<'a> {
3696    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3697        Self {
3698            buf,
3699            pos: 0,
3700            orig_loc,
3701        }
3702    }
3703    pub fn get_buf(&self) -> &'a [u8] {
3704        self.buf
3705    }
3706}
3707impl<'a> Iterator for IterableOvpnPeerDelInput<'a> {
3708    type Item = Result<OvpnPeerDelInput<'a>, ErrorContext>;
3709    fn next(&mut self) -> Option<Self::Item> {
3710        let mut pos;
3711        let mut r#type;
3712        loop {
3713            pos = self.pos;
3714            r#type = None;
3715            if self.buf.len() == self.pos {
3716                return None;
3717            }
3718            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3719                self.pos = self.buf.len();
3720                break;
3721            };
3722            r#type = Some(header.r#type);
3723            let res = match header.r#type {
3724                1u16 => OvpnPeerDelInput::Ifindex({
3725                    let res = parse_u32(next);
3726                    let Some(val) = res else { break };
3727                    val
3728                }),
3729                2u16 => OvpnPeerDelInput::Peer({
3730                    let res = Some(IterablePeerDelInput::with_loc(next, self.orig_loc));
3731                    let Some(val) = res else { break };
3732                    val
3733                }),
3734                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3735                n => continue,
3736            };
3737            return Some(Ok(res));
3738        }
3739        Some(Err(ErrorContext::new(
3740            "OvpnPeerDelInput",
3741            r#type.and_then(|t| OvpnPeerDelInput::attr_from_type(t)),
3742            self.orig_loc,
3743            self.buf.as_ptr().wrapping_add(pos) as usize,
3744        )))
3745    }
3746}
3747impl<'a> std::fmt::Debug for IterableOvpnPeerDelInput<'_> {
3748    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3749        let mut fmt = f.debug_struct("OvpnPeerDelInput");
3750        for attr in self.clone() {
3751            let attr = match attr {
3752                Ok(a) => a,
3753                Err(err) => {
3754                    fmt.finish()?;
3755                    f.write_str("Err(")?;
3756                    err.fmt(f)?;
3757                    return f.write_str(")");
3758                }
3759            };
3760            match attr {
3761                OvpnPeerDelInput::Ifindex(val) => fmt.field("Ifindex", &val),
3762                OvpnPeerDelInput::Peer(val) => fmt.field("Peer", &val),
3763            };
3764        }
3765        fmt.finish()
3766    }
3767}
3768impl IterableOvpnPeerDelInput<'_> {
3769    pub fn lookup_attr(
3770        &self,
3771        offset: usize,
3772        missing_type: Option<u16>,
3773    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3774        let mut stack = Vec::new();
3775        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3776        if missing_type.is_some() && cur == offset {
3777            stack.push(("OvpnPeerDelInput", offset));
3778            return (
3779                stack,
3780                missing_type.and_then(|t| OvpnPeerDelInput::attr_from_type(t)),
3781            );
3782        }
3783        if cur > offset || cur + self.buf.len() < offset {
3784            return (stack, None);
3785        }
3786        let mut attrs = self.clone();
3787        let mut last_off = cur + attrs.pos;
3788        let mut missing = None;
3789        while let Some(attr) = attrs.next() {
3790            let Ok(attr) = attr else { break };
3791            match attr {
3792                OvpnPeerDelInput::Ifindex(val) => {
3793                    if last_off == offset {
3794                        stack.push(("Ifindex", last_off));
3795                        break;
3796                    }
3797                }
3798                OvpnPeerDelInput::Peer(val) => {
3799                    (stack, missing) = val.lookup_attr(offset, missing_type);
3800                    if !stack.is_empty() {
3801                        break;
3802                    }
3803                }
3804                _ => {}
3805            };
3806            last_off = cur + attrs.pos;
3807        }
3808        if !stack.is_empty() {
3809            stack.push(("OvpnPeerDelInput", cur));
3810        }
3811        (stack, missing)
3812    }
3813}
3814#[derive(Clone)]
3815pub enum OvpnKeyconfGet<'a> {
3816    #[doc = "Index of the ovpn interface to operate on\n"]
3817    Ifindex(u32),
3818    #[doc = "Peer specific cipher configuration\n"]
3819    Keyconf(IterableKeyconfGet<'a>),
3820}
3821impl<'a> IterableOvpnKeyconfGet<'a> {
3822    #[doc = "Index of the ovpn interface to operate on\n"]
3823    pub fn get_ifindex(&self) -> Result<u32, ErrorContext> {
3824        let mut iter = self.clone();
3825        iter.pos = 0;
3826        for attr in iter {
3827            if let Ok(OvpnKeyconfGet::Ifindex(val)) = attr {
3828                return Ok(val);
3829            }
3830        }
3831        Err(ErrorContext::new_missing(
3832            "OvpnKeyconfGet",
3833            "Ifindex",
3834            self.orig_loc,
3835            self.buf.as_ptr() as usize,
3836        ))
3837    }
3838    #[doc = "Peer specific cipher configuration\n"]
3839    pub fn get_keyconf(&self) -> Result<IterableKeyconfGet<'a>, ErrorContext> {
3840        let mut iter = self.clone();
3841        iter.pos = 0;
3842        for attr in iter {
3843            if let Ok(OvpnKeyconfGet::Keyconf(val)) = attr {
3844                return Ok(val);
3845            }
3846        }
3847        Err(ErrorContext::new_missing(
3848            "OvpnKeyconfGet",
3849            "Keyconf",
3850            self.orig_loc,
3851            self.buf.as_ptr() as usize,
3852        ))
3853    }
3854}
3855impl OvpnKeyconfGet<'_> {
3856    pub fn new<'a>(buf: &'a [u8]) -> IterableOvpnKeyconfGet<'a> {
3857        IterableOvpnKeyconfGet::with_loc(buf, buf.as_ptr() as usize)
3858    }
3859    fn attr_from_type(r#type: u16) -> Option<&'static str> {
3860        Ovpn::attr_from_type(r#type)
3861    }
3862}
3863#[derive(Clone, Copy, Default)]
3864pub struct IterableOvpnKeyconfGet<'a> {
3865    buf: &'a [u8],
3866    pos: usize,
3867    orig_loc: usize,
3868}
3869impl<'a> IterableOvpnKeyconfGet<'a> {
3870    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
3871        Self {
3872            buf,
3873            pos: 0,
3874            orig_loc,
3875        }
3876    }
3877    pub fn get_buf(&self) -> &'a [u8] {
3878        self.buf
3879    }
3880}
3881impl<'a> Iterator for IterableOvpnKeyconfGet<'a> {
3882    type Item = Result<OvpnKeyconfGet<'a>, ErrorContext>;
3883    fn next(&mut self) -> Option<Self::Item> {
3884        let mut pos;
3885        let mut r#type;
3886        loop {
3887            pos = self.pos;
3888            r#type = None;
3889            if self.buf.len() == self.pos {
3890                return None;
3891            }
3892            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
3893                self.pos = self.buf.len();
3894                break;
3895            };
3896            r#type = Some(header.r#type);
3897            let res = match header.r#type {
3898                1u16 => OvpnKeyconfGet::Ifindex({
3899                    let res = parse_u32(next);
3900                    let Some(val) = res else { break };
3901                    val
3902                }),
3903                3u16 => OvpnKeyconfGet::Keyconf({
3904                    let res = Some(IterableKeyconfGet::with_loc(next, self.orig_loc));
3905                    let Some(val) = res else { break };
3906                    val
3907                }),
3908                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
3909                n => continue,
3910            };
3911            return Some(Ok(res));
3912        }
3913        Some(Err(ErrorContext::new(
3914            "OvpnKeyconfGet",
3915            r#type.and_then(|t| OvpnKeyconfGet::attr_from_type(t)),
3916            self.orig_loc,
3917            self.buf.as_ptr().wrapping_add(pos) as usize,
3918        )))
3919    }
3920}
3921impl<'a> std::fmt::Debug for IterableOvpnKeyconfGet<'_> {
3922    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3923        let mut fmt = f.debug_struct("OvpnKeyconfGet");
3924        for attr in self.clone() {
3925            let attr = match attr {
3926                Ok(a) => a,
3927                Err(err) => {
3928                    fmt.finish()?;
3929                    f.write_str("Err(")?;
3930                    err.fmt(f)?;
3931                    return f.write_str(")");
3932                }
3933            };
3934            match attr {
3935                OvpnKeyconfGet::Ifindex(val) => fmt.field("Ifindex", &val),
3936                OvpnKeyconfGet::Keyconf(val) => fmt.field("Keyconf", &val),
3937            };
3938        }
3939        fmt.finish()
3940    }
3941}
3942impl IterableOvpnKeyconfGet<'_> {
3943    pub fn lookup_attr(
3944        &self,
3945        offset: usize,
3946        missing_type: Option<u16>,
3947    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3948        let mut stack = Vec::new();
3949        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
3950        if missing_type.is_some() && cur == offset {
3951            stack.push(("OvpnKeyconfGet", offset));
3952            return (
3953                stack,
3954                missing_type.and_then(|t| OvpnKeyconfGet::attr_from_type(t)),
3955            );
3956        }
3957        if cur > offset || cur + self.buf.len() < offset {
3958            return (stack, None);
3959        }
3960        let mut attrs = self.clone();
3961        let mut last_off = cur + attrs.pos;
3962        let mut missing = None;
3963        while let Some(attr) = attrs.next() {
3964            let Ok(attr) = attr else { break };
3965            match attr {
3966                OvpnKeyconfGet::Ifindex(val) => {
3967                    if last_off == offset {
3968                        stack.push(("Ifindex", last_off));
3969                        break;
3970                    }
3971                }
3972                OvpnKeyconfGet::Keyconf(val) => {
3973                    (stack, missing) = val.lookup_attr(offset, missing_type);
3974                    if !stack.is_empty() {
3975                        break;
3976                    }
3977                }
3978                _ => {}
3979            };
3980            last_off = cur + attrs.pos;
3981        }
3982        if !stack.is_empty() {
3983            stack.push(("OvpnKeyconfGet", cur));
3984        }
3985        (stack, missing)
3986    }
3987}
3988#[derive(Clone)]
3989pub enum OvpnKeyconfSwapInput<'a> {
3990    #[doc = "Index of the ovpn interface to operate on\n"]
3991    Ifindex(u32),
3992    #[doc = "Peer specific cipher configuration\n"]
3993    Keyconf(IterableKeyconfSwapInput<'a>),
3994}
3995impl<'a> IterableOvpnKeyconfSwapInput<'a> {
3996    #[doc = "Index of the ovpn interface to operate on\n"]
3997    pub fn get_ifindex(&self) -> Result<u32, ErrorContext> {
3998        let mut iter = self.clone();
3999        iter.pos = 0;
4000        for attr in iter {
4001            if let Ok(OvpnKeyconfSwapInput::Ifindex(val)) = attr {
4002                return Ok(val);
4003            }
4004        }
4005        Err(ErrorContext::new_missing(
4006            "OvpnKeyconfSwapInput",
4007            "Ifindex",
4008            self.orig_loc,
4009            self.buf.as_ptr() as usize,
4010        ))
4011    }
4012    #[doc = "Peer specific cipher configuration\n"]
4013    pub fn get_keyconf(&self) -> Result<IterableKeyconfSwapInput<'a>, ErrorContext> {
4014        let mut iter = self.clone();
4015        iter.pos = 0;
4016        for attr in iter {
4017            if let Ok(OvpnKeyconfSwapInput::Keyconf(val)) = attr {
4018                return Ok(val);
4019            }
4020        }
4021        Err(ErrorContext::new_missing(
4022            "OvpnKeyconfSwapInput",
4023            "Keyconf",
4024            self.orig_loc,
4025            self.buf.as_ptr() as usize,
4026        ))
4027    }
4028}
4029impl OvpnKeyconfSwapInput<'_> {
4030    pub fn new<'a>(buf: &'a [u8]) -> IterableOvpnKeyconfSwapInput<'a> {
4031        IterableOvpnKeyconfSwapInput::with_loc(buf, buf.as_ptr() as usize)
4032    }
4033    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4034        Ovpn::attr_from_type(r#type)
4035    }
4036}
4037#[derive(Clone, Copy, Default)]
4038pub struct IterableOvpnKeyconfSwapInput<'a> {
4039    buf: &'a [u8],
4040    pos: usize,
4041    orig_loc: usize,
4042}
4043impl<'a> IterableOvpnKeyconfSwapInput<'a> {
4044    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4045        Self {
4046            buf,
4047            pos: 0,
4048            orig_loc,
4049        }
4050    }
4051    pub fn get_buf(&self) -> &'a [u8] {
4052        self.buf
4053    }
4054}
4055impl<'a> Iterator for IterableOvpnKeyconfSwapInput<'a> {
4056    type Item = Result<OvpnKeyconfSwapInput<'a>, ErrorContext>;
4057    fn next(&mut self) -> Option<Self::Item> {
4058        let mut pos;
4059        let mut r#type;
4060        loop {
4061            pos = self.pos;
4062            r#type = None;
4063            if self.buf.len() == self.pos {
4064                return None;
4065            }
4066            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
4067                self.pos = self.buf.len();
4068                break;
4069            };
4070            r#type = Some(header.r#type);
4071            let res = match header.r#type {
4072                1u16 => OvpnKeyconfSwapInput::Ifindex({
4073                    let res = parse_u32(next);
4074                    let Some(val) = res else { break };
4075                    val
4076                }),
4077                3u16 => OvpnKeyconfSwapInput::Keyconf({
4078                    let res = Some(IterableKeyconfSwapInput::with_loc(next, self.orig_loc));
4079                    let Some(val) = res else { break };
4080                    val
4081                }),
4082                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4083                n => continue,
4084            };
4085            return Some(Ok(res));
4086        }
4087        Some(Err(ErrorContext::new(
4088            "OvpnKeyconfSwapInput",
4089            r#type.and_then(|t| OvpnKeyconfSwapInput::attr_from_type(t)),
4090            self.orig_loc,
4091            self.buf.as_ptr().wrapping_add(pos) as usize,
4092        )))
4093    }
4094}
4095impl<'a> std::fmt::Debug for IterableOvpnKeyconfSwapInput<'_> {
4096    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4097        let mut fmt = f.debug_struct("OvpnKeyconfSwapInput");
4098        for attr in self.clone() {
4099            let attr = match attr {
4100                Ok(a) => a,
4101                Err(err) => {
4102                    fmt.finish()?;
4103                    f.write_str("Err(")?;
4104                    err.fmt(f)?;
4105                    return f.write_str(")");
4106                }
4107            };
4108            match attr {
4109                OvpnKeyconfSwapInput::Ifindex(val) => fmt.field("Ifindex", &val),
4110                OvpnKeyconfSwapInput::Keyconf(val) => fmt.field("Keyconf", &val),
4111            };
4112        }
4113        fmt.finish()
4114    }
4115}
4116impl IterableOvpnKeyconfSwapInput<'_> {
4117    pub fn lookup_attr(
4118        &self,
4119        offset: usize,
4120        missing_type: Option<u16>,
4121    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4122        let mut stack = Vec::new();
4123        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4124        if missing_type.is_some() && cur == offset {
4125            stack.push(("OvpnKeyconfSwapInput", offset));
4126            return (
4127                stack,
4128                missing_type.and_then(|t| OvpnKeyconfSwapInput::attr_from_type(t)),
4129            );
4130        }
4131        if cur > offset || cur + self.buf.len() < offset {
4132            return (stack, None);
4133        }
4134        let mut attrs = self.clone();
4135        let mut last_off = cur + attrs.pos;
4136        let mut missing = None;
4137        while let Some(attr) = attrs.next() {
4138            let Ok(attr) = attr else { break };
4139            match attr {
4140                OvpnKeyconfSwapInput::Ifindex(val) => {
4141                    if last_off == offset {
4142                        stack.push(("Ifindex", last_off));
4143                        break;
4144                    }
4145                }
4146                OvpnKeyconfSwapInput::Keyconf(val) => {
4147                    (stack, missing) = val.lookup_attr(offset, missing_type);
4148                    if !stack.is_empty() {
4149                        break;
4150                    }
4151                }
4152                _ => {}
4153            };
4154            last_off = cur + attrs.pos;
4155        }
4156        if !stack.is_empty() {
4157            stack.push(("OvpnKeyconfSwapInput", cur));
4158        }
4159        (stack, missing)
4160    }
4161}
4162#[derive(Clone)]
4163pub enum OvpnKeyconfDelInput<'a> {
4164    #[doc = "Index of the ovpn interface to operate on\n"]
4165    Ifindex(u32),
4166    #[doc = "Peer specific cipher configuration\n"]
4167    Keyconf(IterableKeyconfDelInput<'a>),
4168}
4169impl<'a> IterableOvpnKeyconfDelInput<'a> {
4170    #[doc = "Index of the ovpn interface to operate on\n"]
4171    pub fn get_ifindex(&self) -> Result<u32, ErrorContext> {
4172        let mut iter = self.clone();
4173        iter.pos = 0;
4174        for attr in iter {
4175            if let Ok(OvpnKeyconfDelInput::Ifindex(val)) = attr {
4176                return Ok(val);
4177            }
4178        }
4179        Err(ErrorContext::new_missing(
4180            "OvpnKeyconfDelInput",
4181            "Ifindex",
4182            self.orig_loc,
4183            self.buf.as_ptr() as usize,
4184        ))
4185    }
4186    #[doc = "Peer specific cipher configuration\n"]
4187    pub fn get_keyconf(&self) -> Result<IterableKeyconfDelInput<'a>, ErrorContext> {
4188        let mut iter = self.clone();
4189        iter.pos = 0;
4190        for attr in iter {
4191            if let Ok(OvpnKeyconfDelInput::Keyconf(val)) = attr {
4192                return Ok(val);
4193            }
4194        }
4195        Err(ErrorContext::new_missing(
4196            "OvpnKeyconfDelInput",
4197            "Keyconf",
4198            self.orig_loc,
4199            self.buf.as_ptr() as usize,
4200        ))
4201    }
4202}
4203impl OvpnKeyconfDelInput<'_> {
4204    pub fn new<'a>(buf: &'a [u8]) -> IterableOvpnKeyconfDelInput<'a> {
4205        IterableOvpnKeyconfDelInput::with_loc(buf, buf.as_ptr() as usize)
4206    }
4207    fn attr_from_type(r#type: u16) -> Option<&'static str> {
4208        Ovpn::attr_from_type(r#type)
4209    }
4210}
4211#[derive(Clone, Copy, Default)]
4212pub struct IterableOvpnKeyconfDelInput<'a> {
4213    buf: &'a [u8],
4214    pos: usize,
4215    orig_loc: usize,
4216}
4217impl<'a> IterableOvpnKeyconfDelInput<'a> {
4218    fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
4219        Self {
4220            buf,
4221            pos: 0,
4222            orig_loc,
4223        }
4224    }
4225    pub fn get_buf(&self) -> &'a [u8] {
4226        self.buf
4227    }
4228}
4229impl<'a> Iterator for IterableOvpnKeyconfDelInput<'a> {
4230    type Item = Result<OvpnKeyconfDelInput<'a>, ErrorContext>;
4231    fn next(&mut self) -> Option<Self::Item> {
4232        let mut pos;
4233        let mut r#type;
4234        loop {
4235            pos = self.pos;
4236            r#type = None;
4237            if self.buf.len() == self.pos {
4238                return None;
4239            }
4240            let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
4241                self.pos = self.buf.len();
4242                break;
4243            };
4244            r#type = Some(header.r#type);
4245            let res = match header.r#type {
4246                1u16 => OvpnKeyconfDelInput::Ifindex({
4247                    let res = parse_u32(next);
4248                    let Some(val) = res else { break };
4249                    val
4250                }),
4251                3u16 => OvpnKeyconfDelInput::Keyconf({
4252                    let res = Some(IterableKeyconfDelInput::with_loc(next, self.orig_loc));
4253                    let Some(val) = res else { break };
4254                    val
4255                }),
4256                n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
4257                n => continue,
4258            };
4259            return Some(Ok(res));
4260        }
4261        Some(Err(ErrorContext::new(
4262            "OvpnKeyconfDelInput",
4263            r#type.and_then(|t| OvpnKeyconfDelInput::attr_from_type(t)),
4264            self.orig_loc,
4265            self.buf.as_ptr().wrapping_add(pos) as usize,
4266        )))
4267    }
4268}
4269impl<'a> std::fmt::Debug for IterableOvpnKeyconfDelInput<'_> {
4270    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4271        let mut fmt = f.debug_struct("OvpnKeyconfDelInput");
4272        for attr in self.clone() {
4273            let attr = match attr {
4274                Ok(a) => a,
4275                Err(err) => {
4276                    fmt.finish()?;
4277                    f.write_str("Err(")?;
4278                    err.fmt(f)?;
4279                    return f.write_str(")");
4280                }
4281            };
4282            match attr {
4283                OvpnKeyconfDelInput::Ifindex(val) => fmt.field("Ifindex", &val),
4284                OvpnKeyconfDelInput::Keyconf(val) => fmt.field("Keyconf", &val),
4285            };
4286        }
4287        fmt.finish()
4288    }
4289}
4290impl IterableOvpnKeyconfDelInput<'_> {
4291    pub fn lookup_attr(
4292        &self,
4293        offset: usize,
4294        missing_type: Option<u16>,
4295    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
4296        let mut stack = Vec::new();
4297        let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
4298        if missing_type.is_some() && cur == offset {
4299            stack.push(("OvpnKeyconfDelInput", offset));
4300            return (
4301                stack,
4302                missing_type.and_then(|t| OvpnKeyconfDelInput::attr_from_type(t)),
4303            );
4304        }
4305        if cur > offset || cur + self.buf.len() < offset {
4306            return (stack, None);
4307        }
4308        let mut attrs = self.clone();
4309        let mut last_off = cur + attrs.pos;
4310        let mut missing = None;
4311        while let Some(attr) = attrs.next() {
4312            let Ok(attr) = attr else { break };
4313            match attr {
4314                OvpnKeyconfDelInput::Ifindex(val) => {
4315                    if last_off == offset {
4316                        stack.push(("Ifindex", last_off));
4317                        break;
4318                    }
4319                }
4320                OvpnKeyconfDelInput::Keyconf(val) => {
4321                    (stack, missing) = val.lookup_attr(offset, missing_type);
4322                    if !stack.is_empty() {
4323                        break;
4324                    }
4325                }
4326                _ => {}
4327            };
4328            last_off = cur + attrs.pos;
4329        }
4330        if !stack.is_empty() {
4331            stack.push(("OvpnKeyconfDelInput", cur));
4332        }
4333        (stack, missing)
4334    }
4335}
4336pub struct PushPeer<Prev: Pusher> {
4337    pub(crate) prev: Option<Prev>,
4338    pub(crate) header_offset: Option<usize>,
4339}
4340impl<Prev: Pusher> Pusher for PushPeer<Prev> {
4341    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
4342        self.prev.as_mut().unwrap().as_vec_mut()
4343    }
4344    fn as_vec(&self) -> &Vec<u8> {
4345        self.prev.as_ref().unwrap().as_vec()
4346    }
4347}
4348impl<Prev: Pusher> PushPeer<Prev> {
4349    pub fn new(prev: Prev) -> Self {
4350        Self {
4351            prev: Some(prev),
4352            header_offset: None,
4353        }
4354    }
4355    pub fn end_nested(mut self) -> Prev {
4356        let mut prev = self.prev.take().unwrap();
4357        if let Some(header_offset) = &self.header_offset {
4358            finalize_nested_header(prev.as_vec_mut(), *header_offset);
4359        }
4360        prev
4361    }
4362    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
4363    pub fn push_id(mut self, value: u32) -> Self {
4364        push_header(self.as_vec_mut(), 1u16, 4 as u16);
4365        self.as_vec_mut().extend(value.to_ne_bytes());
4366        self
4367    }
4368    #[doc = "The remote IPv4 address of the peer\n"]
4369    pub fn push_remote_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4370        push_header(self.as_vec_mut(), 2u16, 4 as u16);
4371        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4372        self
4373    }
4374    #[doc = "The remote IPv6 address of the peer\n"]
4375    pub fn push_remote_ipv6(mut self, value: &[u8]) -> Self {
4376        push_header(self.as_vec_mut(), 3u16, value.len() as u16);
4377        self.as_vec_mut().extend(value);
4378        self
4379    }
4380    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
4381    pub fn push_remote_ipv6_scope_id(mut self, value: u32) -> Self {
4382        push_header(self.as_vec_mut(), 4u16, 4 as u16);
4383        self.as_vec_mut().extend(value.to_ne_bytes());
4384        self
4385    }
4386    #[doc = "The remote port of the peer\n"]
4387    pub fn push_remote_port(mut self, value: u16) -> Self {
4388        push_header(self.as_vec_mut(), 5u16, 2 as u16);
4389        self.as_vec_mut().extend(value.to_be_bytes());
4390        self
4391    }
4392    #[doc = "The socket to be used to communicate with the peer\n"]
4393    pub fn push_socket(mut self, value: u32) -> Self {
4394        push_header(self.as_vec_mut(), 6u16, 4 as u16);
4395        self.as_vec_mut().extend(value.to_ne_bytes());
4396        self
4397    }
4398    #[doc = "The ID of the netns the socket assigned to this peer lives in\n"]
4399    pub fn push_socket_netnsid(mut self, value: i32) -> Self {
4400        push_header(self.as_vec_mut(), 7u16, 4 as u16);
4401        self.as_vec_mut().extend(value.to_ne_bytes());
4402        self
4403    }
4404    #[doc = "The IPv4 address assigned to the peer by the server\n"]
4405    pub fn push_vpn_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4406        push_header(self.as_vec_mut(), 8u16, 4 as u16);
4407        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4408        self
4409    }
4410    #[doc = "The IPv6 address assigned to the peer by the server\n"]
4411    pub fn push_vpn_ipv6(mut self, value: &[u8]) -> Self {
4412        push_header(self.as_vec_mut(), 9u16, value.len() as u16);
4413        self.as_vec_mut().extend(value);
4414        self
4415    }
4416    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
4417    pub fn push_local_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4418        push_header(self.as_vec_mut(), 10u16, 4 as u16);
4419        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4420        self
4421    }
4422    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
4423    pub fn push_local_ipv6(mut self, value: &[u8]) -> Self {
4424        push_header(self.as_vec_mut(), 11u16, value.len() as u16);
4425        self.as_vec_mut().extend(value);
4426        self
4427    }
4428    #[doc = "The local port to be used to send packets to the peer (UDP only)\n"]
4429    pub fn push_local_port(mut self, value: u16) -> Self {
4430        push_header(self.as_vec_mut(), 12u16, 2 as u16);
4431        self.as_vec_mut().extend(value.to_be_bytes());
4432        self
4433    }
4434    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
4435    pub fn push_keepalive_interval(mut self, value: u32) -> Self {
4436        push_header(self.as_vec_mut(), 13u16, 4 as u16);
4437        self.as_vec_mut().extend(value.to_ne_bytes());
4438        self
4439    }
4440    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
4441    pub fn push_keepalive_timeout(mut self, value: u32) -> Self {
4442        push_header(self.as_vec_mut(), 14u16, 4 as u16);
4443        self.as_vec_mut().extend(value.to_ne_bytes());
4444        self
4445    }
4446    #[doc = "The reason why a peer was deleted\n\nAssociated type: [`DelPeerReason`] (enum)"]
4447    pub fn push_del_reason(mut self, value: u32) -> Self {
4448        push_header(self.as_vec_mut(), 15u16, 4 as u16);
4449        self.as_vec_mut().extend(value.to_ne_bytes());
4450        self
4451    }
4452    #[doc = "Number of bytes received over the tunnel\n"]
4453    pub fn push_vpn_rx_bytes(mut self, value: u32) -> Self {
4454        push_header(self.as_vec_mut(), 16u16, 4 as u16);
4455        self.as_vec_mut().extend(value.to_ne_bytes());
4456        self
4457    }
4458    #[doc = "Number of bytes transmitted over the tunnel\n"]
4459    pub fn push_vpn_tx_bytes(mut self, value: u32) -> Self {
4460        push_header(self.as_vec_mut(), 17u16, 4 as u16);
4461        self.as_vec_mut().extend(value.to_ne_bytes());
4462        self
4463    }
4464    #[doc = "Number of packets received over the tunnel\n"]
4465    pub fn push_vpn_rx_packets(mut self, value: u32) -> Self {
4466        push_header(self.as_vec_mut(), 18u16, 4 as u16);
4467        self.as_vec_mut().extend(value.to_ne_bytes());
4468        self
4469    }
4470    #[doc = "Number of packets transmitted over the tunnel\n"]
4471    pub fn push_vpn_tx_packets(mut self, value: u32) -> Self {
4472        push_header(self.as_vec_mut(), 19u16, 4 as u16);
4473        self.as_vec_mut().extend(value.to_ne_bytes());
4474        self
4475    }
4476    #[doc = "Number of bytes received at the transport level\n"]
4477    pub fn push_link_rx_bytes(mut self, value: u32) -> Self {
4478        push_header(self.as_vec_mut(), 20u16, 4 as u16);
4479        self.as_vec_mut().extend(value.to_ne_bytes());
4480        self
4481    }
4482    #[doc = "Number of bytes transmitted at the transport level\n"]
4483    pub fn push_link_tx_bytes(mut self, value: u32) -> Self {
4484        push_header(self.as_vec_mut(), 21u16, 4 as u16);
4485        self.as_vec_mut().extend(value.to_ne_bytes());
4486        self
4487    }
4488    #[doc = "Number of packets received at the transport level\n"]
4489    pub fn push_link_rx_packets(mut self, value: u32) -> Self {
4490        push_header(self.as_vec_mut(), 22u16, 4 as u16);
4491        self.as_vec_mut().extend(value.to_ne_bytes());
4492        self
4493    }
4494    #[doc = "Number of packets transmitted at the transport level\n"]
4495    pub fn push_link_tx_packets(mut self, value: u32) -> Self {
4496        push_header(self.as_vec_mut(), 23u16, 4 as u16);
4497        self.as_vec_mut().extend(value.to_ne_bytes());
4498        self
4499    }
4500    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
4501    pub fn push_tx_id(mut self, value: u32) -> Self {
4502        push_header(self.as_vec_mut(), 24u16, 4 as u16);
4503        self.as_vec_mut().extend(value.to_ne_bytes());
4504        self
4505    }
4506}
4507impl<Prev: Pusher> Drop for PushPeer<Prev> {
4508    fn drop(&mut self) {
4509        if let Some(prev) = &mut self.prev {
4510            if let Some(header_offset) = &self.header_offset {
4511                finalize_nested_header(prev.as_vec_mut(), *header_offset);
4512            }
4513        }
4514    }
4515}
4516pub struct PushPeerNewInput<Prev: Pusher> {
4517    pub(crate) prev: Option<Prev>,
4518    pub(crate) header_offset: Option<usize>,
4519}
4520impl<Prev: Pusher> Pusher for PushPeerNewInput<Prev> {
4521    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
4522        self.prev.as_mut().unwrap().as_vec_mut()
4523    }
4524    fn as_vec(&self) -> &Vec<u8> {
4525        self.prev.as_ref().unwrap().as_vec()
4526    }
4527}
4528impl<Prev: Pusher> PushPeerNewInput<Prev> {
4529    pub fn new(prev: Prev) -> Self {
4530        Self {
4531            prev: Some(prev),
4532            header_offset: None,
4533        }
4534    }
4535    pub fn end_nested(mut self) -> Prev {
4536        let mut prev = self.prev.take().unwrap();
4537        if let Some(header_offset) = &self.header_offset {
4538            finalize_nested_header(prev.as_vec_mut(), *header_offset);
4539        }
4540        prev
4541    }
4542    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
4543    pub fn push_id(mut self, value: u32) -> Self {
4544        push_header(self.as_vec_mut(), 1u16, 4 as u16);
4545        self.as_vec_mut().extend(value.to_ne_bytes());
4546        self
4547    }
4548    #[doc = "The remote IPv4 address of the peer\n"]
4549    pub fn push_remote_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4550        push_header(self.as_vec_mut(), 2u16, 4 as u16);
4551        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4552        self
4553    }
4554    #[doc = "The remote IPv6 address of the peer\n"]
4555    pub fn push_remote_ipv6(mut self, value: &[u8]) -> Self {
4556        push_header(self.as_vec_mut(), 3u16, value.len() as u16);
4557        self.as_vec_mut().extend(value);
4558        self
4559    }
4560    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
4561    pub fn push_remote_ipv6_scope_id(mut self, value: u32) -> Self {
4562        push_header(self.as_vec_mut(), 4u16, 4 as u16);
4563        self.as_vec_mut().extend(value.to_ne_bytes());
4564        self
4565    }
4566    #[doc = "The remote port of the peer\n"]
4567    pub fn push_remote_port(mut self, value: u16) -> Self {
4568        push_header(self.as_vec_mut(), 5u16, 2 as u16);
4569        self.as_vec_mut().extend(value.to_be_bytes());
4570        self
4571    }
4572    #[doc = "The socket to be used to communicate with the peer\n"]
4573    pub fn push_socket(mut self, value: u32) -> Self {
4574        push_header(self.as_vec_mut(), 6u16, 4 as u16);
4575        self.as_vec_mut().extend(value.to_ne_bytes());
4576        self
4577    }
4578    #[doc = "The IPv4 address assigned to the peer by the server\n"]
4579    pub fn push_vpn_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4580        push_header(self.as_vec_mut(), 8u16, 4 as u16);
4581        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4582        self
4583    }
4584    #[doc = "The IPv6 address assigned to the peer by the server\n"]
4585    pub fn push_vpn_ipv6(mut self, value: &[u8]) -> Self {
4586        push_header(self.as_vec_mut(), 9u16, value.len() as u16);
4587        self.as_vec_mut().extend(value);
4588        self
4589    }
4590    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
4591    pub fn push_local_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4592        push_header(self.as_vec_mut(), 10u16, 4 as u16);
4593        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4594        self
4595    }
4596    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
4597    pub fn push_local_ipv6(mut self, value: &[u8]) -> Self {
4598        push_header(self.as_vec_mut(), 11u16, value.len() as u16);
4599        self.as_vec_mut().extend(value);
4600        self
4601    }
4602    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
4603    pub fn push_keepalive_interval(mut self, value: u32) -> Self {
4604        push_header(self.as_vec_mut(), 13u16, 4 as u16);
4605        self.as_vec_mut().extend(value.to_ne_bytes());
4606        self
4607    }
4608    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
4609    pub fn push_keepalive_timeout(mut self, value: u32) -> Self {
4610        push_header(self.as_vec_mut(), 14u16, 4 as u16);
4611        self.as_vec_mut().extend(value.to_ne_bytes());
4612        self
4613    }
4614    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
4615    pub fn push_tx_id(mut self, value: u32) -> Self {
4616        push_header(self.as_vec_mut(), 24u16, 4 as u16);
4617        self.as_vec_mut().extend(value.to_ne_bytes());
4618        self
4619    }
4620}
4621impl<Prev: Pusher> Drop for PushPeerNewInput<Prev> {
4622    fn drop(&mut self) {
4623        if let Some(prev) = &mut self.prev {
4624            if let Some(header_offset) = &self.header_offset {
4625                finalize_nested_header(prev.as_vec_mut(), *header_offset);
4626            }
4627        }
4628    }
4629}
4630pub struct PushPeerSetInput<Prev: Pusher> {
4631    pub(crate) prev: Option<Prev>,
4632    pub(crate) header_offset: Option<usize>,
4633}
4634impl<Prev: Pusher> Pusher for PushPeerSetInput<Prev> {
4635    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
4636        self.prev.as_mut().unwrap().as_vec_mut()
4637    }
4638    fn as_vec(&self) -> &Vec<u8> {
4639        self.prev.as_ref().unwrap().as_vec()
4640    }
4641}
4642impl<Prev: Pusher> PushPeerSetInput<Prev> {
4643    pub fn new(prev: Prev) -> Self {
4644        Self {
4645            prev: Some(prev),
4646            header_offset: None,
4647        }
4648    }
4649    pub fn end_nested(mut self) -> Prev {
4650        let mut prev = self.prev.take().unwrap();
4651        if let Some(header_offset) = &self.header_offset {
4652            finalize_nested_header(prev.as_vec_mut(), *header_offset);
4653        }
4654        prev
4655    }
4656    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
4657    pub fn push_id(mut self, value: u32) -> Self {
4658        push_header(self.as_vec_mut(), 1u16, 4 as u16);
4659        self.as_vec_mut().extend(value.to_ne_bytes());
4660        self
4661    }
4662    #[doc = "The remote IPv4 address of the peer\n"]
4663    pub fn push_remote_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4664        push_header(self.as_vec_mut(), 2u16, 4 as u16);
4665        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4666        self
4667    }
4668    #[doc = "The remote IPv6 address of the peer\n"]
4669    pub fn push_remote_ipv6(mut self, value: &[u8]) -> Self {
4670        push_header(self.as_vec_mut(), 3u16, value.len() as u16);
4671        self.as_vec_mut().extend(value);
4672        self
4673    }
4674    #[doc = "The scope id of the remote IPv6 address of the peer (RFC2553)\n"]
4675    pub fn push_remote_ipv6_scope_id(mut self, value: u32) -> Self {
4676        push_header(self.as_vec_mut(), 4u16, 4 as u16);
4677        self.as_vec_mut().extend(value.to_ne_bytes());
4678        self
4679    }
4680    #[doc = "The remote port of the peer\n"]
4681    pub fn push_remote_port(mut self, value: u16) -> Self {
4682        push_header(self.as_vec_mut(), 5u16, 2 as u16);
4683        self.as_vec_mut().extend(value.to_be_bytes());
4684        self
4685    }
4686    #[doc = "The IPv4 address assigned to the peer by the server\n"]
4687    pub fn push_vpn_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4688        push_header(self.as_vec_mut(), 8u16, 4 as u16);
4689        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4690        self
4691    }
4692    #[doc = "The IPv6 address assigned to the peer by the server\n"]
4693    pub fn push_vpn_ipv6(mut self, value: &[u8]) -> Self {
4694        push_header(self.as_vec_mut(), 9u16, value.len() as u16);
4695        self.as_vec_mut().extend(value);
4696        self
4697    }
4698    #[doc = "The local IPv4 to be used to send packets to the peer (UDP only)\n"]
4699    pub fn push_local_ipv4(mut self, value: std::net::Ipv4Addr) -> Self {
4700        push_header(self.as_vec_mut(), 10u16, 4 as u16);
4701        self.as_vec_mut().extend(&value.to_bits().to_be_bytes());
4702        self
4703    }
4704    #[doc = "The local IPv6 to be used to send packets to the peer (UDP only)\n"]
4705    pub fn push_local_ipv6(mut self, value: &[u8]) -> Self {
4706        push_header(self.as_vec_mut(), 11u16, value.len() as u16);
4707        self.as_vec_mut().extend(value);
4708        self
4709    }
4710    #[doc = "The number of seconds after which a keep alive message is sent to the\npeer\n"]
4711    pub fn push_keepalive_interval(mut self, value: u32) -> Self {
4712        push_header(self.as_vec_mut(), 13u16, 4 as u16);
4713        self.as_vec_mut().extend(value.to_ne_bytes());
4714        self
4715    }
4716    #[doc = "The number of seconds from the last activity after which the peer is\nassumed dead\n"]
4717    pub fn push_keepalive_timeout(mut self, value: u32) -> Self {
4718        push_header(self.as_vec_mut(), 14u16, 4 as u16);
4719        self.as_vec_mut().extend(value.to_ne_bytes());
4720        self
4721    }
4722    #[doc = "The ID value used when transmitting packets to this peer. This way\noutgoing packets can have a different ID than incoming ones. Useful in\nmultipeer-to-multipeer connections, where each peer will advertise the\ntx-id to be used on the link.\n"]
4723    pub fn push_tx_id(mut self, value: u32) -> Self {
4724        push_header(self.as_vec_mut(), 24u16, 4 as u16);
4725        self.as_vec_mut().extend(value.to_ne_bytes());
4726        self
4727    }
4728}
4729impl<Prev: Pusher> Drop for PushPeerSetInput<Prev> {
4730    fn drop(&mut self) {
4731        if let Some(prev) = &mut self.prev {
4732            if let Some(header_offset) = &self.header_offset {
4733                finalize_nested_header(prev.as_vec_mut(), *header_offset);
4734            }
4735        }
4736    }
4737}
4738pub struct PushPeerDelInput<Prev: Pusher> {
4739    pub(crate) prev: Option<Prev>,
4740    pub(crate) header_offset: Option<usize>,
4741}
4742impl<Prev: Pusher> Pusher for PushPeerDelInput<Prev> {
4743    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
4744        self.prev.as_mut().unwrap().as_vec_mut()
4745    }
4746    fn as_vec(&self) -> &Vec<u8> {
4747        self.prev.as_ref().unwrap().as_vec()
4748    }
4749}
4750impl<Prev: Pusher> PushPeerDelInput<Prev> {
4751    pub fn new(prev: Prev) -> Self {
4752        Self {
4753            prev: Some(prev),
4754            header_offset: None,
4755        }
4756    }
4757    pub fn end_nested(mut self) -> Prev {
4758        let mut prev = self.prev.take().unwrap();
4759        if let Some(header_offset) = &self.header_offset {
4760            finalize_nested_header(prev.as_vec_mut(), *header_offset);
4761        }
4762        prev
4763    }
4764    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during operations for a specific device. Also used to match\npackets received from this peer.\n"]
4765    pub fn push_id(mut self, value: u32) -> Self {
4766        push_header(self.as_vec_mut(), 1u16, 4 as u16);
4767        self.as_vec_mut().extend(value.to_ne_bytes());
4768        self
4769    }
4770}
4771impl<Prev: Pusher> Drop for PushPeerDelInput<Prev> {
4772    fn drop(&mut self) {
4773        if let Some(prev) = &mut self.prev {
4774            if let Some(header_offset) = &self.header_offset {
4775                finalize_nested_header(prev.as_vec_mut(), *header_offset);
4776            }
4777        }
4778    }
4779}
4780pub struct PushKeyconf<Prev: Pusher> {
4781    pub(crate) prev: Option<Prev>,
4782    pub(crate) header_offset: Option<usize>,
4783}
4784impl<Prev: Pusher> Pusher for PushKeyconf<Prev> {
4785    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
4786        self.prev.as_mut().unwrap().as_vec_mut()
4787    }
4788    fn as_vec(&self) -> &Vec<u8> {
4789        self.prev.as_ref().unwrap().as_vec()
4790    }
4791}
4792impl<Prev: Pusher> PushKeyconf<Prev> {
4793    pub fn new(prev: Prev) -> Self {
4794        Self {
4795            prev: Some(prev),
4796            header_offset: None,
4797        }
4798    }
4799    pub fn end_nested(mut self) -> Prev {
4800        let mut prev = self.prev.take().unwrap();
4801        if let Some(header_offset) = &self.header_offset {
4802            finalize_nested_header(prev.as_vec_mut(), *header_offset);
4803        }
4804        prev
4805    }
4806    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
4807    pub fn push_peer_id(mut self, value: u32) -> Self {
4808        push_header(self.as_vec_mut(), 1u16, 4 as u16);
4809        self.as_vec_mut().extend(value.to_ne_bytes());
4810        self
4811    }
4812    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
4813    pub fn push_slot(mut self, value: u32) -> Self {
4814        push_header(self.as_vec_mut(), 2u16, 4 as u16);
4815        self.as_vec_mut().extend(value.to_ne_bytes());
4816        self
4817    }
4818    #[doc = "The unique ID of the key in the peer context. Used to fetch the correct\nkey upon decryption\n"]
4819    pub fn push_key_id(mut self, value: u32) -> Self {
4820        push_header(self.as_vec_mut(), 3u16, 4 as u16);
4821        self.as_vec_mut().extend(value.to_ne_bytes());
4822        self
4823    }
4824    #[doc = "The cipher to be used when communicating with the peer\n\nAssociated type: [`CipherAlg`] (enum)"]
4825    pub fn push_cipher_alg(mut self, value: u32) -> Self {
4826        push_header(self.as_vec_mut(), 4u16, 4 as u16);
4827        self.as_vec_mut().extend(value.to_ne_bytes());
4828        self
4829    }
4830    #[doc = "Key material for encrypt direction\n"]
4831    pub fn nested_encrypt_dir(mut self) -> PushKeydir<Self> {
4832        let header_offset = push_nested_header(self.as_vec_mut(), 5u16);
4833        PushKeydir {
4834            prev: Some(self),
4835            header_offset: Some(header_offset),
4836        }
4837    }
4838    #[doc = "Key material for decrypt direction\n"]
4839    pub fn nested_decrypt_dir(mut self) -> PushKeydir<Self> {
4840        let header_offset = push_nested_header(self.as_vec_mut(), 6u16);
4841        PushKeydir {
4842            prev: Some(self),
4843            header_offset: Some(header_offset),
4844        }
4845    }
4846}
4847impl<Prev: Pusher> Drop for PushKeyconf<Prev> {
4848    fn drop(&mut self) {
4849        if let Some(prev) = &mut self.prev {
4850            if let Some(header_offset) = &self.header_offset {
4851                finalize_nested_header(prev.as_vec_mut(), *header_offset);
4852            }
4853        }
4854    }
4855}
4856pub struct PushKeydir<Prev: Pusher> {
4857    pub(crate) prev: Option<Prev>,
4858    pub(crate) header_offset: Option<usize>,
4859}
4860impl<Prev: Pusher> Pusher for PushKeydir<Prev> {
4861    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
4862        self.prev.as_mut().unwrap().as_vec_mut()
4863    }
4864    fn as_vec(&self) -> &Vec<u8> {
4865        self.prev.as_ref().unwrap().as_vec()
4866    }
4867}
4868impl<Prev: Pusher> PushKeydir<Prev> {
4869    pub fn new(prev: Prev) -> Self {
4870        Self {
4871            prev: Some(prev),
4872            header_offset: None,
4873        }
4874    }
4875    pub fn end_nested(mut self) -> Prev {
4876        let mut prev = self.prev.take().unwrap();
4877        if let Some(header_offset) = &self.header_offset {
4878            finalize_nested_header(prev.as_vec_mut(), *header_offset);
4879        }
4880        prev
4881    }
4882    #[doc = "The actual key to be used by the cipher\n"]
4883    pub fn push_cipher_key(mut self, value: &[u8]) -> Self {
4884        push_header(self.as_vec_mut(), 1u16, value.len() as u16);
4885        self.as_vec_mut().extend(value);
4886        self
4887    }
4888    #[doc = "Random nonce to be concatenated to the packet ID, in order to obtain the\nactual cipher IV\n"]
4889    pub fn push_nonce_tail(mut self, value: &[u8]) -> Self {
4890        push_header(self.as_vec_mut(), 2u16, value.len() as u16);
4891        self.as_vec_mut().extend(value);
4892        self
4893    }
4894}
4895impl<Prev: Pusher> Drop for PushKeydir<Prev> {
4896    fn drop(&mut self) {
4897        if let Some(prev) = &mut self.prev {
4898            if let Some(header_offset) = &self.header_offset {
4899                finalize_nested_header(prev.as_vec_mut(), *header_offset);
4900            }
4901        }
4902    }
4903}
4904pub struct PushKeyconfGet<Prev: Pusher> {
4905    pub(crate) prev: Option<Prev>,
4906    pub(crate) header_offset: Option<usize>,
4907}
4908impl<Prev: Pusher> Pusher for PushKeyconfGet<Prev> {
4909    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
4910        self.prev.as_mut().unwrap().as_vec_mut()
4911    }
4912    fn as_vec(&self) -> &Vec<u8> {
4913        self.prev.as_ref().unwrap().as_vec()
4914    }
4915}
4916impl<Prev: Pusher> PushKeyconfGet<Prev> {
4917    pub fn new(prev: Prev) -> Self {
4918        Self {
4919            prev: Some(prev),
4920            header_offset: None,
4921        }
4922    }
4923    pub fn end_nested(mut self) -> Prev {
4924        let mut prev = self.prev.take().unwrap();
4925        if let Some(header_offset) = &self.header_offset {
4926            finalize_nested_header(prev.as_vec_mut(), *header_offset);
4927        }
4928        prev
4929    }
4930    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
4931    pub fn push_peer_id(mut self, value: u32) -> Self {
4932        push_header(self.as_vec_mut(), 1u16, 4 as u16);
4933        self.as_vec_mut().extend(value.to_ne_bytes());
4934        self
4935    }
4936    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
4937    pub fn push_slot(mut self, value: u32) -> Self {
4938        push_header(self.as_vec_mut(), 2u16, 4 as u16);
4939        self.as_vec_mut().extend(value.to_ne_bytes());
4940        self
4941    }
4942    #[doc = "The unique ID of the key in the peer context. Used to fetch the correct\nkey upon decryption\n"]
4943    pub fn push_key_id(mut self, value: u32) -> Self {
4944        push_header(self.as_vec_mut(), 3u16, 4 as u16);
4945        self.as_vec_mut().extend(value.to_ne_bytes());
4946        self
4947    }
4948    #[doc = "The cipher to be used when communicating with the peer\n\nAssociated type: [`CipherAlg`] (enum)"]
4949    pub fn push_cipher_alg(mut self, value: u32) -> Self {
4950        push_header(self.as_vec_mut(), 4u16, 4 as u16);
4951        self.as_vec_mut().extend(value.to_ne_bytes());
4952        self
4953    }
4954}
4955impl<Prev: Pusher> Drop for PushKeyconfGet<Prev> {
4956    fn drop(&mut self) {
4957        if let Some(prev) = &mut self.prev {
4958            if let Some(header_offset) = &self.header_offset {
4959                finalize_nested_header(prev.as_vec_mut(), *header_offset);
4960            }
4961        }
4962    }
4963}
4964pub struct PushKeyconfSwapInput<Prev: Pusher> {
4965    pub(crate) prev: Option<Prev>,
4966    pub(crate) header_offset: Option<usize>,
4967}
4968impl<Prev: Pusher> Pusher for PushKeyconfSwapInput<Prev> {
4969    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
4970        self.prev.as_mut().unwrap().as_vec_mut()
4971    }
4972    fn as_vec(&self) -> &Vec<u8> {
4973        self.prev.as_ref().unwrap().as_vec()
4974    }
4975}
4976impl<Prev: Pusher> PushKeyconfSwapInput<Prev> {
4977    pub fn new(prev: Prev) -> Self {
4978        Self {
4979            prev: Some(prev),
4980            header_offset: None,
4981        }
4982    }
4983    pub fn end_nested(mut self) -> Prev {
4984        let mut prev = self.prev.take().unwrap();
4985        if let Some(header_offset) = &self.header_offset {
4986            finalize_nested_header(prev.as_vec_mut(), *header_offset);
4987        }
4988        prev
4989    }
4990    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
4991    pub fn push_peer_id(mut self, value: u32) -> Self {
4992        push_header(self.as_vec_mut(), 1u16, 4 as u16);
4993        self.as_vec_mut().extend(value.to_ne_bytes());
4994        self
4995    }
4996}
4997impl<Prev: Pusher> Drop for PushKeyconfSwapInput<Prev> {
4998    fn drop(&mut self) {
4999        if let Some(prev) = &mut self.prev {
5000            if let Some(header_offset) = &self.header_offset {
5001                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5002            }
5003        }
5004    }
5005}
5006pub struct PushKeyconfDelInput<Prev: Pusher> {
5007    pub(crate) prev: Option<Prev>,
5008    pub(crate) header_offset: Option<usize>,
5009}
5010impl<Prev: Pusher> Pusher for PushKeyconfDelInput<Prev> {
5011    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
5012        self.prev.as_mut().unwrap().as_vec_mut()
5013    }
5014    fn as_vec(&self) -> &Vec<u8> {
5015        self.prev.as_ref().unwrap().as_vec()
5016    }
5017}
5018impl<Prev: Pusher> PushKeyconfDelInput<Prev> {
5019    pub fn new(prev: Prev) -> Self {
5020        Self {
5021            prev: Some(prev),
5022            header_offset: None,
5023        }
5024    }
5025    pub fn end_nested(mut self) -> Prev {
5026        let mut prev = self.prev.take().unwrap();
5027        if let Some(header_offset) = &self.header_offset {
5028            finalize_nested_header(prev.as_vec_mut(), *header_offset);
5029        }
5030        prev
5031    }
5032    #[doc = "The unique ID of the peer in the device context. To be used to identify\npeers during key operations\n"]
5033    pub fn push_peer_id(mut self, value: u32) -> Self {
5034        push_header(self.as_vec_mut(), 1u16, 4 as u16);
5035        self.as_vec_mut().extend(value.to_ne_bytes());
5036        self
5037    }
5038    #[doc = "The slot where the key should be stored\n\nAssociated type: [`KeySlot`] (enum)"]
5039    pub fn push_slot(mut self, value: u32) -> Self {
5040        push_header(self.as_vec_mut(), 2u16, 4 as u16);
5041        self.as_vec_mut().extend(value.to_ne_bytes());
5042        self
5043    }
5044}
5045impl<Prev: Pusher> Drop for PushKeyconfDelInput<Prev> {
5046    fn drop(&mut self) {
5047        if let Some(prev) = &mut self.prev {
5048            if let Some(header_offset) = &self.header_offset {
5049                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5050            }
5051        }
5052    }
5053}
5054pub struct PushOvpn<Prev: Pusher> {
5055    pub(crate) prev: Option<Prev>,
5056    pub(crate) header_offset: Option<usize>,
5057}
5058impl<Prev: Pusher> Pusher for PushOvpn<Prev> {
5059    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
5060        self.prev.as_mut().unwrap().as_vec_mut()
5061    }
5062    fn as_vec(&self) -> &Vec<u8> {
5063        self.prev.as_ref().unwrap().as_vec()
5064    }
5065}
5066impl<Prev: Pusher> PushOvpn<Prev> {
5067    pub fn new(prev: Prev) -> Self {
5068        Self {
5069            prev: Some(prev),
5070            header_offset: None,
5071        }
5072    }
5073    pub fn end_nested(mut self) -> Prev {
5074        let mut prev = self.prev.take().unwrap();
5075        if let Some(header_offset) = &self.header_offset {
5076            finalize_nested_header(prev.as_vec_mut(), *header_offset);
5077        }
5078        prev
5079    }
5080    #[doc = "Index of the ovpn interface to operate on\n"]
5081    pub fn push_ifindex(mut self, value: u32) -> Self {
5082        push_header(self.as_vec_mut(), 1u16, 4 as u16);
5083        self.as_vec_mut().extend(value.to_ne_bytes());
5084        self
5085    }
5086    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
5087    pub fn nested_peer(mut self) -> PushPeer<Self> {
5088        let header_offset = push_nested_header(self.as_vec_mut(), 2u16);
5089        PushPeer {
5090            prev: Some(self),
5091            header_offset: Some(header_offset),
5092        }
5093    }
5094    #[doc = "Peer specific cipher configuration\n"]
5095    pub fn nested_keyconf(mut self) -> PushKeyconf<Self> {
5096        let header_offset = push_nested_header(self.as_vec_mut(), 3u16);
5097        PushKeyconf {
5098            prev: Some(self),
5099            header_offset: Some(header_offset),
5100        }
5101    }
5102}
5103impl<Prev: Pusher> Drop for PushOvpn<Prev> {
5104    fn drop(&mut self) {
5105        if let Some(prev) = &mut self.prev {
5106            if let Some(header_offset) = &self.header_offset {
5107                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5108            }
5109        }
5110    }
5111}
5112pub struct PushOvpnPeerNewInput<Prev: Pusher> {
5113    pub(crate) prev: Option<Prev>,
5114    pub(crate) header_offset: Option<usize>,
5115}
5116impl<Prev: Pusher> Pusher for PushOvpnPeerNewInput<Prev> {
5117    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
5118        self.prev.as_mut().unwrap().as_vec_mut()
5119    }
5120    fn as_vec(&self) -> &Vec<u8> {
5121        self.prev.as_ref().unwrap().as_vec()
5122    }
5123}
5124impl<Prev: Pusher> PushOvpnPeerNewInput<Prev> {
5125    pub fn new(prev: Prev) -> Self {
5126        Self {
5127            prev: Some(prev),
5128            header_offset: None,
5129        }
5130    }
5131    pub fn end_nested(mut self) -> Prev {
5132        let mut prev = self.prev.take().unwrap();
5133        if let Some(header_offset) = &self.header_offset {
5134            finalize_nested_header(prev.as_vec_mut(), *header_offset);
5135        }
5136        prev
5137    }
5138    #[doc = "Index of the ovpn interface to operate on\n"]
5139    pub fn push_ifindex(mut self, value: u32) -> Self {
5140        push_header(self.as_vec_mut(), 1u16, 4 as u16);
5141        self.as_vec_mut().extend(value.to_ne_bytes());
5142        self
5143    }
5144    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
5145    pub fn nested_peer(mut self) -> PushPeerNewInput<Self> {
5146        let header_offset = push_nested_header(self.as_vec_mut(), 2u16);
5147        PushPeerNewInput {
5148            prev: Some(self),
5149            header_offset: Some(header_offset),
5150        }
5151    }
5152}
5153impl<Prev: Pusher> Drop for PushOvpnPeerNewInput<Prev> {
5154    fn drop(&mut self) {
5155        if let Some(prev) = &mut self.prev {
5156            if let Some(header_offset) = &self.header_offset {
5157                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5158            }
5159        }
5160    }
5161}
5162pub struct PushOvpnPeerSetInput<Prev: Pusher> {
5163    pub(crate) prev: Option<Prev>,
5164    pub(crate) header_offset: Option<usize>,
5165}
5166impl<Prev: Pusher> Pusher for PushOvpnPeerSetInput<Prev> {
5167    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
5168        self.prev.as_mut().unwrap().as_vec_mut()
5169    }
5170    fn as_vec(&self) -> &Vec<u8> {
5171        self.prev.as_ref().unwrap().as_vec()
5172    }
5173}
5174impl<Prev: Pusher> PushOvpnPeerSetInput<Prev> {
5175    pub fn new(prev: Prev) -> Self {
5176        Self {
5177            prev: Some(prev),
5178            header_offset: None,
5179        }
5180    }
5181    pub fn end_nested(mut self) -> Prev {
5182        let mut prev = self.prev.take().unwrap();
5183        if let Some(header_offset) = &self.header_offset {
5184            finalize_nested_header(prev.as_vec_mut(), *header_offset);
5185        }
5186        prev
5187    }
5188    #[doc = "Index of the ovpn interface to operate on\n"]
5189    pub fn push_ifindex(mut self, value: u32) -> Self {
5190        push_header(self.as_vec_mut(), 1u16, 4 as u16);
5191        self.as_vec_mut().extend(value.to_ne_bytes());
5192        self
5193    }
5194    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
5195    pub fn nested_peer(mut self) -> PushPeerSetInput<Self> {
5196        let header_offset = push_nested_header(self.as_vec_mut(), 2u16);
5197        PushPeerSetInput {
5198            prev: Some(self),
5199            header_offset: Some(header_offset),
5200        }
5201    }
5202}
5203impl<Prev: Pusher> Drop for PushOvpnPeerSetInput<Prev> {
5204    fn drop(&mut self) {
5205        if let Some(prev) = &mut self.prev {
5206            if let Some(header_offset) = &self.header_offset {
5207                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5208            }
5209        }
5210    }
5211}
5212pub struct PushOvpnPeerDelInput<Prev: Pusher> {
5213    pub(crate) prev: Option<Prev>,
5214    pub(crate) header_offset: Option<usize>,
5215}
5216impl<Prev: Pusher> Pusher for PushOvpnPeerDelInput<Prev> {
5217    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
5218        self.prev.as_mut().unwrap().as_vec_mut()
5219    }
5220    fn as_vec(&self) -> &Vec<u8> {
5221        self.prev.as_ref().unwrap().as_vec()
5222    }
5223}
5224impl<Prev: Pusher> PushOvpnPeerDelInput<Prev> {
5225    pub fn new(prev: Prev) -> Self {
5226        Self {
5227            prev: Some(prev),
5228            header_offset: None,
5229        }
5230    }
5231    pub fn end_nested(mut self) -> Prev {
5232        let mut prev = self.prev.take().unwrap();
5233        if let Some(header_offset) = &self.header_offset {
5234            finalize_nested_header(prev.as_vec_mut(), *header_offset);
5235        }
5236        prev
5237    }
5238    #[doc = "Index of the ovpn interface to operate on\n"]
5239    pub fn push_ifindex(mut self, value: u32) -> Self {
5240        push_header(self.as_vec_mut(), 1u16, 4 as u16);
5241        self.as_vec_mut().extend(value.to_ne_bytes());
5242        self
5243    }
5244    #[doc = "The peer object containing the attributed of interest for the specific\noperation\n"]
5245    pub fn nested_peer(mut self) -> PushPeerDelInput<Self> {
5246        let header_offset = push_nested_header(self.as_vec_mut(), 2u16);
5247        PushPeerDelInput {
5248            prev: Some(self),
5249            header_offset: Some(header_offset),
5250        }
5251    }
5252}
5253impl<Prev: Pusher> Drop for PushOvpnPeerDelInput<Prev> {
5254    fn drop(&mut self) {
5255        if let Some(prev) = &mut self.prev {
5256            if let Some(header_offset) = &self.header_offset {
5257                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5258            }
5259        }
5260    }
5261}
5262pub struct PushOvpnKeyconfGet<Prev: Pusher> {
5263    pub(crate) prev: Option<Prev>,
5264    pub(crate) header_offset: Option<usize>,
5265}
5266impl<Prev: Pusher> Pusher for PushOvpnKeyconfGet<Prev> {
5267    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
5268        self.prev.as_mut().unwrap().as_vec_mut()
5269    }
5270    fn as_vec(&self) -> &Vec<u8> {
5271        self.prev.as_ref().unwrap().as_vec()
5272    }
5273}
5274impl<Prev: Pusher> PushOvpnKeyconfGet<Prev> {
5275    pub fn new(prev: Prev) -> Self {
5276        Self {
5277            prev: Some(prev),
5278            header_offset: None,
5279        }
5280    }
5281    pub fn end_nested(mut self) -> Prev {
5282        let mut prev = self.prev.take().unwrap();
5283        if let Some(header_offset) = &self.header_offset {
5284            finalize_nested_header(prev.as_vec_mut(), *header_offset);
5285        }
5286        prev
5287    }
5288    #[doc = "Index of the ovpn interface to operate on\n"]
5289    pub fn push_ifindex(mut self, value: u32) -> Self {
5290        push_header(self.as_vec_mut(), 1u16, 4 as u16);
5291        self.as_vec_mut().extend(value.to_ne_bytes());
5292        self
5293    }
5294    #[doc = "Peer specific cipher configuration\n"]
5295    pub fn nested_keyconf(mut self) -> PushKeyconfGet<Self> {
5296        let header_offset = push_nested_header(self.as_vec_mut(), 3u16);
5297        PushKeyconfGet {
5298            prev: Some(self),
5299            header_offset: Some(header_offset),
5300        }
5301    }
5302}
5303impl<Prev: Pusher> Drop for PushOvpnKeyconfGet<Prev> {
5304    fn drop(&mut self) {
5305        if let Some(prev) = &mut self.prev {
5306            if let Some(header_offset) = &self.header_offset {
5307                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5308            }
5309        }
5310    }
5311}
5312pub struct PushOvpnKeyconfSwapInput<Prev: Pusher> {
5313    pub(crate) prev: Option<Prev>,
5314    pub(crate) header_offset: Option<usize>,
5315}
5316impl<Prev: Pusher> Pusher for PushOvpnKeyconfSwapInput<Prev> {
5317    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
5318        self.prev.as_mut().unwrap().as_vec_mut()
5319    }
5320    fn as_vec(&self) -> &Vec<u8> {
5321        self.prev.as_ref().unwrap().as_vec()
5322    }
5323}
5324impl<Prev: Pusher> PushOvpnKeyconfSwapInput<Prev> {
5325    pub fn new(prev: Prev) -> Self {
5326        Self {
5327            prev: Some(prev),
5328            header_offset: None,
5329        }
5330    }
5331    pub fn end_nested(mut self) -> Prev {
5332        let mut prev = self.prev.take().unwrap();
5333        if let Some(header_offset) = &self.header_offset {
5334            finalize_nested_header(prev.as_vec_mut(), *header_offset);
5335        }
5336        prev
5337    }
5338    #[doc = "Index of the ovpn interface to operate on\n"]
5339    pub fn push_ifindex(mut self, value: u32) -> Self {
5340        push_header(self.as_vec_mut(), 1u16, 4 as u16);
5341        self.as_vec_mut().extend(value.to_ne_bytes());
5342        self
5343    }
5344    #[doc = "Peer specific cipher configuration\n"]
5345    pub fn nested_keyconf(mut self) -> PushKeyconfSwapInput<Self> {
5346        let header_offset = push_nested_header(self.as_vec_mut(), 3u16);
5347        PushKeyconfSwapInput {
5348            prev: Some(self),
5349            header_offset: Some(header_offset),
5350        }
5351    }
5352}
5353impl<Prev: Pusher> Drop for PushOvpnKeyconfSwapInput<Prev> {
5354    fn drop(&mut self) {
5355        if let Some(prev) = &mut self.prev {
5356            if let Some(header_offset) = &self.header_offset {
5357                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5358            }
5359        }
5360    }
5361}
5362pub struct PushOvpnKeyconfDelInput<Prev: Pusher> {
5363    pub(crate) prev: Option<Prev>,
5364    pub(crate) header_offset: Option<usize>,
5365}
5366impl<Prev: Pusher> Pusher for PushOvpnKeyconfDelInput<Prev> {
5367    fn as_vec_mut(&mut self) -> &mut Vec<u8> {
5368        self.prev.as_mut().unwrap().as_vec_mut()
5369    }
5370    fn as_vec(&self) -> &Vec<u8> {
5371        self.prev.as_ref().unwrap().as_vec()
5372    }
5373}
5374impl<Prev: Pusher> PushOvpnKeyconfDelInput<Prev> {
5375    pub fn new(prev: Prev) -> Self {
5376        Self {
5377            prev: Some(prev),
5378            header_offset: None,
5379        }
5380    }
5381    pub fn end_nested(mut self) -> Prev {
5382        let mut prev = self.prev.take().unwrap();
5383        if let Some(header_offset) = &self.header_offset {
5384            finalize_nested_header(prev.as_vec_mut(), *header_offset);
5385        }
5386        prev
5387    }
5388    #[doc = "Index of the ovpn interface to operate on\n"]
5389    pub fn push_ifindex(mut self, value: u32) -> Self {
5390        push_header(self.as_vec_mut(), 1u16, 4 as u16);
5391        self.as_vec_mut().extend(value.to_ne_bytes());
5392        self
5393    }
5394    #[doc = "Peer specific cipher configuration\n"]
5395    pub fn nested_keyconf(mut self) -> PushKeyconfDelInput<Self> {
5396        let header_offset = push_nested_header(self.as_vec_mut(), 3u16);
5397        PushKeyconfDelInput {
5398            prev: Some(self),
5399            header_offset: Some(header_offset),
5400        }
5401    }
5402}
5403impl<Prev: Pusher> Drop for PushOvpnKeyconfDelInput<Prev> {
5404    fn drop(&mut self) {
5405        if let Some(prev) = &mut self.prev {
5406            if let Some(header_offset) = &self.header_offset {
5407                finalize_nested_header(prev.as_vec_mut(), *header_offset);
5408            }
5409        }
5410    }
5411}
5412#[doc = "Notify attributes:\n- [`.get_peer()`](IterableOvpn::get_peer)\n"]
5413#[derive(Debug)]
5414pub struct OpPeerDelNotif;
5415impl OpPeerDelNotif {
5416    pub const CMD: u8 = 5u8;
5417    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableOvpn<'a> {
5418        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5419        IterableOvpn::with_loc(attrs, buf.as_ptr() as usize)
5420    }
5421}
5422#[doc = "Notify attributes:\n- [`.get_keyconf()`](IterableOvpnKeyconfGet::get_keyconf)\n"]
5423#[derive(Debug)]
5424pub struct OpKeySwapNotif;
5425impl OpKeySwapNotif {
5426    pub const CMD: u8 = 9u8;
5427    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableOvpnKeyconfGet<'a> {
5428        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5429        IterableOvpnKeyconfGet::with_loc(attrs, buf.as_ptr() as usize)
5430    }
5431}
5432#[doc = "Notify attributes:\n- [`.get_peer()`](IterableOvpn::get_peer)\n"]
5433#[derive(Debug)]
5434pub struct OpPeerFloatNotif;
5435impl OpPeerFloatNotif {
5436    pub const CMD: u8 = 11u8;
5437    pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableOvpn<'a> {
5438        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5439        IterableOvpn::with_loc(attrs, buf.as_ptr() as usize)
5440    }
5441}
5442pub struct NotifGroup;
5443impl NotifGroup {
5444    #[doc = "Notifications:\n- [`OpPeerDelNotif`]\n- [`OpKeySwapNotif`]\n- [`OpPeerFloatNotif`]\n"]
5445    pub const PEERS: &str = "peers";
5446    #[doc = "Notifications:\n- [`OpPeerDelNotif`]\n- [`OpKeySwapNotif`]\n- [`OpPeerFloatNotif`]\n"]
5447    pub const PEERS_CSTR: &CStr = c"peers";
5448}
5449#[doc = "Add a remote peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnPeerNewInput::push_ifindex)\n- [.nested_peer()](PushOvpnPeerNewInput::nested_peer)\n\n"]
5450#[derive(Debug)]
5451pub struct OpPeerNewDo<'r> {
5452    request: Request<'r>,
5453}
5454impl<'r> OpPeerNewDo<'r> {
5455    pub fn new(mut request: Request<'r>) -> Self {
5456        Self::write_header(request.buf_mut());
5457        Self { request: request }
5458    }
5459    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushOvpnPeerNewInput<&'buf mut Vec<u8>> {
5460        Self::write_header(buf);
5461        PushOvpnPeerNewInput::new(buf)
5462    }
5463    pub fn encode(&mut self) -> PushOvpnPeerNewInput<&mut Vec<u8>> {
5464        PushOvpnPeerNewInput::new(self.request.buf_mut())
5465    }
5466    pub fn into_encoder(self) -> PushOvpnPeerNewInput<RequestBuf<'r>> {
5467        PushOvpnPeerNewInput::new(self.request.buf)
5468    }
5469    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpnPeerNewInput<'a> {
5470        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5471        IterableOvpnPeerNewInput::with_loc(attrs, buf.as_ptr() as usize)
5472    }
5473    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5474        let mut header = BuiltinNfgenmsg::new();
5475        header.cmd = 1u8;
5476        header.version = 1u8;
5477        prev.as_vec_mut().extend(header.as_slice());
5478    }
5479}
5480impl NetlinkRequest for OpPeerNewDo<'_> {
5481    fn protocol(&self) -> Protocol {
5482        Protocol::Generic("ovpn".as_bytes())
5483    }
5484    fn flags(&self) -> u16 {
5485        self.request.flags
5486    }
5487    fn payload(&self) -> &[u8] {
5488        self.request.buf()
5489    }
5490    type ReplyType<'buf> = IterableOvpnPeerNewInput<'buf>;
5491    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5492        Self::decode_request(buf)
5493    }
5494    fn lookup(
5495        buf: &[u8],
5496        offset: usize,
5497        missing_type: Option<u16>,
5498    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5499        Self::decode_request(buf).lookup_attr(offset, missing_type)
5500    }
5501}
5502#[doc = "modify a remote peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnPeerSetInput::push_ifindex)\n- [.nested_peer()](PushOvpnPeerSetInput::nested_peer)\n\n"]
5503#[derive(Debug)]
5504pub struct OpPeerSetDo<'r> {
5505    request: Request<'r>,
5506}
5507impl<'r> OpPeerSetDo<'r> {
5508    pub fn new(mut request: Request<'r>) -> Self {
5509        Self::write_header(request.buf_mut());
5510        Self { request: request }
5511    }
5512    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushOvpnPeerSetInput<&'buf mut Vec<u8>> {
5513        Self::write_header(buf);
5514        PushOvpnPeerSetInput::new(buf)
5515    }
5516    pub fn encode(&mut self) -> PushOvpnPeerSetInput<&mut Vec<u8>> {
5517        PushOvpnPeerSetInput::new(self.request.buf_mut())
5518    }
5519    pub fn into_encoder(self) -> PushOvpnPeerSetInput<RequestBuf<'r>> {
5520        PushOvpnPeerSetInput::new(self.request.buf)
5521    }
5522    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpnPeerSetInput<'a> {
5523        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5524        IterableOvpnPeerSetInput::with_loc(attrs, buf.as_ptr() as usize)
5525    }
5526    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5527        let mut header = BuiltinNfgenmsg::new();
5528        header.cmd = 2u8;
5529        header.version = 1u8;
5530        prev.as_vec_mut().extend(header.as_slice());
5531    }
5532}
5533impl NetlinkRequest for OpPeerSetDo<'_> {
5534    fn protocol(&self) -> Protocol {
5535        Protocol::Generic("ovpn".as_bytes())
5536    }
5537    fn flags(&self) -> u16 {
5538        self.request.flags
5539    }
5540    fn payload(&self) -> &[u8] {
5541        self.request.buf()
5542    }
5543    type ReplyType<'buf> = IterableOvpnPeerSetInput<'buf>;
5544    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5545        Self::decode_request(buf)
5546    }
5547    fn lookup(
5548        buf: &[u8],
5549        offset: usize,
5550        missing_type: Option<u16>,
5551    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5552        Self::decode_request(buf).lookup_attr(offset, missing_type)
5553    }
5554}
5555#[doc = "Retrieve data about existing remote peers (or a specific one)\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpn::push_ifindex)\n\nReply attributes:\n- [.get_peer()](IterableOvpn::get_peer)\n\n"]
5556#[derive(Debug)]
5557pub struct OpPeerGetDump<'r> {
5558    request: Request<'r>,
5559}
5560impl<'r> OpPeerGetDump<'r> {
5561    pub fn new(mut request: Request<'r>) -> Self {
5562        Self::write_header(request.buf_mut());
5563        Self {
5564            request: request.set_dump(),
5565        }
5566    }
5567    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushOvpn<&'buf mut Vec<u8>> {
5568        Self::write_header(buf);
5569        PushOvpn::new(buf)
5570    }
5571    pub fn encode(&mut self) -> PushOvpn<&mut Vec<u8>> {
5572        PushOvpn::new(self.request.buf_mut())
5573    }
5574    pub fn into_encoder(self) -> PushOvpn<RequestBuf<'r>> {
5575        PushOvpn::new(self.request.buf)
5576    }
5577    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpn<'a> {
5578        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5579        IterableOvpn::with_loc(attrs, buf.as_ptr() as usize)
5580    }
5581    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5582        let mut header = BuiltinNfgenmsg::new();
5583        header.cmd = 3u8;
5584        header.version = 1u8;
5585        prev.as_vec_mut().extend(header.as_slice());
5586    }
5587}
5588impl NetlinkRequest for OpPeerGetDump<'_> {
5589    fn protocol(&self) -> Protocol {
5590        Protocol::Generic("ovpn".as_bytes())
5591    }
5592    fn flags(&self) -> u16 {
5593        self.request.flags
5594    }
5595    fn payload(&self) -> &[u8] {
5596        self.request.buf()
5597    }
5598    type ReplyType<'buf> = IterableOvpn<'buf>;
5599    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5600        Self::decode_request(buf)
5601    }
5602    fn lookup(
5603        buf: &[u8],
5604        offset: usize,
5605        missing_type: Option<u16>,
5606    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5607        Self::decode_request(buf).lookup_attr(offset, missing_type)
5608    }
5609}
5610#[doc = "Retrieve data about existing remote peers (or a specific one)\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpn::push_ifindex)\n- [.nested_peer()](PushOvpn::nested_peer)\n\nReply attributes:\n- [.get_peer()](IterableOvpn::get_peer)\n\n"]
5611#[derive(Debug)]
5612pub struct OpPeerGetDo<'r> {
5613    request: Request<'r>,
5614}
5615impl<'r> OpPeerGetDo<'r> {
5616    pub fn new(mut request: Request<'r>) -> Self {
5617        Self::write_header(request.buf_mut());
5618        Self { request: request }
5619    }
5620    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushOvpn<&'buf mut Vec<u8>> {
5621        Self::write_header(buf);
5622        PushOvpn::new(buf)
5623    }
5624    pub fn encode(&mut self) -> PushOvpn<&mut Vec<u8>> {
5625        PushOvpn::new(self.request.buf_mut())
5626    }
5627    pub fn into_encoder(self) -> PushOvpn<RequestBuf<'r>> {
5628        PushOvpn::new(self.request.buf)
5629    }
5630    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpn<'a> {
5631        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5632        IterableOvpn::with_loc(attrs, buf.as_ptr() as usize)
5633    }
5634    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5635        let mut header = BuiltinNfgenmsg::new();
5636        header.cmd = 3u8;
5637        header.version = 1u8;
5638        prev.as_vec_mut().extend(header.as_slice());
5639    }
5640}
5641impl NetlinkRequest for OpPeerGetDo<'_> {
5642    fn protocol(&self) -> Protocol {
5643        Protocol::Generic("ovpn".as_bytes())
5644    }
5645    fn flags(&self) -> u16 {
5646        self.request.flags
5647    }
5648    fn payload(&self) -> &[u8] {
5649        self.request.buf()
5650    }
5651    type ReplyType<'buf> = IterableOvpn<'buf>;
5652    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5653        Self::decode_request(buf)
5654    }
5655    fn lookup(
5656        buf: &[u8],
5657        offset: usize,
5658        missing_type: Option<u16>,
5659    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5660        Self::decode_request(buf).lookup_attr(offset, missing_type)
5661    }
5662}
5663#[doc = "Delete existing remote peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnPeerDelInput::push_ifindex)\n- [.nested_peer()](PushOvpnPeerDelInput::nested_peer)\n\n"]
5664#[derive(Debug)]
5665pub struct OpPeerDelDo<'r> {
5666    request: Request<'r>,
5667}
5668impl<'r> OpPeerDelDo<'r> {
5669    pub fn new(mut request: Request<'r>) -> Self {
5670        Self::write_header(request.buf_mut());
5671        Self { request: request }
5672    }
5673    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushOvpnPeerDelInput<&'buf mut Vec<u8>> {
5674        Self::write_header(buf);
5675        PushOvpnPeerDelInput::new(buf)
5676    }
5677    pub fn encode(&mut self) -> PushOvpnPeerDelInput<&mut Vec<u8>> {
5678        PushOvpnPeerDelInput::new(self.request.buf_mut())
5679    }
5680    pub fn into_encoder(self) -> PushOvpnPeerDelInput<RequestBuf<'r>> {
5681        PushOvpnPeerDelInput::new(self.request.buf)
5682    }
5683    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpnPeerDelInput<'a> {
5684        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5685        IterableOvpnPeerDelInput::with_loc(attrs, buf.as_ptr() as usize)
5686    }
5687    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5688        let mut header = BuiltinNfgenmsg::new();
5689        header.cmd = 4u8;
5690        header.version = 1u8;
5691        prev.as_vec_mut().extend(header.as_slice());
5692    }
5693}
5694impl NetlinkRequest for OpPeerDelDo<'_> {
5695    fn protocol(&self) -> Protocol {
5696        Protocol::Generic("ovpn".as_bytes())
5697    }
5698    fn flags(&self) -> u16 {
5699        self.request.flags
5700    }
5701    fn payload(&self) -> &[u8] {
5702        self.request.buf()
5703    }
5704    type ReplyType<'buf> = IterableOvpnPeerDelInput<'buf>;
5705    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5706        Self::decode_request(buf)
5707    }
5708    fn lookup(
5709        buf: &[u8],
5710        offset: usize,
5711        missing_type: Option<u16>,
5712    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5713        Self::decode_request(buf).lookup_attr(offset, missing_type)
5714    }
5715}
5716#[doc = "Add a cipher key for a specific peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpn::push_ifindex)\n- [.nested_keyconf()](PushOvpn::nested_keyconf)\n\n"]
5717#[derive(Debug)]
5718pub struct OpKeyNewDo<'r> {
5719    request: Request<'r>,
5720}
5721impl<'r> OpKeyNewDo<'r> {
5722    pub fn new(mut request: Request<'r>) -> Self {
5723        Self::write_header(request.buf_mut());
5724        Self { request: request }
5725    }
5726    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushOvpn<&'buf mut Vec<u8>> {
5727        Self::write_header(buf);
5728        PushOvpn::new(buf)
5729    }
5730    pub fn encode(&mut self) -> PushOvpn<&mut Vec<u8>> {
5731        PushOvpn::new(self.request.buf_mut())
5732    }
5733    pub fn into_encoder(self) -> PushOvpn<RequestBuf<'r>> {
5734        PushOvpn::new(self.request.buf)
5735    }
5736    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpn<'a> {
5737        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5738        IterableOvpn::with_loc(attrs, buf.as_ptr() as usize)
5739    }
5740    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5741        let mut header = BuiltinNfgenmsg::new();
5742        header.cmd = 6u8;
5743        header.version = 1u8;
5744        prev.as_vec_mut().extend(header.as_slice());
5745    }
5746}
5747impl NetlinkRequest for OpKeyNewDo<'_> {
5748    fn protocol(&self) -> Protocol {
5749        Protocol::Generic("ovpn".as_bytes())
5750    }
5751    fn flags(&self) -> u16 {
5752        self.request.flags
5753    }
5754    fn payload(&self) -> &[u8] {
5755        self.request.buf()
5756    }
5757    type ReplyType<'buf> = IterableOvpn<'buf>;
5758    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5759        Self::decode_request(buf)
5760    }
5761    fn lookup(
5762        buf: &[u8],
5763        offset: usize,
5764        missing_type: Option<u16>,
5765    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5766        Self::decode_request(buf).lookup_attr(offset, missing_type)
5767    }
5768}
5769#[doc = "Retrieve non-sensitive data about peer key and cipher\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnKeyconfGet::push_ifindex)\n- [.nested_keyconf()](PushOvpnKeyconfGet::nested_keyconf)\n\nReply attributes:\n- [.get_keyconf()](IterableOvpnKeyconfGet::get_keyconf)\n\n"]
5770#[derive(Debug)]
5771pub struct OpKeyGetDo<'r> {
5772    request: Request<'r>,
5773}
5774impl<'r> OpKeyGetDo<'r> {
5775    pub fn new(mut request: Request<'r>) -> Self {
5776        Self::write_header(request.buf_mut());
5777        Self { request: request }
5778    }
5779    pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushOvpnKeyconfGet<&'buf mut Vec<u8>> {
5780        Self::write_header(buf);
5781        PushOvpnKeyconfGet::new(buf)
5782    }
5783    pub fn encode(&mut self) -> PushOvpnKeyconfGet<&mut Vec<u8>> {
5784        PushOvpnKeyconfGet::new(self.request.buf_mut())
5785    }
5786    pub fn into_encoder(self) -> PushOvpnKeyconfGet<RequestBuf<'r>> {
5787        PushOvpnKeyconfGet::new(self.request.buf)
5788    }
5789    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpnKeyconfGet<'a> {
5790        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5791        IterableOvpnKeyconfGet::with_loc(attrs, buf.as_ptr() as usize)
5792    }
5793    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5794        let mut header = BuiltinNfgenmsg::new();
5795        header.cmd = 7u8;
5796        header.version = 1u8;
5797        prev.as_vec_mut().extend(header.as_slice());
5798    }
5799}
5800impl NetlinkRequest for OpKeyGetDo<'_> {
5801    fn protocol(&self) -> Protocol {
5802        Protocol::Generic("ovpn".as_bytes())
5803    }
5804    fn flags(&self) -> u16 {
5805        self.request.flags
5806    }
5807    fn payload(&self) -> &[u8] {
5808        self.request.buf()
5809    }
5810    type ReplyType<'buf> = IterableOvpnKeyconfGet<'buf>;
5811    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5812        Self::decode_request(buf)
5813    }
5814    fn lookup(
5815        buf: &[u8],
5816        offset: usize,
5817        missing_type: Option<u16>,
5818    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5819        Self::decode_request(buf).lookup_attr(offset, missing_type)
5820    }
5821}
5822#[doc = "Swap primary and secondary session keys for a specific peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnKeyconfSwapInput::push_ifindex)\n- [.nested_keyconf()](PushOvpnKeyconfSwapInput::nested_keyconf)\n\n"]
5823#[derive(Debug)]
5824pub struct OpKeySwapDo<'r> {
5825    request: Request<'r>,
5826}
5827impl<'r> OpKeySwapDo<'r> {
5828    pub fn new(mut request: Request<'r>) -> Self {
5829        Self::write_header(request.buf_mut());
5830        Self { request: request }
5831    }
5832    pub fn encode_request<'buf>(
5833        buf: &'buf mut Vec<u8>,
5834    ) -> PushOvpnKeyconfSwapInput<&'buf mut Vec<u8>> {
5835        Self::write_header(buf);
5836        PushOvpnKeyconfSwapInput::new(buf)
5837    }
5838    pub fn encode(&mut self) -> PushOvpnKeyconfSwapInput<&mut Vec<u8>> {
5839        PushOvpnKeyconfSwapInput::new(self.request.buf_mut())
5840    }
5841    pub fn into_encoder(self) -> PushOvpnKeyconfSwapInput<RequestBuf<'r>> {
5842        PushOvpnKeyconfSwapInput::new(self.request.buf)
5843    }
5844    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpnKeyconfSwapInput<'a> {
5845        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5846        IterableOvpnKeyconfSwapInput::with_loc(attrs, buf.as_ptr() as usize)
5847    }
5848    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5849        let mut header = BuiltinNfgenmsg::new();
5850        header.cmd = 8u8;
5851        header.version = 1u8;
5852        prev.as_vec_mut().extend(header.as_slice());
5853    }
5854}
5855impl NetlinkRequest for OpKeySwapDo<'_> {
5856    fn protocol(&self) -> Protocol {
5857        Protocol::Generic("ovpn".as_bytes())
5858    }
5859    fn flags(&self) -> u16 {
5860        self.request.flags
5861    }
5862    fn payload(&self) -> &[u8] {
5863        self.request.buf()
5864    }
5865    type ReplyType<'buf> = IterableOvpnKeyconfSwapInput<'buf>;
5866    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5867        Self::decode_request(buf)
5868    }
5869    fn lookup(
5870        buf: &[u8],
5871        offset: usize,
5872        missing_type: Option<u16>,
5873    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5874        Self::decode_request(buf).lookup_attr(offset, missing_type)
5875    }
5876}
5877#[doc = "Delete cipher key for a specific peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnKeyconfDelInput::push_ifindex)\n- [.nested_keyconf()](PushOvpnKeyconfDelInput::nested_keyconf)\n\n"]
5878#[derive(Debug)]
5879pub struct OpKeyDelDo<'r> {
5880    request: Request<'r>,
5881}
5882impl<'r> OpKeyDelDo<'r> {
5883    pub fn new(mut request: Request<'r>) -> Self {
5884        Self::write_header(request.buf_mut());
5885        Self { request: request }
5886    }
5887    pub fn encode_request<'buf>(
5888        buf: &'buf mut Vec<u8>,
5889    ) -> PushOvpnKeyconfDelInput<&'buf mut Vec<u8>> {
5890        Self::write_header(buf);
5891        PushOvpnKeyconfDelInput::new(buf)
5892    }
5893    pub fn encode(&mut self) -> PushOvpnKeyconfDelInput<&mut Vec<u8>> {
5894        PushOvpnKeyconfDelInput::new(self.request.buf_mut())
5895    }
5896    pub fn into_encoder(self) -> PushOvpnKeyconfDelInput<RequestBuf<'r>> {
5897        PushOvpnKeyconfDelInput::new(self.request.buf)
5898    }
5899    pub fn decode_request<'a>(buf: &'a [u8]) -> IterableOvpnKeyconfDelInput<'a> {
5900        let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
5901        IterableOvpnKeyconfDelInput::with_loc(attrs, buf.as_ptr() as usize)
5902    }
5903    fn write_header<Prev: Pusher>(prev: &mut Prev) {
5904        let mut header = BuiltinNfgenmsg::new();
5905        header.cmd = 10u8;
5906        header.version = 1u8;
5907        prev.as_vec_mut().extend(header.as_slice());
5908    }
5909}
5910impl NetlinkRequest for OpKeyDelDo<'_> {
5911    fn protocol(&self) -> Protocol {
5912        Protocol::Generic("ovpn".as_bytes())
5913    }
5914    fn flags(&self) -> u16 {
5915        self.request.flags
5916    }
5917    fn payload(&self) -> &[u8] {
5918        self.request.buf()
5919    }
5920    type ReplyType<'buf> = IterableOvpnKeyconfDelInput<'buf>;
5921    fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
5922        Self::decode_request(buf)
5923    }
5924    fn lookup(
5925        buf: &[u8],
5926        offset: usize,
5927        missing_type: Option<u16>,
5928    ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
5929        Self::decode_request(buf).lookup_attr(offset, missing_type)
5930    }
5931}
5932use crate::traits::LookupFn;
5933use crate::utils::RequestBuf;
5934#[derive(Debug)]
5935pub struct Request<'buf> {
5936    buf: RequestBuf<'buf>,
5937    flags: u16,
5938    writeback: Option<&'buf mut Option<RequestInfo>>,
5939}
5940#[allow(unused)]
5941#[derive(Debug, Clone)]
5942pub struct RequestInfo {
5943    protocol: Protocol,
5944    flags: u16,
5945    name: &'static str,
5946    lookup: LookupFn,
5947}
5948impl Request<'static> {
5949    pub fn new() -> Self {
5950        Self::new_from_buf(Vec::new())
5951    }
5952    pub fn new_from_buf(buf: Vec<u8>) -> Self {
5953        Self {
5954            flags: 0,
5955            buf: RequestBuf::Own(buf),
5956            writeback: None,
5957        }
5958    }
5959    pub fn into_buf(self) -> Vec<u8> {
5960        match self.buf {
5961            RequestBuf::Own(buf) => buf,
5962            _ => unreachable!(),
5963        }
5964    }
5965}
5966impl<'buf> Request<'buf> {
5967    pub fn new_with_buf(buf: &'buf mut Vec<u8>) -> Self {
5968        buf.clear();
5969        Self::new_extend(buf)
5970    }
5971    pub fn new_extend(buf: &'buf mut Vec<u8>) -> Self {
5972        Self {
5973            flags: 0,
5974            buf: RequestBuf::Ref(buf),
5975            writeback: None,
5976        }
5977    }
5978    fn do_writeback(&mut self, protocol: Protocol, name: &'static str, lookup: LookupFn) {
5979        let Some(writeback) = &mut self.writeback else {
5980            return;
5981        };
5982        **writeback = Some(RequestInfo {
5983            protocol,
5984            flags: self.flags,
5985            name,
5986            lookup,
5987        })
5988    }
5989    pub fn buf(&self) -> &Vec<u8> {
5990        self.buf.buf()
5991    }
5992    pub fn buf_mut(&mut self) -> &mut Vec<u8> {
5993        self.buf.buf_mut()
5994    }
5995    #[doc = "Set `NLM_F_CREATE` flag"]
5996    pub fn set_create(mut self) -> Self {
5997        self.flags |= consts::NLM_F_CREATE as u16;
5998        self
5999    }
6000    #[doc = "Set `NLM_F_EXCL` flag"]
6001    pub fn set_excl(mut self) -> Self {
6002        self.flags |= consts::NLM_F_EXCL as u16;
6003        self
6004    }
6005    #[doc = "Set `NLM_F_REPLACE` flag"]
6006    pub fn set_replace(mut self) -> Self {
6007        self.flags |= consts::NLM_F_REPLACE as u16;
6008        self
6009    }
6010    #[doc = "Set `NLM_F_CREATE` and `NLM_F_REPLACE` flag"]
6011    pub fn set_change(self) -> Self {
6012        self.set_create().set_replace()
6013    }
6014    #[doc = "Set `NLM_F_APPEND` flag"]
6015    pub fn set_append(mut self) -> Self {
6016        self.flags |= consts::NLM_F_APPEND as u16;
6017        self
6018    }
6019    #[doc = "Set `self.flags |= flags`"]
6020    pub fn set_flags(mut self, flags: u16) -> Self {
6021        self.flags |= flags;
6022        self
6023    }
6024    #[doc = "Set `self.flags ^= self.flags & flags`"]
6025    pub fn unset_flags(mut self, flags: u16) -> Self {
6026        self.flags ^= self.flags & flags;
6027        self
6028    }
6029    #[doc = "Set `NLM_F_DUMP` flag"]
6030    fn set_dump(mut self) -> Self {
6031        self.flags |= consts::NLM_F_DUMP as u16;
6032        self
6033    }
6034    #[doc = "Add a remote peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnPeerNewInput::push_ifindex)\n- [.nested_peer()](PushOvpnPeerNewInput::nested_peer)\n\n"]
6035    pub fn op_peer_new_do(self) -> OpPeerNewDo<'buf> {
6036        let mut res = OpPeerNewDo::new(self);
6037        res.request
6038            .do_writeback(res.protocol(), "op-peer-new-do", OpPeerNewDo::lookup);
6039        res
6040    }
6041    #[doc = "modify a remote peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnPeerSetInput::push_ifindex)\n- [.nested_peer()](PushOvpnPeerSetInput::nested_peer)\n\n"]
6042    pub fn op_peer_set_do(self) -> OpPeerSetDo<'buf> {
6043        let mut res = OpPeerSetDo::new(self);
6044        res.request
6045            .do_writeback(res.protocol(), "op-peer-set-do", OpPeerSetDo::lookup);
6046        res
6047    }
6048    #[doc = "Retrieve data about existing remote peers (or a specific one)\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpn::push_ifindex)\n\nReply attributes:\n- [.get_peer()](IterableOvpn::get_peer)\n\n"]
6049    pub fn op_peer_get_dump(self) -> OpPeerGetDump<'buf> {
6050        let mut res = OpPeerGetDump::new(self);
6051        res.request
6052            .do_writeback(res.protocol(), "op-peer-get-dump", OpPeerGetDump::lookup);
6053        res
6054    }
6055    #[doc = "Retrieve data about existing remote peers (or a specific one)\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpn::push_ifindex)\n- [.nested_peer()](PushOvpn::nested_peer)\n\nReply attributes:\n- [.get_peer()](IterableOvpn::get_peer)\n\n"]
6056    pub fn op_peer_get_do(self) -> OpPeerGetDo<'buf> {
6057        let mut res = OpPeerGetDo::new(self);
6058        res.request
6059            .do_writeback(res.protocol(), "op-peer-get-do", OpPeerGetDo::lookup);
6060        res
6061    }
6062    #[doc = "Delete existing remote peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnPeerDelInput::push_ifindex)\n- [.nested_peer()](PushOvpnPeerDelInput::nested_peer)\n\n"]
6063    pub fn op_peer_del_do(self) -> OpPeerDelDo<'buf> {
6064        let mut res = OpPeerDelDo::new(self);
6065        res.request
6066            .do_writeback(res.protocol(), "op-peer-del-do", OpPeerDelDo::lookup);
6067        res
6068    }
6069    #[doc = "Add a cipher key for a specific peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpn::push_ifindex)\n- [.nested_keyconf()](PushOvpn::nested_keyconf)\n\n"]
6070    pub fn op_key_new_do(self) -> OpKeyNewDo<'buf> {
6071        let mut res = OpKeyNewDo::new(self);
6072        res.request
6073            .do_writeback(res.protocol(), "op-key-new-do", OpKeyNewDo::lookup);
6074        res
6075    }
6076    #[doc = "Retrieve non-sensitive data about peer key and cipher\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnKeyconfGet::push_ifindex)\n- [.nested_keyconf()](PushOvpnKeyconfGet::nested_keyconf)\n\nReply attributes:\n- [.get_keyconf()](IterableOvpnKeyconfGet::get_keyconf)\n\n"]
6077    pub fn op_key_get_do(self) -> OpKeyGetDo<'buf> {
6078        let mut res = OpKeyGetDo::new(self);
6079        res.request
6080            .do_writeback(res.protocol(), "op-key-get-do", OpKeyGetDo::lookup);
6081        res
6082    }
6083    #[doc = "Swap primary and secondary session keys for a specific peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnKeyconfSwapInput::push_ifindex)\n- [.nested_keyconf()](PushOvpnKeyconfSwapInput::nested_keyconf)\n\n"]
6084    pub fn op_key_swap_do(self) -> OpKeySwapDo<'buf> {
6085        let mut res = OpKeySwapDo::new(self);
6086        res.request
6087            .do_writeback(res.protocol(), "op-key-swap-do", OpKeySwapDo::lookup);
6088        res
6089    }
6090    #[doc = "Delete cipher key for a specific peer\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_ifindex()](PushOvpnKeyconfDelInput::push_ifindex)\n- [.nested_keyconf()](PushOvpnKeyconfDelInput::nested_keyconf)\n\n"]
6091    pub fn op_key_del_do(self) -> OpKeyDelDo<'buf> {
6092        let mut res = OpKeyDelDo::new(self);
6093        res.request
6094            .do_writeback(res.protocol(), "op-key-del-do", OpKeyDelDo::lookup);
6095        res
6096    }
6097}
6098#[cfg(test)]
6099mod generated_tests {
6100    use super::*;
6101    #[test]
6102    fn tests() {
6103        let _ = IterableOvpn::get_peer;
6104        let _ = IterableOvpnKeyconfGet::get_keyconf;
6105        let _ = OpKeySwapNotif;
6106        let _ = OpPeerDelNotif;
6107        let _ = OpPeerFloatNotif;
6108        let _ = PushOvpn::<&mut Vec<u8>>::nested_keyconf;
6109        let _ = PushOvpn::<&mut Vec<u8>>::nested_peer;
6110        let _ = PushOvpn::<&mut Vec<u8>>::push_ifindex;
6111        let _ = PushOvpnKeyconfDelInput::<&mut Vec<u8>>::nested_keyconf;
6112        let _ = PushOvpnKeyconfDelInput::<&mut Vec<u8>>::push_ifindex;
6113        let _ = PushOvpnKeyconfGet::<&mut Vec<u8>>::nested_keyconf;
6114        let _ = PushOvpnKeyconfGet::<&mut Vec<u8>>::push_ifindex;
6115        let _ = PushOvpnKeyconfSwapInput::<&mut Vec<u8>>::nested_keyconf;
6116        let _ = PushOvpnKeyconfSwapInput::<&mut Vec<u8>>::push_ifindex;
6117        let _ = PushOvpnPeerDelInput::<&mut Vec<u8>>::nested_peer;
6118        let _ = PushOvpnPeerDelInput::<&mut Vec<u8>>::push_ifindex;
6119        let _ = PushOvpnPeerNewInput::<&mut Vec<u8>>::nested_peer;
6120        let _ = PushOvpnPeerNewInput::<&mut Vec<u8>>::push_ifindex;
6121        let _ = PushOvpnPeerSetInput::<&mut Vec<u8>>::nested_peer;
6122        let _ = PushOvpnPeerSetInput::<&mut Vec<u8>>::push_ifindex;
6123    }
6124}