|
@@ -1,9 +1,9 @@
|
|
#include "ZT1_jniutils.h"
|
|
#include "ZT1_jniutils.h"
|
|
-#include "ZT1_jnicache.h"
|
|
|
|
|
|
+#include "ZT1_jnilookup.h"
|
|
#include <string>
|
|
#include <string>
|
|
#include <assert.h>
|
|
#include <assert.h>
|
|
|
|
|
|
-extern JniCache cache;
|
|
|
|
|
|
+extern JniLookup lookup;
|
|
|
|
|
|
#ifdef __cplusplus
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
extern "C" {
|
|
@@ -15,7 +15,7 @@ jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
|
|
|
|
|
|
jobject resultObject = NULL;
|
|
jobject resultObject = NULL;
|
|
|
|
|
|
- resultClass = cache.findClass("com/zerotier/sdk/ResultCode");
|
|
|
|
|
|
+ resultClass = lookup.findClass("com/zerotier/sdk/ResultCode");
|
|
if(resultClass == NULL)
|
|
if(resultClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Couldnt find ResultCode class");
|
|
LOGE("Couldnt find ResultCode class");
|
|
@@ -48,7 +48,7 @@ jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- jfieldID enumField = cache.findStaticField(resultClass, fieldName.c_str(), "Lcom/zerotier/sdk/ResultCode;");
|
|
|
|
|
|
+ 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");
|
|
LOGE("Error on FindStaticField");
|
|
@@ -68,7 +68,7 @@ jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status)
|
|
{
|
|
{
|
|
jobject statusObject = NULL;
|
|
jobject statusObject = NULL;
|
|
|
|
|
|
- jclass statusClass = cache.findClass("com/zerotier/sdk/VirtualNetworkStatus");
|
|
|
|
|
|
+ jclass statusClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkStatus");
|
|
if(statusClass == NULL)
|
|
if(statusClass == NULL)
|
|
{
|
|
{
|
|
return NULL; // exception thrown
|
|
return NULL; // exception thrown
|
|
@@ -97,7 +97,7 @@ jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- jfieldID enumField = cache.findStaticField(statusClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkStatus;");
|
|
|
|
|
|
+ jfieldID enumField = lookup.findStaticField(statusClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkStatus;");
|
|
|
|
|
|
statusObject = env->GetStaticObjectField(statusClass, enumField);
|
|
statusObject = env->GetStaticObjectField(statusClass, enumField);
|
|
|
|
|
|
@@ -109,7 +109,7 @@ jobject createEvent(JNIEnv *env, ZT1_Event event)
|
|
jclass eventClass = NULL;
|
|
jclass eventClass = NULL;
|
|
jobject eventObject = NULL;
|
|
jobject eventObject = NULL;
|
|
|
|
|
|
- eventClass = cache.findClass("com/zerotier/sdk/Event");
|
|
|
|
|
|
+ eventClass = lookup.findClass("com/zerotier/sdk/Event");
|
|
if(eventClass == NULL)
|
|
if(eventClass == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
@@ -147,7 +147,7 @@ jobject createEvent(JNIEnv *env, ZT1_Event event)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- jfieldID enumField = cache.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotier/sdk/Event;");
|
|
|
|
|
|
+ jfieldID enumField = lookup.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotier/sdk/Event;");
|
|
|
|
|
|
eventObject = env->GetStaticObjectField(eventClass, enumField);
|
|
eventObject = env->GetStaticObjectField(eventClass, enumField);
|
|
|
|
|
|
@@ -159,7 +159,7 @@ jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role)
|
|
jclass peerRoleClass = NULL;
|
|
jclass peerRoleClass = NULL;
|
|
jobject peerRoleObject = NULL;
|
|
jobject peerRoleObject = NULL;
|
|
|
|
|
|
- peerRoleClass = cache.findClass("com/zerotier/sdk/PeerRole");
|
|
|
|
|
|
+ peerRoleClass = lookup.findClass("com/zerotier/sdk/PeerRole");
|
|
if(peerRoleClass == NULL)
|
|
if(peerRoleClass == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
@@ -179,7 +179,7 @@ jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- jfieldID enumField = cache.findStaticField(peerRoleClass, fieldName.c_str(), "Lcom/zerotier/sdk/PeerRole;");
|
|
|
|
|
|
+ jfieldID enumField = lookup.findStaticField(peerRoleClass, fieldName.c_str(), "Lcom/zerotier/sdk/PeerRole;");
|
|
|
|
|
|
peerRoleObject = env->GetStaticObjectField(peerRoleClass, enumField);
|
|
peerRoleObject = env->GetStaticObjectField(peerRoleClass, enumField);
|
|
|
|
|
|
@@ -191,7 +191,7 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type)
|
|
jclass vntypeClass = NULL;
|
|
jclass vntypeClass = NULL;
|
|
jobject vntypeObject = NULL;
|
|
jobject vntypeObject = NULL;
|
|
|
|
|
|
- vntypeClass = cache.findClass("com/zerotier/sdk/VirtualNetworkType");
|
|
|
|
|
|
+ vntypeClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkType");
|
|
if(env->ExceptionCheck() || vntypeClass == NULL)
|
|
if(env->ExceptionCheck() || vntypeClass == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
@@ -208,7 +208,7 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type)
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- jfieldID enumField = cache.findStaticField(vntypeClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkType;");
|
|
|
|
|
|
+ jfieldID enumField = lookup.findStaticField(vntypeClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkType;");
|
|
vntypeObject = env->GetStaticObjectField(vntypeClass, enumField);
|
|
vntypeObject = env->GetStaticObjectField(vntypeClass, enumField);
|
|
return vntypeObject;
|
|
return vntypeObject;
|
|
}
|
|
}
|
|
@@ -218,7 +218,7 @@ jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfi
|
|
jclass vnetConfigOpClass = NULL;
|
|
jclass vnetConfigOpClass = NULL;
|
|
jobject vnetConfigOpObject = NULL;
|
|
jobject vnetConfigOpObject = NULL;
|
|
|
|
|
|
- vnetConfigOpClass = cache.findClass("com/zerotier/sdk/VirtualNetworkConfigOperation");
|
|
|
|
|
|
+ vnetConfigOpClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkConfigOperation");
|
|
if(env->ExceptionCheck() || vnetConfigOpClass == NULL)
|
|
if(env->ExceptionCheck() || vnetConfigOpClass == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
@@ -241,7 +241,7 @@ jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfi
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- jfieldID enumField = cache.findStaticField(vnetConfigOpClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkConfigOperation;");
|
|
|
|
|
|
+ jfieldID enumField = lookup.findStaticField(vnetConfigOpClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkConfigOperation;");
|
|
vnetConfigOpObject = env->GetStaticObjectField(vnetConfigOpClass, enumField);
|
|
vnetConfigOpObject = env->GetStaticObjectField(vnetConfigOpClass, enumField);
|
|
return vnetConfigOpObject;
|
|
return vnetConfigOpObject;
|
|
}
|
|
}
|
|
@@ -252,14 +252,14 @@ jobject newInetAddress(JNIEnv *env, const sockaddr_storage &addr)
|
|
jclass inetAddressClass = NULL;
|
|
jclass inetAddressClass = NULL;
|
|
jmethodID inetAddress_getByAddress = NULL;
|
|
jmethodID inetAddress_getByAddress = NULL;
|
|
|
|
|
|
- inetAddressClass = cache.findClass("java/net/InetAddress");
|
|
|
|
|
|
+ inetAddressClass = lookup.findClass("java/net/InetAddress");
|
|
if(env->ExceptionCheck() || inetAddressClass == NULL)
|
|
if(env->ExceptionCheck() || inetAddressClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding InetAddress class");
|
|
LOGE("Error finding InetAddress class");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- inetAddress_getByAddress = cache.findStaticMethod(
|
|
|
|
|
|
+ inetAddress_getByAddress = lookup.findStaticMethod(
|
|
inetAddressClass, "getByAddress", "([B)Ljava/net/InetAddress;");
|
|
inetAddressClass, "getByAddress", "([B)Ljava/net/InetAddress;");
|
|
if(env->ExceptionCheck() || inetAddress_getByAddress == NULL)
|
|
if(env->ExceptionCheck() || inetAddress_getByAddress == NULL)
|
|
{
|
|
{
|
|
@@ -315,7 +315,7 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
|
|
jclass inetSocketAddressClass = NULL;
|
|
jclass inetSocketAddressClass = NULL;
|
|
jmethodID inetSocketAddress_constructor = NULL;
|
|
jmethodID inetSocketAddress_constructor = NULL;
|
|
|
|
|
|
- inetSocketAddressClass = cache.findClass("java/net/InetSocketAddress");
|
|
|
|
|
|
+ inetSocketAddressClass = lookup.findClass("java/net/InetSocketAddress");
|
|
if(env->ExceptionCheck() || inetSocketAddressClass == NULL)
|
|
if(env->ExceptionCheck() || inetSocketAddressClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding InetSocketAddress Class");
|
|
LOGE("Error finding InetSocketAddress Class");
|
|
@@ -330,7 +330,7 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- inetSocketAddress_constructor = cache.findMethod(
|
|
|
|
|
|
+ inetSocketAddress_constructor = lookup.findMethod(
|
|
inetSocketAddressClass, "<init>", "(Ljava/net/InetAddress;I)V");
|
|
inetSocketAddressClass, "<init>", "(Ljava/net/InetAddress;I)V");
|
|
if(env->ExceptionCheck() || inetSocketAddress_constructor == NULL)
|
|
if(env->ExceptionCheck() || inetSocketAddress_constructor == NULL)
|
|
{
|
|
{
|
|
@@ -380,13 +380,13 @@ jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc)
|
|
jfieldID macField = NULL;
|
|
jfieldID macField = NULL;
|
|
jfieldID adiField = NULL;
|
|
jfieldID adiField = NULL;
|
|
|
|
|
|
- multicastGroupClass = cache.findClass("com/zerotier/sdk/MulticastGroup");
|
|
|
|
|
|
+ multicastGroupClass = lookup.findClass("com/zerotier/sdk/MulticastGroup");
|
|
if(env->ExceptionCheck() || multicastGroupClass == NULL)
|
|
if(env->ExceptionCheck() || multicastGroupClass == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- multicastGroup_constructor = cache.findMethod(
|
|
|
|
|
|
+ multicastGroup_constructor = lookup.findMethod(
|
|
multicastGroupClass, "<init>", "()V");
|
|
multicastGroupClass, "<init>", "()V");
|
|
if(env->ExceptionCheck() || multicastGroup_constructor == NULL)
|
|
if(env->ExceptionCheck() || multicastGroup_constructor == NULL)
|
|
{
|
|
{
|
|
@@ -399,13 +399,13 @@ jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc)
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- macField = cache.findField(multicastGroupClass, "mac", "J");
|
|
|
|
|
|
+ macField = lookup.findField(multicastGroupClass, "mac", "J");
|
|
if(env->ExceptionCheck() || macField == NULL)
|
|
if(env->ExceptionCheck() || macField == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- adiField = cache.findField(multicastGroupClass, "adi", "J");
|
|
|
|
|
|
+ adiField = lookup.findField(multicastGroupClass, "adi", "J");
|
|
if(env->ExceptionCheck() || adiField == NULL)
|
|
if(env->ExceptionCheck() || adiField == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
@@ -431,56 +431,56 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT1_PeerPhysicalPath &ppp)
|
|
|
|
|
|
jmethodID ppp_constructor = NULL;
|
|
jmethodID ppp_constructor = NULL;
|
|
|
|
|
|
- pppClass = cache.findClass("com/zerotier/sdk/PeerPhysicalPath");
|
|
|
|
|
|
+ pppClass = lookup.findClass("com/zerotier/sdk/PeerPhysicalPath");
|
|
if(env->ExceptionCheck() || pppClass == NULL)
|
|
if(env->ExceptionCheck() || pppClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding PeerPhysicalPath class");
|
|
LOGE("Error finding PeerPhysicalPath class");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- addressField = cache.findField(pppClass, "address", "Ljava/net/InetSocketAddress;");
|
|
|
|
|
|
+ addressField = lookup.findField(pppClass, "address", "Ljava/net/InetSocketAddress;");
|
|
if(env->ExceptionCheck() || addressField == NULL)
|
|
if(env->ExceptionCheck() || addressField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding address field");
|
|
LOGE("Error finding address field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- lastSendField = cache.findField(pppClass, "lastSend", "J");
|
|
|
|
|
|
+ lastSendField = lookup.findField(pppClass, "lastSend", "J");
|
|
if(env->ExceptionCheck() || lastSendField == NULL)
|
|
if(env->ExceptionCheck() || lastSendField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding lastSend field");
|
|
LOGE("Error finding lastSend field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- lastReceiveField = cache.findField(pppClass, "lastReceive", "J");
|
|
|
|
|
|
+ lastReceiveField = lookup.findField(pppClass, "lastReceive", "J");
|
|
if(env->ExceptionCheck() || lastReceiveField == NULL)
|
|
if(env->ExceptionCheck() || lastReceiveField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding lastReceive field");
|
|
LOGE("Error finding lastReceive field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- fixedField = cache.findField(pppClass, "fixed", "Z");
|
|
|
|
|
|
+ fixedField = lookup.findField(pppClass, "fixed", "Z");
|
|
if(env->ExceptionCheck() || fixedField == NULL)
|
|
if(env->ExceptionCheck() || fixedField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding fixed field");
|
|
LOGE("Error finding fixed field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- activeField = cache.findField(pppClass, "active", "Z");
|
|
|
|
|
|
+ activeField = lookup.findField(pppClass, "active", "Z");
|
|
if(env->ExceptionCheck() || activeField == NULL)
|
|
if(env->ExceptionCheck() || activeField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding active field");
|
|
LOGE("Error finding active field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- preferredField = cache.findField(pppClass, "preferred", "Z");
|
|
|
|
|
|
+ preferredField = lookup.findField(pppClass, "preferred", "Z");
|
|
if(env->ExceptionCheck() || preferredField == NULL)
|
|
if(env->ExceptionCheck() || preferredField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding preferred field");
|
|
LOGE("Error finding preferred field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- ppp_constructor = cache.findMethod(pppClass, "<init>", "()V");
|
|
|
|
|
|
+ ppp_constructor = lookup.findMethod(pppClass, "<init>", "()V");
|
|
if(env->ExceptionCheck() || ppp_constructor == NULL)
|
|
if(env->ExceptionCheck() || ppp_constructor == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding PeerPhysicalPath constructor");
|
|
LOGE("Error finding PeerPhysicalPath constructor");
|
|
@@ -532,77 +532,77 @@ jobject newPeer(JNIEnv *env, const ZT1_Peer &peer)
|
|
|
|
|
|
jmethodID peer_constructor = NULL;
|
|
jmethodID peer_constructor = NULL;
|
|
|
|
|
|
- peerClass = cache.findClass("com/zerotier/sdk/Peer");
|
|
|
|
|
|
+ peerClass = lookup.findClass("com/zerotier/sdk/Peer");
|
|
if(env->ExceptionCheck() || peerClass == NULL)
|
|
if(env->ExceptionCheck() || peerClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding Peer class");
|
|
LOGE("Error finding Peer class");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- addressField = cache.findField(peerClass, "address", "J");
|
|
|
|
|
|
+ addressField = lookup.findField(peerClass, "address", "J");
|
|
if(env->ExceptionCheck() || addressField == NULL)
|
|
if(env->ExceptionCheck() || addressField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding address field of Peer object");
|
|
LOGE("Error finding address field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- lastUnicastFrameField = cache.findField(peerClass, "lastUnicastFrame", "J");
|
|
|
|
|
|
+ lastUnicastFrameField = lookup.findField(peerClass, "lastUnicastFrame", "J");
|
|
if(env->ExceptionCheck() || lastUnicastFrameField == NULL)
|
|
if(env->ExceptionCheck() || lastUnicastFrameField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding lastUnicastFrame field of Peer object");
|
|
LOGE("Error finding lastUnicastFrame field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- lastMulticastFrameField = cache.findField(peerClass, "lastMulticastFrame", "J");
|
|
|
|
|
|
+ lastMulticastFrameField = lookup.findField(peerClass, "lastMulticastFrame", "J");
|
|
if(env->ExceptionCheck() || lastMulticastFrameField == NULL)
|
|
if(env->ExceptionCheck() || lastMulticastFrameField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding lastMulticastFrame field of Peer object");
|
|
LOGE("Error finding lastMulticastFrame field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- versionMajorField = cache.findField(peerClass, "versionMajor", "I");
|
|
|
|
|
|
+ versionMajorField = lookup.findField(peerClass, "versionMajor", "I");
|
|
if(env->ExceptionCheck() || versionMajorField == NULL)
|
|
if(env->ExceptionCheck() || versionMajorField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding versionMajor field of Peer object");
|
|
LOGE("Error finding versionMajor field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- versionMinorField = cache.findField(peerClass, "versionMinor", "I");
|
|
|
|
|
|
+ versionMinorField = lookup.findField(peerClass, "versionMinor", "I");
|
|
if(env->ExceptionCheck() || versionMinorField == NULL)
|
|
if(env->ExceptionCheck() || versionMinorField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding versionMinor field of Peer object");
|
|
LOGE("Error finding versionMinor field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- versionRevField = cache.findField(peerClass, "versionRev", "I");
|
|
|
|
|
|
+ versionRevField = lookup.findField(peerClass, "versionRev", "I");
|
|
if(env->ExceptionCheck() || versionRevField == NULL)
|
|
if(env->ExceptionCheck() || versionRevField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding versionRev field of Peer object");
|
|
LOGE("Error finding versionRev field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- latencyField = cache.findField(peerClass, "latency", "I");
|
|
|
|
|
|
+ latencyField = lookup.findField(peerClass, "latency", "I");
|
|
if(env->ExceptionCheck() || latencyField == NULL)
|
|
if(env->ExceptionCheck() || latencyField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding latency field of Peer object");
|
|
LOGE("Error finding latency field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- roleField = cache.findField(peerClass, "role", "Lcom/zerotier/sdk/PeerRole;");
|
|
|
|
|
|
+ roleField = lookup.findField(peerClass, "role", "Lcom/zerotier/sdk/PeerRole;");
|
|
if(env->ExceptionCheck() || roleField == NULL)
|
|
if(env->ExceptionCheck() || roleField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding role field of Peer object");
|
|
LOGE("Error finding role field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- pathsField = cache.findField(peerClass, "paths", "[Lcom/zerotier/sdk/PeerPhysicalPath;");
|
|
|
|
|
|
+ pathsField = lookup.findField(peerClass, "paths", "[Lcom/zerotier/sdk/PeerPhysicalPath;");
|
|
if(env->ExceptionCheck() || pathsField == NULL)
|
|
if(env->ExceptionCheck() || pathsField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding paths field of Peer object");
|
|
LOGE("Error finding paths field of Peer object");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- peer_constructor = cache.findMethod(peerClass, "<init>", "()V");
|
|
|
|
|
|
+ peer_constructor = lookup.findMethod(peerClass, "<init>", "()V");
|
|
if(env->ExceptionCheck() || peer_constructor == NULL)
|
|
if(env->ExceptionCheck() || peer_constructor == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding Peer constructor");
|
|
LOGE("Error finding Peer constructor");
|
|
@@ -625,7 +625,7 @@ jobject newPeer(JNIEnv *env, const ZT1_Peer &peer)
|
|
env->SetIntField(peerObject, latencyField, peer.latency);
|
|
env->SetIntField(peerObject, latencyField, peer.latency);
|
|
env->SetObjectField(peerObject, roleField, createPeerRole(env, peer.role));
|
|
env->SetObjectField(peerObject, roleField, createPeerRole(env, peer.role));
|
|
|
|
|
|
- jclass peerPhysicalPathClass = cache.findClass("com/zerotier/sdk/PeerPhysicalPath");
|
|
|
|
|
|
+ jclass peerPhysicalPathClass = lookup.findClass("com/zerotier/sdk/PeerPhysicalPath");
|
|
if(env->ExceptionCheck() || peerPhysicalPathClass == NULL)
|
|
if(env->ExceptionCheck() || peerPhysicalPathClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding PeerPhysicalPath class");
|
|
LOGE("Error finding PeerPhysicalPath class");
|
|
@@ -675,14 +675,14 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig
|
|
jfieldID multicastSubscriptionsField = NULL;
|
|
jfieldID multicastSubscriptionsField = NULL;
|
|
jfieldID assignedAddressesField = NULL;
|
|
jfieldID assignedAddressesField = NULL;
|
|
|
|
|
|
- vnetConfigClass = cache.findClass("com/zerotier/sdk/VirtualNetworkConfig");
|
|
|
|
|
|
+ vnetConfigClass = lookup.findClass("com/zerotier/sdk/VirtualNetworkConfig");
|
|
if(vnetConfigClass == NULL)
|
|
if(vnetConfigClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Couldn't find com.zerotier.sdk.VirtualNetworkConfig");
|
|
LOGE("Couldn't find com.zerotier.sdk.VirtualNetworkConfig");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- vnetConfig_constructor = cache.findMethod(
|
|
|
|
|
|
+ vnetConfig_constructor = lookup.findMethod(
|
|
vnetConfigClass, "<init>", "()V");
|
|
vnetConfigClass, "<init>", "()V");
|
|
if(env->ExceptionCheck() || vnetConfig_constructor == NULL)
|
|
if(env->ExceptionCheck() || vnetConfig_constructor == NULL)
|
|
{
|
|
{
|
|
@@ -697,98 +697,98 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- nwidField = cache.findField(vnetConfigClass, "nwid", "J");
|
|
|
|
|
|
+ nwidField = lookup.findField(vnetConfigClass, "nwid", "J");
|
|
if(env->ExceptionCheck() || nwidField == NULL)
|
|
if(env->ExceptionCheck() || nwidField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting nwid field");
|
|
LOGE("Error getting nwid field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- macField = cache.findField(vnetConfigClass, "mac", "J");
|
|
|
|
|
|
+ macField = lookup.findField(vnetConfigClass, "mac", "J");
|
|
if(env->ExceptionCheck() || macField == NULL)
|
|
if(env->ExceptionCheck() || macField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting mac field");
|
|
LOGE("Error getting mac field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- nameField = cache.findField(vnetConfigClass, "name", "Ljava/lang/String;");
|
|
|
|
|
|
+ nameField = lookup.findField(vnetConfigClass, "name", "Ljava/lang/String;");
|
|
if(env->ExceptionCheck() || nameField == NULL)
|
|
if(env->ExceptionCheck() || nameField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting name field");
|
|
LOGE("Error getting name field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- statusField = cache.findField(vnetConfigClass, "status", "Lcom/zerotier/sdk/VirtualNetworkStatus;");
|
|
|
|
|
|
+ statusField = lookup.findField(vnetConfigClass, "status", "Lcom/zerotier/sdk/VirtualNetworkStatus;");
|
|
if(env->ExceptionCheck() || statusField == NULL)
|
|
if(env->ExceptionCheck() || statusField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting status field");
|
|
LOGE("Error getting status field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- typeField = cache.findField(vnetConfigClass, "type", "Lcom/zerotier/sdk/VirtualNetworkType;");
|
|
|
|
|
|
+ typeField = lookup.findField(vnetConfigClass, "type", "Lcom/zerotier/sdk/VirtualNetworkType;");
|
|
if(env->ExceptionCheck() || typeField == NULL)
|
|
if(env->ExceptionCheck() || typeField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting type field");
|
|
LOGE("Error getting type field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- mtuField = cache.findField(vnetConfigClass, "mtu", "I");
|
|
|
|
|
|
+ mtuField = lookup.findField(vnetConfigClass, "mtu", "I");
|
|
if(env->ExceptionCheck() || mtuField == NULL)
|
|
if(env->ExceptionCheck() || mtuField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting mtu field");
|
|
LOGE("Error getting mtu field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- dhcpField = cache.findField(vnetConfigClass, "dhcp", "Z");
|
|
|
|
|
|
+ dhcpField = lookup.findField(vnetConfigClass, "dhcp", "Z");
|
|
if(env->ExceptionCheck() || dhcpField == NULL)
|
|
if(env->ExceptionCheck() || dhcpField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting dhcp field");
|
|
LOGE("Error getting dhcp field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- bridgeField = cache.findField(vnetConfigClass, "bridge", "Z");
|
|
|
|
|
|
+ bridgeField = lookup.findField(vnetConfigClass, "bridge", "Z");
|
|
if(env->ExceptionCheck() || bridgeField == NULL)
|
|
if(env->ExceptionCheck() || bridgeField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting bridge field");
|
|
LOGE("Error getting bridge field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- broadcastEnabledField = cache.findField(vnetConfigClass, "broadcastEnabled", "Z");
|
|
|
|
|
|
+ broadcastEnabledField = lookup.findField(vnetConfigClass, "broadcastEnabled", "Z");
|
|
if(env->ExceptionCheck() || broadcastEnabledField == NULL)
|
|
if(env->ExceptionCheck() || broadcastEnabledField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting broadcastEnabled field");
|
|
LOGE("Error getting broadcastEnabled field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- portErrorField = cache.findField(vnetConfigClass, "portError", "I");
|
|
|
|
|
|
+ portErrorField = lookup.findField(vnetConfigClass, "portError", "I");
|
|
if(env->ExceptionCheck() || portErrorField == NULL)
|
|
if(env->ExceptionCheck() || portErrorField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting portError field");
|
|
LOGE("Error getting portError field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- enabledField = cache.findField(vnetConfigClass, "enabled", "Z");
|
|
|
|
|
|
+ enabledField = lookup.findField(vnetConfigClass, "enabled", "Z");
|
|
if(env->ExceptionCheck() || enabledField == NULL)
|
|
if(env->ExceptionCheck() || enabledField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting enabled field");
|
|
LOGE("Error getting enabled field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- netconfRevisionField = cache.findField(vnetConfigClass, "netconfRevision", "J");
|
|
|
|
|
|
+ netconfRevisionField = lookup.findField(vnetConfigClass, "netconfRevision", "J");
|
|
if(env->ExceptionCheck() || netconfRevisionField == NULL)
|
|
if(env->ExceptionCheck() || netconfRevisionField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting netconfRevision field");
|
|
LOGE("Error getting netconfRevision field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- multicastSubscriptionsField = cache.findField(vnetConfigClass, "multicastSubscriptions", "[Lcom/zerotier/sdk/MulticastGroup;");
|
|
|
|
|
|
+ multicastSubscriptionsField = lookup.findField(vnetConfigClass, "multicastSubscriptions", "[Lcom/zerotier/sdk/MulticastGroup;");
|
|
if(env->ExceptionCheck() || multicastSubscriptionsField == NULL)
|
|
if(env->ExceptionCheck() || multicastSubscriptionsField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting multicastSubscriptions field");
|
|
LOGE("Error getting multicastSubscriptions field");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- assignedAddressesField = cache.findField(vnetConfigClass, "assignedAddresses", "[Ljava/net/InetSocketAddress;");
|
|
|
|
|
|
+ assignedAddressesField = lookup.findField(vnetConfigClass, "assignedAddresses", "[Ljava/net/InetSocketAddress;");
|
|
if(env->ExceptionCheck() || assignedAddressesField == NULL)
|
|
if(env->ExceptionCheck() || assignedAddressesField == NULL)
|
|
{
|
|
{
|
|
LOGE("Error getting assignedAddresses field");
|
|
LOGE("Error getting assignedAddresses field");
|
|
@@ -825,7 +825,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig
|
|
env->SetBooleanField(vnetConfigObj, enabledField, vnetConfig.enabled);
|
|
env->SetBooleanField(vnetConfigObj, enabledField, vnetConfig.enabled);
|
|
env->SetIntField(vnetConfigObj, portErrorField, vnetConfig.portError);
|
|
env->SetIntField(vnetConfigObj, portErrorField, vnetConfig.portError);
|
|
|
|
|
|
- jclass multicastGroupClass = cache.findClass("com/zerotier/sdk/MulticastGroup");
|
|
|
|
|
|
+ jclass multicastGroupClass = lookup.findClass("com/zerotier/sdk/MulticastGroup");
|
|
if(env->ExceptionCheck() || multicastGroupClass == NULL)
|
|
if(env->ExceptionCheck() || multicastGroupClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding MulticastGroup class");
|
|
LOGE("Error finding MulticastGroup class");
|
|
@@ -850,7 +850,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig
|
|
}
|
|
}
|
|
env->SetObjectField(vnetConfigObj, multicastSubscriptionsField, mcastSubsArrayObj);
|
|
env->SetObjectField(vnetConfigObj, multicastSubscriptionsField, mcastSubsArrayObj);
|
|
|
|
|
|
- jclass inetSocketAddressClass = cache.findClass("java/net/InetSocketAddress");
|
|
|
|
|
|
+ jclass inetSocketAddressClass = lookup.findClass("java/net/InetSocketAddress");
|
|
if(env->ExceptionCheck() || inetSocketAddressClass == NULL)
|
|
if(env->ExceptionCheck() || inetSocketAddressClass == NULL)
|
|
{
|
|
{
|
|
LOGE("Error finding InetSocketAddress class");
|
|
LOGE("Error finding InetSocketAddress class");
|
|
@@ -887,13 +887,13 @@ jobject newVersion(JNIEnv *env, int major, int minor, int rev, long featureFlags
|
|
jclass versionClass = NULL;
|
|
jclass versionClass = NULL;
|
|
jmethodID versionConstructor = NULL;
|
|
jmethodID versionConstructor = NULL;
|
|
|
|
|
|
- versionClass = cache.findClass("com/zerotier/sdk/Version");
|
|
|
|
|
|
+ versionClass = lookup.findClass("com/zerotier/sdk/Version");
|
|
if(env->ExceptionCheck() || versionClass == NULL)
|
|
if(env->ExceptionCheck() || versionClass == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- versionConstructor = cache.findMethod(
|
|
|
|
|
|
+ versionConstructor = lookup.findMethod(
|
|
versionClass, "<init>", "()V");
|
|
versionClass, "<init>", "()V");
|
|
if(env->ExceptionCheck() || versionConstructor == NULL)
|
|
if(env->ExceptionCheck() || versionConstructor == NULL)
|
|
{
|
|
{
|
|
@@ -912,25 +912,25 @@ jobject newVersion(JNIEnv *env, int major, int minor, int rev, long featureFlags
|
|
jfieldID revisionField = NULL;
|
|
jfieldID revisionField = NULL;
|
|
jfieldID featureFlagsField = NULL;
|
|
jfieldID featureFlagsField = NULL;
|
|
|
|
|
|
- majorField = cache.findField(versionClass, "major", "I");
|
|
|
|
|
|
+ majorField = lookup.findField(versionClass, "major", "I");
|
|
if(env->ExceptionCheck() || majorField == NULL)
|
|
if(env->ExceptionCheck() || majorField == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- minorField = cache.findField(versionClass, "minor", "I");
|
|
|
|
|
|
+ minorField = lookup.findField(versionClass, "minor", "I");
|
|
if(env->ExceptionCheck() || minorField == NULL)
|
|
if(env->ExceptionCheck() || minorField == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- revisionField = cache.findField(versionClass, "revision", "I");
|
|
|
|
|
|
+ revisionField = lookup.findField(versionClass, "revision", "I");
|
|
if(env->ExceptionCheck() || revisionField == NULL)
|
|
if(env->ExceptionCheck() || revisionField == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
- featureFlagsField = cache.findField(versionClass, "featureFlags", "J");
|
|
|
|
|
|
+ featureFlagsField = lookup.findField(versionClass, "featureFlags", "J");
|
|
if(env->ExceptionCheck() || featureFlagsField == NULL)
|
|
if(env->ExceptionCheck() || featureFlagsField == NULL)
|
|
{
|
|
{
|
|
return NULL;
|
|
return NULL;
|