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.
Trait Implementations§
Source§impl<T: AsRef<[u8]>> PrettyPrint for Packet<T>
impl<T: AsRef<[u8]>> PrettyPrint for Packet<T>
Source§fn pretty_print(
buffer: &dyn AsRef<[u8]>,
f: &mut Formatter<'_>,
indent: &mut PrettyIndent,
) -> Result
fn pretty_print( buffer: &dyn AsRef<[u8]>, f: &mut Formatter<'_>, indent: &mut PrettyIndent, ) -> Result
impl<T: Eq + AsRef<[u8]>> Eq for Packet<T>
impl<T: AsRef<[u8]>> StructuralPartialEq for Packet<T>
Auto Trait Implementations§
impl<T> Freeze for Packet<T>where
T: Freeze,
impl<T> RefUnwindSafe for Packet<T>where
T: RefUnwindSafe,
impl<T> Send for Packet<T>where
T: Send,
impl<T> Sync for Packet<T>where
T: Sync,
impl<T> Unpin for Packet<T>where
T: Unpin,
impl<T> UnwindSafe for Packet<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)