Skip to main content

net_wire/ipv6/
next_header.rs

1/// An IPv6 Next Header value from the IANA Protocol Numbers registry.
2#[repr(transparent)]
3#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
4pub struct Ipv6NextHeader(u8);
5
6impl Ipv6NextHeader {
7    /// IPv6 Hop-by-Hop Options (`0`).
8    pub const HOPOPT: Self = Self(0);
9    /// Routing (`43`).
10    pub const ROUTING: Self = Self(43);
11    /// Fragment (`44`).
12    pub const FRAGMENT: Self = Self(44);
13    /// Encapsulating Security Payload (`50`).
14    pub const ESP: Self = Self(50);
15    /// Authentication Header (`51`).
16    pub const AUTHENTICATION: Self = Self(51);
17    /// Destination Options (`60`).
18    pub const DESTINATION_OPTIONS: Self = Self(60);
19    /// Transmission Control Protocol (`6`).
20    pub const TCP: Self = Self(6);
21    /// User Datagram Protocol (`17`).
22    pub const UDP: Self = Self(17);
23    /// Internet Control Message Protocol for IPv6 (`58`).
24    pub const ICMPV6: Self = Self(58);
25    /// No Next Header (`59`).
26    pub const NO_NEXT_HEADER: Self = Self(59);
27
28    /// Preserves a Next Header value, including unassigned values.
29    #[inline]
30    pub const fn new(raw: u8) -> Self {
31        Self(raw)
32    }
33
34    /// Returns the encoded Next Header value.
35    #[inline]
36    pub const fn raw(self) -> u8 {
37        self.0
38    }
39}