pub struct Tap { /* private fields */ }
Expand description
A cross-platform TAP interface, suitable for tunnelling link-layer packets.
Implementations§
Source§impl Tap
impl Tap
Sourcepub fn new_named(if_name: Interface) -> Result<Self>
pub fn new_named(if_name: Interface) -> Result<Self>
Opens or creates a TUN device of the given name.
Sourcepub fn set_state(&mut self, state: DeviceState) -> Result<()>
pub fn set_state(&mut self, state: DeviceState) -> Result<()>
Sets the adapter state of the TAP device (e.g. “up” or “down”).
Sourcepub fn mtu(&self) -> Result<usize>
pub fn mtu(&self) -> Result<usize>
Retrieves the Maximum Transmission Unit (MTU) of the TAP device.
Sourcepub fn set_nonblocking(&mut self, nonblocking: bool) -> Result<()>
pub fn set_nonblocking(&mut self, nonblocking: bool) -> Result<()>
Sets the blocking mode of the TAP device for reads/writes.
Sourcepub fn nonblocking(&self) -> Result<bool>
pub fn nonblocking(&self) -> Result<bool>
Retrieves the blocking mode of the TAP device.
Sourcepub fn addrs(&self) -> Result<Vec<AddressInfo>>
pub fn addrs(&self) -> Result<Vec<AddressInfo>>
Retrieves the network-layer addresses assigned to the interface.
Most platforms automatically assign a link-local IPv6 address to TAP devices on creation.
Developers should take this into account and avoid the incorrect assumption that addrs()
will return only the addresses they have assigned via add_addr()
.
Sourcepub fn add_addr<A: Into<AddAddress>>(&self, req: A) -> Result<()>
pub fn add_addr<A: Into<AddAddress>>(&self, req: A) -> Result<()>
Assigns a network-layer address to the interface.
Sourcepub fn remove_addr(&self, addr: IpAddr) -> Result<()>
pub fn remove_addr(&self, addr: IpAddr) -> Result<()>
Removes the specified network-layer address from the interface.