pub struct IcmpPacket {
pub icmp_type: u8,
pub code: u8,
pub checksum: u16,
pub identifier: u16,
pub sequence: u16,
pub data: Vec<u8>,
}Expand description
ICMP packet structure for echo requests and replies
Fields§
§icmp_type: u8ICMP type (8 for echo request, 0 for echo reply)
code: u8ICMP code (usually 0 for echo)
checksum: u16Internet checksum
identifier: u16Identifier to match requests with replies
sequence: u16Sequence number for ordering
data: Vec<u8>Payload data
Implementations§
Source§impl IcmpPacket
impl IcmpPacket
Sourcepub fn new_echo_request(
identifier: u16,
sequence: u16,
data_size: usize,
) -> Self
pub fn new_echo_request( identifier: u16, sequence: u16, data_size: usize, ) -> Self
Create a new ICMP echo request packet
Sourcepub fn from_bytes(data: &[u8]) -> PingResult<Self>
pub fn from_bytes(data: &[u8]) -> PingResult<Self>
Create an ICMP packet from raw bytes
Sourcepub fn calculate_checksum(&mut self)
pub fn calculate_checksum(&mut self)
Calculate and set the checksum for this packet
Sourcepub fn is_echo_reply(&self) -> bool
pub fn is_echo_reply(&self) -> bool
Check if this is an echo reply packet
Trait Implementations§
Source§impl Clone for IcmpPacket
impl Clone for IcmpPacket
Source§fn clone(&self) -> IcmpPacket
fn clone(&self) -> IcmpPacket
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for IcmpPacket
impl RefUnwindSafe for IcmpPacket
impl Send for IcmpPacket
impl Sync for IcmpPacket
impl Unpin for IcmpPacket
impl UnwindSafe for IcmpPacket
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
Mutably borrows from an owned value. Read more