IcmpConfig

Struct IcmpConfig 

Source
pub struct IcmpConfig {
    pub socket_family: SocketFamily,
    pub bind: Option<SocketAddr>,
    pub ttl: Option<u32>,
    pub hoplimit: Option<u32>,
    pub read_timeout: Option<Duration>,
    pub write_timeout: Option<Duration>,
    pub interface: Option<String>,
    pub sock_type_hint: IcmpSocketType,
    pub fib: Option<u32>,
}
Expand description

Configuration for an ICMP socket.

Fields§

§socket_family: SocketFamily

The socket family.

§bind: Option<SocketAddr>

Optional bind address for the socket.

§ttl: Option<u32>

Time-to-live for IPv4 packets.

§hoplimit: Option<u32>

Hop limit for IPv6 packets.

§read_timeout: Option<Duration>

Read timeout for the socket.

§write_timeout: Option<Duration>

Write timeout for the socket.

§interface: Option<String>

Network interface to use for the socket.

§sock_type_hint: IcmpSocketType

Socket type hint, DGRAM preferred on Linux, RAW fallback on macOS/Windows.

§fib: Option<u32>

FreeBSD only: optional FIB (Forwarding Information Base) support.

Implementations§

Source§

impl IcmpConfig

Source

pub fn new(kind: IcmpKind) -> Self

Creates a new ICMP configuration with the specified kind.

Source

pub fn with_bind(self, addr: SocketAddr) -> Self

Set bind address for the socket.

Source

pub fn with_ttl(self, ttl: u32) -> Self

Set the time-to-live for IPv4 packets.

Source

pub fn with_hoplimit(self, hops: u32) -> Self

Set the hop limit for IPv6 packets.

Source

pub fn with_read_timeout(self, timeout: Duration) -> Self

Set the read timeout for the socket.

Source

pub fn with_write_timeout(self, timeout: Duration) -> Self

Set the write timeout for the socket.

Source

pub fn with_interface(self, iface: impl Into<String>) -> Self

Set the network interface to use for the socket.

Source

pub fn with_sock_type(self, ty: IcmpSocketType) -> Self

Set the socket type hint. (DGRAM or RAW)

Source

pub fn with_fib(self, fib: u32) -> Self

Set the FIB (Forwarding Information Base) for FreeBSD.

Trait Implementations§

Source§

impl Clone for IcmpConfig

Source§

fn clone(&self) -> IcmpConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IcmpConfig

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.