Struct Adapter

Source
pub struct Adapter { /* private fields */ }
Expand description

Implementations§

Source§

impl Adapter

Source

pub fn get_name(&self) -> Result<String, Error>

Returns the Friendly Name of this adapter, which is the human readable name shown in Windows

Source

pub fn set_name(&self, name: &str) -> Result<(), Error>

Sets the Friendly Name of this adapter, which is the human readable name shown in Windows

Note: This is different from Adapter Name, which is a GUID.

Source

pub fn get_guid(&self) -> u128

Source

pub fn create( wintun: &Wintun, name: &str, tunnel_type: &str, guid: Option<u128>, ) -> Result<Arc<Adapter>, Error>

Creates a new wintun adapter inside the name name with tunnel type tunnel_type

Optionally a GUID can be specified that will become the GUID of this adapter once created.

Source

pub fn open(wintun: &Wintun, name: &str) -> Result<Arc<Adapter>, Error>

Attempts to open an existing wintun interface name name.

Source

pub fn delete(self) -> Result<(), Error>

Delete an adapter, consuming it in the process

Source

pub fn start_session(self: &Arc<Self>, capacity: u32) -> Result<Session, Error>

Initiates a new wintun session on the given adapter.

Capacity is the size in bytes of the ring buffer used internally by the driver. Must be a power of two between crate::MIN_RING_CAPACITY and crate::MAX_RING_CAPACITY inclusive.

Source

pub fn get_luid(&self) -> NET_LUID_LH

Returns the Win32 LUID for this adapter

Source

pub fn set_mtu(&self, mtu: usize) -> Result<(), Error>

Set MTU of this adapter

Source

pub fn get_mtu(&self) -> Result<usize, Error>

Returns MTU of this adapter

Source

pub fn get_adapter_index(&self) -> Result<u32, Error>

Returns the Win32 interface index of this adapter. Useful for specifying the interface when executing netsh interface ip commands

Source

pub fn set_address(&self, address: Ipv4Addr) -> Result<(), Error>

Sets the IP address for this adapter, using command netsh.

Source

pub fn set_gateway(&self, gateway: Option<Ipv4Addr>) -> Result<(), Error>

Sets the gateway for this adapter, using command netsh.

Source

pub fn set_netmask(&self, mask: Ipv4Addr) -> Result<(), Error>

Sets the subnet mask for this adapter, using command netsh.

Source

pub fn set_dns_servers(&self, dns_servers: &[IpAddr]) -> Result<(), Error>

Sets the DNS servers for this adapter

Source

pub fn set_network_addresses_tuple( &self, address: IpAddr, mask: IpAddr, gateway: Option<IpAddr>, ) -> Result<(), Error>

Sets the network addresses of this adapter, including network address, subnet mask, and gateway

Source

pub fn get_addresses(&self) -> Result<Vec<IpAddr>, Error>

Returns the IP addresses of this adapter, including IPv4 and IPv6 addresses

Source

pub fn get_gateways(&self) -> Result<Vec<IpAddr>, Error>

Returns the gateway addresses of this adapter, including IPv4 and IPv6 addresses

Source

pub fn get_netmask_of_address( &self, target_address: &IpAddr, ) -> Result<IpAddr, Error>

Returns the subnet mask of the given address

Trait Implementations§

Source§

impl Drop for Adapter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.