diff options
| author | David Lönnhager <david.l@mullvad.net> | 2021-02-18 17:22:08 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2021-02-22 11:59:08 +0100 |
| commit | d7f2abebf97a3e01587c9f950b575fc0ec70a998 (patch) | |
| tree | daca7281e02a7f0a6bab59dfa9448b724e3b65d9 /talpid-core/src | |
| parent | 94ead81c7cb560b61e7fe3e92a733efa23e6a2b2 (diff) | |
| download | mullvadvpn-d7f2abebf97a3e01587c9f950b575fc0ec70a998.tar.xz mullvadvpn-d7f2abebf97a3e01587c9f950b575fc0ec70a998.zip | |
Add WintunAdapter::guid() method
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/tunnel/openvpn/windows.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/talpid-core/src/tunnel/openvpn/windows.rs b/talpid-core/src/tunnel/openvpn/windows.rs index f5112816b5..a97b923f92 100644 --- a/talpid-core/src/tunnel/openvpn/windows.rs +++ b/talpid-core/src/tunnel/openvpn/windows.rs @@ -13,6 +13,8 @@ use winapi::{ guiddef::GUID, ifdef::NET_LUID, minwindef::{BOOL, FARPROC, HINSTANCE, HMODULE}, + netioapi::ConvertInterfaceLuidToGuid, + winerror::NO_ERROR, }, um::{ libloaderapi::{ @@ -152,6 +154,15 @@ impl WintunAdapter { pub fn luid(&self) -> NET_LUID { unsafe { self.dll_handle.get_adapter_luid(self.handle) } } + + pub fn guid(&self) -> io::Result<GUID> { + let mut guid = mem::MaybeUninit::zeroed(); + let result = unsafe { ConvertInterfaceLuidToGuid(&self.luid(), guid.as_mut_ptr()) }; + if result != NO_ERROR { + return Err(io::Error::last_os_error()); + } + Ok(unsafe { guid.assume_init() }) + } } impl Drop for WintunAdapter { |
