pub struct Adapter { /* private fields */ }
Expand description
Wrapper around a https://git.zx2c4.com/wintun/about/#wintun_adapter_handle
Implementations§
Source§impl Adapter
impl Adapter
Sourcepub fn get_name(&self) -> Result<String, Error>
pub fn get_name(&self) -> Result<String, Error>
Returns the Friendly Name
of this adapter,
which is the human readable name shown in Windows
Sourcepub fn set_name(&self, name: &str) -> Result<(), Error>
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.
pub fn get_guid(&self) -> u128
Sourcepub fn create(
wintun: &Wintun,
name: &str,
tunnel_type: &str,
guid: Option<u128>,
) -> Result<Arc<Adapter>, Error>
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.
Sourcepub fn open(wintun: &Wintun, name: &str) -> Result<Arc<Adapter>, Error>
pub fn open(wintun: &Wintun, name: &str) -> Result<Arc<Adapter>, Error>
Attempts to open an existing wintun interface name name
.
Sourcepub fn start_session(self: &Arc<Self>, capacity: u32) -> Result<Session, Error>
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.
Sourcepub fn get_luid(&self) -> NET_LUID_LH
pub fn get_luid(&self) -> NET_LUID_LH
Returns the Win32 LUID for this adapter
Sourcepub fn get_adapter_index(&self) -> Result<u32, Error>
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
Sourcepub fn set_address(&self, address: Ipv4Addr) -> Result<(), Error>
pub fn set_address(&self, address: Ipv4Addr) -> Result<(), Error>
Sets the IP address for this adapter, using command netsh
.
Sourcepub fn set_gateway(&self, gateway: Option<Ipv4Addr>) -> Result<(), Error>
pub fn set_gateway(&self, gateway: Option<Ipv4Addr>) -> Result<(), Error>
Sets the gateway for this adapter, using command netsh
.
Sourcepub fn set_netmask(&self, mask: Ipv4Addr) -> Result<(), Error>
pub fn set_netmask(&self, mask: Ipv4Addr) -> Result<(), Error>
Sets the subnet mask for this adapter, using command netsh
.
Sourcepub fn set_dns_servers(&self, dns_servers: &[IpAddr]) -> Result<(), Error>
pub fn set_dns_servers(&self, dns_servers: &[IpAddr]) -> Result<(), Error>
Sets the DNS servers for this adapter
Sourcepub fn set_network_addresses_tuple(
&self,
address: IpAddr,
mask: IpAddr,
gateway: Option<IpAddr>,
) -> Result<(), Error>
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
Sourcepub fn get_addresses(&self) -> Result<Vec<IpAddr>, Error>
pub fn get_addresses(&self) -> Result<Vec<IpAddr>, Error>
Returns the IP addresses of this adapter, including IPv4 and IPv6 addresses