pub struct TunTapDriver { /* private fields */ }Expand description
A driver for a virtual TUN (IP) or TAP (Ethernet) interface.
Implementations§
Source§impl TunTapDriver
impl TunTapDriver
Sourcepub fn new(name: &str, hardware_addr: HardwareAddress) -> Result<TunTapDriver>
pub fn new(name: &str, hardware_addr: HardwareAddress) -> Result<TunTapDriver>
Attaches to a TUN/TAP interface called name, or creates it if it does not exist.
hardware_addr is the address the interface reports to the stack, and picks the
medium: HardwareAddress::Ip opens a TUN interface, an Ethernet address opens a
TAP one.
If name is a persistent interface configured with UID of the current user,
no special privileges are needed. Otherwise, this requires superuser privileges
or a corresponding capability set on the executable.
Sourcepub fn from_fd(
fd: RawFd,
hardware_addr: HardwareAddress,
mtu: usize,
) -> Result<TunTapDriver>
pub fn from_fd( fd: RawFd, hardware_addr: HardwareAddress, mtu: usize, ) -> Result<TunTapDriver>
Attaches to a TUN/TAP interface specified by file descriptor fd.
On platforms like Android, a file descriptor to a tun interface is exposed. On these platforms, a TunTapDriver cannot be instantiated with a name.
hardware_addr is the address the interface reports to the stack, and picks the
medium, as in new.