summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2015-09-26 13:47:55 -0700
committerGrant Limberg <glimberg@gmail.com>2015-09-26 13:47:55 -0700
commite8cdff3eafd8096da22122eabddf57a09fe2bb90 (patch)
treed231aa6d9ccccc8ced6e1ead606ce16ff551cab9 /java
parent53d98343b7b444508259f6f1643e8d6724fb11e9 (diff)
parentf69454ec9879a0b0a424f743ca144d1123ef7e99 (diff)
downloadinfinitytier-e8cdff3eafd8096da22122eabddf57a09fe2bb90.tar.gz
infinitytier-e8cdff3eafd8096da22122eabddf57a09fe2bb90.zip
Merge branch 'adamierymenko-dev' into android-jni-dev
also update for changed function calls that now accept a local address # Conflicts: # include/ZeroTierOne.h # java/CMakeLists.txt # java/jni/Android.mk # java/jni/ZT1_jnicache.cpp # java/jni/ZT1_jnilookup.h # java/jni/ZT1_jniutils.cpp # java/jni/com_zerotierone_sdk_Node.cpp
Diffstat (limited to 'java')
-rw-r--r--java/CMakeLists.txt4
-rw-r--r--java/jni/Android.mk4
-rw-r--r--java/jni/ZT_jnilookup.cpp (renamed from java/jni/ZT1_jnilookup.cpp)4
-rw-r--r--java/jni/ZT_jnilookup.h (renamed from java/jni/ZT1_jnilookup.h)4
-rw-r--r--java/jni/ZT_jniutils.cpp (renamed from java/jni/ZT1_jniutils.cpp)88
-rw-r--r--java/jni/ZT_jniutils.h (renamed from java/jni/ZT1_jniutils.h)24
-rw-r--r--java/jni/com_zerotierone_sdk_Node.cpp261
-rw-r--r--java/jni/com_zerotierone_sdk_Node.h4
-rw-r--r--java/src/com/zerotier/sdk/Node.java4
-rw-r--r--java/src/com/zerotier/sdk/VirtualNetworkConfig.java2
10 files changed, 226 insertions, 173 deletions
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index 484517f8..008b747b 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -53,8 +53,8 @@ set(src_files
../osdep/Http.cpp
../osdep/OSUtils.cpp
jni/com_zerotierone_sdk_Node.cpp
- jni/ZT1_jniutils.cpp
- jni/ZT1_jnilookup.cpp
+ jni/ZT_jniutils.cpp
+ jni/ZT_jnicache.cpp
)
set(include_dirs
diff --git a/java/jni/Android.mk b/java/jni/Android.mk
index 56e6fb80..22dfe4f1 100644
--- a/java/jni/Android.mk
+++ b/java/jni/Android.mk
@@ -40,7 +40,7 @@ LOCAL_SRC_FILES := \
# JNI Files
LOCAL_SRC_FILES += \
com_zerotierone_sdk_Node.cpp \
- ZT1_jniutils.cpp \
- ZT1_jnilookup.cpp
+ ZT_jniutils.cpp \
+ ZT_jnilookup.cpp
include $(BUILD_SHARED_LIBRARY) \ No newline at end of file
diff --git a/java/jni/ZT1_jnilookup.cpp b/java/jni/ZT_jnilookup.cpp
index d8f5cc7f..be52a366 100644
--- a/java/jni/ZT1_jnilookup.cpp
+++ b/java/jni/ZT_jnilookup.cpp
@@ -25,8 +25,8 @@
* LLC. Start here: http://www.zerotier.com/
*/
-#include "ZT1_jnilookup.h"
-#include "ZT1_jniutils.h"
+#include "ZT_jnilookup.h"
+#include "ZT_jniutils.h"
JniLookup::JniLookup()
: m_jvm(NULL)
diff --git a/java/jni/ZT1_jnilookup.h b/java/jni/ZT_jnilookup.h
index cf496f88..f5bd97d7 100644
--- a/java/jni/ZT1_jnilookup.h
+++ b/java/jni/ZT_jnilookup.h
@@ -25,8 +25,8 @@
* LLC. Start here: http://www.zerotier.com/
*/
-#ifndef ZT1_JNILOOKUP_H_
-#define ZT1_JNILOOKUP_H_
+#ifndef ZT_JNILOOKUP_H_
+#define ZT_JNILOOKUP_H_
#include <jni.h>
#include <map>
diff --git a/java/jni/ZT1_jniutils.cpp b/java/jni/ZT_jniutils.cpp
index 90f3bb84..bd8d8708 100644
--- a/java/jni/ZT1_jniutils.cpp
+++ b/java/jni/ZT_jniutils.cpp
@@ -1,5 +1,5 @@
-#include "ZT1_jniutils.h"
-#include "ZT1_jnilookup.h"
+#include "ZT_jniutils.h"
+#include "ZT_jnilookup.h"
#include <string>
#include <assert.h>
@@ -9,7 +9,7 @@ extern JniLookup lookup;
extern "C" {
#endif
-jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
+jobject createResultObject(JNIEnv *env, ZT_ResultCode code)
{
jclass resultClass = NULL;
@@ -25,23 +25,23 @@ jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
std::string fieldName;
switch(code)
{
- case ZT1_RESULT_OK:
- LOGV("ZT1_RESULT_OK");
+ case ZT_RESULT_OK:
+ LOGV("ZT_RESULT_OK");
fieldName = "RESULT_OK";
break;
- case ZT1_RESULT_FATAL_ERROR_OUT_OF_MEMORY:
- LOGV("ZT1_RESULT_FATAL_ERROR_OUT_OF_MEMORY");
+ case ZT_RESULT_FATAL_ERROR_OUT_OF_MEMORY:
+ LOGV("ZT_RESULT_FATAL_ERROR_OUT_OF_MEMORY");
fieldName = "RESULT_FATAL_ERROR_OUT_OF_MEMORY";
break;
- case ZT1_RESULT_FATAL_ERROR_DATA_STORE_FAILED:
+ case ZT_RESULT_FATAL_ERROR_DATA_STORE_FAILED:
LOGV("RESULT_FATAL_ERROR_DATA_STORE_FAILED");
fieldName = "RESULT_FATAL_ERROR_DATA_STORE_FAILED";
break;
- case ZT1_RESULT_ERROR_NETWORK_NOT_FOUND:
+ case ZT_RESULT_ERROR_NETWORK_NOT_FOUND:
LOGV("RESULT_FATAL_ERROR_DATA_STORE_FAILED");
fieldName = "RESULT_ERROR_NETWORK_NOT_FOUND";
break;
- case ZT1_RESULT_FATAL_ERROR_INTERNAL:
+ case ZT_RESULT_FATAL_ERROR_INTERNAL:
default:
LOGV("RESULT_FATAL_ERROR_DATA_STORE_FAILED");
fieldName = "RESULT_FATAL_ERROR_INTERNAL";
@@ -64,7 +64,7 @@ jobject createResultObject(JNIEnv *env, ZT1_ResultCode code)
}
-jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status)
+jobject createVirtualNetworkStatus(JNIEnv *env, ZT_VirtualNetworkStatus status)
{
jobject statusObject = NULL;
@@ -77,22 +77,22 @@ jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status)
std::string fieldName;
switch(status)
{
- case ZT1_NETWORK_STATUS_REQUESTING_CONFIGURATION:
+ case ZT_NETWORK_STATUS_REQUESTING_CONFIGURATION:
fieldName = "NETWORK_STATUS_REQUESTING_CONFIGURATION";
break;
- case ZT1_NETWORK_STATUS_OK:
+ case ZT_NETWORK_STATUS_OK:
fieldName = "NETWORK_STATUS_OK";
break;
- case ZT1_NETWORK_STATUS_ACCESS_DENIED:
+ case ZT_NETWORK_STATUS_ACCESS_DENIED:
fieldName = "NETWORK_STATUS_ACCESS_DENIED";
break;
- case ZT1_NETWORK_STATUS_NOT_FOUND:
+ case ZT_NETWORK_STATUS_NOT_FOUND:
fieldName = "NETWORK_STATUS_NOT_FOUND";
break;
- case ZT1_NETWORK_STATUS_PORT_ERROR:
+ case ZT_NETWORK_STATUS_PORT_ERROR:
fieldName = "NETWORK_STATUS_PORT_ERROR";
break;
- case ZT1_NETWORK_STATUS_CLIENT_TOO_OLD:
+ case ZT_NETWORK_STATUS_CLIENT_TOO_OLD:
fieldName = "NETWORK_STATUS_CLIENT_TOO_OLD";
break;
}
@@ -104,7 +104,7 @@ jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status)
return statusObject;
}
-jobject createEvent(JNIEnv *env, ZT1_Event event)
+jobject createEvent(JNIEnv *env, ZT_Event event)
{
jclass eventClass = NULL;
jobject eventObject = NULL;
@@ -118,31 +118,31 @@ jobject createEvent(JNIEnv *env, ZT1_Event event)
std::string fieldName;
switch(event)
{
- case ZT1_EVENT_UP:
+ case ZT_EVENT_UP:
fieldName = "EVENT_UP";
break;
- case ZT1_EVENT_OFFLINE:
+ case ZT_EVENT_OFFLINE:
fieldName = "EVENT_OFFLINE";
break;
- case ZT1_EVENT_ONLINE:
+ case ZT_EVENT_ONLINE:
fieldName = "EVENT_ONLINE";
break;
- case ZT1_EVENT_DOWN:
+ case ZT_EVENT_DOWN:
fieldName = "EVENT_DOWN";
break;
- case ZT1_EVENT_FATAL_ERROR_IDENTITY_COLLISION:
+ case ZT_EVENT_FATAL_ERROR_IDENTITY_COLLISION:
fieldName = "EVENT_FATAL_ERROR_IDENTITY_COLLISION";
break;
- case ZT1_EVENT_SAW_MORE_RECENT_VERSION:
+ case ZT_EVENT_SAW_MORE_RECENT_VERSION:
fieldName = "EVENT_SAW_MORE_RECENT_VERSION";
break;
- case ZT1_EVENT_AUTHENTICATION_FAILURE:
+ case ZT_EVENT_AUTHENTICATION_FAILURE:
fieldName = "EVENT_AUTHENTICATION_FAILURE";
break;
- case ZT1_EVENT_INVALID_PACKET:
+ case ZT_EVENT_INVALID_PACKET:
fieldName = "EVENT_INVALID_PACKET";
break;
- case ZT1_EVENT_TRACE:
+ case ZT_EVENT_TRACE:
fieldName = "EVENT_TRACE";
break;
}
@@ -154,7 +154,7 @@ jobject createEvent(JNIEnv *env, ZT1_Event event)
return eventObject;
}
-jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role)
+jobject createPeerRole(JNIEnv *env, ZT_PeerRole role)
{
jclass peerRoleClass = NULL;
jobject peerRoleObject = NULL;
@@ -168,14 +168,14 @@ jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role)
std::string fieldName;
switch(role)
{
- case ZT1_PEER_ROLE_LEAF:
+ case ZT_PEER_ROLE_LEAF:
fieldName = "PEER_ROLE_LEAF";
break;
- case ZT1_PEER_ROLE_RELAY:
+ case ZT_PEER_ROLE_RELAY:
fieldName = "PEER_ROLE_RELAY";
break;
- case ZT1_PEER_ROLE_ROOT:
- fieldName = "PEER_ROLE_ROOT";
+ case ZT_PEER_ROLE_ROOT:
+ fieldName = "PEER_ROLE_ROOTS";
break;
}
@@ -186,7 +186,7 @@ jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role)
return peerRoleObject;
}
-jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type)
+jobject createVirtualNetworkType(JNIEnv *env, ZT_VirtualNetworkType type)
{
jclass vntypeClass = NULL;
jobject vntypeObject = NULL;
@@ -200,10 +200,10 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type)
std::string fieldName;
switch(type)
{
- case ZT1_NETWORK_TYPE_PRIVATE:
+ case ZT_NETWORK_TYPE_PRIVATE:
fieldName = "NETWORK_TYPE_PRIVATE";
break;
- case ZT1_NETWORK_TYPE_PUBLIC:
+ case ZT_NETWORK_TYPE_PUBLIC:
fieldName = "NETWORK_TYPE_PUBLIC";
break;
}
@@ -213,7 +213,7 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type)
return vntypeObject;
}
-jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfigOperation op)
+jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT_VirtualNetworkConfigOperation op)
{
jclass vnetConfigOpClass = NULL;
jobject vnetConfigOpObject = NULL;
@@ -227,16 +227,16 @@ jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfi
std::string fieldName;
switch(op)
{
- case ZT1_VIRTUAL_NETWORK_CONFIG_OPERATION_UP:
+ case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP:
fieldName = "VIRTUAL_NETWORK_CONFIG_OPERATION_UP";
break;
- case ZT1_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE:
+ case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE:
fieldName = "VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE";
break;
- case ZT1_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN:
+ case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN:
fieldName = "VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN";
break;
- case ZT1_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY:
+ case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY:
fieldName = "VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY";
break;
}
@@ -372,7 +372,7 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
return inetSocketAddressObject;
}
-jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc)
+jobject newMulticastGroup(JNIEnv *env, const ZT_MulticastGroup &mc)
{
jclass multicastGroupClass = NULL;
jmethodID multicastGroup_constructor = NULL;
@@ -417,7 +417,7 @@ jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc)
return multicastGroupObj;
}
-jobject newPeerPhysicalPath(JNIEnv *env, const ZT1_PeerPhysicalPath &ppp)
+jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp)
{
LOGV("newPeerPhysicalPath Called");
jclass pppClass = NULL;
@@ -514,7 +514,7 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT1_PeerPhysicalPath &ppp)
return pppObject;
}
-jobject newPeer(JNIEnv *env, const ZT1_Peer &peer)
+jobject newPeer(JNIEnv *env, const ZT_Peer &peer)
{
LOGV("newPeer called");
@@ -656,7 +656,7 @@ jobject newPeer(JNIEnv *env, const ZT1_Peer &peer)
return peerObject;
}
-jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig)
+jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig)
{
jclass vnetConfigClass = NULL;
jmethodID vnetConfig_constructor = NULL;
diff --git a/java/jni/ZT1_jniutils.h b/java/jni/ZT_jniutils.h
index 880f67d7..b76a28c2 100644
--- a/java/jni/ZT1_jniutils.h
+++ b/java/jni/ZT_jniutils.h
@@ -1,5 +1,5 @@
-#ifndef ZT1_jniutils_h_
-#define ZT1_jniutils_h_
+#ifndef ZT_jniutils_h_
+#define ZT_jniutils_h_
#include <stdio.h>
#include <jni.h>
#include <ZeroTierOne.h>
@@ -23,22 +23,22 @@ extern "C" {
#define LOGE(...) fprintf(stdout, __VA_ARGS__)
#endif
-jobject createResultObject(JNIEnv *env, ZT1_ResultCode code);
-jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status);
-jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type);
-jobject createEvent(JNIEnv *env, ZT1_Event event);
-jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role);
-jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfigOperation op);
+jobject createResultObject(JNIEnv *env, ZT_ResultCode code);
+jobject createVirtualNetworkStatus(JNIEnv *env, ZT_VirtualNetworkStatus status);
+jobject createVirtualNetworkType(JNIEnv *env, ZT_VirtualNetworkType type);
+jobject createEvent(JNIEnv *env, ZT_Event event);
+jobject createPeerRole(JNIEnv *env, ZT_PeerRole role);
+jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT_VirtualNetworkConfigOperation op);
jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr);
jobject newInetAddress(JNIEnv *env, const sockaddr_storage &addr);
-jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc);
+jobject newMulticastGroup(JNIEnv *env, const ZT_MulticastGroup &mc);
-jobject newPeer(JNIEnv *env, const ZT1_Peer &peer);
-jobject newPeerPhysicalPath(JNIEnv *env, const ZT1_PeerPhysicalPath &ppp);
+jobject newPeer(JNIEnv *env, const ZT_Peer &peer);
+jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp);
-jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &config);
+jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &config);
jobject newVersion(JNIEnv *env, int major, int minor, int rev, long featureFlags);
diff --git a/java/jni/com_zerotierone_sdk_Node.cpp b/java/jni/com_zerotierone_sdk_Node.cpp
index e98342e7..e513cdf5 100644
--- a/java/jni/com_zerotierone_sdk_Node.cpp
+++ b/java/jni/com_zerotierone_sdk_Node.cpp
@@ -26,8 +26,8 @@
*/
#include "com_zerotierone_sdk_Node.h"
-#include "ZT1_jniutils.h"
-#include "ZT1_jnilookup.h"
+#include "ZT_jniutils.h"
+#include "ZT_jnilookup.h"
#include <ZeroTierOne.h>
#include "Mutex.hpp"
@@ -75,7 +75,7 @@ namespace {
JavaVM *jvm;
- ZT1_Node *node;
+ ZT_Node *node;
jobject dataStoreGetListener;
jobject dataStorePutListener;
@@ -87,11 +87,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)
{
LOGV("VritualNetworkConfigFunctionCallback");
JniRef *ref = (JniRef*)userData;
@@ -134,7 +134,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,
@@ -189,11 +189,11 @@ 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)
{
LOGV("EventCallback");
JniRef *ref = (JniRef*)userData;
- if(ref->node != node && event != ZT1_EVENT_UP)
+ if(ref->node != node && event != ZT_EVENT_UP)
{
LOGE("Nodes not equal. ref->node %p, node %p. Event: %d", ref->node, node, event);
return;
@@ -252,18 +252,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()
@@ -275,8 +275,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()
@@ -288,7 +288,7 @@ namespace {
}
}
break;
- case ZT1_EVENT_TRACE:
+ case ZT_EVENT_TRACE:
{
LOGV("Trace Event");
// call onTrace()
@@ -303,7 +303,7 @@ namespace {
}
}
- long DataStoreGetFunction(ZT1_Node *node,void *userData,
+ long DataStoreGetFunction(ZT_Node *node,void *userData,
const char *objectName,
void *buffer,
unsigned long bufferSize,
@@ -375,7 +375,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,
@@ -440,12 +440,13 @@ namespace {
}
}
- int WirePacketSendFunction(ZT1_Node *node,void *userData,\
- const struct sockaddr_storage *address,
+ int WirePacketSendFunction(ZT_Node *node,void *userData,\
+ const struct sockaddr_storage *localAddress,
+ const struct sockaddr_storage *remoteAddress,
const void *buffer,
unsigned int bufferSize)
{
- LOGV("WirePacketSendFunction(%p, %p, %d)", address, buffer, bufferSize);
+ LOGV("WirePacketSendFunction(%p, %p, %p, %d)", localAddress, remoteAddress, buffer, bufferSize);
JniRef *ref = (JniRef*)userData;
assert(ref->node == node);
@@ -468,10 +469,11 @@ namespace {
return -2;
}
- jobject addressObj = newInetSocketAddress(env, *address);
+ jobject localAddressObj = newInetSocketAddress(env, *localAddress);
+ jobject remoteAddressObj = newInetSocketAddress(env, *remoteAddress);
jbyteArray bufferObj = env->NewByteArray(bufferSize);
env->SetByteArrayRegion(bufferObj, 0, bufferSize, (jbyte*)buffer);
- int retval = env->CallIntMethod(ref->packetSender, packetSenderCallbackMethod, addressObj, bufferObj);
+ int retval = env->CallIntMethod(ref->packetSender, packetSenderCallbackMethod, localAddressObj, remoteAddressObj, bufferObj);
LOGV("JNI Packet Sender returned: %d", retval);
return retval;
@@ -481,7 +483,7 @@ namespace {
static NodeMap nodeMap;
ZeroTier::Mutex nodeMapMutex;
- ZT1_Node* findNode(uint64_t nodeId)
+ ZT_Node* findNode(uint64_t nodeId)
{
ZeroTier::Mutex::Lock lock(nodeMapMutex);
NodeMap::iterator found = nodeMap.find(nodeId);
@@ -514,10 +516,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);
@@ -609,7 +611,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,
@@ -618,17 +620,16 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init(
&WirePacketSendFunction,
&VirtualNetworkFrameFunctionCallback,
&VirtualNetworkConfigFunctionCallback,
- &EventCallback);
+ &EventCallback,
+ NULL);
- LOGI("Node Created.");
-
- 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;
@@ -652,7 +653,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;
@@ -666,7 +667,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;
@@ -696,18 +697,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;
@@ -725,7 +726,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,
@@ -753,24 +754,25 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
JNIEnv *env, jobject obj,
jlong id,
jlong in_now,
+ jobject in_localAddress,
jobject in_remoteAddress,
jbyteArray in_packetData,
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.
LOGE("Couldn't find a valid node!");
- 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)
{
LOGE("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;
@@ -781,7 +783,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
{
LOGE("Can't find InetAddress class");
// can't find java.net.InetAddress
- return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
+ return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
}
jmethodID getAddressMethod = lookup.findMethod(
@@ -789,23 +791,29 @@ 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 = lookup.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 = lookup.findMethod(
InetSocketAddressClass, "getAddress", "()Ljava/net/InetAddress;");
- jobject addrObject = env->CallObjectMethod(in_remoteAddress, inetSockGetAddressMethod);
+ jobject localAddrObj = NULL;
+ if(in_localAddress != NULL)
+ {
+ localAddrObj = env->CallObjectMethod(in_localAddress, inetSockGetAddressMethod);
+ }
+
+ jobject remoteAddrObject = env->CallObjectMethod(in_remoteAddress, inetSockGetAddressMethod);
- if(addrObject == NULL)
+ if(remoteAddrObject == NULL)
{
- return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
+ return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
}
jmethodID inetSock_getPort = lookup.findMethod(
@@ -814,30 +822,72 @@ 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()
- int port = env->CallIntMethod(in_remoteAddress, inetSock_getPort);
+ int remotePort = env->CallIntMethod(in_remoteAddress, inetSock_getPort);
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()
- jbyteArray addressArray = (jbyteArray)env->CallObjectMethod(addrObject, getAddressMethod);
- if(addressArray == NULL)
+ jbyteArray remoteAddressArray = (jbyteArray)env->CallObjectMethod(remoteAddrObject, getAddressMethod);
+ if(remoteAddressArray == NULL)
{
LOGE("Unable to call getAddress()");
// 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);
- // get the address bytes
- jbyte *addr = (jbyte*)env->GetPrimitiveArrayCritical(addressArray, NULL);
+ unsigned int addrSize = env->GetArrayLength(remoteAddressArray);
+
+
+ sockaddr_storage localAddress = {};
+
+ if(localAddrObj == NULL)
+ {
+ localAddress = ZT_SOCKADDR_NULL;
+ }
+ else
+ {
+ int localPort = env->CallIntMethod(in_localAddress, inetSock_getPort);
+ jbyteArray localAddressArray = (jbyteArray)env->CallObjectMethod(localAddrObj, getAddressMethod);
+ if(localAddressArray != NULL)
+ {
+
+ unsigned int localAddrSize = env->GetArrayLength(localAddressArray);
+ jbyte *addr = (jbyte*)env->GetPrimitiveArrayCritical(localAddressArray, NULL);
+
+ if(localAddrSize == 16)
+ {
+ sockaddr_in6 ipv6 = {};
+ ipv6.sin6_family = AF_INET6;
+ ipv6.sin6_port = htons(localPort);
+ memcpy(ipv6.sin6_addr.s6_addr, addr, 16);
+ memcpy(&localAddress, &ipv6, sizeof(sockaddr_in6));
+ }
+ else if(localAddrSize)
+ {
+ // IPV4 address
+ sockaddr_in ipv4 = {};
+ ipv4.sin_family = AF_INET;
+ ipv4.sin_port = htons(localPort);
+ memcpy(&ipv4.sin_addr, addr, 4);
+ memcpy(&localAddress, &ipv4, sizeof(sockaddr_in));
+ }
+ else
+ {
+ localAddress = ZT_SOCKADDR_NULL;
+ }
+ env->ReleasePrimitiveArrayCritical(localAddressArray, addr, 0);
+ }
+ }
+ // get the address bytes
+ jbyte *addr = (jbyte*)env->GetPrimitiveArrayCritical(remoteAddressArray, NULL);
sockaddr_storage remoteAddress = {};
if(addrSize == 16)
@@ -845,7 +895,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
// IPV6 address
sockaddr_in6 ipv6 = {};
ipv6.sin6_family = AF_INET6;
- ipv6.sin6_port = htons(port);
+ ipv6.sin6_port = htons(remotePort);
memcpy(ipv6.sin6_addr.s6_addr, addr, 16);
memcpy(&remoteAddress, &ipv6, sizeof(sockaddr_in6));
}
@@ -854,7 +904,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
// IPV4 address
sockaddr_in ipv4 = {};
ipv4.sin_family = AF_INET;
- ipv4.sin_port = htons(port);
+ ipv4.sin_port = htons(remotePort);
memcpy(&ipv4.sin_addr, addr, 4);
memcpy(&remoteAddress, &ipv4, sizeof(sockaddr_in));
}
@@ -862,16 +912,16 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
{
LOGE("Unknown IP version");
// unknown address type
- env->ReleasePrimitiveArrayCritical(addressArray, addr, 0);
- return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
+ env->ReleasePrimitiveArrayCritical(remoteAddressArray, addr, 0);
+ return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
}
- env->ReleasePrimitiveArrayCritical(addressArray, addr, 0);
+ env->ReleasePrimitiveArrayCritical(remoteAddressArray, addr, 0);
unsigned int packetLength = env->GetArrayLength(in_packetData);
if(packetLength == 0)
{
LOGE("Empty packet?!?");
- return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
+ return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
}
void *packetData = env->GetPrimitiveArrayCritical(in_packetData, NULL);
void *localData = malloc(packetLength);
@@ -880,16 +930,17 @@ 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,
+ &localAddress,
&remoteAddress,
localData,
packetLength,
&nextBackgroundTaskDeadline);
- if(rc != ZT1_RESULT_OK)
+ if(rc != ZT_RESULT_OK)
{
- LOGE("ZT1_Node_processWirePacket returned: %d", rc);
+ LOGE("ZT_Node_processWirePacket returned: %d", rc);
}
free(localData);
@@ -913,23 +964,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 = (jlong*)env->GetPrimitiveArrayCritical(out_nextBackgroundTaskDeadline, NULL);
outDeadline[0] = (jlong)nextBackgroundTaskDeadline;
@@ -947,16 +998,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);
}
@@ -970,16 +1021,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);
}
@@ -997,18 +1048,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);
@@ -1027,18 +1078,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);
@@ -1053,14 +1104,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;
}
@@ -1073,7 +1124,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.
@@ -1103,8 +1154,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;
@@ -1165,18 +1216,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;
}
@@ -1194,7 +1245,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);
}
@@ -1208,18 +1259,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;
}
@@ -1228,7 +1279,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;
}
@@ -1236,7 +1287,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;
}
@@ -1246,7 +1297,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;
}
@@ -1262,7 +1313,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers(
}
}
- ZT1_Node_freeQueryResult(node, peerList);
+ ZT_Node_freeQueryResult(node, peerList);
peerList = NULL;
return peerArrayObj;
@@ -1277,14 +1328,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;
@@ -1294,7 +1345,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;
}
@@ -1303,7 +1354,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;
}
@@ -1318,7 +1369,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_networks(
}
}
- ZT1_Node_freeQueryResult(node, networkList);
+ ZT_Node_freeQueryResult(node, networkList);
return networkListObject;
}
diff --git a/java/jni/com_zerotierone_sdk_Node.h b/java/jni/com_zerotierone_sdk_Node.h
index b2e3ed2a..7c1011ab 100644
--- a/java/jni/com_zerotierone_sdk_Node.h
+++ b/java/jni/com_zerotierone_sdk_Node.h
@@ -34,10 +34,10 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame
/*
* Class: com_zerotier_sdk_Node
* Method: processWirePacket
- * Signature: (JJLjava/net/InetSockAddress;[B[J)Lcom/zerotier/sdk/ResultCode;
+ * Signature: (JJLjava/net/InetSockAddress;Ljava/net/InetSockAddress;[B[J)Lcom/zerotier/sdk/ResultCode;
*/
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket
- (JNIEnv *, jobject, jlong, jlong, jobject, jbyteArray, jlongArray);
+ (JNIEnv *, jobject, jlong, jlong, jobject, jobject, jbyteArray, jlongArray);
/*
* Class: com_zerotier_sdk_Node
diff --git a/java/src/com/zerotier/sdk/Node.java b/java/src/com/zerotier/sdk/Node.java
index e5b12697..4bc6e184 100644
--- a/java/src/com/zerotier/sdk/Node.java
+++ b/java/src/com/zerotier/sdk/Node.java
@@ -169,11 +169,12 @@ public class Node {
*/
public ResultCode processWirePacket(
long now,
+ InetSocketAddress localAddress,
InetSocketAddress remoteAddress,
byte[] packetData,
long[] nextBackgroundTaskDeadline) {
return processWirePacket(
- nodeId, now, remoteAddress, packetData,
+ nodeId, now, localAddress, remoteAddress, packetData,
nextBackgroundTaskDeadline);
}
@@ -393,6 +394,7 @@ public class Node {
private native ResultCode processWirePacket(
long nodeId,
long now,
+ InetSocketAddress localAddress,
InetSocketAddress remoteAddress,
byte[] packetData,
long[] nextBackgroundTaskDeadline);
diff --git a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java
index 278fafd2..9816180b 100644
--- a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java
+++ b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java
@@ -35,7 +35,7 @@ import java.net.InetSocketAddress;
public final class VirtualNetworkConfig implements Comparable<VirtualNetworkConfig> {
public static final int MAX_MULTICAST_SUBSCRIPTIONS = 4096;
- public static final int ZT1_MAX_ZT_ASSIGNED_ADDRESSES = 16;
+ public static final int ZT_MAX_ZT_ASSIGNED_ADDRESSES = 16;
private long nwid;
private long mac;