summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--talpid-core/src/winnet.rs28
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;
+}