#[repr(C)]pub struct Icmpv6Hdr {
pub type_: u8,
pub code: u8,
pub check: [u8; 2],
pub data: [u8; 4],
}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: [u8; 4]Implementations§
Source§impl Icmpv6Hdr
impl Icmpv6Hdr
pub const LEN: usize
pub fn icmp_type(&self) -> Result<Icmpv6Type, IcmpError>
Sourcepub fn checksum(&self) -> u16
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.
Sourcepub fn set_checksum(&mut self, checksum: u16)
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.
Sourcepub fn data(&self) -> Result<Icmpv6HdrData<'_>, IcmpError>
pub fn data(&self) -> Result<Icmpv6HdrData<'_>, IcmpError>
Returns a type-safe view over the data bytes based on the ICMPv6 type.
Sourcepub fn data_mut(&mut self) -> Result<Icmpv6HdrDataMut<'_>, IcmpError>
pub fn data_mut(&mut self) -> Result<Icmpv6HdrDataMut<'_>, IcmpError>
Returns a mutable type-safe view over the data bytes based on the ICMPv6 type.
Source§impl Icmpv6Hdr
These are the unsafe alternatives to the safe functions on Icmpv6Hdr that do prevent undefined behavior.
impl Icmpv6Hdr
These are the unsafe alternatives to the safe functions on Icmpv6Hdr that do prevent undefined behavior.
Sourcepub unsafe fn id_sequence_unchecked(&self) -> &IcmpIdSequence
pub unsafe fn id_sequence_unchecked(&self) -> &IcmpIdSequence
Returns a reference to the ID and sequence fields.
§Safety
Caller must ensure ICMPv6 type is 128 (Echo Request) or 129 (Echo Reply) before calling this function. Accessing the fields with other ICMPv6 types may result in undefined behavior.
Sourcepub unsafe fn id_sequence_mut_unchecked(&mut self) -> &mut IcmpIdSequence
pub unsafe fn id_sequence_mut_unchecked(&mut self) -> &mut IcmpIdSequence
Returns a mutable reference to the ID and sequence fields.
§Safety
Caller must ensure ICMPv6 type is 128 (Echo Request) or 129 (Echo Reply) before calling this function. Accessing the fields with other ICMPv6 types may result in undefined behavior.
Sourcepub unsafe fn packet_too_big_unchecked(&self) -> &IcmpPacketTooBig
pub unsafe fn packet_too_big_unchecked(&self) -> &IcmpPacketTooBig
Returns a reference to the Packet Too Big message (Type 2).
§Safety
Caller must ensure ICMPv6 type is 2 (Packet Too Big) before calling. Accessing the fields with other types may result in undefined behavior.
Sourcepub unsafe fn packet_too_big_mut_unchecked(&mut self) -> &mut IcmpPacketTooBig
pub unsafe fn packet_too_big_mut_unchecked(&mut self) -> &mut IcmpPacketTooBig
Returns a mutable reference to the Packet Too Big message (Type 2).
§Safety
Caller must ensure ICMPv6 type is 2 (Packet Too Big) before calling. Accessing the fields with other types may result in undefined behavior.
Sourcepub unsafe fn parameter_problem_unchecked(&self) -> &Icmpv6ParamProblem
pub unsafe fn parameter_problem_unchecked(&self) -> &Icmpv6ParamProblem
Returns a reference to the Parameter Problem message (Type 4).
§Safety
Caller must ensure ICMPv6 type is 4 (Parameter Problem) before calling. Accessing the fields with other types may result in undefined behavior.
Sourcepub unsafe fn parameter_problem_mut_unchecked(
&mut self,
) -> &mut Icmpv6ParamProblem
pub unsafe fn parameter_problem_mut_unchecked( &mut self, ) -> &mut Icmpv6ParamProblem
Returns a mutable reference to the Parameter Problem message (Type 4).
§Safety
Caller must ensure ICMPv6 type is 4 (Parameter Problem) before calling. Accessing the fields with other types may result in undefined behavior.
Sourcepub unsafe fn redirect_unchecked(&self) -> &Icmpv6Redirect
pub unsafe fn redirect_unchecked(&self) -> &Icmpv6Redirect
Returns a reference to the 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.
Sourcepub unsafe fn redirect_mut_unchecked(&mut self) -> &mut Icmpv6Redirect
pub unsafe fn redirect_mut_unchecked(&mut self) -> &mut Icmpv6Redirect
Returns a mutable reference to the 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.
Trait Implementations§
Source§impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for Icmpv6Hdr
impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for Icmpv6Hdr
Source§impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for Icmpv6Hdr
impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for Icmpv6Hdr
Source§impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for Icmpv6Hdr
impl<WincodeConfig: Config> ZeroCopy<WincodeConfig> for Icmpv6Hdr
Source§fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes<'de>(bytes: &'de [u8], config: C) -> Result<&'de Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
crate::ZeroCopy::from_bytes, but allows the caller to provide a custom configuration.Source§fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
fn from_bytes_mut<'de>(
bytes: &'de mut [u8],
config: C,
) -> Result<&'de mut Self, ReadError>where
Self: Sized + SchemaRead<'de, C, Dst = Self>,
crate::ZeroCopy::from_bytes_mut, but allows the caller to provide a custom configuration.impl Copy for Icmpv6Hdr
Auto Trait Implementations§
impl Freeze for Icmpv6Hdr
impl RefUnwindSafe for Icmpv6Hdr
impl Send for Icmpv6Hdr
impl Sync for Icmpv6Hdr
impl Unpin for Icmpv6Hdr
impl UnsafeUnpin for Icmpv6Hdr
impl UnwindSafe for Icmpv6Hdr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
Source§impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
Source§impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.Source§impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
Source§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader into a new Self::Dst.Source§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader into dst.Source§impl<T, C> Serialize<C> for T
impl<T, C> Serialize<C> for T
Source§fn serialize_into(
dst: impl Writer,
src: &Self::Src,
config: C,
) -> Result<(), WriteError>
fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>
Writer.