Struct etherparse::Icmpv6Header
source · 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
impl Icmpv6Header
sourcepub const MIN_SERIALIZED_SIZE: usize = 8usize
pub const MIN_SERIALIZED_SIZE: 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.
sourcepub const MAX_SERIALIZED_SIZE: usize = 40usize
pub const MAX_SERIALIZED_SIZE: 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.
sourcepub fn new(icmp_type: Icmpv6Type) -> Icmpv6Header
pub fn new(icmp_type: Icmpv6Type) -> Icmpv6Header
Setups a new header with the checksum beeing set to 0.
sourcepub fn with_checksum(
icmp_type: Icmpv6Type,
source_ip: [u8; 16],
destination_ip: [u8; 16],
payload: &[u8]
) -> Result<Icmpv6Header, ValueError>
pub fn with_checksum(
icmp_type: Icmpv6Type,
source_ip: [u8; 16],
destination_ip: [u8; 16],
payload: &[u8]
) -> Result<Icmpv6Header, ValueError>
Creates a Icmpv6Header
with a checksum calculated based
on the given payload & ip addresses from the IPv6 header.
sourcepub fn from_slice(slice: &[u8]) -> Result<(Icmpv6Header, &[u8]), ReadError>
pub fn from_slice(slice: &[u8]) -> Result<(Icmpv6Header, &[u8]), ReadError>
Reads an icmp6 header from a slice directly and returns a tuple containing the resulting header & unused part of the slice.
sourcepub fn read<T: Read + Sized>(reader: &mut T) -> Result<Icmpv6Header, ReadError>
pub fn read<T: Read + Sized>(reader: &mut T) -> Result<Icmpv6Header, ReadError>
Read a ICMPv6 header from the given reader
sourcepub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), WriteError>
pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), WriteError>
Write the ICMPv6 header to the given writer.
sourcepub fn header_len(&self) -> usize
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.
sourcepub fn fixed_payload_size(&self) -> Option<usize>
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.
sourcepub fn update_checksum(
&mut self,
source_ip: [u8; 16],
destination_ip: [u8; 16],
payload: &[u8]
) -> Result<(), ValueError>
pub fn update_checksum(
&mut self,
source_ip: [u8; 16],
destination_ip: [u8; 16],
payload: &[u8]
) -> Result<(), ValueError>
Updates the checksum of the header.
Trait Implementations§
source§impl Clone for Icmpv6Header
impl Clone for Icmpv6Header
source§fn clone(&self) -> Icmpv6Header
fn clone(&self) -> Icmpv6Header
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more