summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-05-29 17:18:18 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-06-10 21:42:33 +0000
commit421dc7ee3eed206c7dce8f7e9dc93bb8d4e19c04 (patch)
treec6d228e5e96a1813b03727bd79800adc9ef4c83a
parent68a39f07dd266a9a9e56a9215e65ae95995a12dc (diff)
downloadmullvadvpn-421dc7ee3eed206c7dce8f7e9dc93bb8d4e19c04.tar.xz
mullvadvpn-421dc7ee3eed206c7dce8f7e9dc93bb8d4e19c04.zip
Interface with Android's `libwg` library
-rw-r--r--talpid-core/src/tunnel/wireguard/wireguard_go.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/talpid-core/src/tunnel/wireguard/wireguard_go.rs b/talpid-core/src/tunnel/wireguard/wireguard_go.rs
index 322c10a05e..0f918b4e9b 100644
--- a/talpid-core/src/tunnel/wireguard/wireguard_go.rs
+++ b/talpid-core/src/tunnel/wireguard/wireguard_go.rs
@@ -108,7 +108,8 @@ type WgLogLevel = i32;
// wireguard-go supports log levels 0 through 3 with 3 being the most verbose
const WG_GO_LOG_DEBUG: WgLogLevel = 3;
-#[link(name = "wg", kind = "static")]
+#[cfg_attr(target_os = "android", link(name = "wg", kind = "dylib"))]
+#[cfg_attr(not(target_os = "android"), link(name = "wg", kind = "static"))]
extern "C" {
// Creates a new wireguard tunnel, uses the specific interface name, MTU and file descriptors
// for the tunnel device and logging.
@@ -123,6 +124,15 @@ extern "C" {
log_fd: Fd,
logLevel: WgLogLevel,
) -> i32;
+
// Pass a handle that was created by wgTurnOnWithFd to stop a wireguard tunnel.
fn wgTurnOff(handle: i32) -> i32;
+
+ // Returns the file descriptor of the tunnel IPv4 socket.
+ #[cfg(target_os = "android")]
+ fn wgGetSocketV4(handle: i32) -> Fd;
+
+ // Returns the file descriptor of the tunnel IPv6 socket.
+ #[cfg(target_os = "android")]
+ fn wgGetSocketV6(handle: i32) -> Fd;
}