pub struct VCLTun { /* private fields */ }Expand description
A TUN virtual network interface for capturing and injecting IP packets.
Requires root or CAP_NET_ADMIN on Linux, administrator privileges on Windows.
Implementations§
Source§impl VCLTun
impl VCLTun
Sourcepub fn create(config: TunConfig) -> Result<Self, VCLError>
pub fn create(config: TunConfig) -> Result<Self, VCLError>
Create and configure a new TUN interface.
§Errors
Returns VCLError::IoError if:
- Not running as root / missing
CAP_NET_ADMIN(Linux) - Not running as administrator (Windows)
- Interface name is invalid or already in use
- TUN/Wintun driver not available
Sourcepub async fn read_packet(&mut self) -> Result<Vec<u8>, VCLError>
pub async fn read_packet(&mut self) -> Result<Vec<u8>, VCLError>
Read the next IP packet from the TUN interface.
Sourcepub async fn write_packet(&mut self, packet: &[u8]) -> Result<(), VCLError>
pub async fn write_packet(&mut self, packet: &[u8]) -> Result<(), VCLError>
Write (inject) a raw IP packet into the TUN interface.
Sourcepub fn destination(&self) -> Ipv4Addr
pub fn destination(&self) -> Ipv4Addr
Returns the remote destination IP of the TUN interface.
Auto Trait Implementations§
impl Freeze for VCLTun
impl !RefUnwindSafe for VCLTun
impl Send for VCLTun
impl Sync for VCLTun
impl Unpin for VCLTun
impl UnsafeUnpin for VCLTun
impl !UnwindSafe for VCLTun
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more