pub struct Icmpv4Packet<T: AsRef<[u8]>> { /* private fields */ }
Expand description
A read/write wrapper around an Internet Control Message Protocol version 4 packet buffer.
Implementations§
Source§impl<T: AsRef<[u8]>> Packet<T>
impl<T: AsRef<[u8]>> Packet<T>
Sourcepub 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.
Sourcepub fn new_checked(buffer: T) -> Result<Packet<T>>
pub fn new_checked(buffer: T) -> Result<Packet<T>>
Shorthand for a combination of new_unchecked and check_len.
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
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.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the packet, returning the underlying buffer.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn verify_checksum(&self) -> bool
pub fn verify_checksum(&self) -> bool
Source§impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T>
impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T>
Sourcepub fn set_msg_type(&mut self, value: Message)
pub fn set_msg_type(&mut self, value: Message)
Set the message type field.
Sourcepub fn set_msg_code(&mut self, value: u8)
pub fn set_msg_code(&mut self, value: u8)
Set the message code field.
Sourcepub fn set_checksum(&mut self, value: u16)
pub fn set_checksum(&mut self, value: u16)
Set the checksum field.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn fill_checksum(&mut self)
pub fn fill_checksum(&mut self)
Compute and fill in the header checksum.