From f4292c298f6aa7aad6a00f88f6016e4bc78f53f7 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 12 Mar 2021 00:02:06 +0100 Subject: WIP: add dhcp functions --- .../src/main/java/com/wireguard/android/backend/GoBackend.java | 2 ++ tunnel/tools/libwg-go/api-android.go | 10 +++++++++- tunnel/tools/libwg-go/jni.c | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java index c7381487..4ac270ef 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -68,6 +68,8 @@ public final class GoBackend implements Backend { alwaysOnCallback = cb; } + private static native void wgDHCP(int handle); + private static native String wgGetConfig(int handle); private static native int wgGetSocketV4(int handle); diff --git a/tunnel/tools/libwg-go/api-android.go b/tunnel/tools/libwg-go/api-android.go index 2a4e68b3..abbdf61a 100644 --- a/tunnel/tools/libwg-go/api-android.go +++ b/tunnel/tools/libwg-go/api-android.go @@ -178,11 +178,19 @@ func wgTurnOn(interfaceName string, tunFd int32, settings string) int32 { handle.uapi = uapi tunnelHandles[i] = handle - go handle.startDHCPv6() +// go handle.startDHCPv6() return i } +func wgDHCP(tunnelHandles int32) { + handle, ok := tunnelHandles[tunnelHandle] + if !ok { + return + } + handle.startDHCPv6() +} + //export wgTurnOff func wgTurnOff(tunnelHandle int32) { handle, ok := tunnelHandles[tunnelHandle] diff --git a/tunnel/tools/libwg-go/jni.c b/tunnel/tools/libwg-go/jni.c index 3f877d47..0f56210f 100644 --- a/tunnel/tools/libwg-go/jni.c +++ b/tunnel/tools/libwg-go/jni.c @@ -33,6 +33,11 @@ JNIEXPORT jint JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOn(JNI return ret; } +JNIEXPORT void JNICALL Java_com_wireguard_android_backend_GoBackend_wgDHCP(JNIEnv *env, jclass c, jint handle) +{ + wgDHCP(handle); +} + JNIEXPORT void JNICALL Java_com_wireguard_android_backend_GoBackend_wgTurnOff(JNIEnv *env, jclass c, jint handle) { wgTurnOff(handle); -- cgit v1.2.3