pub struct Icmpv4Packet {
pub typ: u8,
pub code: u8,
pub checksum: u16,
pub message: Icmpv4Message,
}Expand description
An Icmpv4 Packet.
Fields§
§typ: u8§code: u8§checksum: u16§message: Icmpv4MessageImplementations§
Source§impl Icmpv4Packet
impl Icmpv4Packet
Sourcepub fn parse<B: AsRef<[u8]>>(bytes: B) -> Result<Self, PacketParseError>
pub fn parse<B: AsRef<[u8]>>(bytes: B) -> Result<Self, PacketParseError>
Parse an Icmpv4Packet from bytes including the IPv4 header.
Sourcepub fn get_bytes(&self, with_checksum: bool) -> Vec<u8> ⓘ
pub fn get_bytes(&self, with_checksum: bool) -> Vec<u8> ⓘ
Get this packet serialized to bytes suitable for sending on the wire.
Sourcepub fn calculate_checksum(&self) -> u16
pub fn calculate_checksum(&self) -> u16
Calculate the checksum for the packet given the provided source and destination addresses.
Sourcepub fn with_checksum(self) -> Self
pub fn with_checksum(self) -> Self
Populate the checksum field of this Packet.
Trait Implementations§
Source§impl Debug for Icmpv4Packet
impl Debug for Icmpv4Packet
Source§impl TryFrom<&[u8]> for Icmpv4Packet
impl TryFrom<&[u8]> for Icmpv4Packet
Source§impl WithEchoReply for Icmpv4Packet
impl WithEchoReply for Icmpv4Packet
type Packet = Icmpv4Packet
fn with_echo_reply( identifier: u16, sequence: u16, payload: Vec<u8>, ) -> Result<Self, IcmpPacketBuildError>
Source§impl WithEchoRequest for Icmpv4Packet
impl WithEchoRequest for Icmpv4Packet
type Packet = Icmpv4Packet
fn with_echo_request( identifier: u16, sequence: u16, payload: Vec<u8>, ) -> Result<Self::Packet, IcmpPacketBuildError>
Source§impl WithParameterProblem for Icmpv4Packet
impl WithParameterProblem for Icmpv4Packet
Source§impl WithTimeExceeded for Icmpv4Packet
impl WithTimeExceeded for Icmpv4Packet
type Packet = Icmpv4Packet
fn with_time_exceeded( code: u8, packet: Vec<u8>, ) -> Result<Self::Packet, IcmpPacketBuildError>
Source§impl WithTimestampReply for Icmpv4Packet
impl WithTimestampReply for Icmpv4Packet
type Packet = Icmpv4Packet
fn with_timestamp_reply( identifier: u16, sequence: u16, originate: u32, receive: u32, transmit: u32, ) -> Result<Self::Packet, IcmpPacketBuildError>
Source§impl WithTimestampRequest for Icmpv4Packet
impl WithTimestampRequest for Icmpv4Packet
type Packet = Icmpv4Packet
fn with_timestamp_request( identifier: u16, sequence: u16, originate: u32, receive: u32, transmit: u32, ) -> Result<Self::Packet, IcmpPacketBuildError>
Source§impl WithUnreachable for Icmpv4Packet
impl WithUnreachable for Icmpv4Packet
type Packet = Icmpv4Packet
fn with_unreachable( code: u8, packet: Vec<u8>, ) -> Result<Self::Packet, IcmpPacketBuildError>
Auto Trait Implementations§
impl Freeze for Icmpv4Packet
impl RefUnwindSafe for Icmpv4Packet
impl Send for Icmpv4Packet
impl Sync for Icmpv4Packet
impl Unpin for Icmpv4Packet
impl UnsafeUnpin for Icmpv4Packet
impl UnwindSafe for Icmpv4Packet
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