pub struct TunnelInterface { /* private fields */ }Expand description
Virtual tunnel network interface
Implementations§
Source§impl TunnelInterface
impl TunnelInterface
Sourcepub fn create(config: TunnelConfig) -> Result<Self, TunnelError>
pub fn create(config: TunnelConfig) -> Result<Self, TunnelError>
Create a new tunnel interface from configuration
Sourcepub fn bring_up(&mut self) -> Result<(), TunnelError>
pub fn bring_up(&mut self) -> Result<(), TunnelError>
Bring the interface up
Sourcepub fn bring_down(&mut self)
pub fn bring_down(&mut self)
Bring the interface down and flush queues
Sourcepub fn send_packet(&mut self, data: &[u8]) -> Result<(), TunnelError>
pub fn send_packet(&mut self, data: &[u8]) -> Result<(), TunnelError>
Enqueue a packet for transmission
Sourcepub fn receive_packet(&mut self) -> Result<Vec<u8>, TunnelError>
pub fn receive_packet(&mut self) -> Result<Vec<u8>, TunnelError>
Dequeue a received packet
Sourcepub fn inject_rx(&mut self, data: Vec<u8>) -> Result<(), TunnelError>
pub fn inject_rx(&mut self, data: Vec<u8>) -> Result<(), TunnelError>
Enqueue a packet into the receive queue (called by the VPN transport layer)
Sourcepub fn drain_tx(&mut self) -> Option<Vec<u8>>
pub fn drain_tx(&mut self) -> Option<Vec<u8>>
Dequeue a packet from the transmit queue (called by the VPN transport layer)
Sourcepub fn set_mtu(&mut self, mtu: u16) -> Result<(), TunnelError>
pub fn set_mtu(&mut self, mtu: u16) -> Result<(), TunnelError>
Set the MTU for this interface
Sourcepub fn get_stats(&self) -> TunnelStats
pub fn get_stats(&self) -> TunnelStats
Get interface statistics
Sourcepub fn tunnel_type(&self) -> TunnelType
pub fn tunnel_type(&self) -> TunnelType
Get the tunnel type
Sourcepub fn state(&self) -> TunnelState
pub fn state(&self) -> TunnelState
Get the current state
Sourcepub fn config(&self) -> &TunnelConfig
pub fn config(&self) -> &TunnelConfig
Get the configuration
Sourcepub fn set_encap(&mut self, encap: EncapsulationHeader)
pub fn set_encap(&mut self, encap: EncapsulationHeader)
Set the encapsulation header
Sourcepub fn encap(&self) -> Option<&EncapsulationHeader>
pub fn encap(&self) -> Option<&EncapsulationHeader>
Get the encapsulation header