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

source

pub const MIN_LEN: usize = 8usize

Minimum length of an raw IPv6 extension header in bytes/octets.

source

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.”

source

pub const MIN_PAYLOAD_LEN: usize = 6usize

Minimum length of a Ipv6RawExtHeader payload

source

pub const MAX_PAYLOAD_LEN: usize = 2_046usize

Maximum length of a Ipv6RawExtHeader the payload

source

pub fn header_type_supported(next_header: IpNumber) -> bool

Returns true if the given header type ip number can be represented in an Ipv6ExtensionHeader.

source

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 the next header and extended 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.

source

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.

source

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.

source

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.

source

pub fn read<T: Read + Seek + Sized>( reader: &mut T ) -> Result<Ipv6RawExtHeader, Error>

Available on crate feature std only.

Read an fragment header from the current reader position.

source

pub fn read_limited<T: Read + Seek + Sized>( reader: &mut LimitedReader<T> ) -> Result<Ipv6RawExtHeader, LimitedReadError>

Available on crate feature std only.

Read an fragment header from the current limited reader position.

source

pub fn write<W: Write + Sized>(&self, writer: &mut W) -> Result<(), Error>

Available on crate feature std only.

Writes a given IPv6 extension header to the current position.

source

pub fn to_bytes(&self) -> ArrayVec<u8, { Ipv6RawExtHeader::MAX_LEN }>

Returns the serialized header.

source

pub fn header_len(&self) -> usize

Length of the header in bytes.

Trait Implementations§

source§

impl Clone for Ipv6RawExtHeader

source§

fn clone(&self) -> Ipv6RawExtHeader

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Ipv6RawExtHeader

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for Ipv6RawExtHeader

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for Ipv6RawExtHeader

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Ipv6RawExtHeader

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.