pub struct Icmpv6Header {
    pub icmp_type: Icmpv6Type,
    pub checksum: u16,
}
Expand description

The statically sized data at the start of an ICMPv6 packet (at least the first 8 bytes of an ICMPv6 packet).

Fields§

§icmp_type: Icmpv6Type

Type & type specific values & code.

§checksum: u16

Checksum in the ICMPv6 header.

Implementations§

source§

impl Icmpv6Header

source

pub const MIN_LEN: usize = 8usize

Minimum number of bytes an ICMP header needs to have.

Note that minimum size can be larger depending on the type and code.

source

pub const MIN_SERIALIZED_SIZE: usize = 8usize

👎Deprecated since 0.14.0: Please use Icmpv6Header::MIN_LEN instead

Deprecated, use Icmpv6Header::MIN_LEN instead.

source

pub const MAX_LEN: usize = 40usize

Maximum number of bytes/octets an Icmpv6Header takes up in serialized form.

Currently this number is determined by the biggest planned ICMPv6 header type, which is currently the “Neighbor Discovery Protocol” “Redirect” message.

source

pub const MAX_SERIALIZED_SIZE: usize = 40usize

👎Deprecated since 0.14.0: Please use Icmpv6Header::MAX_LEN instead

Deprecated, use Icmpv6Header::MAX_LEN instead.

source

pub fn new(icmp_type: Icmpv6Type) -> Icmpv6Header

Setups a new header with the checksum being set to 0.

source

pub fn with_checksum( icmp_type: Icmpv6Type, source_ip: [u8; 16], destination_ip: [u8; 16], payload: &[u8] ) -> Result<Icmpv6Header, ValueTooBigError<usize>>

Creates a Icmpv6Header with a checksum calculated based on the given payload & ip addresses from the IPv6 header.

source

pub fn from_slice(slice: &[u8]) -> Result<(Icmpv6Header, &[u8]), LenError>

Reads an icmp6 header from a slice directly and returns a tuple containing the resulting header & unused part of the slice.

source

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

Available on crate feature std only.

Read a ICMPv6 header from the given reader

source

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

Available on crate feature std only.

Write the ICMPv6 header to the given writer.

source

pub fn header_len(&self) -> usize

Serialized length of the header in bytes/octets.

Note that this size is not the size of the entire ICMPv6 packet but only the header.

source

pub fn fixed_payload_size(&self) -> Option<usize>

If the ICMP type has a fixed size returns the number of bytes that should be present after the header of this type.

source

pub fn update_checksum( &mut self, source_ip: [u8; 16], destination_ip: [u8; 16], payload: &[u8] ) -> Result<(), ValueTooBigError<usize>>

Updates the checksum of the header.

source

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

Returns the header on the wire bytes.

Trait Implementations§

source§

impl Clone for Icmpv6Header

source§

fn clone(&self) -> Icmpv6Header

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 Icmpv6Header

source§

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

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

impl PartialEq for Icmpv6Header

source§

fn eq(&self, other: &Icmpv6Header) -> 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 Icmpv6Header

source§

impl StructuralPartialEq for Icmpv6Header

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.