IcmpV6Hdr

Struct IcmpV6Hdr 

Source
#[repr(C, packed(1))]
pub struct IcmpV6Hdr { pub type_: u8, pub code: u8, pub check: [u8; 2], pub data: IcmpV6HdrUn, }
Expand description

Represents an ICMPv6 header as defined in RFC 4443. The header consists of a type and code field identifying the message type, a checksum for error detection, and a data field whose format depends on the message type.

The type_ field identifies the general category of message, such as:

  • 1: Destination Unreachable
  • 2: Packet Too Big
  • 3: Time Exceeded
  • 4: Parameter Problem
  • 128: Echo Request
  • 129: Echo Reply

The code field provides additional context for the message type.

The check field contains a checksum calculated over an IPv6 pseudo-header, the ICMPv6 header, and its payload.

The data field contains type-specific data such as echo identifiers/sequence numbers, MTU values, or pointers to errors in received packets.

Fields§

§type_: u8§code: u8§check: [u8; 2]§data: IcmpV6HdrUn

Implementations§

Source§

impl IcmpV6Hdr

Source

pub const LEN: usize = 40usize

Source

pub fn checksum(&self) -> u16

Returns the ICMPv6 header checksum value in host byte order. This field is used to detect corruption in the ICMPv6 header and payload.

Source

pub fn set_checksum(&mut self, checksum: u16)

Sets the ICMPv6 header checksum field to the given value. The checksum value should be calculated over the pseudo-header, ICMPv6 header, and payload according to RFC 4443. The value will be stored in network byte order.

Source

pub fn echo_id(&self) -> Result<u16, IcmpError>

Returns the identification field from ICMPv6 Echo Request/Reply messages. Only valid for ICMPv6 Types: 128 (Echo Request), 129 (Echo Reply).

Source

pub fn set_echo_id(&mut self, id: u16) -> Result<(), IcmpError>

Sets the identification field for ICMPv6 Echo Request/Reply messages. Only valid for ICMPv6 Types: 128 (Echo Request), 129 (Echo Reply).

Source

pub fn echo_sequence(&self) -> Result<u16, IcmpError>

Returns the sequence number from ICMPv6 Echo Request/Reply messages. Only valid for ICMPv6 Types: 128 (Echo Request), 129 (Echo Reply).

Source

pub fn set_echo_sequence(&mut self, sequence: u16) -> Result<(), IcmpError>

Sets the sequence number for ICMPv6 Echo Request/Reply messages. Only valid for ICMPv6 Types: 128 (Echo Request), 129 (Echo Reply).

Source

pub fn mtu(&self) -> Result<u32, IcmpError>

Returns the MTU field from an ICMPv6 Packet Too Big message (Type 2). This value indicates the maximum packet size that can be handled by the next hop.

Source

pub fn set_mtu(&mut self, mtu: u32) -> Result<(), IcmpError>

Sets the MTU field for an ICMPv6 Packet Too Big message (Type 2). This should be set to the maximum packet size that can be handled by the next hop.

Source

pub fn pointer(&self) -> Result<u32, IcmpError>

Returns the pointer field from an ICMPv6 Parameter Problem message (Type 4). The pointer indicates the offset within the invoking packet where the error was detected.

Source

pub fn set_pointer(&mut self, pointer: u32) -> Result<(), IcmpError>

Sets the pointer field for an ICMPv6 Parameter Problem message (Type 4). The pointer should indicate the offset within the invoking packet where the error was detected.

Source

pub fn redirect_reserved(&self) -> Result<[u8; 4], IcmpError>

Returns the 4-byte reserved field from an ICMPv6 Redirect message (Type 137). This field is currently unused and MUST be initialized to zeros by the sender.

Source

pub fn set_redirect_reserved( &mut self, reserved: [u8; 4], ) -> Result<(), IcmpError>

Sets the 4-byte reserved field for an ICMPv6 Redirect message (Type 137). This field is currently unused and MUST be set to zeros.

Source

pub fn redirect_target_address(&self) -> Result<Ipv6Addr, IcmpError>

Returns the Target Address from an ICMPv6 Redirect message (Type 137). This field contains the address that is a better first hop to use for the destination.

Source

pub fn set_redirect_target_address( &mut self, addr: Ipv6Addr, ) -> Result<(), IcmpError>

Sets the Target Address for an ICMPv6 Redirect message (Type 137). This should be set to the address that is a better first hop to use for the destination.

Source

pub fn redirect_destination_address(&self) -> Result<Ipv6Addr, IcmpError>

Returns the Destination Address from an ICMPv6 Redirect message (Type 137). This field contains the IP address of the destination that is redirected to the target.

Source

pub fn set_redirect_destination_address( &mut self, addr: Ipv6Addr, ) -> Result<(), IcmpError>

Sets the Destination Address for an ICMPv6 Redirect message (Type 137). This should be set to the IP address of the destination that is redirected to the target.

Source§

impl IcmpV6Hdr

Source

pub unsafe fn echo_id_unchecked(&self) -> u16

Returns the identification field from ICMPv6 Echo Request/Reply messages. Only valid for ICMPv6 Types: 128 (Echo Request), 129 (Echo Reply).

§Safety

Caller must ensure ICMPv6 type is 128 (Echo Request) or 129 (Echo Reply) before calling. Accessing echo fields with other types may result in undefined behavior.

