blob: b6e459429f9d5526db12b8101cb51f40b250b046 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
mod icmp;
pub use icmp::Error;
/// Trait for sending ICMP requests to get some traffic from a remote server
#[async_trait::async_trait]
pub trait Pinger: Send {
/// Sends an ICMP packet
async fn send_icmp(&mut self) -> Result<(), Error>;
/// Clears all resources used by the pinger.
async fn reset(&mut self) {}
}
/// Create a new pinger
pub fn new_pinger(
addr: std::net::Ipv4Addr,
#[cfg(any(target_os = "linux", target_os = "macos"))] interface_name: String,
) -> Result<Box<dyn Pinger>, Error> {
Ok(Box::new(icmp::Pinger::new(
addr,
#[cfg(any(target_os = "linux", target_os = "macos"))]
interface_name,
)?))
}
|