Struct net::wire::Icmpv4Packet
pub struct Icmpv4Packet<T>where
T: AsRef<[u8]>,{ /* private fields */ }
Expand description
A read/write wrapper around an Internet Control Message Protocol version 4 packet buffer.
Implementations§
§impl<T> Packet<T>where
T: AsRef<[u8]>,
impl<T> Packet<T>where T: AsRef<[u8]>,
pub const fn new_unchecked(buffer: T) -> Packet<T>
pub const fn new_unchecked(buffer: T) -> Packet<T>
Imbue a raw octet buffer with ICMPv4 packet structure.
pub fn new_checked(buffer: T) -> Result<Packet<T>, Error>
pub fn new_checked(buffer: T) -> Result<Packet<T>, Error>
Shorthand for a combination of new_unchecked and check_len.
pub fn check_len(&self) -> Result<(), Error>
pub fn check_len(&self) -> Result<(), Error>
Ensure that no accessor method will panic if called.
Returns Err(Error)
if the buffer is too short.
The result of this check is invalidated by calling set_header_len.
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the packet, returning the underlying buffer.
pub fn echo_ident(&self) -> u16
pub fn echo_ident(&self) -> u16
Return the identifier field (for echo request and reply packets).
Panics
This function may panic if this packet is not an echo request or reply packet.
pub fn echo_seq_no(&self) -> u16
pub fn echo_seq_no(&self) -> u16
Return the sequence number field (for echo request and reply packets).
Panics
This function may panic if this packet is not an echo request or reply packet.
pub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Return the header length. The result depends on the value of the message type field.
pub fn verify_checksum(&self) -> bool
pub fn verify_checksum(&self) -> bool
§impl<T> Packet<T>where
T: AsRef<[u8]> + AsMut<[u8]>,
impl<T> Packet<T>where T: AsRef<[u8]> + AsMut<[u8]>,
pub fn set_msg_type(&mut self, value: Message)
pub fn set_msg_type(&mut self, value: Message)
Set the message type field.
pub fn set_msg_code(&mut self, value: u8)
pub fn set_msg_code(&mut self, value: u8)
Set the message code field.
pub fn set_checksum(&mut self, value: u16)
pub fn set_checksum(&mut self, value: u16)
Set the checksum field.
pub fn set_echo_ident(&mut self, value: u16)
pub fn set_echo_ident(&mut self, value: u16)
Set the identifier field (for echo request and reply packets).
Panics
This function may panic if this packet is not an echo request or reply packet.
pub fn set_echo_seq_no(&mut self, value: u16)
pub fn set_echo_seq_no(&mut self, value: u16)
Set the sequence number field (for echo request and reply packets).
Panics
This function may panic if this packet is not an echo request or reply packet.
pub fn fill_checksum(&mut self)
pub fn fill_checksum(&mut self)
Compute and fill in the header checksum.