Source

pub unsafe fn set_echo_id_unchecked(&mut self, id: u16)

Sets the identification field for ICMPv6 Echo Request/Reply messages. Only valid for ICMPv6 Types: 128 (Echo Request), 129 (Echo Reply).

§Safety

Caller must ensure ICMPv6 type is 128 (Echo Request) or 129 (Echo Reply) before calling. Accessing echo fields with other types may result in undefined behavior.

Source

pub unsafe fn echo_sequence_unchecked(&self) -> u16

Returns the sequence number from ICMPv6 Echo Request/Reply messages. Only valid for ICMPv6 Types: 128 (Echo Request), 129 (Echo Reply).

§Safety

Caller must ensure ICMPv6 type is 128 (Echo Request) or 129 (Echo Reply) before calling. Accessing echo fields with other types may result in undefined behavior.

Source

pub unsafe fn set_echo_sequence_unchecked(&mut self, sequence: u16)

Sets the sequence number for ICMPv6 Echo Request/Reply messages. Only valid for ICMPv6 Types: 128 (Echo Request), 129 (Echo Reply).

§Safety

Caller must ensure ICMPv6 type is 128 (Echo Request) or 129 (Echo Reply) before calling. Accessing echo fields with other types may result in undefined behavior.

Source

pub unsafe fn mtu_unchecked(&self) -> u32

Returns the MTU field from an ICMPv6 Packet Too Big message (Type 2). This value indicates the maximum packet size that can be handled by the next hop.

§Safety

Caller must ensure ICMPv6 type is 2 (Packet Too Big) before calling. Accessing MTU field with other types may result in undefined behavior.

Source

pub unsafe fn set_mtu_unchecked(&mut self, mtu: u32)

Sets the MTU field for an ICMPv6 Packet Too Big message (Type 2). This should be set to the maximum packet size that can be handled by the next hop.

§Safety

Caller must ensure ICMPv6 type is 2 (Packet Too Big) before calling. Accessing MTU field with other types may result in undefined behavior.

Source

pub unsafe fn pointer_unchecked(&self) -> u32

Returns the pointer field from an ICMPv6 Parameter Problem message (Type 4). The pointer indicates the offset within the invoking packet where the error was detected.

§Safety

Caller must ensure ICMPv6 type is 4 (Parameter Problem) before calling. Accessing pointer field with other types may result in undefined behavior.

Source

pub unsafe fn set_pointer_unchecked(&mut self, pointer: u32)

Sets the pointer field for an ICMPv6 Parameter Problem message (Type 4). The pointer should indicate the offset within the invoking packet where the error was detected.

§Safety

Caller must ensure ICMPv6 type is 4 (Parameter Problem) before calling. Accessing pointer field with other types may result in undefined behavior.

Source

pub unsafe fn redirect_reserved_unchecked(&self) -> [u8; 4]

Returns the 4-byte reserved field from an ICMPv6 Redirect message (Type 137). This field is currently unused and MUST be initialized to zeros by the sender.

§Safety

Caller must ensure ICMPv6 type is 137 (Redirect) before calling. Accessing redirect fields with other types may result in undefined behavior.

Source

pub unsafe fn set_redirect_reserved_unchecked(&mut self, reserved: [u8; 4])

Sets the 4-byte reserved field for an ICMPv6 Redirect message (Type 137). This field is currently unused and MUST be set to zeros.

§Safety

Caller must ensure ICMPv6 type is 137 (Redirect) before calling. Accessing redirect fields with other types may result in undefined behavior.

Source

pub unsafe fn redirect_target_address_unchecked(&self) -> Ipv6Addr

Returns the Target Address from an ICMPv6 Redirect message (Type 137). This field contains the address that is a better first hop to use for the destination.

§Safety

Caller must ensure ICMPv6 type is 137 (Redirect) before calling. Accessing redirect fields with other types may result in undefined behavior.

Source

pub unsafe fn set_redirect_target_address_unchecked(&mut self, addr: Ipv6Addr)

Sets the Target Address for an ICMPv6 Redirect message (Type 137). This should be set to the address that is a better first hop to use for the destination.

§Safety

Caller must ensure ICMPv6 type is 137 (Redirect) before calling. Accessing redirect fields with other types may result in undefined behavior.

Source

pub unsafe fn redirect_destination_address_unchecked(&self) -> Ipv6Addr

Returns the Destination Address from an ICMPv6 Redirect message (Type 137). This field contains the IP address of the destination that is redirected to the target.

§Safety

Caller must ensure ICMPv6 type is 137 (Redirect) before calling. Accessing redirect fields with other types may result in undefined behavior.

Source

pub unsafe fn set_redirect_destination_address_unchecked( &mut self, addr: Ipv6Addr, )

Sets the Destination Address for an ICMPv6 Redirect message (Type 137). This should be set to the IP address of the destination that is redirected to the target.

§Safety

Caller must ensure ICMPv6 type is 137 (Redirect) before calling. Accessing redirect fields with other types may result in undefined behavior.

Trait Implementations§

Source§

impl Clone for IcmpV6Hdr

Source§

fn clone(&self) -> IcmpV6Hdr

Returns a duplicate 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 IcmpV6Hdr

Source§

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

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

impl Copy for IcmpV6Hdr

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.