mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 13:07:55 +00:00
replace old direct calls to FindClass, GetMethodID, etc with calls that use the cache
This commit is contained in:
parent
079d248eab
commit
818339f966
@ -3,19 +3,19 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
extern JniCache cache;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern JniCache cache;
|
|
||||||
|
|
||||||
jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
|
jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
|
||||||
{
|
{
|
||||||
jclass resultClass = NULL;
|
jclass resultClass = NULL;
|
||||||
|
|
||||||
jobject resultObject = NULL;
|
jobject resultObject = NULL;
|
||||||
|
|
||||||
resultClass = env->FindClass("com/zerotierone/sdk/ResultCode");
|
resultClass = cache.findClass("com/zerotierone/sdk/ResultCode");
|
||||||
if(resultClass == NULL)
|
if(resultClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL; // exception thrown
|
return NULL; // exception thrown
|
||||||
@ -42,7 +42,7 @@ jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID enumField = env->GetStaticFieldID(resultClass, fieldName.c_str(), "Lcom/zerotierone/sdk/ResultCode;");
|
jfieldID enumField = cache.findStaticField(resultClass, fieldName.c_str(), "Lcom/zerotierone/sdk/ResultCode;");
|
||||||
|
|
||||||
resultObject = env->GetStaticObjectField(resultClass, enumField);
|
resultObject = env->GetStaticObjectField(resultClass, enumField);
|
||||||
|
|
||||||
@ -52,16 +52,12 @@ jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
|
|||||||
|
|
||||||
jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status)
|
jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status)
|
||||||
{
|
{
|
||||||
jclass statusClass = NULL;
|
|
||||||
jobject statusObject = NULL;
|
jobject statusObject = NULL;
|
||||||
|
|
||||||
|
jclass statusClass = cache.findClass("com/zerotierone/sdk/VirtualNetworkStatus");
|
||||||
if(statusClass == NULL)
|
if(statusClass == NULL)
|
||||||
{
|
{
|
||||||
statusClass = env->FindClass("com/zerotierone/sdk/VirtualNetworkStatus");
|
return NULL; // exception thrown
|
||||||
if(statusClass == NULL)
|
|
||||||
{
|
|
||||||
return NULL; // exception thrown
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fieldName;
|
std::string fieldName;
|
||||||
@ -87,7 +83,7 @@ jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID enumField = env->GetStaticFieldID(statusClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkStatus;");
|
jfieldID enumField = cache.findStaticField(statusClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkStatus;");
|
||||||
|
|
||||||
statusObject = env->GetStaticObjectField(statusClass, enumField);
|
statusObject = env->GetStaticObjectField(statusClass, enumField);
|
||||||
|
|
||||||
@ -99,7 +95,7 @@ jobject createEvent(JNIEnv *env, ZT1_Event event)
|
|||||||
jclass eventClass = NULL;
|
jclass eventClass = NULL;
|
||||||
jobject eventObject = NULL;
|
jobject eventObject = NULL;
|
||||||
|
|
||||||
eventClass = env->FindClass("com/zerotierone/sdk/Event");
|
eventClass = cache.findClass("com/zerotierone/sdk/Event");
|
||||||
if(eventClass == NULL)
|
if(eventClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -137,7 +133,7 @@ jobject createEvent(JNIEnv *env, ZT1_Event event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID enumField = env->GetStaticFieldID(eventClass, fieldName.c_str(), "Lcom/zerotierone/sdk/Event;");
|
jfieldID enumField = cache.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotierone/sdk/Event;");
|
||||||
|
|
||||||
eventObject = env->GetStaticObjectField(eventClass, enumField);
|
eventObject = env->GetStaticObjectField(eventClass, enumField);
|
||||||
|
|
||||||
@ -149,7 +145,7 @@ jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role)
|
|||||||
jclass peerRoleClass = NULL;
|
jclass peerRoleClass = NULL;
|
||||||
jobject peerRoleObject = NULL;
|
jobject peerRoleObject = NULL;
|
||||||
|
|
||||||
peerRoleClass = env->FindClass("com/zerotierone/sdk/PeerRole");
|
peerRoleClass = cache.findClass("com/zerotierone/sdk/PeerRole");
|
||||||
if(peerRoleClass == NULL)
|
if(peerRoleClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -169,7 +165,7 @@ jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID enumField = env->GetStaticFieldID(peerRoleClass, fieldName.c_str(), "Lcom/zerotierone/sdk/PeerRole;");
|
jfieldID enumField = cache.findStaticField(peerRoleClass, fieldName.c_str(), "Lcom/zerotierone/sdk/PeerRole;");
|
||||||
|
|
||||||
peerRoleObject = env->GetStaticObjectField(peerRoleClass, enumField);
|
peerRoleObject = env->GetStaticObjectField(peerRoleClass, enumField);
|
||||||
|
|
||||||
@ -181,7 +177,7 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type)
|
|||||||
jclass vntypeClass = NULL;
|
jclass vntypeClass = NULL;
|
||||||
jobject vntypeObject = NULL;
|
jobject vntypeObject = NULL;
|
||||||
|
|
||||||
vntypeClass = env->FindClass("com/zerotierone/sdk/VirtualNetworkType");
|
vntypeClass = cache.findClass("com/zerotierone/sdk/VirtualNetworkType");
|
||||||
if(vntypeClass == NULL)
|
if(vntypeClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -198,7 +194,7 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID enumField = env->GetStaticFieldID(vntypeClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkType;");
|
jfieldID enumField = cache.findStaticField(vntypeClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkType;");
|
||||||
vntypeObject = env->GetStaticObjectField(vntypeClass, enumField);
|
vntypeObject = env->GetStaticObjectField(vntypeClass, enumField);
|
||||||
return vntypeObject;
|
return vntypeObject;
|
||||||
}
|
}
|
||||||
@ -208,7 +204,7 @@ jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfi
|
|||||||
jclass vnetConfigOpClass = NULL;
|
jclass vnetConfigOpClass = NULL;
|
||||||
jobject vnetConfigOpObject = NULL;
|
jobject vnetConfigOpObject = NULL;
|
||||||
|
|
||||||
vnetConfigOpClass = env->FindClass("com/zerotierone/sdk/VirtualNetworkConfigOperation");
|
vnetConfigOpClass = cache.findClass("com/zerotierone/sdk/VirtualNetworkConfigOperation");
|
||||||
if(vnetConfigOpClass == NULL)
|
if(vnetConfigOpClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -231,7 +227,7 @@ jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfi
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
jfieldID enumField = env->GetStaticFieldID(vnetConfigOpClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkConfigOperation;");
|
jfieldID enumField = cache.findStaticField(vnetConfigOpClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkConfigOperation;");
|
||||||
vnetConfigOpObject = env->GetStaticObjectField(vnetConfigOpClass, enumField);
|
vnetConfigOpObject = env->GetStaticObjectField(vnetConfigOpClass, enumField);
|
||||||
return vnetConfigOpObject;
|
return vnetConfigOpObject;
|
||||||
}
|
}
|
||||||
@ -241,13 +237,13 @@ jobject newArrayList(JNIEnv *env)
|
|||||||
jclass arrayListClass = NULL;
|
jclass arrayListClass = NULL;
|
||||||
jmethodID arrayList_constructor = NULL;
|
jmethodID arrayList_constructor = NULL;
|
||||||
|
|
||||||
arrayListClass = env->FindClass("java/util/ArrayList");
|
arrayListClass = cache.findClass("java/util/ArrayList");
|
||||||
if(arrayListClass == NULL)
|
if(arrayListClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayList_constructor = env->GetMethodID(
|
arrayList_constructor = cache.findMethod(
|
||||||
arrayListClass, "<init>", "()V");
|
arrayListClass, "<init>", "()V");
|
||||||
if(arrayList_constructor == NULL)
|
if(arrayList_constructor == NULL)
|
||||||
{
|
{
|
||||||
@ -267,13 +263,13 @@ bool appendItemToArrayList(JNIEnv *env, jobject array, jobject object)
|
|||||||
jclass arrayListClass = NULL;
|
jclass arrayListClass = NULL;
|
||||||
jmethodID arrayList_add = NULL;
|
jmethodID arrayList_add = NULL;
|
||||||
|
|
||||||
arrayListClass = env->FindClass("java/util/ArrayList");
|
arrayListClass = cache.findClass("java/util/ArrayList");
|
||||||
if(arrayListClass == NULL)
|
if(arrayListClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayList_add = env->GetMethodID(arrayListClass, "add", "(Ljava.lang.Object;)Z");
|
arrayList_add = cache.findMethod(arrayListClass, "add", "(Ljava.lang.Object;)Z");
|
||||||
if(arrayList_add == NULL)
|
if(arrayList_add == NULL)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -287,13 +283,13 @@ jobject newInetAddress(JNIEnv *env, const sockaddr_storage &addr)
|
|||||||
jclass inetAddressClass = NULL;
|
jclass inetAddressClass = NULL;
|
||||||
jmethodID inetAddress_getByAddress = NULL;
|
jmethodID inetAddress_getByAddress = NULL;
|
||||||
|
|
||||||
inetAddressClass = env->FindClass("java/net/InetAddress");
|
inetAddressClass = cache.findClass("java/net/InetAddress");
|
||||||
if(inetAddressClass == NULL)
|
if(inetAddressClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
inetAddress_getByAddress = env->GetStaticMethodID(
|
inetAddress_getByAddress = cache.findStaticMethod(
|
||||||
inetAddressClass, "getByAddress", "([B)Ljava/net/InetAddress;");
|
inetAddressClass, "getByAddress", "([B)Ljava/net/InetAddress;");
|
||||||
if(inetAddress_getByAddress == NULL)
|
if(inetAddress_getByAddress == NULL)
|
||||||
{
|
{
|
||||||
@ -341,7 +337,7 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
|
|||||||
jclass inetSocketAddressClass = NULL;
|
jclass inetSocketAddressClass = NULL;
|
||||||
jmethodID inetSocketAddress_constructor = NULL;
|
jmethodID inetSocketAddress_constructor = NULL;
|
||||||
|
|
||||||
inetSocketAddressClass = env->FindClass("java/net/InetSocketAddress");
|
inetSocketAddressClass = cache.findClass("java/net/InetSocketAddress");
|
||||||
if(inetSocketAddressClass == NULL)
|
if(inetSocketAddressClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -354,7 +350,7 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
inetSocketAddress_constructor = env->GetMethodID(
|
inetSocketAddress_constructor = cache.findMethod(
|
||||||
inetSocketAddressClass, "<init>", "(Ljava/net/InetAddress;I)V");
|
inetSocketAddressClass, "<init>", "(Ljava/net/InetAddress;I)V");
|
||||||
if(inetSocketAddress_constructor == NULL)
|
if(inetSocketAddress_constructor == NULL)
|
||||||
{
|
{
|
||||||
@ -390,13 +386,13 @@ jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc)
|
|||||||
jfieldID macField = NULL;
|
jfieldID macField = NULL;
|
||||||
jfieldID adiField = NULL;
|
jfieldID adiField = NULL;
|
||||||
|
|
||||||
multicastGroupClass = env->FindClass("com/zerotierone/sdk/MulticastGroup");
|
multicastGroupClass = cache.findClass("com/zerotierone/sdk/MulticastGroup");
|
||||||
if(multicastGroupClass == NULL)
|
if(multicastGroupClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
multicastGroup_constructor = env->GetMethodID(
|
multicastGroup_constructor = cache.findMethod(
|
||||||
multicastGroupClass, "<init>", "()V");
|
multicastGroupClass, "<init>", "()V");
|
||||||
if(multicastGroup_constructor == NULL)
|
if(multicastGroup_constructor == NULL)
|
||||||
{
|
{
|
||||||
@ -411,7 +407,7 @@ jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc)
|
|||||||
|
|
||||||
if(macField == NULL)
|
if(macField == NULL)
|
||||||
{
|
{
|
||||||
macField = env->GetFieldID(multicastGroupClass, "mac", "J");
|
macField = cache.findField(multicastGroupClass, "mac", "J");
|
||||||
if(macField == NULL)
|
if(macField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -420,7 +416,7 @@ jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc)
|
|||||||
|
|
||||||
if(adiField == NULL)
|
if(adiField == NULL)
|
||||||
{
|
{
|
||||||
adiField = env->GetFieldID(multicastGroupClass, "adi", "J");
|
adiField = cache.findField(multicastGroupClass, "adi", "J");
|
||||||
if(adiField == NULL)
|
if(adiField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -446,49 +442,49 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT1_PeerPhysicalPath &ppp)
|
|||||||
|
|
||||||
jmethodID ppp_constructor = NULL;
|
jmethodID ppp_constructor = NULL;
|
||||||
|
|
||||||
pppClass = env->FindClass("com/zerotierone/sdk/PeerPhysicalPath");
|
pppClass = cache.findClass("com/zerotierone/sdk/PeerPhysicalPath");
|
||||||
if(pppClass == NULL)
|
if(pppClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
addressField = env->GetFieldID(pppClass, "address", "Ljava/net/InetAddress;");
|
addressField = cache.findField(pppClass, "address", "Ljava/net/InetAddress;");
|
||||||
if(addressField == NULL)
|
if(addressField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastSendField = env->GetFieldID(pppClass, "lastSend", "J");
|
lastSendField = cache.findField(pppClass, "lastSend", "J");
|
||||||
if(lastSendField == NULL)
|
if(lastSendField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastReceiveField = env->GetFieldID(pppClass, "lastReceive", "J");
|
lastReceiveField = cache.findField(pppClass, "lastReceive", "J");
|
||||||
if(lastReceiveField == NULL)
|
if(lastReceiveField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedField = env->GetFieldID(pppClass, "fixed", "Z");
|
fixedField = cache.findField(pppClass, "fixed", "Z");
|
||||||
if(fixedField == NULL)
|
if(fixedField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
activeField = env->GetFieldID(pppClass, "active", "Z");
|
activeField = cache.findField(pppClass, "active", "Z");
|
||||||
if(activeField == NULL)
|
if(activeField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
preferredField = env->GetFieldID(pppClass, "preferred", "Z");
|
preferredField = cache.findField(pppClass, "preferred", "Z");
|
||||||
if(preferredField == NULL)
|
if(preferredField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ppp_constructor = env->GetMethodID(pppClass, "<init>", "()V");
|
ppp_constructor = cache.findMethod(pppClass, "<init>", "()V");
|
||||||
if(ppp_constructor == NULL)
|
if(ppp_constructor == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -528,67 +524,67 @@ jobject newPeer(JNIEnv *env, const ZT1_Peer &peer)
|
|||||||
|
|
||||||
jmethodID peer_constructor = NULL;
|
jmethodID peer_constructor = NULL;
|
||||||
|
|
||||||
peerClass = env->FindClass("com/zerotierone/sdk/Peer");
|
peerClass = cache.findClass("com/zerotierone/sdk/Peer");
|
||||||
if(peerClass == NULL)
|
if(peerClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
addressField = env->GetFieldID(peerClass, "address", "J");
|
addressField = cache.findField(peerClass, "address", "J");
|
||||||
if(addressField == NULL)
|
if(addressField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastUnicastFrameField = env->GetFieldID(peerClass, "lastUnicastFrame", "J");
|
lastUnicastFrameField = cache.findField(peerClass, "lastUnicastFrame", "J");
|
||||||
if(lastUnicastFrameField == NULL)
|
if(lastUnicastFrameField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastMulticastFrameField = env->GetFieldID(peerClass, "lastMulticastFrame", "J");
|
lastMulticastFrameField = cache.findField(peerClass, "lastMulticastFrame", "J");
|
||||||
if(lastMulticastFrameField == NULL)
|
if(lastMulticastFrameField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionMajorField = env->GetFieldID(peerClass, "versionMajor", "I");
|
versionMajorField = cache.findField(peerClass, "versionMajor", "I");
|
||||||
if(versionMajorField == NULL)
|
if(versionMajorField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionMinorField = env->GetFieldID(peerClass, "versionMinor", "I");
|
versionMinorField = cache.findField(peerClass, "versionMinor", "I");
|
||||||
if(versionMinorField == NULL)
|
if(versionMinorField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionRevField = env->GetFieldID(peerClass, "versionRev", "I");
|
versionRevField = cache.findField(peerClass, "versionRev", "I");
|
||||||
if(versionRevField == NULL)
|
if(versionRevField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
latencyField = env->GetFieldID(peerClass, "latency", "I");
|
latencyField = cache.findField(peerClass, "latency", "I");
|
||||||
if(latencyField == NULL)
|
if(latencyField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
roleField = env->GetFieldID(peerClass, "role", "Lcom/zerotierone/sdk/PeerRole;");
|
roleField = cache.findField(peerClass, "role", "Lcom/zerotierone/sdk/PeerRole;");
|
||||||
if(roleField == NULL)
|
if(roleField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pathsField = env->GetFieldID(peerClass, "paths", "Ljava.util.ArrayList;");
|
pathsField = cache.findField(peerClass, "paths", "Ljava.util.ArrayList;");
|
||||||
if(pathsField == NULL)
|
if(pathsField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer_constructor = env->GetMethodID(peerClass, "<init>", "()V");
|
peer_constructor = cache.findMethod(peerClass, "<init>", "()V");
|
||||||
if(peer_constructor == NULL)
|
if(peer_constructor == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -640,14 +636,14 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig
|
|||||||
jfieldID multicastSubscriptionsField = NULL;
|
jfieldID multicastSubscriptionsField = NULL;
|
||||||
jfieldID assignedAddressesField = NULL;
|
jfieldID assignedAddressesField = NULL;
|
||||||
|
|
||||||
vnetConfigClass = env->FindClass("com/zerotierone/sdk/VirtualNetworkConfig");
|
vnetConfigClass = cache.findClass("com/zerotierone/sdk/VirtualNetworkConfig");
|
||||||
if(vnetConfigClass == NULL)
|
if(vnetConfigClass == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Couldn't find com.zerotierone.sdk.VirtualNetworkConfig");
|
LOGE("Couldn't find com.zerotierone.sdk.VirtualNetworkConfig");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
vnetConfig_constructor = env->GetMethodID(
|
vnetConfig_constructor = cache.findMethod(
|
||||||
vnetConfigClass, "<init>", "()V");
|
vnetConfigClass, "<init>", "()V");
|
||||||
if(vnetConfig_constructor == NULL)
|
if(vnetConfig_constructor == NULL)
|
||||||
{
|
{
|
||||||
@ -662,98 +658,98 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nwidField = env->GetFieldID(vnetConfigClass, "nwid", "J");
|
nwidField = cache.findField(vnetConfigClass, "nwid", "J");
|
||||||
if(nwidField == NULL)
|
if(nwidField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting nwid field");
|
LOGE("Error getting nwid field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
macField = env->GetFieldID(vnetConfigClass, "mac", "J");
|
macField = cache.findField(vnetConfigClass, "mac", "J");
|
||||||
if(macField == NULL)
|
if(macField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting mac field");
|
LOGE("Error getting mac field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nameField = env->GetFieldID(vnetConfigClass, "name", "Ljava/lang/String;");
|
nameField = cache.findField(vnetConfigClass, "name", "Ljava/lang/String;");
|
||||||
if(nameField == NULL)
|
if(nameField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting name field");
|
LOGE("Error getting name field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
statusField = env->GetFieldID(vnetConfigClass, "status", "Lcom/zerotierone/sdk/VirtualNetworkStatus;");
|
statusField = cache.findField(vnetConfigClass, "status", "Lcom/zerotierone/sdk/VirtualNetworkStatus;");
|
||||||
if(statusField == NULL)
|
if(statusField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting status field");
|
LOGE("Error getting status field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
typeField = env->GetFieldID(vnetConfigClass, "type", "Lcom/zerotierone/sdk/VirtualNetworkType;");
|
typeField = cache.findField(vnetConfigClass, "type", "Lcom/zerotierone/sdk/VirtualNetworkType;");
|
||||||
if(typeField == NULL)
|
if(typeField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting type field");
|
LOGE("Error getting type field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mtuField = env->GetFieldID(vnetConfigClass, "mtu", "I");
|
mtuField = cache.findField(vnetConfigClass, "mtu", "I");
|
||||||
if(mtuField == NULL)
|
if(mtuField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting mtu field");
|
LOGE("Error getting mtu field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dhcpField = env->GetFieldID(vnetConfigClass, "dhcp", "Z");
|
dhcpField = cache.findField(vnetConfigClass, "dhcp", "Z");
|
||||||
if(dhcpField == NULL)
|
if(dhcpField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting dhcp field");
|
LOGE("Error getting dhcp field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bridgeField = env->GetFieldID(vnetConfigClass, "bridge", "Z");
|
bridgeField = cache.findField(vnetConfigClass, "bridge", "Z");
|
||||||
if(bridgeField == NULL)
|
if(bridgeField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting bridge field");
|
LOGE("Error getting bridge field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcastEnabledField = env->GetFieldID(vnetConfigClass, "broadcastEnabled", "Z");
|
broadcastEnabledField = cache.findField(vnetConfigClass, "broadcastEnabled", "Z");
|
||||||
if(broadcastEnabledField == NULL)
|
if(broadcastEnabledField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting broadcastEnabled field");
|
LOGE("Error getting broadcastEnabled field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
portErrorField = env->GetFieldID(vnetConfigClass, "portError", "I");
|
portErrorField = cache.findField(vnetConfigClass, "portError", "I");
|
||||||
if(portErrorField == NULL)
|
if(portErrorField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting portError field");
|
LOGE("Error getting portError field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
enabledField = env->GetFieldID(vnetConfigClass, "enabled", "Z");
|
enabledField = cache.findField(vnetConfigClass, "enabled", "Z");
|
||||||
if(enabledField == NULL)
|
if(enabledField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting enabled field");
|
LOGE("Error getting enabled field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
netconfRevisionField = env->GetFieldID(vnetConfigClass, "netconfRevision", "J");
|
netconfRevisionField = cache.findField(vnetConfigClass, "netconfRevision", "J");
|
||||||
if(netconfRevisionField == NULL)
|
if(netconfRevisionField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting netconfRevision field");
|
LOGE("Error getting netconfRevision field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
multicastSubscriptionsField = env->GetFieldID(vnetConfigClass, "multicastSubscriptions", "Ljava/util/ArrayList;");
|
multicastSubscriptionsField = cache.findField(vnetConfigClass, "multicastSubscriptions", "Ljava/util/ArrayList;");
|
||||||
if(multicastSubscriptionsField == NULL)
|
if(multicastSubscriptionsField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting multicastSubscriptions field");
|
LOGE("Error getting multicastSubscriptions field");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
assignedAddressesField = env->GetFieldID(vnetConfigClass, "assignedAddresses", "Ljava/util/ArrayList;");
|
assignedAddressesField = cache.findField(vnetConfigClass, "assignedAddresses", "Ljava/util/ArrayList;");
|
||||||
if(assignedAddressesField == NULL)
|
if(assignedAddressesField == NULL)
|
||||||
{
|
{
|
||||||
LOGE("Error getting assignedAddresses field");
|
LOGE("Error getting assignedAddresses field");
|
||||||
@ -817,13 +813,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 = env->FindClass("com/zerotierone/sdk/Version");
|
versionClass = cache.findClass("com/zerotierone/sdk/Version");
|
||||||
if(versionClass == NULL)
|
if(versionClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionConstructor = env->GetMethodID(
|
versionConstructor = cache.findMethod(
|
||||||
versionClass, "<init>", "()V");
|
versionClass, "<init>", "()V");
|
||||||
if(versionConstructor == NULL)
|
if(versionConstructor == NULL)
|
||||||
{
|
{
|
||||||
@ -842,25 +838,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 = env->GetFieldID(versionClass, "major", "I");
|
majorField = cache.findField(versionClass, "major", "I");
|
||||||
if(majorField == NULL)
|
if(majorField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
minorField = env->GetFieldID(versionClass, "minor", "I");
|
minorField = cache.findField(versionClass, "minor", "I");
|
||||||
if(minorField == NULL)
|
if(minorField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
revisionField = env->GetFieldID(versionClass, "revision", "I");
|
revisionField = cache.findField(versionClass, "revision", "I");
|
||||||
if(revisionField == NULL)
|
if(revisionField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
featureFlagsField = env->GetFieldID(versionClass, "featureFlags", "J");
|
featureFlagsField = cache.findField(versionClass, "featureFlags", "J");
|
||||||
if(featureFlagsField == NULL)
|
if(featureFlagsField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -36,13 +36,13 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
// global static JNI Cache Object
|
||||||
|
JniCache cache;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// global static JNI Cache Object
|
|
||||||
static JniCache cache;
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct JniRef
|
struct JniRef
|
||||||
{
|
{
|
||||||
@ -103,7 +103,7 @@ namespace {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID configListenerCallbackMethod = env->GetMethodID(configListenerClass,
|
jmethodID configListenerCallbackMethod = cache.findMethod(configListenerClass,
|
||||||
"onNetworkConfigurationUpdated",
|
"onNetworkConfigurationUpdated",
|
||||||
"(JLcom/zerotierone/sdk/VirtualNetworkConfigOperation;Lcom/zerotierone/sdk/VirtualNetworkConfig;)I");
|
"(JLcom/zerotierone/sdk/VirtualNetworkConfigOperation;Lcom/zerotierone/sdk/VirtualNetworkConfig;)I");
|
||||||
if(configListenerCallbackMethod == NULL)
|
if(configListenerCallbackMethod == NULL)
|
||||||
@ -154,7 +154,7 @@ namespace {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID frameListenerCallbackMethod = env->GetMethodID(
|
jmethodID frameListenerCallbackMethod = cache.findMethod(
|
||||||
frameListenerClass,
|
frameListenerClass,
|
||||||
"onVirtualNetworkFrame", "(JJJJJ[B)V");
|
"onVirtualNetworkFrame", "(JJJJJ[B)V");
|
||||||
if(frameListenerCallbackMethod == NULL)
|
if(frameListenerCallbackMethod == NULL)
|
||||||
@ -185,7 +185,7 @@ namespace {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID onEventMethod = env->GetMethodID(eventListenerClass,
|
jmethodID onEventMethod = cache.findMethod(eventListenerClass,
|
||||||
"onEvent", "(Lcom/zerotierone/sdk/Event;)V");
|
"onEvent", "(Lcom/zerotierone/sdk/Event;)V");
|
||||||
if(onEventMethod == NULL)
|
if(onEventMethod == NULL)
|
||||||
{
|
{
|
||||||
@ -194,7 +194,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
jmethodID onOutOfDateMethod = env->GetMethodID(eventListenerClass,
|
jmethodID onOutOfDateMethod = cache.findMethod(eventListenerClass,
|
||||||
"onOutOfDate", "(Lcom/zerotierone/sdk/Version;)V");
|
"onOutOfDate", "(Lcom/zerotierone/sdk/Version;)V");
|
||||||
if(onOutOfDateMethod == NULL)
|
if(onOutOfDateMethod == NULL)
|
||||||
{
|
{
|
||||||
@ -203,7 +203,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
jmethodID onNetworkErrorMethod = env->GetMethodID(eventListenerClass,
|
jmethodID onNetworkErrorMethod = cache.findMethod(eventListenerClass,
|
||||||
"onNetworkError", "(Lcom/zerotierone/sdk/Event;Ljava/net/InetSocketAddress;)V");
|
"onNetworkError", "(Lcom/zerotierone/sdk/Event;Ljava/net/InetSocketAddress;)V");
|
||||||
if(onNetworkErrorMethod == NULL)
|
if(onNetworkErrorMethod == NULL)
|
||||||
{
|
{
|
||||||
@ -212,7 +212,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
jmethodID onTraceMethod = env->GetMethodID(eventListenerClass,
|
jmethodID onTraceMethod = cache.findMethod(eventListenerClass,
|
||||||
"onTrace", "(Ljava/lang/String;)V");
|
"onTrace", "(Ljava/lang/String;)V");
|
||||||
if(onTraceMethod == NULL)
|
if(onTraceMethod == NULL)
|
||||||
{
|
{
|
||||||
@ -292,7 +292,7 @@ namespace {
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID dataStoreGetCallbackMethod = env->GetMethodID(
|
jmethodID dataStoreGetCallbackMethod = cache.findMethod(
|
||||||
dataStoreGetClass,
|
dataStoreGetClass,
|
||||||
"onDataStoreGet",
|
"onDataStoreGet",
|
||||||
"(Ljava/lang/String;[BJ[J)J");
|
"(Ljava/lang/String;[BJ[J)J");
|
||||||
@ -361,7 +361,7 @@ namespace {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID dataStorePutCallbackMethod = env->GetMethodID(
|
jmethodID dataStorePutCallbackMethod = cache.findMethod(
|
||||||
dataStorePutClass,
|
dataStorePutClass,
|
||||||
"onDataStorePut",
|
"onDataStorePut",
|
||||||
"(Ljava/lang/String;[BZ)I");
|
"(Ljava/lang/String;[BZ)I");
|
||||||
@ -371,7 +371,7 @@ namespace {
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID deleteMethod = env->GetMethodID(dataStorePutClass,
|
jmethodID deleteMethod = cache.findMethod(dataStorePutClass,
|
||||||
"onDelete", "(Ljava/lang/String;)I");
|
"onDelete", "(Ljava/lang/String;)I");
|
||||||
if(deleteMethod == NULL)
|
if(deleteMethod == NULL)
|
||||||
{
|
{
|
||||||
@ -421,7 +421,7 @@ namespace {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID packetSenderCallbackMethod = env->GetMethodID(packetSenderClass,
|
jmethodID packetSenderCallbackMethod = cache.findMethod(packetSenderClass,
|
||||||
"onSendPacketRequested", "(Ljava/net/InetSocketAddress;I[B)I");
|
"onSendPacketRequested", "(Ljava/net/InetSocketAddress;I[B)I");
|
||||||
if(packetSenderCallbackMethod == NULL)
|
if(packetSenderCallbackMethod == NULL)
|
||||||
{
|
{
|
||||||
@ -479,7 +479,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init(
|
|||||||
env->GetJavaVM(&ref->jvm);
|
env->GetJavaVM(&ref->jvm);
|
||||||
|
|
||||||
jclass cls = env->GetObjectClass(obj);
|
jclass cls = env->GetObjectClass(obj);
|
||||||
jfieldID fid = env->GetFieldID(
|
jfieldID fid = cache.findField(
|
||||||
cls, "getListener", "Lcom/zerotierone/sdk/DataStoreGetListener;");
|
cls, "getListener", "Lcom/zerotierone/sdk/DataStoreGetListener;");
|
||||||
|
|
||||||
if(fid == NULL)
|
if(fid == NULL)
|
||||||
@ -494,7 +494,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init(
|
|||||||
}
|
}
|
||||||
ref->dataStoreGetListener = env->NewGlobalRef(tmp);
|
ref->dataStoreGetListener = env->NewGlobalRef(tmp);
|
||||||
|
|
||||||
fid = env->GetFieldID(
|
fid = cache.findField(
|
||||||
cls, "putListener", "Lcom/zerotierone/sdk/DataStorePutListener;");
|
cls, "putListener", "Lcom/zerotierone/sdk/DataStorePutListener;");
|
||||||
|
|
||||||
if(fid == NULL)
|
if(fid == NULL)
|
||||||
@ -509,7 +509,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init(
|
|||||||
}
|
}
|
||||||
ref->dataStorePutListener = env->NewGlobalRef(tmp);
|
ref->dataStorePutListener = env->NewGlobalRef(tmp);
|
||||||
|
|
||||||
fid = env->GetFieldID(
|
fid = cache.findField(
|
||||||
cls, "sender", "Lcom/zerotierone/sdk/PacketSender;");
|
cls, "sender", "Lcom/zerotierone/sdk/PacketSender;");
|
||||||
if(fid == NULL)
|
if(fid == NULL)
|
||||||
{
|
{
|
||||||
@ -523,7 +523,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init(
|
|||||||
}
|
}
|
||||||
ref->packetSender = env->NewGlobalRef(tmp);
|
ref->packetSender = env->NewGlobalRef(tmp);
|
||||||
|
|
||||||
fid = env->GetFieldID(
|
fid = cache.findField(
|
||||||
cls, "frameListener", "Lcom/zerotierone/sdk/VirtualNetworkFrameListener;");
|
cls, "frameListener", "Lcom/zerotierone/sdk/VirtualNetworkFrameListener;");
|
||||||
if(fid == NULL)
|
if(fid == NULL)
|
||||||
{
|
{
|
||||||
@ -537,7 +537,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init(
|
|||||||
}
|
}
|
||||||
ref->frameListener = env->NewGlobalRef(tmp);
|
ref->frameListener = env->NewGlobalRef(tmp);
|
||||||
|
|
||||||
fid = env->GetFieldID(
|
fid = cache.findField(
|
||||||
cls, "configListener", "Lcom/zerotierone/sdk/VirtualNetworkConfigListener;");
|
cls, "configListener", "Lcom/zerotierone/sdk/VirtualNetworkConfigListener;");
|
||||||
if(fid == NULL)
|
if(fid == NULL)
|
||||||
{
|
{
|
||||||
@ -551,7 +551,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init(
|
|||||||
}
|
}
|
||||||
ref->configListener = env->NewGlobalRef(tmp);
|
ref->configListener = env->NewGlobalRef(tmp);
|
||||||
|
|
||||||
fid = env->GetFieldID(
|
fid = cache.findField(
|
||||||
cls, "eventListener", "Lcom/zerotierone/sdk/EventListener;");
|
cls, "eventListener", "Lcom/zerotierone/sdk/EventListener;");
|
||||||
if(fid == NULL)
|
if(fid == NULL)
|
||||||
{
|
{
|
||||||
@ -722,14 +722,14 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processWirePacket(
|
|||||||
unsigned int linkDesparation = (unsigned int)in_linkDesparation;
|
unsigned int linkDesparation = (unsigned int)in_linkDesparation;
|
||||||
|
|
||||||
// get the java.net.InetSocketAddress class and getAddress() method
|
// get the java.net.InetSocketAddress class and getAddress() method
|
||||||
jclass inetAddressClass = env->FindClass("java/net/InetAddress");
|
jclass inetAddressClass = cache.findClass("java/net/InetAddress");
|
||||||
if(inetAddressClass == NULL)
|
if(inetAddressClass == NULL)
|
||||||
{
|
{
|
||||||
// can't find java.net.InetAddress
|
// can't find java.net.InetAddress
|
||||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID getAddressMethod = env->GetMethodID(
|
jmethodID getAddressMethod = cache.findMethod(
|
||||||
inetAddressClass, "getAddress", "()[B");
|
inetAddressClass, "getAddress", "()[B");
|
||||||
if(getAddressMethod == NULL)
|
if(getAddressMethod == NULL)
|
||||||
{
|
{
|
||||||
@ -737,13 +737,13 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processWirePacket(
|
|||||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass InetSocketAddressClass = env->FindClass("java/net/InetSocketAddress");
|
jclass InetSocketAddressClass = cache.findClass("java/net/InetSocketAddress");
|
||||||
if(InetSocketAddressClass == NULL)
|
if(InetSocketAddressClass == NULL)
|
||||||
{
|
{
|
||||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
jmethodID inetSockGetAddressMethod = env->GetMethodID(
|
jmethodID inetSockGetAddressMethod = cache.findMethod(
|
||||||
InetSocketAddressClass, "getAddress", "()Ljava/net/InetAddress;");
|
InetSocketAddressClass, "getAddress", "()Ljava/net/InetAddress;");
|
||||||
|
|
||||||
jobject addrObject = env->CallObjectMethod(in_remoteAddress, inetSockGetAddressMethod);
|
jobject addrObject = env->CallObjectMethod(in_remoteAddress, inetSockGetAddressMethod);
|
||||||
@ -951,7 +951,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastUnsubscribe(
|
|||||||
|
|
||||||
uint64_t nwid = (uint64_t)in_nwid;
|
uint64_t nwid = (uint64_t)in_nwid;
|
||||||
uint64_t multicastGroup = (uint64_t)in_multicastGroup;
|
uint64_t multicastGroup = (uint64_t)in_multicastGroup;
|
||||||
uint64_t multicastAdi = (uint64_t)in_multicastAdi;
|
unsigned long multicastAdi = (unsigned long)in_multicastAdi;
|
||||||
|
|
||||||
ZT1_ResultCode rc = ZT1_Node_multicastUnsubscribe(
|
ZT1_ResultCode rc = ZT1_Node_multicastUnsubscribe(
|
||||||
node, nwid, multicastGroup, multicastAdi);
|
node, nwid, multicastGroup, multicastAdi);
|
||||||
@ -999,13 +999,13 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_status
|
|||||||
jmethodID nodeStatusConstructor = NULL;
|
jmethodID nodeStatusConstructor = NULL;
|
||||||
|
|
||||||
// create a com.zerotierone.sdk.NodeStatus object
|
// create a com.zerotierone.sdk.NodeStatus object
|
||||||
nodeStatusClass = env->FindClass("com/zerotierone/sdk/NodeStatus");
|
nodeStatusClass = cache.findClass("com/zerotierone/sdk/NodeStatus");
|
||||||
if(nodeStatusClass == NULL)
|
if(nodeStatusClass == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeStatusConstructor = env->GetMethodID(
|
nodeStatusConstructor = cache.findMethod(
|
||||||
nodeStatusClass, "<init>", "()V");
|
nodeStatusClass, "<init>", "()V");
|
||||||
if(nodeStatusConstructor == NULL)
|
if(nodeStatusConstructor == NULL)
|
||||||
{
|
{
|
||||||
@ -1026,25 +1026,25 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_status
|
|||||||
jfieldID secretIdentityField = NULL;
|
jfieldID secretIdentityField = NULL;
|
||||||
jfieldID onlineField = NULL;
|
jfieldID onlineField = NULL;
|
||||||
|
|
||||||
addressField = env->GetFieldID(nodeStatusClass, "address", "J");
|
addressField = cache.findField(nodeStatusClass, "address", "J");
|
||||||
if(addressField == NULL)
|
if(addressField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
publicIdentityField = env->GetFieldID(nodeStatusClass, "publicIdentity", "Ljava/lang/String;");
|
publicIdentityField = cache.findField(nodeStatusClass, "publicIdentity", "Ljava/lang/String;");
|
||||||
if(publicIdentityField == NULL)
|
if(publicIdentityField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
secretIdentityField = env->GetFieldID(nodeStatusClass, "secretIdentity", "Ljava/lang/String;");
|
secretIdentityField = cache.findField(nodeStatusClass, "secretIdentity", "Ljava/lang/String;");
|
||||||
if(secretIdentityField == NULL)
|
if(secretIdentityField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
onlineField = env->GetFieldID(nodeStatusClass, "online", "Z");
|
onlineField = cache.findField(nodeStatusClass, "online", "Z");
|
||||||
if(onlineField == NULL)
|
if(onlineField == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user