Struct Icmpv4Packet

Source
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: Icmpv4Message

Implementations§

Source§

impl Icmpv4Packet

Source

pub fn parse<B: AsRef<[u8]>>(bytes: B) -> Result<Self, PacketParseError>

Parse an Icmpv4Packet from bytes including the IPv4 header.

Source

pub fn get_bytes(&self, with_checksum: bool) -> Vec<u8>

Get this packet serialized to bytes suitable for sending on the wire.

Source

pub fn calculate_checksum(&self) -> u16

Calculate the checksum for the packet given the provided source and destination addresses.

Source

pub fn with_checksum(self) -> Self

Populate the checksum field of this Packet.

Trait Implementations§

Source§

impl Debug for Icmpv4Packet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TryFrom<&[u8]> for Icmpv4Packet

Source§

type Error = PacketParseError

The type returned in the event of a conversion error.
Source§

fn try_from(b: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl WithEchoRequest for Icmpv4Packet

Source§

type Packet = Icmpv4Packet

Source§

fn with_echo_request( identifier: u16, sequence: u16, payload: Vec<u8>, ) -> Result<Self::Packet, IcmpPacketBuildError>

Source§

impl WithParameterProblem for Icmpv4Packet

Source§

impl WithTimeExceeded for Icmpv4Packet

Source§

impl WithUnreachable for Icmpv4Packet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.