diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-08-10 15:20:16 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-09-11 12:52:20 -0300 |
| commit | a48db3716139de1dea6baaf4db9d47936760ed8e (patch) | |
| tree | 534da20d163aac05dff47fdaa060f1c4ca95c181 | |
| parent | c9c216c74b0cb7fbff5d5cd943359b11b93e0b38 (diff) | |
| download | mullvadvpn-a48db3716139de1dea6baaf4db9d47936760ed8e.tar.xz mullvadvpn-a48db3716139de1dea6baaf4db9d47936760ed8e.zip | |
Bridge `GetTapInterfaceIpv6Status` to Rust
| -rw-r--r-- | talpid-core/src/winnet.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/talpid-core/src/winnet.rs b/talpid-core/src/winnet.rs index 4ce9f06f46..ef3930649c 100644 --- a/talpid-core/src/winnet.rs +++ b/talpid-core/src/winnet.rs @@ -12,6 +12,9 @@ error_chain!{ InvalidInterfaceAlias{ description("Supplied interface alias is invalid") } + GetIpv6Status { + description("Failed to read IPv6 status on the TAP network interface") + } } } @@ -62,3 +65,28 @@ extern "system" { sink_context: *mut c_void, ) -> u32; } + + +/// Checks if IPv6 is enabled for the TAP interface +pub fn get_tap_interface_ipv6_status() -> Result<bool> { + let tap_ipv6_status = unsafe { GetTapInterfaceIpv6Status(Some(error_sink), ptr::null_mut()) }; + + match tap_ipv6_status { + // Enabled + 0 => Ok(true), + // Disabled + 1 => Ok(false), + // Failure + 2 => Err(Error::from(ErrorKind::GetIpv6Status)), + // Unexpected value + _ => { + error!("Unexpected return code from GetTapInterfaceIpv6Status"); + Err(Error::from(ErrorKind::GetIpv6Status)) + } + } +} + +extern "system" { + #[link_name(GetTapInterfaceIpv6Status)] + fn GetTapInterfaceIpv6Status(sink: Option<ErrorSink>, sink_context: *mut c_void) -> u32; +} |
