diff --git a/java/jni/ZT_jnicache.cpp b/java/jni/ZT_jnicache.cpp index 68cacbd78..c721a9ee1 100644 --- a/java/jni/ZT_jnicache.cpp +++ b/java/jni/ZT_jnicache.cpp @@ -176,15 +176,7 @@ void setupJNICache(JavaVM *vm) { EXCEPTIONANDNULLCHECK(Peer_ctor = env->GetMethodID(Peer_class, "", "(JIIIILcom/zerotier/sdk/PeerRole;[Lcom/zerotier/sdk/PeerPhysicalPath;)V")); EXCEPTIONANDNULLCHECK(Version_ctor = env->GetMethodID(Version_class, "", "(III)V")); EXCEPTIONANDNULLCHECK(VirtualNetworkConfigListener_onNetworkConfigurationUpdated_method = env->GetMethodID(VirtualNetworkConfigListener_class, "onNetworkConfigurationUpdated", "(JLcom/zerotier/sdk/VirtualNetworkConfigOperation;Lcom/zerotier/sdk/VirtualNetworkConfig;)I")); - - - // - // ANDROID-56: temporarily remove parameters to prevent crashing - // -// EXCEPTIONANDNULLCHECK(VirtualNetworkConfig_ctor = env->GetMethodID(VirtualNetworkConfig_class, "", "(JJLjava/lang/String;Lcom/zerotier/sdk/VirtualNetworkStatus;Lcom/zerotier/sdk/VirtualNetworkType;IZZZIJ[Ljava/net/InetSocketAddress;[Lcom/zerotier/sdk/VirtualNetworkRoute;Lcom/zerotier/sdk/VirtualNetworkDNS;)V")); - EXCEPTIONANDNULLCHECK(VirtualNetworkConfig_ctor = env->GetMethodID(VirtualNetworkConfig_class, "", "(JJLjava/lang/String;Lcom/zerotier/sdk/VirtualNetworkStatus;Lcom/zerotier/sdk/VirtualNetworkType;IZZZ[Ljava/net/InetSocketAddress;[Lcom/zerotier/sdk/VirtualNetworkRoute;Lcom/zerotier/sdk/VirtualNetworkDNS;)V")); - - + EXCEPTIONANDNULLCHECK(VirtualNetworkConfig_ctor = env->GetMethodID(VirtualNetworkConfig_class, "", "(JJLjava/lang/String;Lcom/zerotier/sdk/VirtualNetworkStatus;Lcom/zerotier/sdk/VirtualNetworkType;IZZZIJ[Ljava/net/InetSocketAddress;[Lcom/zerotier/sdk/VirtualNetworkRoute;Lcom/zerotier/sdk/VirtualNetworkDNS;)V")); EXCEPTIONANDNULLCHECK(VirtualNetworkDNS_ctor = env->GetMethodID(VirtualNetworkDNS_class, "", "(Ljava/lang/String;Ljava/util/ArrayList;)V")); EXCEPTIONANDNULLCHECK(VirtualNetworkFrameListener_onVirtualNetworkFrame_method = env->GetMethodID(VirtualNetworkFrameListener_class, "onVirtualNetworkFrame", "(JJJJJ[B)V")); EXCEPTIONANDNULLCHECK(VirtualNetworkRoute_ctor = env->GetMethodID(VirtualNetworkRoute_class, "", "(Ljava/net/InetSocketAddress;Ljava/net/InetSocketAddress;II)V")); diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 17e6a9b3e..053c5adb0 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -307,11 +307,8 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig) vnetConfig.dhcp, vnetConfig.bridge, vnetConfig.broadcastEnabled, - // - // ANDROID-56: temporarily remove parameters to prevent crashing - // -// vnetConfig.portError, -// vnetConfig.netconfRevision, + vnetConfig.portError, + vnetConfig.netconfRevision, assignedAddrArrayObj, routesArrayObj, dnsObj); diff --git a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java index fea354d07..bcf64854a 100644 --- a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java +++ b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java @@ -66,12 +66,9 @@ public class VirtualNetworkConfig implements Comparable { private final boolean broadcastEnabled; - // - // ANDROID-56: temporarily remove parameters to prevent crashing - // -// private final int portError; -// -// private final long netconfRevision; + private final int portError; + + private final long netconfRevision; private final InetSocketAddress[] assignedAddresses; @@ -79,7 +76,7 @@ public class VirtualNetworkConfig implements Comparable { private final VirtualNetworkDNS dns; - public VirtualNetworkConfig(long nwid, long mac, String name, VirtualNetworkStatus status, VirtualNetworkType type, int mtu, boolean dhcp, boolean bridge, boolean broadcastEnabled, InetSocketAddress[] assignedAddresses, VirtualNetworkRoute[] routes, VirtualNetworkDNS dns) { + public VirtualNetworkConfig(long nwid, long mac, String name, VirtualNetworkStatus status, VirtualNetworkType type, int mtu, boolean dhcp, boolean bridge, boolean broadcastEnabled, int portError, long netconfRevision, InetSocketAddress[] assignedAddresses, VirtualNetworkRoute[] routes, VirtualNetworkDNS dns) { this.nwid = nwid; this.mac = mac; this.name = name; @@ -92,11 +89,11 @@ public class VirtualNetworkConfig implements Comparable { this.dhcp = dhcp; this.bridge = bridge; this.broadcastEnabled = broadcastEnabled; -// this.portError = portError; -// if (netconfRevision < 0) { -// throw new RuntimeException("netconfRevision < 0: " + netconfRevision); -// } -// this.netconfRevision = netconfRevision; + this.portError = portError; + if (netconfRevision < 0) { + throw new RuntimeException("netconfRevision < 0: " + netconfRevision); + } + this.netconfRevision = netconfRevision; this.assignedAddresses = assignedAddresses; this.routes = routes; this.dns = dns; @@ -104,7 +101,7 @@ public class VirtualNetworkConfig implements Comparable { @Override public String toString() { - return "VirtualNetworkConfig(" + StringUtils.networkIdToString(nwid) + ", " + StringUtils.macAddressToString(mac) + ", " + name + ", " + status + ", " + type + ", " + mtu + ", " + dhcp + ", " + bridge + ", " + broadcastEnabled + ", " + Arrays.toString(assignedAddresses) + ", " + Arrays.toString(routes) + ", " + dns + ")"; + return "VirtualNetworkConfig(" + StringUtils.networkIdToString(nwid) + ", " + StringUtils.macAddressToString(mac) + ", " + name + ", " + status + ", " + type + ", " + mtu + ", " + dhcp + ", " + bridge + ", " + broadcastEnabled + ", " + portError + ", " + netconfRevision + ", " + Arrays.toString(assignedAddresses) + ", " + Arrays.toString(routes) + ", " + dns + ")"; } @Override @@ -171,17 +168,17 @@ public class VirtualNetworkConfig implements Comparable { return false; } -// if (this.portError != cfg.portError) { -// Log.i(TAG, "Port Error Changed. Old: " + this.portError + ", New: " + cfg.portError); -// -// return false; -// } -// -// if (this.netconfRevision != cfg.netconfRevision) { -// Log.i(TAG, "NetConfRevision Changed. Old: " + this.netconfRevision + ", New: " + cfg.netconfRevision); -// -// return false; -// } + if (this.portError != cfg.portError) { + Log.i(TAG, "Port Error Changed. Old: " + this.portError + ", New: " + cfg.portError); + + return false; + } + + if (this.netconfRevision != cfg.netconfRevision) { + Log.i(TAG, "NetConfRevision Changed. Old: " + this.netconfRevision + ", New: " + cfg.netconfRevision); + + return false; + } if (!Arrays.equals(assignedAddresses, cfg.assignedAddresses)) { @@ -280,8 +277,8 @@ public class VirtualNetworkConfig implements Comparable { result = 37 * result + (dhcp ? 1 : 0); result = 37 * result + (bridge ? 1 : 0); result = 37 * result + (broadcastEnabled ? 1 : 0); -// result = 37 * result + portError; -// result = 37 * result + (int) (netconfRevision ^ (netconfRevision >>> 32)); + result = 37 * result + portError; + result = 37 * result + (int) (netconfRevision ^ (netconfRevision >>> 32)); result = 37 * result + Arrays.hashCode(assignedAddresses); result = 37 * result + Arrays.hashCode(routes); result = 37 * result + (dns == null ? 0 : dns.hashCode()); @@ -362,18 +359,18 @@ public class VirtualNetworkConfig implements Comparable { /** * If the network is in PORT_ERROR state, this is the error most recently returned by the port config callback */ -// public int getPortError() { -// return portError; -// } + public int getPortError() { + return portError; + } /** * Network config revision as reported by netconf master * *

If this is zero, it means we're still waiting for our netconf.

*/ -// public long getNetconfRevision() { -// return netconfRevision; -// } + public long getNetconfRevision() { + return netconfRevision; + } /** * ZeroTier-assigned addresses (in {@link InetSocketAddress} objects)