Skip to main content

L3Device

Trait L3Device 

Source
pub trait L3Device: Send + Sync {
    // Required methods
    fn set_handler(&self, h: L3Handler);
    fn send(&self, packet: &Packet) -> Result<()>;
    fn addr(&self) -> IpPrefix;
    fn set_addr(&self, prefix: IpPrefix) -> Result<()>;
    fn close(&self) -> Result<()>;

    // Provided method
    fn stats(&self) -> Option<&DeviceStats> { ... }
}
Expand description

A Layer 3 (IP) network device.

Addr returns the device’s current IP prefix; set_addr updates it, typically from a DHCP client or other source of dynamic configuration.

Required Methods§

Source

fn set_handler(&self, h: L3Handler)

Source

fn send(&self, packet: &Packet) -> Result<()>

Source

fn addr(&self) -> IpPrefix

Source

fn set_addr(&self, prefix: IpPrefix) -> Result<()>

Source

fn close(&self) -> Result<()>

Provided Methods§

Source

fn stats(&self) -> Option<&DeviceStats>

Traffic counters, if the device keeps any. See L2Device::stats.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: L3Device + ?Sized> L3Device for Arc<T>

Source§

fn set_handler(&self, h: L3Handler)

Source§

fn send(&self, p: &Packet) -> Result<()>

Source§

fn addr(&self) -> IpPrefix

Source§

fn set_addr(&self, p: IpPrefix) -> Result<()>

Source§

fn close(&self) -> Result<()>

Source§

fn stats(&self) -> Option<&DeviceStats>

Implementors§

Source§

impl L3Device for Client

Available on crate feature vclient only.
Source§

impl L3Device for ImpairL3

Available on crate feature impair only.
Source§

impl L3Device for Nat

Available on crate feature nat only.
Source§

impl L3Device for NsSide

Available on crate feature slirp only.
Source§

impl L3Device for PipeL3

Source§

impl L3Device for Stack

Available on crate feature slirp only.
Source§

impl L3Device for TapL3

Available on crate feature pcap only.
Source§

impl L3Device for Tun

Available on crate feature tuntap only.