diff --git a/artwork/ZeroTierIcon512x512.png b/artwork/ZeroTierIcon512x512.png
new file mode 100644
index 000000000..d225c2e33
Binary files /dev/null and b/artwork/ZeroTierIcon512x512.png differ
diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt
index 25e326389..008b747bc 100644
--- a/java/CMakeLists.txt
+++ b/java/CMakeLists.txt
@@ -59,6 +59,7 @@ set(src_files
set(include_dirs
${CMAKE_CURRENT_SOURCE_DIR}/../include/
+ ${CMAKE_CURRENT_SOURCE_DIR}/../node/
${Java_INCLUDE_DIRS})
if(WIN32)
diff --git a/java/build.xml b/java/build.xml
index e24a0e13c..4604ad66e 100644
--- a/java/build.xml
+++ b/java/build.xml
@@ -1,4 +1,4 @@
-
+
@@ -9,7 +9,7 @@
-
+
@@ -24,6 +24,10 @@
+
+
+
+
-
+
+
-
+
+
+
+
@@ -91,7 +105,7 @@
overwrite="true"/>
-
+
@@ -101,23 +115,4 @@
-
-
\ No newline at end of file
diff --git a/java/jni/Android.mk b/java/jni/Android.mk
index 4dd4a57a2..3da3b04b6 100644
--- a/java/jni/Android.mk
+++ b/java/jni/Android.mk
@@ -4,7 +4,9 @@ include $(CLEAR_VARS)
LOCAL_MODULE := ZeroTierOneJNI
LOCAL_C_INCLUDES := $(ZT1)/include
+LOCAL_C_INCLUDES += $(ZT1)/node
LOCAL_LDLIBS := -llog
+# LOCAL_CFLAGS := -g
# ZeroTierOne SDK source files
LOCAL_SRC_FILES := \
@@ -13,7 +15,6 @@ LOCAL_SRC_FILES := \
$(ZT1)/ext/http-parser/http_parser.c \
$(ZT1)/node/C25519.cpp \
$(ZT1)/node/CertificateOfMembership.cpp \
- $(ZT1)/node/Defaults.cpp \
$(ZT1)/node/Dictionary.cpp \
$(ZT1)/node/Identity.cpp \
$(ZT1)/node/IncomingPacket.cpp \
@@ -24,6 +25,7 @@ LOCAL_SRC_FILES := \
$(ZT1)/node/Node.cpp \
$(ZT1)/node/OutboundMulticast.cpp \
$(ZT1)/node/Packet.cpp \
+ $(ZT1)/node/Path.cpp \
$(ZT1)/node/Peer.cpp \
$(ZT1)/node/Poly1305.cpp \
$(ZT1)/node/Salsa20.cpp \
@@ -39,6 +41,6 @@ LOCAL_SRC_FILES := \
LOCAL_SRC_FILES += \
com_zerotierone_sdk_Node.cpp \
ZT_jniutils.cpp \
- ZT_jnicache.cpp
+ ZT_jnilookup.cpp
include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/java/jni/Application.mk b/java/jni/Application.mk
index 3118ec2e4..608e94c0a 100644
--- a/java/jni/Application.mk
+++ b/java/jni/Application.mk
@@ -1,4 +1,5 @@
-APP_ABI := armeabi armeabi-v7a arm64-v8a x86
-APP_STL := gnustl_static
-APP_CPPFLAGS += -Wall -fPIE -fstack-protector -fexceptions -DZT_TRACE
-
+NDK_TOOLCHAIN_VERSION := clang
+APP_STL := c++_static
+APP_CPPFLAGS := -O3 -fPIC -fPIE -fvectorize -Wall -fstack-protector -fexceptions -fno-strict-aliasing -Wno-deprecated-register -DZT_NO_TYPE_PUNNING=1
+APP_PLATFORM := android-14
+APP_ABI := all
diff --git a/java/jni/ZT1_jnicache.cpp b/java/jni/ZT1_jnicache.cpp
deleted file mode 100644
index d8141058a..000000000
--- a/java/jni/ZT1_jnicache.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2015 ZeroTier, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * --
- *
- * ZeroTier may be used and distributed under the terms of the GPLv3, which
- * are available at: http://www.gnu.org/licenses/gpl-3.0.html
- *
- * If you would like to embed ZeroTier into a commercial application or
- * redistribute it in a modified binary form, please contact ZeroTier Networks
- * LLC. Start here: http://www.zerotier.com/
- */
-
-#include "ZT_jnicache.h"
-#include "ZT_jniutils.h"
-
-JniCache::JniCache()
- : m_jvm(NULL)
- , m_classes()
- , m_fields()
- , m_staticFields()
- , m_methods()
- , m_staticMethods()
-{
- LOGV("JNI Cache Created");
-}
-
-JniCache::JniCache(JavaVM *jvm)
- : m_jvm(jvm)
- , m_classes()
- , m_fields()
- , m_staticFields()
- , m_methods()
- , m_staticMethods()
-{
- LOGV("JNI Cache Created");
-}
-
-JniCache::~JniCache()
-{
- LOGV("JNI Cache Destroyed");
- clearCache();
-}
-
-void JniCache::clearCache()
-{
- if(m_jvm)
- {
- JNIEnv *env = NULL;
- if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
- return;
-
- for(ClassMap::iterator iter = m_classes.begin(), end = m_classes.end();
- iter != end; ++iter)
- {
- env->DeleteGlobalRef(iter->second);
- }
- }
-
- m_classes.clear();
- m_fields.clear();
- m_staticFields.clear();
- m_methods.clear();
- m_staticMethods.clear();
-}
-
-void JniCache::setJavaVM(JavaVM *jvm)
-{
- LOGV("Assigned JVM to object");
- m_jvm = jvm;
-}
-
-
-jclass JniCache::findClass(const std::string &name)
-{
- if(!m_jvm)
- return NULL;
-
- ClassMap::iterator found = m_classes.find(name);
-
- if(found == m_classes.end())
- {
- // get the class from the JVM
- JNIEnv *env = NULL;
- if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
- {
- LOGE("Error retreiving JNI Environment");
- return NULL;
- }
-
- jclass localCls = env->FindClass(name.c_str());
- if(env->ExceptionCheck())
- {
- LOGE("Error finding class: %s", name.c_str());
- return NULL;
- }
-
- jclass cls = (jclass)env->NewGlobalRef(localCls);
-
- m_classes.insert(std::make_pair(name, cls));
-
- return cls;
- }
-
- LOGV("Returning cached %s", name.c_str());
- return found->second;
-}
-
-
-jmethodID JniCache::findMethod(jclass cls, const std::string &methodName, const std::string &methodSig)
-{
- if(!m_jvm)
- return NULL;
-
- std::string id = methodName + methodSig;
-
- MethodMap::iterator found = m_methods.find(id);
- if(found == m_methods.end())
- {
- JNIEnv *env = NULL;
- if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
- {
- return NULL;
- }
-
- jmethodID mid = env->GetMethodID(cls, methodName.c_str(), methodSig.c_str());
- if(env->ExceptionCheck())
- {
- return NULL;
- }
-
- m_methods.insert(std::make_pair(id, mid));
-
- return mid;
- }
-
- return found->second;
-}
-
-jmethodID JniCache::findStaticMethod(jclass cls, const std::string &methodName, const std::string &methodSig)
-{
- if(!m_jvm)
- return NULL;
-
- std::string id = methodName + methodSig;
-
- MethodMap::iterator found = m_staticMethods.find(id);
- if(found == m_staticMethods.end())
- {
- JNIEnv *env = NULL;
- if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
- {
- return NULL;
- }
-
- jmethodID mid = env->GetStaticMethodID(cls, methodName.c_str(), methodSig.c_str());
- if(env->ExceptionCheck())
- {
- return NULL;
- }
-
- m_staticMethods.insert(std::make_pair(id, mid));
-
- return mid;
- }
-
- return found->second;
-}
-
-jfieldID JniCache::findField(jclass cls, const std::string &fieldName, const std::string &typeStr)
-{
- if(!m_jvm)
- return NULL;
-
- std::string id = fieldName + typeStr;
-
- FieldMap::iterator found = m_fields.find(id);
- if(found == m_fields.end())
- {
- JNIEnv *env = NULL;
- if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
- {
- return NULL;
- }
-
- jfieldID fid = env->GetFieldID(cls, fieldName.c_str(), typeStr.c_str());
- if(env->ExceptionCheck())
- {
- return NULL;
- }
-
- m_fields.insert(std::make_pair(id, fid));
-
- return fid;
- }
-
- return found->second;
-}
-
-jfieldID JniCache::findStaticField(jclass cls, const std::string &fieldName, const std::string &typeStr)
-{
- if(!m_jvm)
- return NULL;
-
- std::string id = fieldName + typeStr;
-
- FieldMap::iterator found = m_staticFields.find(id);
- if(found == m_staticFields.end())
- {
- JNIEnv *env = NULL;
- if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
- {
- return NULL;
- }
-
- jfieldID fid = env->GetStaticFieldID(cls, fieldName.c_str(), typeStr.c_str());
- if(env->ExceptionCheck())
- {
- return NULL;
- }
-
- m_staticFields.insert(std::make_pair(id, fid));
-
- return fid;
- }
-
- return found->second;
-}
\ No newline at end of file
diff --git a/java/jni/ZT_jnilookup.cpp b/java/jni/ZT_jnilookup.cpp
new file mode 100644
index 000000000..be52a3666
--- /dev/null
+++ b/java/jni/ZT_jnilookup.cpp
@@ -0,0 +1,158 @@
+/*
+ * ZeroTier One - Network Virtualization Everywhere
+ * Copyright (C) 2011-2015 ZeroTier, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * --
+ *
+ * ZeroTier may be used and distributed under the terms of the GPLv3, which
+ * are available at: http://www.gnu.org/licenses/gpl-3.0.html
+ *
+ * If you would like to embed ZeroTier into a commercial application or
+ * redistribute it in a modified binary form, please contact ZeroTier Networks
+ * LLC. Start here: http://www.zerotier.com/
+ */
+
+#include "ZT_jnilookup.h"
+#include "ZT_jniutils.h"
+
+JniLookup::JniLookup()
+ : m_jvm(NULL)
+{
+ LOGV("JNI Cache Created");
+}
+
+JniLookup::JniLookup(JavaVM *jvm)
+ : m_jvm(jvm)
+{
+ LOGV("JNI Cache Created");
+}
+
+JniLookup::~JniLookup()
+{
+ LOGV("JNI Cache Destroyed");
+}
+
+
+void JniLookup::setJavaVM(JavaVM *jvm)
+{
+ LOGV("Assigned JVM to object");
+ m_jvm = jvm;
+}
+
+
+jclass JniLookup::findClass(const std::string &name)
+{
+ if(!m_jvm)
+ return NULL;
+
+ // get the class from the JVM
+ JNIEnv *env = NULL;
+ if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
+ {
+ LOGE("Error retreiving JNI Environment");
+ return NULL;
+ }
+
+ jclass cls = env->FindClass(name.c_str());
+ if(env->ExceptionCheck())
+ {
+ LOGE("Error finding class: %s", name.c_str());
+ return NULL;
+ }
+
+ return cls;
+}
+
+
+jmethodID JniLookup::findMethod(jclass cls, const std::string &methodName, const std::string &methodSig)
+{
+ if(!m_jvm)
+ return NULL;
+
+ JNIEnv *env = NULL;
+ if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
+ {
+ return NULL;
+ }
+
+ jmethodID mid = env->GetMethodID(cls, methodName.c_str(), methodSig.c_str());
+ if(env->ExceptionCheck())
+ {
+ return NULL;
+ }
+
+ return mid;
+}
+
+jmethodID JniLookup::findStaticMethod(jclass cls, const std::string &methodName, const std::string &methodSig)
+{
+ if(!m_jvm)
+ return NULL;
+
+ JNIEnv *env = NULL;
+ if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
+ {
+ return NULL;
+ }
+
+ jmethodID mid = env->GetStaticMethodID(cls, methodName.c_str(), methodSig.c_str());
+ if(env->ExceptionCheck())
+ {
+ return NULL;
+ }
+
+ return mid;
+}
+
+jfieldID JniLookup::findField(jclass cls, const std::string &fieldName, const std::string &typeStr)
+{
+ if(!m_jvm)
+ return NULL;
+
+ JNIEnv *env = NULL;
+ if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
+ {
+ return NULL;
+ }
+
+ jfieldID fid = env->GetFieldID(cls, fieldName.c_str(), typeStr.c_str());
+ if(env->ExceptionCheck())
+ {
+ return NULL;
+ }
+
+ return fid;
+}
+
+jfieldID JniLookup::findStaticField(jclass cls, const std::string &fieldName, const std::string &typeStr)
+{
+ if(!m_jvm)
+ return NULL;
+
+ JNIEnv *env = NULL;
+ if(m_jvm->GetEnv((void**)&env, JNI_VERSION_1_6) != JNI_OK)
+ {
+ return NULL;
+ }
+
+ jfieldID fid = env->GetStaticFieldID(cls, fieldName.c_str(), typeStr.c_str());
+ if(env->ExceptionCheck())
+ {
+ return NULL;
+ }
+
+ return fid;
+}
\ No newline at end of file
diff --git a/java/jni/ZT1_jnicache.h b/java/jni/ZT_jnilookup.h
similarity index 78%
rename from java/jni/ZT1_jnicache.h
rename to java/jni/ZT_jnilookup.h
index 001c13feb..f5bd97d7d 100644
--- a/java/jni/ZT1_jnicache.h
+++ b/java/jni/ZT_jnilookup.h
@@ -25,8 +25,8 @@
* LLC. Start here: http://www.zerotier.com/
*/
-#ifndef ZT_JNICACHE_H_
-#define ZT_JNICACHE_H_
+#ifndef ZT_JNILOOKUP_H_
+#define ZT_JNILOOKUP_H_
#include
#include
*/
EVENT_FATAL_ERROR_IDENTITY_COLLISION,
-
- /**
- * A more recent version was observed on the network
- *
- * Right now this is only triggered if a hub or rootserver reports a
- * more recent version, and only once. It can be used to trigger a
- * software update check.
- *
- * Meta-data: {@link Version}, more recent version number
- */
- EVENT_SAW_MORE_RECENT_VERSION,
-
- /**
- * A packet failed authentication
- *
- * Meta-data: {@link InetSocketAddress} containing origin address of packet
- */
- EVENT_AUTHENTICATION_FAILURE,
-
- /**
- * A received packet was not valid
- *
- * Meta-data: {@link InetSocketAddress} containing origin address of packet
- */
- EVENT_INVALID_PACKET,
/**
* Trace (debugging) message
diff --git a/java/src/com/zerotier/sdk/EventListener.java b/java/src/com/zerotier/sdk/EventListener.java
index 078023d95..91050aaa9 100644
--- a/java/src/com/zerotier/sdk/EventListener.java
+++ b/java/src/com/zerotier/sdk/EventListener.java
@@ -41,21 +41,6 @@ public interface EventListener {
*/
public void onEvent(Event event);
- /**
- * Callback for network error events: {@link Event.EVENT_AUTHENTICATION_FAILUER}, {link Event.EVENT_INVALID_PACKET}
- *
- * @param event {@link Event} enum
- * @param source {@link InetSocketAddress} containing the origin address of the packet
- */
- public void onNetworkError(Event event, InetSocketAddress source);
-
- /**
- * Callback when the node detects that it's out of date.
- *
- * @param newVersion {@link Version} object with the latest version of ZeroTier One
- */
- public void onOutOfDate(Version newVersion);
-
/**
* Trace messages
*
diff --git a/java/src/com/zerotier/sdk/MulticastGroup.java b/java/src/com/zerotier/sdk/MulticastGroup.java
index 5c4df87a4..68114424f 100644
--- a/java/src/com/zerotier/sdk/MulticastGroup.java
+++ b/java/src/com/zerotier/sdk/MulticastGroup.java
@@ -33,6 +33,10 @@ public final class MulticastGroup {
private long mac;
private long adi;
+ public boolean equals(MulticastGroup other) {
+ return mac == other.mac && adi == other.adi;
+ }
+
/**
* MAC address (least significant 48 bits)
*/
diff --git a/java/src/com/zerotier/sdk/Node.java b/java/src/com/zerotier/sdk/Node.java
index e5b126979..4bc6e1846 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/PacketSender.java b/java/src/com/zerotier/sdk/PacketSender.java
index 5302f5ce5..ab31729be 100644
--- a/java/src/com/zerotier/sdk/PacketSender.java
+++ b/java/src/com/zerotier/sdk/PacketSender.java
@@ -37,11 +37,13 @@ public interface PacketSender {
* on failure. Note that success does not (of course) guarantee packet
* delivery. It only means that the packet appears to have been sent.
*
- * @param addr {@link InetSocketAddress} to send to
+ * @param localAddr {@link InetSocketAddress} to send from. Set to null if not specified.
+ * @param remoteAddr {@link InetSocketAddress} to send to
* @param packetData data to send
* @return 0 on success, any error code on failure.
*/
public int onSendPacketRequested(
- InetSocketAddress addr,
+ InetSocketAddress localAddr,
+ InetSocketAddress remoteAddr,
byte[] packetData);
}
diff --git a/java/src/com/zerotier/sdk/PeerRole.java b/java/src/com/zerotier/sdk/PeerRole.java
index 7a5156e1b..d7d55f053 100644
--- a/java/src/com/zerotier/sdk/PeerRole.java
+++ b/java/src/com/zerotier/sdk/PeerRole.java
@@ -34,12 +34,12 @@ public enum PeerRole {
PEER_ROLE_LEAF,
/**
- * Locally federated hub
+ * relay node
*/
- PEER_ROLE_HUB,
+ PEER_ROLE_RELAY,
/**
- * planetary rootserver
+ * root server
*/
- PEER_ROLE_ROOTSERVER
+ PEER_ROLE_ROOT
}
\ No newline at end of file
diff --git a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java
index 78ac9da57..9816180bd 100644
--- a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java
+++ b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java
@@ -27,11 +27,13 @@
package com.zerotier.sdk;
+import java.lang.Comparable;
+import java.lang.Override;
import java.lang.String;
import java.util.ArrayList;
import java.net.InetSocketAddress;
-public final class VirtualNetworkConfig {
+public final class VirtualNetworkConfig implements Comparable {
public static final int MAX_MULTICAST_SUBSCRIPTIONS = 4096;
public static final int ZT_MAX_ZT_ASSIGNED_ADDRESSES = 16;
@@ -54,6 +56,40 @@ public final class VirtualNetworkConfig {
}
+ public boolean equals(VirtualNetworkConfig cfg) {
+ boolean aaEqual = true;
+ if(assignedAddresses.length == cfg.assignedAddresses.length) {
+ for(int i = 0; i < assignedAddresses.length; ++i) {
+ if(!assignedAddresses[i].equals(cfg.assignedAddresses[i])) {
+ return false;
+ }
+ }
+ } else {
+ aaEqual = false;
+ }
+
+ return nwid == cfg.nwid &&
+ mac == cfg.mac &&
+ name.equals(cfg.name) &&
+ status.equals(cfg.status) &&
+ type.equals(cfg.type) &&
+ mtu == cfg.mtu &&
+ dhcp == cfg.dhcp &&
+ bridge == cfg.bridge &&
+ broadcastEnabled == cfg.broadcastEnabled &&
+ portError == cfg.portError &&
+ enabled == cfg.enabled &&
+ aaEqual;
+ }
+
+ public int compareTo(VirtualNetworkConfig cfg) {
+ if(cfg.nwid == this.nwid) {
+ return 0;
+ } else {
+ return this.nwid > cfg.nwid ? 1 : -1;
+ }
+ }
+
/**
* 64-bit ZeroTier network ID
*/