From d063f583eecbcd98837cbbb98a79ac604664625b Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 5 Sep 2016 13:52:29 -0700 Subject: Added VirtualNetworkRoute class and added it to VirtualNetworkConfig --- java/jni/ZT_jniutils.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 512bf839..5f54751d 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -609,6 +609,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig) jfieldID portErrorField = NULL; jfieldID netconfRevisionField = NULL; jfieldID assignedAddressesField = NULL; + jfieldID routesField = NULL; vnetConfigClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkConfig"); if(vnetConfigClass == NULL) @@ -716,6 +717,13 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig) return NULL; } + routesField = lookup.findField(vnetConfigClass, "routes", "[Lcom/zerotier/sdk/VirtualNetworkRoute"); + if(env->ExceptionCheck() || routesField == NULL) + { + LOGE("Error getting routes field"); + return NULL; + } + env->SetLongField(vnetConfigObj, nwidField, vnetConfig.nwid); env->SetLongField(vnetConfigObj, macField, vnetConfig.mac); jstring nameStr = env->NewStringUTF(vnetConfig.name); @@ -773,6 +781,34 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig) env->SetObjectField(vnetConfigObj, assignedAddressesField, assignedAddrArrayObj); + jclass virtualNetworkRouteClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkRoute"); + if(env->ExceptionCheck() || virtualNetworkRouteClass == NULL) + { + LOGE("Error finding VirtualNetworkRoute class"); + return NULL; + } + + jobjectArray routesArrayObj = env->NewObjectArray( + vnetConfig.routeCount, virtualNetworkRouteClass, NULL); + if(env->ExceptionCheck() || routesArrayObj == NULL) + { + LOGE("Error creating VirtualNetworkRoute[] array"); + return NULL; + } + + for(unsigned int i = 0; i < vnetConfig.routeCount; ++i) + { + jobject routeObj = newVirtualNetworkRoute(env, vnetConfig.routes[i]); + env->SetObjectArrayElement(routesArrayObj, i, routeObj); + if(env->ExceptionCheck()) + { + LOGE("Error assigning VirtualNetworkRoute to array"); + return NULL; + } + } + + env->SetObjectField(vnetConfigObj, routesField, routesArrayObj); + return vnetConfigObj; } @@ -831,6 +867,72 @@ jobject newVersion(JNIEnv *env, int major, int minor, int rev) return versionObj; } +jobject newVirtualNetworkRoute(JNIEnv *env, const ZT_VirtualNetworkRoute &route) +{ + jclass virtualNetworkRouteClass = NULL; + jmethodID routeConstructor = NULL; + + virtualNetworkRouteClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkRoute"); + if(env->ExceptionCheck() || virtualNetworkRouteClass == NULL) + { + return NULL; + } + + routeConstructor = lookup.findMethod(virtualNetworkRouteClass, "", "()V"); + if(env->ExceptionCheck() || routeConstructor == NULL) + { + return NULL; + } + + jobject routeObj = env->NewObject(virtualNetworkRouteClass, routeConstructor); + if(env->ExceptionCheck() || routeObj == NULL) + { + return NULL; + } + + jfieldID targetField = NULL; + jfieldID viaField = NULL; + jfieldID flagsField = NULL; + jfieldID metricField = NULL; + + targetField = lookup.findField(virtualNetworkRouteClass, "target", + "Ljava/net/InetSocketAddress"); + if(env->ExceptionCheck() || targetField == NULL) + { + return NULL; + } + + viaField = lookup.findField(virtualNetworkRouteClass, "via", + "Ljava/net/InetSocketAddress"); + if(env->ExceptionCheck() || targetField == NULL) + { + return NULL; + } + + flagsField = lookup.findField(virtualNetworkRouteClass, "flags", "I"); + if(env->ExceptionCheck() || flagsField == NULL) + { + return NULL; + } + + metricField = lookup.findField(virtualNetworkRouteClass, "metric", "I"); + if(env->ExceptionCheck() || metricField == NULL) + { + return NULL; + } + + jobject targetObj = newInetSocketAddress(env, route.target); + jobject viaObj = newInetSocketAddress(env, route.via); + + env->SetObjectField(routeObj, targetField, targetObj); + env->SetObjectField(routeObj, viaField, viaObj); + env->SetIntField(routeObj, flagsField, (jint)route.flags); + env->SetIntField(routeObj, metricField, (jint)route.metric); + + return routeObj; +} + #ifdef __cplusplus } -#endif \ No newline at end of file +#endif + -- cgit v1.2.3 From 43b3ec4b1afa3c3833f1f61ec10c9f22bd5e7359 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 5 Sep 2016 16:19:04 -0700 Subject: forgot a semicolon in a JNI java type specifier. --- java/jni/ZT_jniutils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 5f54751d..d7d205a7 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -710,14 +710,16 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig) return NULL; } - assignedAddressesField = lookup.findField(vnetConfigClass, "assignedAddresses", "[Ljava/net/InetSocketAddress;"); + assignedAddressesField = lookup.findField(vnetConfigClass, "assignedAddresses", + "[Ljava/net/InetSocketAddress;"); if(env->ExceptionCheck() || assignedAddressesField == NULL) { LOGE("Error getting assignedAddresses field"); return NULL; } - routesField = lookup.findField(vnetConfigClass, "routes", "[Lcom/zerotier/sdk/VirtualNetworkRoute"); + routesField = lookup.findField(vnetConfigClass, "routes", + "[Lcom/zerotier/sdk/VirtualNetworkRoute;"); if(env->ExceptionCheck() || routesField == NULL) { LOGE("Error getting routes field"); -- cgit v1.2.3 From 407ad659eab4314764310e2c9d274e73147f6034 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 6 Sep 2016 17:59:01 -0700 Subject: Reflect changes to strut ZT_PeerPhysicalPath --- java/jni/ZT_jniutils.cpp | 9 --------- java/src/com/zerotier/sdk/PeerPhysicalPath.java | 8 -------- 2 files changed, 17 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index d7d205a7..f73c408b 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -371,7 +371,6 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp) jfieldID addressField = NULL; jfieldID lastSendField = NULL; jfieldID lastReceiveField = NULL; - jfieldID activeField = NULL; jfieldID preferredField = NULL; jmethodID ppp_constructor = NULL; @@ -404,13 +403,6 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp) return NULL; } - activeField = lookup.findField(pppClass, "active", "Z"); - if(env->ExceptionCheck() || activeField == NULL) - { - LOGE("Error finding active field"); - return NULL; - } - preferredField = lookup.findField(pppClass, "preferred", "Z"); if(env->ExceptionCheck() || preferredField == NULL) { @@ -441,7 +433,6 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp) env->SetObjectField(pppObject, addressField, addressObject); env->SetLongField(pppObject, lastSendField, ppp.lastSend); env->SetLongField(pppObject, lastReceiveField, ppp.lastReceive); - env->SetBooleanField(pppObject, activeField, ppp.active); env->SetBooleanField(pppObject, preferredField, ppp.preferred); if(env->ExceptionCheck()) { diff --git a/java/src/com/zerotier/sdk/PeerPhysicalPath.java b/java/src/com/zerotier/sdk/PeerPhysicalPath.java index d64ea56b..3f9a8612 100644 --- a/java/src/com/zerotier/sdk/PeerPhysicalPath.java +++ b/java/src/com/zerotier/sdk/PeerPhysicalPath.java @@ -37,7 +37,6 @@ public final class PeerPhysicalPath { private long lastSend; private long lastReceive; private boolean fixed; - private boolean active; private boolean preferred; private PeerPhysicalPath() {} @@ -70,13 +69,6 @@ public final class PeerPhysicalPath { return fixed; } - /** - * Is path active? - */ - public final boolean isActive() { - return active; - } - /** * Is path preferred? */ -- cgit v1.2.3 From dccca7df1a893dacc50a605d707917f579d05db9 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 8 Sep 2016 17:45:40 -0700 Subject: another couple of missing semicolons --- java/jni/ZT_jniutils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index f73c408b..495efa12 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -889,14 +889,14 @@ jobject newVirtualNetworkRoute(JNIEnv *env, const ZT_VirtualNetworkRoute &route) jfieldID metricField = NULL; targetField = lookup.findField(virtualNetworkRouteClass, "target", - "Ljava/net/InetSocketAddress"); + "Ljava/net/InetSocketAddress;"); if(env->ExceptionCheck() || targetField == NULL) { return NULL; } viaField = lookup.findField(virtualNetworkRouteClass, "via", - "Ljava/net/InetSocketAddress"); + "Ljava/net/InetSocketAddress;"); if(env->ExceptionCheck() || targetField == NULL) { return NULL; -- cgit v1.2.3 From 5fadd8bdd25577cf8fd626a2a2decbedf28c0dd6 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 19 Sep 2016 12:54:19 -0700 Subject: ZT_PEER_ROLE_RELAY -> ZT_PEER_ROLE_UPSTREAM in JNI glue --- java/jni/ZT_jniutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 495efa12..411a836a 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -162,7 +162,7 @@ jobject createPeerRole(JNIEnv *env, ZT_PeerRole role) case ZT_PEER_ROLE_LEAF: fieldName = "PEER_ROLE_LEAF"; break; - case ZT_PEER_ROLE_RELAY: + case ZT_PEER_ROLE_UPSTREAM: fieldName = "PEER_ROLE_RELAY"; break; case ZT_PEER_ROLE_ROOT: -- cgit v1.2.3 From d87f0293e3bdbb013ce2b48d5518a22e3ecd8c71 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 19 Sep 2016 13:40:53 -0700 Subject: Don't print a few error messages when they don't matter.
 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- java/jni/ZT_jniutils.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 411a836a..6faa91a4 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -313,11 +313,20 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr) return NULL; } - jobject inetAddressObject = newInetAddress(env, addr); + jobject inetAddressObject = NULL; + + if(addr.ss_family != 0) + { + inetAddressObject = newInetAddress(env, addr); - if(env->ExceptionCheck() || inetAddressObject == NULL) + if(env->ExceptionCheck() || inetAddressObject == NULL) + { + LOGE("Error creating new inet address"); + return NULL; + } + } + else { - LOGE("Error creating new inet address"); return NULL; } @@ -350,10 +359,9 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr) break; default: { - LOGE("ERROR: addr.ss_family is not set or unknown"); break; } - }; + } jobject inetSocketAddressObject = env->NewObject(inetSocketAddressClass, inetSocketAddress_constructor, inetAddressObject, port); -- cgit v1.2.3 From 0564bb3b35117c7367469dd5582a5a4093078586 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 21 Sep 2016 14:09:46 -0700 Subject: added missing copyright/license info from ZT_jniutils --- java/jni/ZT_jniutils.cpp | 18 ++++++++++++++++++ java/jni/ZT_jniutils.h | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 6faa91a4..7ecc7256 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -1,3 +1,21 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "ZT_jniutils.h" #include "ZT_jnilookup.h" #include diff --git a/java/jni/ZT_jniutils.h b/java/jni/ZT_jniutils.h index 4dec7201..e35d4f42 100644 --- a/java/jni/ZT_jniutils.h +++ b/java/jni/ZT_jniutils.h @@ -1,3 +1,21 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef ZT_jniutils_h_ #define ZT_jniutils_h_ #include -- cgit v1.2.3 From 40d3993ceb64f924167572c3add7300abb434562 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 21 Sep 2016 14:12:20 -0700 Subject: java code still needed to reflect PEER_ROLE_RELAY rename to PEER_ROLE_UPSTREAM --- java/jni/ZT_jniutils.cpp | 2 +- java/src/com/zerotier/sdk/PeerRole.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 7ecc7256..27ca7374 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -181,7 +181,7 @@ jobject createPeerRole(JNIEnv *env, ZT_PeerRole role) fieldName = "PEER_ROLE_LEAF"; break; case ZT_PEER_ROLE_UPSTREAM: - fieldName = "PEER_ROLE_RELAY"; + fieldName = "PEER_ROLE_UPSTREAM"; break; case ZT_PEER_ROLE_ROOT: fieldName = "PEER_ROLE_ROOTS"; diff --git a/java/src/com/zerotier/sdk/PeerRole.java b/java/src/com/zerotier/sdk/PeerRole.java index d7d55f05..f281c1b6 100644 --- a/java/src/com/zerotier/sdk/PeerRole.java +++ b/java/src/com/zerotier/sdk/PeerRole.java @@ -34,9 +34,9 @@ public enum PeerRole { PEER_ROLE_LEAF, /** - * relay node + * upstream node */ - PEER_ROLE_RELAY, + PEER_ROLE_UPSTREAM, /** * root server -- cgit v1.2.3 From e1c930f1b7a44d2a1c37d4b9b6f348c2ed7260fc Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 9 Nov 2016 16:33:01 -0800 Subject: update JNI wrapper to reflect removal of lastMulticastFrame and lastUnicastFrame from ZT_Peer struct --- java/jni/ZT_jniutils.cpp | 18 ------------------ java/src/com/zerotier/sdk/Peer.java | 16 ---------------- 2 files changed, 34 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 27ca7374..6b882c6d 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -475,8 +475,6 @@ jobject newPeer(JNIEnv *env, const ZT_Peer &peer) jclass peerClass = NULL; jfieldID addressField = NULL; - jfieldID lastUnicastFrameField = NULL; - jfieldID lastMulticastFrameField = NULL; jfieldID versionMajorField = NULL; jfieldID versionMinorField = NULL; jfieldID versionRevField = NULL; @@ -500,20 +498,6 @@ jobject newPeer(JNIEnv *env, const ZT_Peer &peer) return NULL; } - lastUnicastFrameField = lookup.findField(peerClass, "lastUnicastFrame", "J"); - if(env->ExceptionCheck() || lastUnicastFrameField == NULL) - { - LOGE("Error finding lastUnicastFrame field of Peer object"); - return NULL; - } - - lastMulticastFrameField = lookup.findField(peerClass, "lastMulticastFrame", "J"); - if(env->ExceptionCheck() || lastMulticastFrameField == NULL) - { - LOGE("Error finding lastMulticastFrame field of Peer object"); - return NULL; - } - versionMajorField = lookup.findField(peerClass, "versionMajor", "I"); if(env->ExceptionCheck() || versionMajorField == NULL) { @@ -571,8 +555,6 @@ jobject newPeer(JNIEnv *env, const ZT_Peer &peer) } env->SetLongField(peerObject, addressField, (jlong)peer.address); - env->SetLongField(peerObject, lastUnicastFrameField, (jlong)peer.lastUnicastFrame); - env->SetLongField(peerObject, lastMulticastFrameField, (jlong)peer.lastMulticastFrame); env->SetIntField(peerObject, versionMajorField, peer.versionMajor); env->SetIntField(peerObject, versionMinorField, peer.versionMinor); env->SetIntField(peerObject, versionRevField, peer.versionRev); diff --git a/java/src/com/zerotier/sdk/Peer.java b/java/src/com/zerotier/sdk/Peer.java index fb2d1065..eb3d7130 100644 --- a/java/src/com/zerotier/sdk/Peer.java +++ b/java/src/com/zerotier/sdk/Peer.java @@ -34,8 +34,6 @@ import java.util.ArrayList; */ public final class Peer { private long address; - private long lastUnicastFrame; - private long lastMulticastFrame; private int versionMajor; private int versionMinor; private int versionRev; @@ -52,20 +50,6 @@ public final class Peer { return address; } - /** - * Time we last received a unicast frame from this peer - */ - public final long lastUnicastFrame() { - return lastUnicastFrame; - } - - /** - * Time we last received a multicast rame from this peer - */ - public final long lastMulticastFrame() { - return lastMulticastFrame; - } - /** * Remote major version or -1 if not known */ -- cgit v1.2.3 From f149dd9401b1cd3f9b32a59bcdd8abe65af3bc77 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Fri, 13 Jan 2017 11:36:48 -0800 Subject: fix Android NDK build --- java/jni/Android.mk | 6 ++-- java/jni/ZT_jniutils.cpp | 20 ++++++------ java/jni/com_zerotierone_sdk_Node.cpp | 58 ++++++++++++++++++----------------- 3 files changed, 44 insertions(+), 40 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/Android.mk b/java/jni/Android.mk index 73eb2c46..e5d501f8 100644 --- a/java/jni/Android.mk +++ b/java/jni/Android.mk @@ -35,9 +35,9 @@ LOCAL_SRC_FILES := \ $(ZT1)/node/Switch.cpp \ $(ZT1)/node/Tag.cpp \ $(ZT1)/node/Topology.cpp \ - $(ZT1)/node/Utils.cpp \ - $(ZT1)/osdep/Http.cpp \ - $(ZT1)/osdep/OSUtils.cpp + $(ZT1)/node/Utils.cpp +# $(ZT1)/osdep/Http.cpp \ +# $(ZT1)/osdep/OSUtils.cpp # JNI Files LOCAL_SRC_FILES += \ diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 6b882c6d..e355271c 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #include "ZT_jniutils.h" #include "ZT_jnilookup.h" #include @@ -30,7 +30,7 @@ extern "C" { jobject createResultObject(JNIEnv *env, ZT_ResultCode code) { jclass resultClass = NULL; - + jobject resultObject = NULL; resultClass = lookup.findClass("com/zerotier/sdk/ResultCode"); @@ -67,14 +67,14 @@ jobject createResultObject(JNIEnv *env, ZT_ResultCode code) } jfieldID enumField = lookup.findStaticField(resultClass, fieldName.c_str(), "Lcom/zerotier/sdk/ResultCode;"); - if(env->ExceptionCheck() || enumField == NULL) + if(env->ExceptionCheck() || enumField == NULL) { LOGE("Error on FindStaticField"); return NULL; } resultObject = env->GetStaticObjectField(resultClass, enumField); - if(env->ExceptionCheck() || resultObject == NULL) + if(env->ExceptionCheck() || resultObject == NULL) { LOGE("Error on GetStaticObjectField"); } @@ -154,6 +154,8 @@ jobject createEvent(JNIEnv *env, ZT_Event event) case ZT_EVENT_TRACE: fieldName = "EVENT_TRACE"; break; + case ZT_EVENT_USER_MESSAGE: + break; } jfieldID enumField = lookup.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotier/sdk/Event;"); @@ -332,7 +334,7 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr) } jobject inetAddressObject = NULL; - + if(addr.ss_family != 0) { inetAddressObject = newInetAddress(env, addr); @@ -468,7 +470,7 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp) return pppObject; } -jobject newPeer(JNIEnv *env, const ZT_Peer &peer) +jobject newPeer(JNIEnv *env, const ZT_Peer &peer) { LOGV("newPeer called"); @@ -570,7 +572,7 @@ jobject newPeer(JNIEnv *env, const ZT_Peer &peer) jobjectArray arrayObject = env->NewObjectArray( peer.pathCount, peerPhysicalPathClass, NULL); - if(env->ExceptionCheck() || arrayObject == NULL) + if(env->ExceptionCheck() || arrayObject == NULL) { LOGE("Error creating PeerPhysicalPath[] array"); return NULL; @@ -709,7 +711,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig) return NULL; } - assignedAddressesField = lookup.findField(vnetConfigClass, "assignedAddresses", + assignedAddressesField = lookup.findField(vnetConfigClass, "assignedAddresses", "[Ljava/net/InetSocketAddress;"); if(env->ExceptionCheck() || assignedAddressesField == NULL) { @@ -717,7 +719,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig) return NULL; } - routesField = lookup.findField(vnetConfigClass, "routes", + routesField = lookup.findField(vnetConfigClass, "routes", "[Lcom/zerotier/sdk/VirtualNetworkRoute;"); if(env->ExceptionCheck() || routesField == NULL) { diff --git a/java/jni/com_zerotierone_sdk_Node.cpp b/java/jni/com_zerotierone_sdk_Node.cpp index d0228d13..eb62d985 100644 --- a/java/jni/com_zerotierone_sdk_Node.cpp +++ b/java/jni/com_zerotierone_sdk_Node.cpp @@ -139,8 +139,8 @@ namespace { } return env->CallIntMethod( - ref->configListener, - configListenerCallbackMethod, + ref->configListener, + configListenerCallbackMethod, (jlong)nwid, operationObject, networkConfigObject); } @@ -203,7 +203,7 @@ namespace { void EventCallback(ZT_Node *node, void *userData, - enum ZT_Event event, + enum ZT_Event event, const void *data) { LOGV("EventCallback"); @@ -291,6 +291,8 @@ namespace { } } break; + case ZT_EVENT_USER_MESSAGE: + break; } } @@ -348,7 +350,7 @@ namespace { objectName, buffer, bufferIndex, objectSizeObj); long retval = (long)env->CallLongMethod( - ref->dataStoreGetListener, dataStoreGetCallbackMethod, + ref->dataStoreGetListener, dataStoreGetCallbackMethod, nameStr, bufferObj, (jlong)bufferIndex, objectSizeObj); if(retval > 0) @@ -463,7 +465,7 @@ namespace { LOGE("Couldn't find onSendPacketRequested method"); return -2; } - + jobject localAddressObj = NULL; if(memcmp(localAddress, &ZT_SOCKADDR_NULL, sizeof(sockaddr_storage)) != 0) { @@ -496,7 +498,7 @@ namespace { } } -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { lookup.setJavaVM(vm); return JNI_VERSION_1_6; @@ -641,7 +643,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init( ZeroTier::Mutex::Lock lock(nodeMapMutex); ref->node = node; nodeMap.insert(std::make_pair(ref->id, ref)); - + return resultObject; } @@ -659,7 +661,7 @@ JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete( NodeMap::iterator found; { - ZeroTier::Mutex::Lock lock(nodeMapMutex); + ZeroTier::Mutex::Lock lock(nodeMapMutex); found = nodeMap.find(nodeId); } @@ -685,9 +687,9 @@ JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete( * Signature: (JJJJJII[B[J)Lcom/zerotier/sdk/ResultCode; */ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame( - JNIEnv *env, jobject obj, - jlong id, - jlong in_now, + JNIEnv *env, jobject obj, + jlong id, + jlong in_now, jlong in_nwid, jlong in_sourceMac, jlong in_destMac, @@ -697,7 +699,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame( jlongArray out_nextBackgroundTaskDeadline) { uint64_t nodeId = (uint64_t) id; - + ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -752,9 +754,9 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame( * Signature: (JJLjava/net/InetSocketAddress;I[B[J)Lcom/zerotier/sdk/ResultCode; */ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( - JNIEnv *env, jobject obj, + JNIEnv *env, jobject obj, jlong id, - jlong in_now, + jlong in_now, jobject in_localAddress, jobject in_remoteAddress, jbyteArray in_packetData, @@ -820,7 +822,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( jmethodID inetSock_getPort = lookup.findMethod( InetSocketAddressClass, "getPort", "()I"); - if(env->ExceptionCheck() || inetSock_getPort == NULL) + if(env->ExceptionCheck() || inetSock_getPort == NULL) { LOGE("Couldn't find getPort method on InetSocketAddress"); return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL); @@ -844,10 +846,10 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( } unsigned int addrSize = env->GetArrayLength(remoteAddressArray); - + sockaddr_storage localAddress = {}; - + if(localAddrObj == NULL) { localAddress = ZT_SOCKADDR_NULL; @@ -939,7 +941,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( localData, packetLength, &nextBackgroundTaskDeadline); - if(rc != ZT_RESULT_OK) + if(rc != ZT_RESULT_OK) { LOGE("ZT_Node_processWirePacket returned: %d", rc); } @@ -959,7 +961,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( * Signature: (JJ[J)Lcom/zerotier/sdk/ResultCode; */ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks( - JNIEnv *env, jobject obj, + JNIEnv *env, jobject obj, jlong id, jlong in_now, jlongArray out_nextBackgroundTaskDeadline) @@ -1032,7 +1034,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave( uint64_t nwid = (uint64_t)in_nwid; ZT_ResultCode rc = ZT_Node_leave(node, nwid, NULL); - + return createResultObject(env, rc); } @@ -1042,8 +1044,8 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave( * Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode; */ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe( - JNIEnv *env, jobject obj, - jlong id, + JNIEnv *env, jobject obj, + jlong id, jlong in_nwid, jlong in_multicastGroup, jlong in_multicastAdi) @@ -1072,8 +1074,8 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe( * Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode; */ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastUnsubscribe( - JNIEnv *env, jobject obj, - jlong id, + JNIEnv *env, jobject obj, + jlong id, jlong in_nwid, jlong in_multicastGroup, jlong in_multicastAdi) @@ -1141,7 +1143,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status { return NULL; } - + nodeStatusConstructor = lookup.findMethod( nodeStatusClass, "", "()V"); if(nodeStatusConstructor == NULL) @@ -1225,7 +1227,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networkConfig( } ZT_VirtualNetworkConfig *vnetConfig = ZT_Node_networkConfig(node, nwid); - + jobject vnetConfigObject = newNetworkConfig(env, *vnetConfig); ZT_Node_freeQueryResult(node, vnetConfig); @@ -1267,7 +1269,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers( } ZT_PeerList *peerList = ZT_Node_peers(node); - + if(peerList == NULL) { LOGE("ZT_Node_peers returned NULL"); @@ -1306,7 +1308,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers( { jobject peerObj = newPeer(env, peerList->peers[i]); env->SetObjectArrayElement(peerArrayObj, i, peerObj); - if(env->ExceptionCheck()) + if(env->ExceptionCheck()) { LOGE("Error assigning Peer object to array"); break; -- cgit v1.2.3 From 9ae49b5b85092ad3d6d9128a084c93f2a70661f9 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 13 Feb 2017 10:51:36 -0800 Subject: Update JNI with new root terminology --- java/jni/ZT_jniutils.cpp | 8 ++++---- java/src/com/zerotier/sdk/PeerRole.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index e355271c..7bdc7611 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -182,11 +182,11 @@ jobject createPeerRole(JNIEnv *env, ZT_PeerRole role) case ZT_PEER_ROLE_LEAF: fieldName = "PEER_ROLE_LEAF"; break; - case ZT_PEER_ROLE_UPSTREAM: - fieldName = "PEER_ROLE_UPSTREAM"; + case ZT_PEER_ROLE_MOON: + fieldName = "PEER_ROLE_MOON"; break; - case ZT_PEER_ROLE_ROOT: - fieldName = "PEER_ROLE_ROOTS"; + case ZT_PEER_ROLE_PLANET: + fieldName = "PEER_ROLE_PLANET"; break; } diff --git a/java/src/com/zerotier/sdk/PeerRole.java b/java/src/com/zerotier/sdk/PeerRole.java index f281c1b6..fce183d9 100644 --- a/java/src/com/zerotier/sdk/PeerRole.java +++ b/java/src/com/zerotier/sdk/PeerRole.java @@ -34,12 +34,12 @@ public enum PeerRole { PEER_ROLE_LEAF, /** - * upstream node + * moon root */ - PEER_ROLE_UPSTREAM, + PEER_ROLE_MOON, /** - * root server + * planetary root */ - PEER_ROLE_ROOT + PEER_ROLE_PLANET } \ No newline at end of file -- cgit v1.2.3 From 3d4a1b575e693b5a0b907eb9bc5edf8739af63f8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 3 Oct 2017 11:25:26 -0700 Subject: Update Android NDK with uint64_t -> int64_t changes --- java/jni/ZT_jniutils.cpp | 3 ++ java/jni/com_zerotierone_sdk_Node.cpp | 54 ++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 26 deletions(-) (limited to 'java/jni/ZT_jniutils.cpp') diff --git a/java/jni/ZT_jniutils.cpp b/java/jni/ZT_jniutils.cpp index 7bdc7611..c52a2066 100644 --- a/java/jni/ZT_jniutils.cpp +++ b/java/jni/ZT_jniutils.cpp @@ -156,6 +156,9 @@ jobject createEvent(JNIEnv *env, ZT_Event event) break; case ZT_EVENT_USER_MESSAGE: break; + case ZT_EVENT_REMOTE_TRACE: + default: + break; } jfieldID enumField = lookup.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotier/sdk/Event;"); diff --git a/java/jni/com_zerotierone_sdk_Node.cpp b/java/jni/com_zerotierone_sdk_Node.cpp index 01ca6d7f..02a42837 100644 --- a/java/jni/com_zerotierone_sdk_Node.cpp +++ b/java/jni/com_zerotierone_sdk_Node.cpp @@ -86,7 +86,7 @@ namespace { portMapper = NULL; } - uint64_t id; + int64_t id; JavaVM *jvm; @@ -292,6 +292,8 @@ namespace { } break; case ZT_EVENT_USER_MESSAGE: + case ZT_EVENT_REMOTE_TRACE: + default: break; } } @@ -665,11 +667,11 @@ namespace { return true; } - typedef std::map NodeMap; + typedef std::map NodeMap; static NodeMap nodeMap; ZeroTier::Mutex nodeMapMutex; - ZT_Node* findNode(uint64_t nodeId) + ZT_Node* findNode(int64_t nodeId) { ZeroTier::Mutex::Lock lock(nodeMapMutex); NodeMap::iterator found = nodeMap.find(nodeId); @@ -707,7 +709,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init( ZT_Node *node; JniRef *ref = new JniRef; - ref->id = (uint64_t)now; + ref->id = (int64_t)now; env->GetJavaVM(&ref->jvm); jclass cls = env->GetObjectClass(obj); @@ -825,7 +827,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init( ref, NULL, ref->callbacks, - (uint64_t)now); + (int64_t)now); if(rc != ZT_RESULT_OK) { @@ -864,7 +866,7 @@ JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete( JNIEnv *env, jobject obj, jlong id) { LOGV("Destroying ZT_Node struct"); - uint64_t nodeId = (uint64_t)id; + int64_t nodeId = (int64_t)id; NodeMap::iterator found; { @@ -905,7 +907,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame( jbyteArray in_frameData, jlongArray out_nextBackgroundTaskDeadline) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) @@ -921,7 +923,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame( return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL); } - uint64_t now = (uint64_t)in_now; + int64_t now = (int64_t)in_now; uint64_t nwid = (uint64_t)in_nwid; uint64_t sourceMac = (uint64_t)in_sourceMac; uint64_t destMac = (uint64_t)in_destMac; @@ -934,7 +936,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame( memcpy(localData, frameData, frameLength); env->ReleasePrimitiveArrayCritical(in_frameData, frameData, 0); - uint64_t nextBackgroundTaskDeadline = 0; + int64_t nextBackgroundTaskDeadline = 0; ZT_ResultCode rc = ZT_Node_processVirtualNetworkFrame( node, @@ -970,7 +972,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( jbyteArray in_packetData, jlongArray out_nextBackgroundTaskDeadline) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -986,7 +988,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL); } - uint64_t now = (uint64_t)in_now; + int64_t now = (int64_t)in_now; // get the java.net.InetSocketAddress class and getAddress() method jclass inetAddressClass = lookup.findClass("java/net/InetAddress"); @@ -1092,7 +1094,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( memcpy(localData, packetData, packetLength); env->ReleasePrimitiveArrayCritical(in_packetData, packetData, 0); - uint64_t nextBackgroundTaskDeadline = 0; + int64_t nextBackgroundTaskDeadline = 0; ZT_ResultCode rc = ZT_Node_processWirePacket( node, @@ -1128,7 +1130,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks( jlong in_now, jlongArray out_nextBackgroundTaskDeadline) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1142,8 +1144,8 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks( return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL); } - uint64_t now = (uint64_t)in_now; - uint64_t nextBackgroundTaskDeadline = 0; + int64_t now = (int64_t)in_now; + int64_t nextBackgroundTaskDeadline = 0; ZT_ResultCode rc = ZT_Node_processBackgroundTasks(node, NULL, now, &nextBackgroundTaskDeadline); @@ -1162,7 +1164,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks( JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_join( JNIEnv *env, jobject obj, jlong id, jlong in_nwid) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1185,7 +1187,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_join( JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave( JNIEnv *env, jobject obj, jlong id, jlong in_nwid) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1212,7 +1214,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe( jlong in_multicastGroup, jlong in_multicastAdi) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1242,7 +1244,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastUnsubscribe( jlong in_multicastGroup, jlong in_multicastAdi) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1271,7 +1273,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_orbit( jlong in_moonWorldId, jlong in_moonSeed) { - uint64_t nodeId = (uint64_t)id; + int64_t nodeId = (int64_t)id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1295,7 +1297,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_deorbit( jlong id, jlong in_moonWorldId) { - uint64_t nodeId = (uint64_t)id; + int64_t nodeId = (int64_t)id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1316,7 +1318,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_deorbit( JNIEXPORT jlong JNICALL Java_com_zerotier_sdk_Node_address( JNIEnv *env , jobject obj, jlong id) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1336,7 +1338,7 @@ JNIEXPORT jlong JNICALL Java_com_zerotier_sdk_Node_address( JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status (JNIEnv *env, jobject obj, jlong id) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1428,7 +1430,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networkConfig( JNIEnv *env, jobject obj, jlong id, jlong nwid) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1470,7 +1472,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_version( JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers( JNIEnv *env, jobject obj, jlong id) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { @@ -1539,7 +1541,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers( JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_networks( JNIEnv *env, jobject obj, jlong id) { - uint64_t nodeId = (uint64_t) id; + int64_t nodeId = (int64_t) id; ZT_Node *node = findNode(nodeId); if(node == NULL) { -- cgit v1.2.3