diff options
Diffstat (limited to 'java')
36 files changed, 1394 insertions, 0 deletions
diff --git a/java/README.md b/java/README.md new file mode 100644 index 00000000..10735691 --- /dev/null +++ b/java/README.md @@ -0,0 +1,4 @@ +ZeroTier One SDK - Android JNI Wrapper +===== + +To Build: <path to Android-ndk>/ndk-build ZT1=<path to ZeroTierOne root> diff --git a/java/jni/Android.mk b/java/jni/Android.mk new file mode 100644 index 00000000..74be8d4f --- /dev/null +++ b/java/jni/Android.mk @@ -0,0 +1,41 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := ZeroTierOneJNI +LOCAL_C_INCLUDES := $(ZT1)/include + +# ZeroTierOne SDK source files +LOCAL_SRC_FILES := \ + $(ZT1)/ext/lz4/lz4.c \ + $(ZT1)/ext/json-parser/json.c \ + $(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 \ + $(ZT1)/node/InetAddress.cpp \ + $(ZT1)/node/Multicaster.cpp \ + $(ZT1)/node/Network.cpp \ + $(ZT1)/node/NetworkConfig.cpp \ + $(ZT1)/node/Node.cpp \ + $(ZT1)/node/OutboundMulticast.cpp \ + $(ZT1)/node/Packet.cpp \ + $(ZT1)/node/Peer.cpp \ + $(ZT1)/node/Poly1305.cpp \ + $(ZT1)/node/Salsa20.cpp \ + $(ZT1)/node/SelfAwareness.cpp \ + $(ZT1)/node/SHA512.cpp \ + $(ZT1)/node/Switch.cpp \ + $(ZT1)/node/Topology.cpp \ + $(ZT1)/node/Utils.cpp \ + $(ZT1)/osdep/Http.cpp \ + $(ZT1)/osdep/OSUtils.cpp + +# JNI Files +LOCAL_SRC_FILES += \ + com_zerotierone_sdk_Node.cpp + +include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file diff --git a/java/jni/Application.mk b/java/jni/Application.mk new file mode 100644 index 00000000..11c5c2cf --- /dev/null +++ b/java/jni/Application.mk @@ -0,0 +1,3 @@ +APP_ABI := armeabi armeabi-v7a arm64-v8a x86 +APP_STL := gnustl_static +APP_CPPFLAGS += -fexceptions
\ No newline at end of file diff --git a/java/jni/com_zerotierone_sdk_DataStoreGetListener.h b/java/jni/com_zerotierone_sdk_DataStoreGetListener.h new file mode 100644 index 00000000..8c7fcfa8 --- /dev/null +++ b/java/jni/com_zerotierone_sdk_DataStoreGetListener.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_DataStoreGetListener */ + +#ifndef _Included_com_zerotierone_sdk_DataStoreGetListener +#define _Included_com_zerotierone_sdk_DataStoreGetListener +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_DataStorePutListener.h b/java/jni/com_zerotierone_sdk_DataStorePutListener.h new file mode 100644 index 00000000..7ed0339f --- /dev/null +++ b/java/jni/com_zerotierone_sdk_DataStorePutListener.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_DataStorePutListener */ + +#ifndef _Included_com_zerotierone_sdk_DataStorePutListener +#define _Included_com_zerotierone_sdk_DataStorePutListener +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_Event.h b/java/jni/com_zerotierone_sdk_Event.h new file mode 100644 index 00000000..a223871a --- /dev/null +++ b/java/jni/com_zerotierone_sdk_Event.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_Event */ + +#ifndef _Included_com_zerotierone_sdk_Event +#define _Included_com_zerotierone_sdk_Event +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_EventListener.h b/java/jni/com_zerotierone_sdk_EventListener.h new file mode 100644 index 00000000..a810c5bf --- /dev/null +++ b/java/jni/com_zerotierone_sdk_EventListener.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_EventListener */ + +#ifndef _Included_com_zerotierone_sdk_EventListener +#define _Included_com_zerotierone_sdk_EventListener +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_MulticastGroup.h b/java/jni/com_zerotierone_sdk_MulticastGroup.h new file mode 100644 index 00000000..269aaa52 --- /dev/null +++ b/java/jni/com_zerotierone_sdk_MulticastGroup.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_MulticastGroup */ + +#ifndef _Included_com_zerotierone_sdk_MulticastGroup +#define _Included_com_zerotierone_sdk_MulticastGroup +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_Node.cpp b/java/jni/com_zerotierone_sdk_Node.cpp new file mode 100644 index 00000000..24ea0cfc --- /dev/null +++ b/java/jni/com_zerotierone_sdk_Node.cpp @@ -0,0 +1,298 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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 <jni.h> + +#include <ZeroTierOne.h> + +#include <map> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + +namespace { + + struct JniRef + { + JniRef() + : env(NULL) + , node(NULL) + , dataStoreGetListener(NULL) + , dataStorePutListener(NULL) + , packetSender(NULL) + , frameListener(NULL) + , configListener(NULL) + {} + uint64_t id; + + JNIEnv *env; + + ZT1_Node *node; + + jobject dataStoreGetListener; + jobject dataStorePutListener; + jobject packetSender; + jobject frameListener; + jobject configListener; + }; + + + int VirtualNetworkConfigFunctionCallback(ZT1_Node *node,void *userData,uint64_t,enum ZT1_VirtualNetworkConfigOperation,const ZT1_VirtualNetworkConfig *) + { + JniRef *ref = (JniRef*)userData; + assert(ref->node == node); + + JNIEnv *env = ref->env; + + return 0; + } + + void VirtualNetworkFrameFunctionCallback(ZT1_Node *node,void *userData,uint64_t,uint64_t,uint64_t,unsigned int,unsigned int,const void *,unsigned int) + { + JniRef *ref = (JniRef*)userData; + assert(ref->node == node); + + JNIEnv *env = ref->env; + } + + void EventCallback(ZT1_Node *node,void *userData,enum ZT1_Event,const void *) + { + JniRef *ref = (JniRef*)userData; + assert(ref->node == node); + + JNIEnv *env = ref->env; + } + + long DataStoreGetFunction(ZT1_Node *node,void *userData,const char *,void *,unsigned long,unsigned long,unsigned long *) + { + JniRef *ref = (JniRef*)userData; + assert(ref->node == node); + + JNIEnv *env = ref->env; + + return 0; + } + + int DataStorePutFunction(ZT1_Node *node,void *userData,const char *,const void *,unsigned long,int) + { + JniRef *ref = (JniRef*)userData; + assert(ref->node == node); + + JNIEnv *env = ref->env; + + return 0; + } + + int WirePacketSendFunction(ZT1_Node *node,void *userData,const struct sockaddr_storage *,unsigned int,const void *,unsigned int) + { + JniRef *ref = (JniRef*)userData; + assert(ref->node == node); + + JNIEnv *env = ref->env; + + return 0; + } + + typedef std::map<uint64_t, JniRef*> NodeMap; + static NodeMap nodeMap; + + jobject createResultObject(JNIEnv *env, ZT1_ResultCode code) + { + // cache the class and constructor so we don't have to + // look them up every time we need to create a java + // ResultCode object + static jclass resultClass = NULL; + static jmethodID constructorId = NULL; + + jobject resultObject = NULL; + + if(resultClass == NULL) + { + resultClass = env->FindClass("com/zerotierone/sdk/ResultCode"); + if(resultClass == NULL) + { + return NULL; // exception thrown + } + } + + if(constructorId = NULL) + { + constructorId = env->GetMethodID(resultClass, "<init>", "(I)V"); + if(constructorId == NULL) + { + return NULL; // exception thrown + } + } + + resultObject = env->NewObject(resultClass, constructorId, (jlong)code); + + return resultObject; + } +} + +/* + * Class: com_zerotierone_sdk_Node + * Method: node_init + * Signature: (J)Lcom/zerotierone/sdk/ResultCode; + */ +JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init + (JNIEnv *env, jobject obj, jlong now) +{ + jobject resultObject = createResultObject(env, ZT1_RESULT_OK); + + ZT1_Node *node; + JniRef *ref = new JniRef; + + ZT1_ResultCode rc = ZT1_Node_new( + &node, + ref, + (uint64_t)now, + &DataStoreGetFunction, + &DataStorePutFunction, + &WirePacketSendFunction, + &VirtualNetworkFrameFunctionCallback, + &VirtualNetworkConfigFunctionCallback, + &EventCallback); + + if(rc != ZT1_RESULT_OK) + { + resultObject = createResultObject(env, rc); + if(node) + { + ZT1_Node_delete(node); + node = NULL; + } + delete ref; + ref = NULL; + return resultObject; + } + + + ref->id = (uint64_t)now; + ref->env = env; + ref->node = node; + + jclass cls = env->GetObjectClass(obj); + jfieldID fid = env->GetFieldID( + cls, "getListener", "Lcom.zerotierone.sdk.DataStoreGetListener;"); + + if(fid == NULL) + { + return NULL; // exception already thrown + } + + ref->dataStoreGetListener = env->GetObjectField(obj, fid); + if(ref->dataStoreGetListener == NULL) + { + return NULL; + } + + fid = env->GetFieldID( + cls, "putListener", "Lcom.zerotierone.sdk.DataStorePutLisetner;"); + + if(fid == NULL) + { + return NULL; // exception already thrown + } + + ref->dataStorePutListener = env->GetObjectField(obj, fid); + if(ref->dataStorePutListener == NULL) + { + return NULL; + } + + fid = env->GetFieldID( + cls, "sender", "Lcom.zerotierone.sdk.PacketSender;"); + if(fid == NULL) + { + return NULL; // exception already thrown + } + + ref->packetSender = env->GetObjectField(obj, fid); + if(ref->packetSender == NULL) + { + return NULL; + } + + fid = env->GetFieldID( + cls, "frameListener", "Lcom.zerotierone.sdk.VirtualNetworkFrameListener;"); + if(fid == NULL) + { + return NULL; // exception already thrown + } + + ref->frameListener = env->GetObjectField(obj, fid); + if(ref->frameListener = NULL) + { + return NULL; + } + + fid = env->GetFieldID( + cls, "configListener", "Lcom.zerotierone.sdk.VirtualNetworkConfigListener;"); + if(fid == NULL) + { + return NULL; // exception already thrown + } + + ref->configListener = env->GetObjectField(obj, fid); + if(ref->configListener == NULL) + { + return NULL; + } + + nodeMap.insert(std::make_pair(ref->id, ref)); + + return resultObject; +} + +/* + * Class: com_zerotierone_sdk_Node + * Method: node_delete + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_com_zerotierone_sdk_Node_node_1delete + (JNIEnv *env, jobject obj, jlong id) +{ + uint64_t nodeId = (uint64_t)id; + + NodeMap::iterator found = nodeMap.find(nodeId); + if(found != nodeMap.end()) + { + JniRef *ref = found->second; + nodeMap.erase(found); + delete ref; + ref = NULL; + } +} + + + +#ifdef __cplusplus +} // extern "C" +#endif
\ No newline at end of file diff --git a/java/jni/com_zerotierone_sdk_Node.h b/java/jni/com_zerotierone_sdk_Node.h new file mode 100644 index 00000000..706e7bcd --- /dev/null +++ b/java/jni/com_zerotierone_sdk_Node.h @@ -0,0 +1,85 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_Node */ + +#ifndef _Included_com_zerotierone_sdk_Node +#define _Included_com_zerotierone_sdk_Node +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_zerotierone_sdk_Node + * Method: node_init + * Signature: (J)Lcom/zerotierone/sdk/ResultCode; + */ +JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init + (JNIEnv *, jobject, jlong); + +/* + * Class: com_zerotierone_sdk_Node + * Method: node_delete + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_com_zerotierone_sdk_Node_node_1delete + (JNIEnv *, jobject, jlong); + +/* + * Class: com_zerotierone_sdk_Node + * Method: processVirtualNetworkFrame + * Signature: (JJJJJIILjava/nio/ByteBuffer;ILjava/lang/Long;)Lcom/zerotierone/sdk/ResultCode; + */ +JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processVirtualNetworkFrame + (JNIEnv *, jobject, jlong, jlong, jlong, jlong, jlong, jint, jint, jobject, jint, jobject); + +/* + * Class: com_zerotierone_sdk_Node + * Method: processBackgroundTasks + * Signature: (JJLjava/lang/Long;)Lcom/zerotierone/sdk/ResultCode; + */ +JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processBackgroundTasks + (JNIEnv *, jobject, jlong, jlong, jobject); + +/* + * Class: com_zerotierone_sdk_Node + * Method: join + * Signature: (JJ)Lcom/zerotierone/sdk/ResultCode; + */ +JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_join + (JNIEnv *, jobject, jlong, jlong); + +/* + * Class: com_zerotierone_sdk_Node + * Method: leave + * Signature: (JJ)Lcom/zerotierone/sdk/ResultCode; + */ +JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_leave + (JNIEnv *, jobject, jlong, jlong); + +/* + * Class: com_zerotierone_sdk_Node + * Method: multicastSubscribe + * Signature: (JJJJ)Lcom/zerotierone/sdk/ResultCode; + */ +JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastSubscribe + (JNIEnv *, jobject, jlong, jlong, jlong, jlong); + +/* + * Class: com_zerotierone_sdk_Node + * Method: multicastUnsubscribe + * Signature: (JJJJ)Lcom/zerotierone/sdk/ResultCode; + */ +JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastUnsubscribe + (JNIEnv *, jobject, jlong, jlong, jlong, jlong); + +/* + * Class: com_zerotierone_sdk_Node + * Method: address + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_com_zerotierone_sdk_Node_address + (JNIEnv *, jobject, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_NodeStatus.h b/java/jni/com_zerotierone_sdk_NodeStatus.h new file mode 100644 index 00000000..abd6df46 --- /dev/null +++ b/java/jni/com_zerotierone_sdk_NodeStatus.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_NodeStatus */ + +#ifndef _Included_com_zerotierone_sdk_NodeStatus +#define _Included_com_zerotierone_sdk_NodeStatus +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_PacketSender.h b/java/jni/com_zerotierone_sdk_PacketSender.h new file mode 100644 index 00000000..c5cadf8f --- /dev/null +++ b/java/jni/com_zerotierone_sdk_PacketSender.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_PacketSender */ + +#ifndef _Included_com_zerotierone_sdk_PacketSender +#define _Included_com_zerotierone_sdk_PacketSender +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_ResultCode.h b/java/jni/com_zerotierone_sdk_ResultCode.h new file mode 100644 index 00000000..9121912d --- /dev/null +++ b/java/jni/com_zerotierone_sdk_ResultCode.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_ResultCode */ + +#ifndef _Included_com_zerotierone_sdk_ResultCode +#define _Included_com_zerotierone_sdk_ResultCode +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_Version.h b/java/jni/com_zerotierone_sdk_Version.h new file mode 100644 index 00000000..8e4b6caa --- /dev/null +++ b/java/jni/com_zerotierone_sdk_Version.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_Version */ + +#ifndef _Included_com_zerotierone_sdk_Version +#define _Included_com_zerotierone_sdk_Version +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_VirtualNetworkConfig.h b/java/jni/com_zerotierone_sdk_VirtualNetworkConfig.h new file mode 100644 index 00000000..450fd15d --- /dev/null +++ b/java/jni/com_zerotierone_sdk_VirtualNetworkConfig.h @@ -0,0 +1,15 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_VirtualNetworkConfig */ + +#ifndef _Included_com_zerotierone_sdk_VirtualNetworkConfig +#define _Included_com_zerotierone_sdk_VirtualNetworkConfig +#ifdef __cplusplus +extern "C" { +#endif +#undef com_zerotierone_sdk_VirtualNetworkConfig_MAX_MULTICAST_SUBSCRIPTIONS +#define com_zerotierone_sdk_VirtualNetworkConfig_MAX_MULTICAST_SUBSCRIPTIONS 4096L +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_VirtualNetworkConfigListener.h b/java/jni/com_zerotierone_sdk_VirtualNetworkConfigListener.h new file mode 100644 index 00000000..66f36c7a --- /dev/null +++ b/java/jni/com_zerotierone_sdk_VirtualNetworkConfigListener.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_VirtualNetworkConfigListener */ + +#ifndef _Included_com_zerotierone_sdk_VirtualNetworkConfigListener +#define _Included_com_zerotierone_sdk_VirtualNetworkConfigListener +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_VirtualNetworkConfigOperation.h b/java/jni/com_zerotierone_sdk_VirtualNetworkConfigOperation.h new file mode 100644 index 00000000..2ae9bd4d --- /dev/null +++ b/java/jni/com_zerotierone_sdk_VirtualNetworkConfigOperation.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_VirtualNetworkConfigOperation */ + +#ifndef _Included_com_zerotierone_sdk_VirtualNetworkConfigOperation +#define _Included_com_zerotierone_sdk_VirtualNetworkConfigOperation +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_VirtualNetworkFrameListener.h b/java/jni/com_zerotierone_sdk_VirtualNetworkFrameListener.h new file mode 100644 index 00000000..31003b34 --- /dev/null +++ b/java/jni/com_zerotierone_sdk_VirtualNetworkFrameListener.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_VirtualNetworkFrameListener */ + +#ifndef _Included_com_zerotierone_sdk_VirtualNetworkFrameListener +#define _Included_com_zerotierone_sdk_VirtualNetworkFrameListener +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_VirtualNetworkStatus.h b/java/jni/com_zerotierone_sdk_VirtualNetworkStatus.h new file mode 100644 index 00000000..a436b44b --- /dev/null +++ b/java/jni/com_zerotierone_sdk_VirtualNetworkStatus.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_VirtualNetworkStatus */ + +#ifndef _Included_com_zerotierone_sdk_VirtualNetworkStatus +#define _Included_com_zerotierone_sdk_VirtualNetworkStatus +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/jni/com_zerotierone_sdk_VirtualNetworkType.h b/java/jni/com_zerotierone_sdk_VirtualNetworkType.h new file mode 100644 index 00000000..d26bc4cf --- /dev/null +++ b/java/jni/com_zerotierone_sdk_VirtualNetworkType.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class com_zerotierone_sdk_VirtualNetworkType */ + +#ifndef _Included_com_zerotierone_sdk_VirtualNetworkType +#define _Included_com_zerotierone_sdk_VirtualNetworkType +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/src/com/zerotierone/sdk/DataStoreGetListener.java b/java/src/com/zerotierone/sdk/DataStoreGetListener.java new file mode 100644 index 00000000..60e1c3e8 --- /dev/null +++ b/java/src/com/zerotierone/sdk/DataStoreGetListener.java @@ -0,0 +1,38 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + +public interface DataStoreGetListener { + public int onDataStoreGet(Node node, + String name, + ByteBuffer buffer, + long bufferSize, + long index, + Long out_objectSize); +} diff --git a/java/src/com/zerotierone/sdk/DataStorePutListener.java b/java/src/com/zerotierone/sdk/DataStorePutListener.java new file mode 100644 index 00000000..4e9404d9 --- /dev/null +++ b/java/src/com/zerotierone/sdk/DataStorePutListener.java @@ -0,0 +1,37 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + +public interface DataStorePutListener { + public int onDataStorePut(Node node, + String name, + ByteBuffer buffer, + long bufferSize, + boolean secure); +} diff --git a/java/src/com/zerotierone/sdk/Event.java b/java/src/com/zerotierone/sdk/Event.java new file mode 100644 index 00000000..c5558676 --- /dev/null +++ b/java/src/com/zerotierone/sdk/Event.java @@ -0,0 +1,38 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ + +package com.zerotierone.sdk; + +public enum Event { + EVENT_UP, + EVENT_OFFLINE, + EVENT_DOWN, + EVENT_FATAL_ERROR_IDENTITY_COLLISION, + EVENT_AUTHENTICATION_FAILURE, + EVENT_INVALID_PACKET, + EVENT_TRACE +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/EventListener.java b/java/src/com/zerotierone/sdk/EventListener.java new file mode 100644 index 00000000..9e3e4d24 --- /dev/null +++ b/java/src/com/zerotierone/sdk/EventListener.java @@ -0,0 +1,34 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ + +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + +public interface EventListener { + public void onEvent(Node node,Event event, ByteBuffer buffer); +} diff --git a/java/src/com/zerotierone/sdk/MulticastGroup.java b/java/src/com/zerotierone/sdk/MulticastGroup.java new file mode 100644 index 00000000..c1318d86 --- /dev/null +++ b/java/src/com/zerotierone/sdk/MulticastGroup.java @@ -0,0 +1,33 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ +package com.zerotierone.sdk; + + +public class MulticastGroup { + private long mac; + private long adi; +} diff --git a/java/src/com/zerotierone/sdk/Node.java b/java/src/com/zerotierone/sdk/Node.java new file mode 100644 index 00000000..635f2b9e --- /dev/null +++ b/java/src/com/zerotierone/sdk/Node.java @@ -0,0 +1,186 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ + +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; +import java.lang.Long; + +public class Node { + static { + System.loadLibrary("ZeroTierOneJNI"); + } + + private static final String TAG = "NODE"; + + /** + * Node ID for JNI purposes. + * Currently set to the now value passed in at the constructor + * + * -1 if the node has already been closed + */ + private final long nodeId; + + private final DataStoreGetListener getListener; + private final DataStorePutListener putListener; + private final PacketSender sender; + private final VirtualNetworkFrameListener frameListener; + private final VirtualNetworkConfigListener configListener; + + public Node(long now, + DataStoreGetListener getListener, + DataStorePutListener putListener, + PacketSender sender, + VirtualNetworkFrameListener frameListener, + VirtualNetworkConfigListener configListener) + { + this.nodeId = now; + + this.getListener = getListener; + this.putListener = putListener; + this.sender = sender; + this.frameListener = frameListener; + this.configListener = configListener; + + ResultCode rc = node_init(now); + if(rc.getValue() != ResultCode.RESULT_OK) + { + // TODO: Throw Exception + } + } + + public void close() { + if(nodeId != -1) { + node_delete(nodeId); + nodeId = -1; + } + } + + @Override + protected void finalize() { + close(); + } + + private native ResultCode processVirtualNetworkFrame( + long nodeId, + long now, + long nwid, + long sourceMac, + long destMac, + int etherType, + int vlanId, + ByteBuffer frameData, + int frameLength, + Long nextBackgroundTaskDeadline); + + public ResultCode processVirtualNetworkFrame( + long now, + long nwid, + long sourceMac, + long destMac, + int etherType, + int vlanId, + ByteBuffer frameData, + int frameLength, + Long nextBackgroundTaskDeadline) { + return processVirtualNetworkFrame( + nodeId, now, nwid, sourceMac, destMac, etherType, vlanId, + frameData, frameLength, nextBackgroundTaskDeadline); + } + + public ResultCode processBackgroundTasks(long now, long nextBackgroundTaskDeadline) { + return processBackgroundTasks(nodeId, now, nextBackgroundTaskDeadline); + } + + public ResultCode join(long nwid) { + return join(nodeId, nwid); + } + + public ResultCode leave(long nwid) { + return leave(nodeId, nwid); + } + + public ResultCode multicastSubscribe( + long nwid, + long multicastGroup) { + return multicastSubscribe(nodeId, nwid, multicastGroup, 0); + } + + public ResultCode multicastSubscribe( + long nwid, + long multicastGroup, + long multicastAdi) { + return multicastSubscribe(nodeId, nwid, multicastGroup, multicastAdi); + } + + public ResultCode multicastUnsubscribe( + long nwid, + long multicastGroup) { + return multicastUnsubscribe(nodeId, nwid, multicastGroup, 0); + } + + public ResultCode multicastUnsubscribe( + long nwid, + long multicastGroup, + long multicastAdi) { + return multicastUnsubscribe(nodeId, nwid, multicastGroup, multicastAdi); + } + + public long address() { + return address(nodeId); + } + + /** + * function declarations for JNI + */ + private native ResultCode node_init(long now); + + private native void node_delete(long nodeId); + + private native ResultCode processBackgroundTasks( + long nodeId, + long now, + Long nextBackgroundTaskDeadline); + + private native ResultCode join(long nodeId, long nwid); + + private native ResultCode leave(long nodeId, long nwid); + + private native ResultCode multicastSubscribe( + long nodeId, + long nwid, + long multicastGroup, + long multicastAdi); + + private native ResultCode multicastUnsubscribe( + long nodeId, + long nwid, + long multicastGroup, + long multicastAdi); + + private native long address(long nodeId); +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/NodeStatus.java b/java/src/com/zerotierone/sdk/NodeStatus.java new file mode 100644 index 00000000..4f584bcb --- /dev/null +++ b/java/src/com/zerotierone/sdk/NodeStatus.java @@ -0,0 +1,51 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ + +package com.zerotierone.sdk; + +public class NodeStatus { + private long address; + private String publicIdentity; + private String secretIdentity; + private int online; + + public long getAddres() { + return address; + } + + public String getPublicIdentity() { + return publicIdentity; + } + + public String getSecretIdentity() { + return secretIdentity; + } + + public boolean isOnline() { + return online != 0; + } +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/PacketSender.java b/java/src/com/zerotierone/sdk/PacketSender.java new file mode 100644 index 00000000..0e007ffb --- /dev/null +++ b/java/src/com/zerotierone/sdk/PacketSender.java @@ -0,0 +1,38 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + + +public interface PacketSender { + public int onSendPacketRequested(Node node, + String addr, + int linkDesc, + ByteBuffer packetData, + long dataLength); +} diff --git a/java/src/com/zerotierone/sdk/ResultCode.java b/java/src/com/zerotierone/sdk/ResultCode.java new file mode 100644 index 00000000..7597c0f2 --- /dev/null +++ b/java/src/com/zerotierone/sdk/ResultCode.java @@ -0,0 +1,45 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ + +package com.zerotierone.sdk; + +public enum ResultCode { + + RESULT_OK(0), + RESULT_FATAL_ERROR_OUT_OF_MEMORY(1), + RESULT_FATAL_ERROR_DATA_STORE_FAILED(2), + RESULT_FATAL_ERROR_INTERNAL(3), + RESULT_ERROR_NETWORK_NOT_FOUND(1000); + + private final int id; + ResultCode(int id) { this.id = id; } + public int getValue() { return id; } + + public boolean isFatal(int id) { + return (id > 0 && id < 1000); + } +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/Version.java b/java/src/com/zerotierone/sdk/Version.java new file mode 100644 index 00000000..b260c9de --- /dev/null +++ b/java/src/com/zerotierone/sdk/Version.java @@ -0,0 +1,35 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ + +package com.zerotierone.sdk; + +public class Version { + public int major; + public int minor; + public int revision; + public long featureFlags; +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java b/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java new file mode 100644 index 00000000..3717b334 --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java @@ -0,0 +1,51 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ + +package com.zerotierone.sdk; + +import java.lang.String; +import java.util.ArrayList; + +public class VirtualNetworkConfig { + public static final int MAX_MULTICAST_SUBSCRIPTIONS = 4096; + private long nwid; + private long mac; + private String name; + private VirtualNetworkStatus status; + private VirtualNetworkType type; + private int mtu; + private int dhcp; + private int bridge; + private int broadcastEnabled; + private int portError; + private boolean enabled; + private long netconfRevision; + private int multicastSubscriptionCount; + private ArrayList<MulticastGroup> multicastSubscriptions; + + // TODO: sockaddr_storage +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java b/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java new file mode 100644 index 00000000..78d11987 --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java @@ -0,0 +1,38 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ + + +package com.zerotierone.sdk; + + +public interface VirtualNetworkConfigListener { + public void onNetworkConfigurationUpdated( + Node node, + long someValue, + VirtualNetworkConfigOperation op, + VirtualNetworkConfig config); +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkConfigOperation.java b/java/src/com/zerotierone/sdk/VirtualNetworkConfigOperation.java new file mode 100644 index 00000000..2bf6ce09 --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkConfigOperation.java @@ -0,0 +1,34 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ +package com.zerotierone.sdk; + +public enum VirtualNetworkConfigOperation { + VIRTUAL_NETWORK_CONFIG_OPERATION_UP, + VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE, + VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN, + VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY +} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java b/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java new file mode 100644 index 00000000..fed5d95c --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java @@ -0,0 +1,40 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + +public interface VirtualNetworkFrameListener { + void onVirtualNetworkFrame(Node node, + long nwid, + long srcMac, + long destMac, + long etherType, + long vlanId, + ByteBuffer frameData, + long len); +} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java b/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java new file mode 100644 index 00000000..1102d2ea --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java @@ -0,0 +1,36 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ +package com.zerotierone.sdk; + +public enum VirtualNetworkStatus { + NETWORK_STATUS_REQUESTING_CONFIGURATION, + NETWORK_STATUS_OK, + NETWORK_STATUS_ACCESS_DENIED, + NETWORK_STATUS_NOT_FOUND, + NETWORK_STATUS_PORT_ERROR, + NETWORK_STATUS_CLIENT_TOO_OLD +} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkType.java b/java/src/com/zerotierone/sdk/VirtualNetworkType.java new file mode 100644 index 00000000..b4a8ce2f --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkType.java @@ -0,0 +1,32 @@ +/* + * 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 <http://www.gnu.org/licenses/>. + * + * -- + * + * 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/ + */ +package com.zerotierone.sdk; + +public enum VirtualNetworkType { + NETWORK_TYPE_PRIVATE, + NETWORK_TYPE_PUBLIC +} |
