Struct etherparse::Ipv6RawExtHeader
source · pub struct Ipv6RawExtHeader {
pub next_header: IpNumber,
/* 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 Ipv6RawExtHeader
:
- Hop by Hop
- Destination Options
- Routing
- Mobility
- Host Identity Protocol
- Shim6 Protocol
Fields§
§next_header: IpNumber
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 Ipv6RawExtHeader
impl Ipv6RawExtHeader
sourcepub const MIN_LEN: usize = 8usize
pub const MIN_LEN: usize = 8usize
Minimum length of an raw IPv6 extension header in bytes/octets.
sourcepub const MAX_LEN: usize = 2_048usize
pub const MAX_LEN: usize = 2_048usize
Maximum length of an raw IPv6 extension header in bytes/octets.
This number is calculated by multiplying the maximum “hdr ext len” (0xff) with 8 and adding 8. As RFC8200 states that “hdr ext len” is defined as “8-bit unsigned integer. Length of the Hop-by-Hop Options header in 8-octet units, not including the first 8 octets.”
sourcepub const MIN_PAYLOAD_LEN: usize = 6usize
pub const MIN_PAYLOAD_LEN: usize = 6usize
Minimum length of a Ipv6RawExtHeader payload
sourcepub const MAX_PAYLOAD_LEN: usize = 2_046usize
pub const MAX_PAYLOAD_LEN: usize = 2_046usize
Maximum length of a Ipv6RawExtHeader the payload
sourcepub fn header_type_supported(next_header: IpNumber) -> bool
pub fn header_type_supported(next_header: IpNumber) -> bool
Returns true if the given header type ip number can be represented in an Ipv6ExtensionHeader
.
sourcepub fn new_raw(
next_header: IpNumber,
payload: &[u8]
) -> Result<Ipv6RawExtHeader, ExtPayloadLenError>
pub fn new_raw( next_header: IpNumber, payload: &[u8] ) -> Result<Ipv6RawExtHeader, ExtPayloadLenError>
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 (Ipv6RawExtHeader::MAX_PAYLOAD_LEN
).
If a payload with a non supported length is provided a crate::err::ipv6_exts::ExtPayloadLenError
is returned.
sourcepub fn from_slice(slice: &[u8]) -> Result<(Ipv6RawExtHeader, &[u8]), LenError>
pub fn from_slice(slice: &[u8]) -> Result<(Ipv6RawExtHeader, &[u8]), LenError>
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<(), ExtPayloadLenError>
pub fn set_payload(&mut self, payload: &[u8]) -> Result<(), ExtPayloadLenError>
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 (crate::Ipv6RawExtHeader::MAX_PAYLOAD_LEN
).
If a payload with a non supported length is provided a crate::err::ipv6_exts::ExtPayloadLenError
is returned and the payload of the header is not changed.
sourcepub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<Ipv6RawExtHeader, Error>
Available on crate feature std
only.
pub fn read<T: Read + Seek + Sized>( reader: &mut T ) -> Result<Ipv6RawExtHeader, Error>
std
only.Read an fragment header from the current reader position.
sourcepub fn read_limited<T: Read + Seek + Sized>(
reader: &mut LimitedReader<T>
) -> Result<Ipv6RawExtHeader, LimitedReadError>
Available on crate feature std
only.
pub fn read_limited<T: Read + Seek + Sized>( reader: &mut LimitedReader<T> ) -> Result<Ipv6RawExtHeader, LimitedReadError>
std
only.Read an fragment header from the current limited reader position.
sourcepub fn write<W: Write + Sized>(&self, writer: &mut W) -> Result<(), Error>
Available on crate feature std
only.
pub fn write<W: Write + Sized>(&self, writer: &mut W) -> Result<(), Error>
std
only.Writes a given IPv6 extension header to the current position.
sourcepub fn to_bytes(&self) -> ArrayVec<u8, { Ipv6RawExtHeader::MAX_LEN }>
pub fn to_bytes(&self) -> ArrayVec<u8, { Ipv6RawExtHeader::MAX_LEN }>
Returns the serialized header.
sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Length of the header in bytes.
Trait Implementations§
source§impl Clone for Ipv6RawExtHeader
impl Clone for Ipv6RawExtHeader
source§fn clone(&self) -> Ipv6RawExtHeader
fn clone(&self) -> Ipv6RawExtHeader
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more