diff options
| author | David Lönnhager <david.l@mullvad.net> | 2021-05-04 11:13:33 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2021-05-20 11:01:11 +0200 |
| commit | 1269fc404aed61d3453c8ac2d7da40f68eb4d420 (patch) | |
| tree | eec1d18fdbd47563c64910a4db36a1a5be60788b /talpid-core | |
| parent | 8e9a4e68af1669594b8a9ded67f4307f157bd399 (diff) | |
| download | mullvadvpn-1269fc404aed61d3453c8ac2d7da40f68eb4d420.tar.xz mullvadvpn-1269fc404aed61d3453c8ac2d7da40f68eb4d420.zip | |
Add GetIpInterfaceEntry function
Diffstat (limited to 'talpid-core')
| -rw-r--r-- | talpid-core/src/tunnel/openvpn/windows.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/talpid-core/src/tunnel/openvpn/windows.rs b/talpid-core/src/tunnel/openvpn/windows.rs index c51cb8d805..e29b37cb7e 100644 --- a/talpid-core/src/tunnel/openvpn/windows.rs +++ b/talpid-core/src/tunnel/openvpn/windows.rs @@ -14,8 +14,8 @@ use winapi::{ ifdef::NET_LUID, minwindef::{BOOL, FARPROC, HINSTANCE, HMODULE}, netioapi::{ - CancelMibChangeNotify2, ConvertInterfaceLuidToGuid, NotifyIpInterfaceChange, - MIB_IPINTERFACE_ROW, + CancelMibChangeNotify2, ConvertInterfaceLuidToGuid, GetIpInterfaceEntry, + NotifyIpInterfaceChange, MIB_IPINTERFACE_ROW, }, ntdef::FALSE, winerror::NO_ERROR, @@ -491,6 +491,19 @@ pub fn notify_ip_interface_change<'a, T: FnMut(&MIB_IPINTERFACE_ROW, u32) + Send Ok(context) } +pub fn get_ip_interface_entry(family: u16, luid: &NET_LUID) -> io::Result<MIB_IPINTERFACE_ROW> { + let mut row: MIB_IPINTERFACE_ROW = unsafe { mem::zeroed() }; + row.Family = family; + row.InterfaceLuid = *luid; + + let result = unsafe { GetIpInterfaceEntry(&mut row as *mut _) }; + if result != NO_ERROR { + return Err(io::Error::last_os_error()); + } + + Ok(row) +} + #[cfg(test)] mod tests { use super::*; |
