(1) Make ZT_ naming convention consistent (get rid of ZT1_), (2) Make local interface a full sockaddr_storage instead of an int identifier, which turns out to be better for multi-homing and other uses.
This commit is contained in:
parent
0e5aac6a11
commit
f69454ec98
29 changed files with 622 additions and 622 deletions
|
@ -26,8 +26,8 @@
|
|||
*/
|
||||
|
||||
#include "com_zerotierone_sdk_Node.h"
|
||||
#include "ZT1_jniutils.h"
|
||||
#include "ZT1_jnicache.h"
|
||||
#include "ZT_jniutils.h"
|
||||
#include "ZT_jnicache.h"
|
||||
|
||||
#include <ZeroTierOne.h>
|
||||
|
||||
|
@ -74,7 +74,7 @@ namespace {
|
|||
|
||||
JavaVM *jvm;
|
||||
|
||||
ZT1_Node *node;
|
||||
ZT_Node *node;
|
||||
|
||||
jobject dataStoreGetListener;
|
||||
jobject dataStorePutListener;
|
||||
|
@ -86,11 +86,11 @@ namespace {
|
|||
|
||||
|
||||
int VirtualNetworkConfigFunctionCallback(
|
||||
ZT1_Node *node,
|
||||
ZT_Node *node,
|
||||
void *userData,
|
||||
uint64_t nwid,
|
||||
enum ZT1_VirtualNetworkConfigOperation operation,
|
||||
const ZT1_VirtualNetworkConfig *config)
|
||||
enum ZT_VirtualNetworkConfigOperation operation,
|
||||
const ZT_VirtualNetworkConfig *config)
|
||||
{
|
||||
LOGD("VritualNetworkConfigFunctionCallback");
|
||||
JniRef *ref = (JniRef*)userData;
|
||||
|
@ -133,7 +133,7 @@ namespace {
|
|||
(jlong)nwid, operationObject, networkConfigObject);
|
||||
}
|
||||
|
||||
void VirtualNetworkFrameFunctionCallback(ZT1_Node *node,void *userData,
|
||||
void VirtualNetworkFrameFunctionCallback(ZT_Node *node,void *userData,
|
||||
uint64_t nwid,
|
||||
uint64_t sourceMac,
|
||||
uint64_t destMac,
|
||||
|
@ -186,7 +186,7 @@ namespace {
|
|||
}
|
||||
|
||||
|
||||
void EventCallback(ZT1_Node *node,void *userData,enum ZT1_Event event, const void *data)
|
||||
void EventCallback(ZT_Node *node,void *userData,enum ZT_Event event, const void *data)
|
||||
{
|
||||
LOGD("EventCallback");
|
||||
JniRef *ref = (JniRef*)userData;
|
||||
|
@ -245,18 +245,18 @@ namespace {
|
|||
|
||||
switch(event)
|
||||
{
|
||||
case ZT1_EVENT_UP:
|
||||
case ZT1_EVENT_OFFLINE:
|
||||
case ZT1_EVENT_ONLINE:
|
||||
case ZT1_EVENT_DOWN:
|
||||
case ZT1_EVENT_FATAL_ERROR_IDENTITY_COLLISION:
|
||||
case ZT_EVENT_UP:
|
||||
case ZT_EVENT_OFFLINE:
|
||||
case ZT_EVENT_ONLINE:
|
||||
case ZT_EVENT_DOWN:
|
||||
case ZT_EVENT_FATAL_ERROR_IDENTITY_COLLISION:
|
||||
{
|
||||
LOGV("Regular Event");
|
||||
// call onEvent()
|
||||
env->CallVoidMethod(ref->eventListener, onEventMethod, eventObject);
|
||||
}
|
||||
break;
|
||||
case ZT1_EVENT_SAW_MORE_RECENT_VERSION:
|
||||
case ZT_EVENT_SAW_MORE_RECENT_VERSION:
|
||||
{
|
||||
LOGV("Version Event");
|
||||
// call onOutOfDate()
|
||||
|
@ -268,8 +268,8 @@ namespace {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case ZT1_EVENT_AUTHENTICATION_FAILURE:
|
||||
case ZT1_EVENT_INVALID_PACKET:
|
||||
case ZT_EVENT_AUTHENTICATION_FAILURE:
|
||||
case ZT_EVENT_INVALID_PACKET:
|
||||
{
|
||||
LOGV("Network Error Event");
|
||||
// call onNetworkError()
|
||||
|
@ -281,7 +281,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case ZT1_EVENT_TRACE:
|
||||
case ZT_EVENT_TRACE:
|
||||
{
|
||||
LOGV("Trace Event");
|
||||
// call onTrace()
|
||||
|
@ -296,7 +296,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
long DataStoreGetFunction(ZT1_Node *node,void *userData,
|
||||
long DataStoreGetFunction(ZT_Node *node,void *userData,
|
||||
const char *objectName,
|
||||
void *buffer,
|
||||
unsigned long bufferSize,
|
||||
|
@ -368,7 +368,7 @@ namespace {
|
|||
return retval;
|
||||
}
|
||||
|
||||
int DataStorePutFunction(ZT1_Node *node,void *userData,
|
||||
int DataStorePutFunction(ZT_Node *node,void *userData,
|
||||
const char *objectName,
|
||||
const void *buffer,
|
||||
unsigned long bufferSize,
|
||||
|
@ -426,7 +426,7 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
int WirePacketSendFunction(ZT1_Node *node,void *userData,\
|
||||
int WirePacketSendFunction(ZT_Node *node,void *userData,\
|
||||
const struct sockaddr_storage *address,
|
||||
const void *buffer,
|
||||
unsigned int bufferSize)
|
||||
|
@ -466,7 +466,7 @@ namespace {
|
|||
typedef std::map<uint64_t, JniRef*> NodeMap;
|
||||
static NodeMap nodeMap;
|
||||
|
||||
ZT1_Node* findNode(uint64_t nodeId)
|
||||
ZT_Node* findNode(uint64_t nodeId)
|
||||
{
|
||||
NodeMap::iterator found = nodeMap.find(nodeId);
|
||||
if(found != nodeMap.end())
|
||||
|
@ -498,10 +498,10 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
|
|||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init(
|
||||
JNIEnv *env, jobject obj, jlong now)
|
||||
{
|
||||
LOGV("Creating ZT1_Node struct");
|
||||
jobject resultObject = createResultObject(env, ZT1_RESULT_OK);
|
||||
LOGV("Creating ZT_Node struct");
|
||||
jobject resultObject = createResultObject(env, ZT_RESULT_OK);
|
||||
|
||||
ZT1_Node *node;
|
||||
ZT_Node *node;
|
||||
JniRef *ref = new JniRef;
|
||||
ref->id = (uint64_t)now;
|
||||
env->GetJavaVM(&ref->jvm);
|
||||
|
@ -593,7 +593,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init(
|
|||
}
|
||||
ref->eventListener = env->NewGlobalRef(tmp);
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_new(
|
||||
ZT_ResultCode rc = ZT_Node_new(
|
||||
&node,
|
||||
ref,
|
||||
(uint64_t)now,
|
||||
|
@ -604,13 +604,13 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init(
|
|||
&VirtualNetworkConfigFunctionCallback,
|
||||
&EventCallback);
|
||||
|
||||
if(rc != ZT1_RESULT_OK)
|
||||
if(rc != ZT_RESULT_OK)
|
||||
{
|
||||
LOGE("Error creating Node: %d", rc);
|
||||
resultObject = createResultObject(env, rc);
|
||||
if(node)
|
||||
{
|
||||
ZT1_Node_delete(node);
|
||||
ZT_Node_delete(node);
|
||||
node = NULL;
|
||||
}
|
||||
delete ref;
|
||||
|
@ -632,7 +632,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init(
|
|||
JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete(
|
||||
JNIEnv *env, jobject obj, jlong id)
|
||||
{
|
||||
LOGV("Destroying ZT1_Node struct");
|
||||
LOGV("Destroying ZT_Node struct");
|
||||
uint64_t nodeId = (uint64_t)id;
|
||||
|
||||
NodeMap::iterator found = nodeMap.find(nodeId);
|
||||
|
@ -641,7 +641,7 @@ JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete(
|
|||
JniRef *ref = found->second;
|
||||
nodeMap.erase(found);
|
||||
|
||||
ZT1_Node_delete(ref->node);
|
||||
ZT_Node_delete(ref->node);
|
||||
|
||||
delete ref;
|
||||
ref = NULL;
|
||||
|
@ -671,18 +671,18 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame(
|
|||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
unsigned int nbtd_len = env->GetArrayLength(out_nextBackgroundTaskDeadline);
|
||||
if(nbtd_len < 1)
|
||||
{
|
||||
// array for next background task length has 0 elements!
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
uint64_t now = (uint64_t)in_now;
|
||||
|
@ -697,7 +697,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame(
|
|||
|
||||
uint64_t nextBackgroundTaskDeadline = 0;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_processVirtualNetworkFrame(
|
||||
ZT_ResultCode rc = ZT_Node_processVirtualNetworkFrame(
|
||||
node,
|
||||
now,
|
||||
nwid,
|
||||
|
@ -732,17 +732,17 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
jlongArray out_nextBackgroundTaskDeadline)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
unsigned int nbtd_len = env->GetArrayLength(out_nextBackgroundTaskDeadline);
|
||||
if(nbtd_len < 1)
|
||||
{
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
uint64_t now = (uint64_t)in_now;
|
||||
|
@ -752,7 +752,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
if(inetAddressClass == NULL)
|
||||
{
|
||||
// can't find java.net.InetAddress
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
jmethodID getAddressMethod = cache.findMethod(
|
||||
|
@ -760,13 +760,13 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
if(getAddressMethod == NULL)
|
||||
{
|
||||
// cant find InetAddress.getAddres()
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
jclass InetSocketAddressClass = cache.findClass("java/net/InetSocketAddress");
|
||||
if(InetSocketAddressClass == NULL)
|
||||
{
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
jmethodID inetSockGetAddressMethod = cache.findMethod(
|
||||
|
@ -776,7 +776,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
|
||||
if(addrObject == NULL)
|
||||
{
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
jmethodID inetSock_getPort = cache.findMethod(
|
||||
|
@ -785,7 +785,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
if(env->ExceptionCheck() || inetSock_getPort == NULL)
|
||||
{
|
||||
LOGE("Couldn't find getPort method on InetSocketAddress");
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
// call InetSocketAddress.getPort()
|
||||
|
@ -793,7 +793,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
if(env->ExceptionCheck())
|
||||
{
|
||||
LOGE("Exception calling InetSocketAddress.getPort()");
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
// Call InetAddress.getAddress()
|
||||
|
@ -801,7 +801,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
if(addressArray == NULL)
|
||||
{
|
||||
// unable to call getAddress()
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
unsigned int addrSize = env->GetArrayLength(addressArray);
|
||||
|
@ -833,7 +833,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
{
|
||||
// unknown address type
|
||||
env->ReleaseByteArrayElements(addressArray, addr, 0);
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -842,7 +842,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
|||
|
||||
uint64_t nextBackgroundTaskDeadline = 0;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_processWirePacket(
|
||||
ZT_ResultCode rc = ZT_Node_processWirePacket(
|
||||
node,
|
||||
now,
|
||||
&remoteAddress,
|
||||
|
@ -872,23 +872,23 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks(
|
|||
jlongArray out_nextBackgroundTaskDeadline)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
unsigned int nbtd_len = env->GetArrayLength(out_nextBackgroundTaskDeadline);
|
||||
if(nbtd_len < 1)
|
||||
{
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
uint64_t now = (uint64_t)in_now;
|
||||
uint64_t nextBackgroundTaskDeadline = 0;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_processBackgroundTasks(node, now, &nextBackgroundTaskDeadline);
|
||||
ZT_ResultCode rc = ZT_Node_processBackgroundTasks(node, now, &nextBackgroundTaskDeadline);
|
||||
|
||||
jlong *outDeadline = env->GetLongArrayElements(out_nextBackgroundTaskDeadline, NULL);
|
||||
outDeadline[0] = (jlong)nextBackgroundTaskDeadline;
|
||||
|
@ -906,16 +906,16 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_join(
|
|||
JNIEnv *env, jobject obj, jlong id, jlong in_nwid)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
uint64_t nwid = (uint64_t)in_nwid;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_join(node, nwid);
|
||||
ZT_ResultCode rc = ZT_Node_join(node, nwid);
|
||||
|
||||
return createResultObject(env, rc);
|
||||
}
|
||||
|
@ -929,16 +929,16 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave(
|
|||
JNIEnv *env, jobject obj, jlong id, jlong in_nwid)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
uint64_t nwid = (uint64_t)in_nwid;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_leave(node, nwid);
|
||||
ZT_ResultCode rc = ZT_Node_leave(node, nwid);
|
||||
|
||||
return createResultObject(env, rc);
|
||||
}
|
||||
|
@ -956,18 +956,18 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe(
|
|||
jlong in_multicastAdi)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
uint64_t nwid = (uint64_t)in_nwid;
|
||||
uint64_t multicastGroup = (uint64_t)in_multicastGroup;
|
||||
unsigned long multicastAdi = (unsigned long)in_multicastAdi;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_multicastSubscribe(
|
||||
ZT_ResultCode rc = ZT_Node_multicastSubscribe(
|
||||
node, nwid, multicastGroup, multicastAdi);
|
||||
|
||||
return createResultObject(env, rc);
|
||||
|
@ -986,18 +986,18 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastUnsubscribe(
|
|||
jlong in_multicastAdi)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
uint64_t nwid = (uint64_t)in_nwid;
|
||||
uint64_t multicastGroup = (uint64_t)in_multicastGroup;
|
||||
unsigned long multicastAdi = (unsigned long)in_multicastAdi;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_multicastUnsubscribe(
|
||||
ZT_ResultCode rc = ZT_Node_multicastUnsubscribe(
|
||||
node, nwid, multicastGroup, multicastAdi);
|
||||
|
||||
return createResultObject(env, rc);
|
||||
|
@ -1012,14 +1012,14 @@ JNIEXPORT jlong JNICALL Java_com_zerotier_sdk_Node_address(
|
|||
JNIEnv *env , jobject obj, jlong id)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t address = ZT1_Node_address(node);
|
||||
uint64_t address = ZT_Node_address(node);
|
||||
return (jlong)address;
|
||||
}
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status
|
|||
(JNIEnv *env, jobject obj, jlong id)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
|
@ -1062,8 +1062,8 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ZT1_NodeStatus nodeStatus;
|
||||
ZT1_Node_status(node, &nodeStatus);
|
||||
ZT_NodeStatus nodeStatus;
|
||||
ZT_Node_status(node, &nodeStatus);
|
||||
|
||||
jfieldID addressField = NULL;
|
||||
jfieldID publicIdentityField = NULL;
|
||||
|
@ -1124,18 +1124,18 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networkConfig(
|
|||
JNIEnv *env, jobject obj, jlong id, jlong nwid)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZT1_VirtualNetworkConfig *vnetConfig = ZT1_Node_networkConfig(node, nwid);
|
||||
ZT_VirtualNetworkConfig *vnetConfig = ZT_Node_networkConfig(node, nwid);
|
||||
|
||||
jobject vnetConfigObject = newNetworkConfig(env, *vnetConfig);
|
||||
|
||||
ZT1_Node_freeQueryResult(node, vnetConfig);
|
||||
ZT_Node_freeQueryResult(node, vnetConfig);
|
||||
|
||||
return vnetConfigObject;
|
||||
}
|
||||
|
@ -1153,7 +1153,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_version(
|
|||
int revision = 0;
|
||||
unsigned long featureFlags = 0;
|
||||
|
||||
ZT1_version(&major, &minor, &revision, &featureFlags);
|
||||
ZT_version(&major, &minor, &revision, &featureFlags);
|
||||
|
||||
return newVersion(env, major, minor, revision, featureFlags);
|
||||
}
|
||||
|
@ -1167,18 +1167,18 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers(
|
|||
JNIEnv *env, jobject obj, jlong id)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZT1_PeerList *peerList = ZT1_Node_peers(node);
|
||||
ZT_PeerList *peerList = ZT_Node_peers(node);
|
||||
|
||||
if(peerList == NULL)
|
||||
{
|
||||
LOGE("ZT1_Node_peers returned NULL");
|
||||
LOGE("ZT_Node_peers returned NULL");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1187,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers(
|
|||
if(env->EnsureLocalCapacity(peerCount))
|
||||
{
|
||||
LOGE("EnsureLocalCapacity failed!!");
|
||||
ZT1_Node_freeQueryResult(node, peerList);
|
||||
ZT_Node_freeQueryResult(node, peerList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1195,7 +1195,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers(
|
|||
if(env->ExceptionCheck() || peerClass == NULL)
|
||||
{
|
||||
LOGE("Error finding Peer class");
|
||||
ZT1_Node_freeQueryResult(node, peerList);
|
||||
ZT_Node_freeQueryResult(node, peerList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1205,7 +1205,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers(
|
|||
if(env->ExceptionCheck() || peerArrayObj == NULL)
|
||||
{
|
||||
LOGE("Error creating Peer[] array");
|
||||
ZT1_Node_freeQueryResult(node, peerList);
|
||||
ZT_Node_freeQueryResult(node, peerList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1221,7 +1221,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers(
|
|||
}
|
||||
}
|
||||
|
||||
ZT1_Node_freeQueryResult(node, peerList);
|
||||
ZT_Node_freeQueryResult(node, peerList);
|
||||
peerList = NULL;
|
||||
|
||||
return peerArrayObj;
|
||||
|
@ -1236,14 +1236,14 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_networks(
|
|||
JNIEnv *env, jobject obj, jlong id)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
ZT1_Node *node = findNode(nodeId);
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
// cannot find valid node. We should never get here.
|
||||
return 0;
|
||||
}
|
||||
|
||||
ZT1_VirtualNetworkList *networkList = ZT1_Node_networks(node);
|
||||
ZT_VirtualNetworkList *networkList = ZT_Node_networks(node);
|
||||
if(networkList == NULL)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -1253,7 +1253,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_networks(
|
|||
if(env->ExceptionCheck() || vnetConfigClass == NULL)
|
||||
{
|
||||
LOGE("Error finding VirtualNetworkConfig class");
|
||||
ZT1_Node_freeQueryResult(node, networkList);
|
||||
ZT_Node_freeQueryResult(node, networkList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1262,7 +1262,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_networks(
|
|||
if(env->ExceptionCheck() || networkListObject == NULL)
|
||||
{
|
||||
LOGE("Error creating VirtualNetworkConfig[] array");
|
||||
ZT1_Node_freeQueryResult(node, networkList);
|
||||
ZT_Node_freeQueryResult(node, networkList);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1277,7 +1277,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_networks(
|
|||
}
|
||||
}
|
||||
|
||||
ZT1_Node_freeQueryResult(node, networkList);
|
||||
ZT_Node_freeQueryResult(node, networkList);
|
||||
|
||||
return networkListObject;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue