Struct etherparse::Ipv6RawExtensionHeader
source · pub struct Ipv6RawExtensionHeader {
pub next_header: u8,
/* private fields */
}
Expand description
Raw IPv6 extension header (undecoded payload).
IPv6 extension header with only minimal data interpretation. NOTE only ipv6 header extensions with the first two bytes representing the next header and the header length in 8-octets (- 8 octets) can be represented with this struct. This excludes the “Authentication Header” (AH) and “Encapsulating Security Payload” (ESP).
The following headers can be represented in a Ipv6RawExtensionHeader
:
- Hop by Hop
- Destination Options
- Routing
- Mobility
- Host Identity Protocol
- Shim6 Protocol
Fields§
§next_header: u8
IP protocol number specifying the next header or transport layer protocol.
See IpNumber or ip_number for a definition of the known values.
Implementations§
source§impl Ipv6RawExtensionHeader
impl Ipv6RawExtensionHeader
sourcepub const MIN_PAYLOAD_LEN: usize = 6usize
pub const MIN_PAYLOAD_LEN: usize = 6usize
Minimum length of a Ipv6RawExtensionHeader payload
sourcepub const MAX_PAYLOAD_LEN: usize = 2_046usize
pub const MAX_PAYLOAD_LEN: usize = 2_046usize
Maximum length of a Ipv6RawExtensionHeader the payload
sourcepub fn header_type_supported(next_header: u8) -> bool
pub fn header_type_supported(next_header: u8) -> bool
Returns true if the given header type ip number can be represented in an Ipv6ExtensionHeader
.
sourcepub fn new_raw(
next_header: u8,
payload: &[u8]
) -> Result<Ipv6RawExtensionHeader, ValueError>
pub fn new_raw(
next_header: u8,
payload: &[u8]
) -> Result<Ipv6RawExtensionHeader, ValueError>
Creates an generic IPv6 extension header with the given data.
Arguments
next_header
- type of content after this header (protocol number)payload
- slice containing the data of the header. This must NOT contain thenext header
andextended header length
fields of the header.
Note that payload
must have at least the length of 6 bytes and only supports
length increases in steps of 8. This measn that the following expression must be true (payload.len() + 2) % 8 == 0
.
The maximum length of the payload is 2046
bytes (Ipv6RawExtensionHeader::MAX_PAYLOAD_LEN
).
If a payload with a non supported length is provided a ValueError
is returned.
sourcepub fn from_slice(
slice: &[u8]
) -> Result<(Ipv6RawExtensionHeader, &[u8]), ReadError>
pub fn from_slice(
slice: &[u8]
) -> Result<(Ipv6RawExtensionHeader, &[u8]), ReadError>
Read an Ipv6ExtensionHeader from a slice and return the header & unused parts of the slice.
sourcepub fn payload(&self) -> &[u8] ⓘ
pub fn payload(&self) -> &[u8] ⓘ
Return a slice containing the current payload. This does NOT contain
the next_header
and header_length
fields. But everything after these
two fields.
sourcepub fn set_payload(&mut self, payload: &[u8]) -> Result<(), ValueError>
pub fn set_payload(&mut self, payload: &[u8]) -> Result<(), ValueError>
Sets the payload (content of the header after the next_header
& header_length
fields).
Note that payload
must have at least the length of 6 bytes and only supports
length increases in steps of 8. This measn that the following expression must be true (payload.len() + 2) % 8 == 0
.
The maximum length of the payload is 2046
bytes (Ipv6RawExtensionHeader::MAX_PAYLOAD_LEN
).
If a payload with a non supported length is provided a ValueError
is returned and the payload of the header is not changed.
sourcepub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<Ipv6RawExtensionHeader, ReadError>
pub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<Ipv6RawExtensionHeader, ReadError>
Read an fragment header from the current reader position.
sourcepub fn write<W: Write + Sized>(&self, writer: &mut W) -> Result<(), WriteError>
pub fn write<W: Write + Sized>(&self, writer: &mut W) -> Result<(), WriteError>
Writes a given IPv6 extension header to the current position.
sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Length of the header in bytes.
Trait Implementations§
source§impl Clone for Ipv6RawExtensionHeader
impl Clone for Ipv6RawExtensionHeader
source§fn clone(&self) -> Ipv6RawExtensionHeader
fn clone(&self) -> Ipv6RawExtensionHeader
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more