From 742c59a7c7ca1bcd47984e6db868d6e42580811e Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Sat, 2 May 2015 16:54:00 -0700 Subject: Refactor package name from com.zerotierone.sdk to com.zerotier.sdk --- java/jni/ZT1_jniutils.cpp | 44 +-- java/jni/com_zerotierone_sdk_Node.cpp | 106 ++--- java/jni/com_zerotierone_sdk_Node.h | 84 ++-- .../src/com/zerotier/sdk/DataStoreGetListener.java | 58 +++ .../src/com/zerotier/sdk/DataStorePutListener.java | 59 +++ java/src/com/zerotier/sdk/Event.java | 123 ++++++ java/src/com/zerotier/sdk/EventListener.java | 67 ++++ java/src/com/zerotier/sdk/MulticastGroup.java | 49 +++ java/src/com/zerotier/sdk/NativeUtils.java | 93 +++++ java/src/com/zerotier/sdk/Node.java | 433 +++++++++++++++++++++ java/src/com/zerotier/sdk/NodeException.java | 36 ++ java/src/com/zerotier/sdk/NodeStatus.java | 69 ++++ java/src/com/zerotier/sdk/PacketSender.java | 49 +++ java/src/com/zerotier/sdk/Peer.java | 110 ++++++ java/src/com/zerotier/sdk/PeerPhysicalPath.java | 86 ++++ java/src/com/zerotier/sdk/PeerRole.java | 45 +++ java/src/com/zerotier/sdk/ResultCode.java | 74 ++++ java/src/com/zerotier/sdk/Version.java | 37 ++ .../src/com/zerotier/sdk/VirtualNetworkConfig.java | 170 ++++++++ .../zerotier/sdk/VirtualNetworkConfigListener.java | 60 +++ .../sdk/VirtualNetworkConfigOperation.java | 49 +++ .../zerotier/sdk/VirtualNetworkFrameListener.java | 48 +++ .../src/com/zerotier/sdk/VirtualNetworkStatus.java | 59 +++ java/src/com/zerotier/sdk/VirtualNetworkType.java | 39 ++ .../com/zerotierone/sdk/DataStoreGetListener.java | 58 --- .../com/zerotierone/sdk/DataStorePutListener.java | 59 --- java/src/com/zerotierone/sdk/Event.java | 123 ------ java/src/com/zerotierone/sdk/EventListener.java | 67 ---- java/src/com/zerotierone/sdk/MulticastGroup.java | 49 --- java/src/com/zerotierone/sdk/NativeUtils.java | 93 ----- java/src/com/zerotierone/sdk/Node.java | 433 --------------------- java/src/com/zerotierone/sdk/NodeException.java | 36 -- java/src/com/zerotierone/sdk/NodeStatus.java | 69 ---- java/src/com/zerotierone/sdk/PacketSender.java | 49 --- java/src/com/zerotierone/sdk/Peer.java | 110 ------ java/src/com/zerotierone/sdk/PeerPhysicalPath.java | 86 ---- java/src/com/zerotierone/sdk/PeerRole.java | 45 --- java/src/com/zerotierone/sdk/ResultCode.java | 74 ---- java/src/com/zerotierone/sdk/Version.java | 37 -- .../com/zerotierone/sdk/VirtualNetworkConfig.java | 170 -------- .../sdk/VirtualNetworkConfigListener.java | 60 --- .../sdk/VirtualNetworkConfigOperation.java | 49 --- .../sdk/VirtualNetworkFrameListener.java | 48 --- .../com/zerotierone/sdk/VirtualNetworkStatus.java | 59 --- .../com/zerotierone/sdk/VirtualNetworkType.java | 39 -- 45 files changed, 1930 insertions(+), 1930 deletions(-) create mode 100644 java/src/com/zerotier/sdk/DataStoreGetListener.java create mode 100644 java/src/com/zerotier/sdk/DataStorePutListener.java create mode 100644 java/src/com/zerotier/sdk/Event.java create mode 100644 java/src/com/zerotier/sdk/EventListener.java create mode 100644 java/src/com/zerotier/sdk/MulticastGroup.java create mode 100644 java/src/com/zerotier/sdk/NativeUtils.java create mode 100644 java/src/com/zerotier/sdk/Node.java create mode 100644 java/src/com/zerotier/sdk/NodeException.java create mode 100644 java/src/com/zerotier/sdk/NodeStatus.java create mode 100644 java/src/com/zerotier/sdk/PacketSender.java create mode 100644 java/src/com/zerotier/sdk/Peer.java create mode 100644 java/src/com/zerotier/sdk/PeerPhysicalPath.java create mode 100644 java/src/com/zerotier/sdk/PeerRole.java create mode 100644 java/src/com/zerotier/sdk/ResultCode.java create mode 100644 java/src/com/zerotier/sdk/Version.java create mode 100644 java/src/com/zerotier/sdk/VirtualNetworkConfig.java create mode 100644 java/src/com/zerotier/sdk/VirtualNetworkConfigListener.java create mode 100644 java/src/com/zerotier/sdk/VirtualNetworkConfigOperation.java create mode 100644 java/src/com/zerotier/sdk/VirtualNetworkFrameListener.java create mode 100644 java/src/com/zerotier/sdk/VirtualNetworkStatus.java create mode 100644 java/src/com/zerotier/sdk/VirtualNetworkType.java delete mode 100644 java/src/com/zerotierone/sdk/DataStoreGetListener.java delete mode 100644 java/src/com/zerotierone/sdk/DataStorePutListener.java delete mode 100644 java/src/com/zerotierone/sdk/Event.java delete mode 100644 java/src/com/zerotierone/sdk/EventListener.java delete mode 100644 java/src/com/zerotierone/sdk/MulticastGroup.java delete mode 100644 java/src/com/zerotierone/sdk/NativeUtils.java delete mode 100644 java/src/com/zerotierone/sdk/Node.java delete mode 100644 java/src/com/zerotierone/sdk/NodeException.java delete mode 100644 java/src/com/zerotierone/sdk/NodeStatus.java delete mode 100644 java/src/com/zerotierone/sdk/PacketSender.java delete mode 100644 java/src/com/zerotierone/sdk/Peer.java delete mode 100644 java/src/com/zerotierone/sdk/PeerPhysicalPath.java delete mode 100644 java/src/com/zerotierone/sdk/PeerRole.java delete mode 100644 java/src/com/zerotierone/sdk/ResultCode.java delete mode 100644 java/src/com/zerotierone/sdk/Version.java delete mode 100644 java/src/com/zerotierone/sdk/VirtualNetworkConfig.java delete mode 100644 java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java delete mode 100644 java/src/com/zerotierone/sdk/VirtualNetworkConfigOperation.java delete mode 100644 java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java delete mode 100644 java/src/com/zerotierone/sdk/VirtualNetworkStatus.java delete mode 100644 java/src/com/zerotierone/sdk/VirtualNetworkType.java (limited to 'java') diff --git a/java/jni/ZT1_jniutils.cpp b/java/jni/ZT1_jniutils.cpp index 99c5348d..5bda6ae9 100644 --- a/java/jni/ZT1_jniutils.cpp +++ b/java/jni/ZT1_jniutils.cpp @@ -15,7 +15,7 @@ jobject createResultObject(JNIEnv *env, ZT1_ResultCode code) jobject resultObject = NULL; - resultClass = cache.findClass("com/zerotierone/sdk/ResultCode"); + resultClass = cache.findClass("com/zerotier/sdk/ResultCode"); if(resultClass == NULL) { return NULL; // exception thrown @@ -42,7 +42,7 @@ jobject createResultObject(JNIEnv *env, ZT1_ResultCode code) break; } - jfieldID enumField = cache.findStaticField(resultClass, fieldName.c_str(), "Lcom/zerotierone/sdk/ResultCode;"); + jfieldID enumField = cache.findStaticField(resultClass, fieldName.c_str(), "Lcom/zerotier/sdk/ResultCode;"); resultObject = env->GetStaticObjectField(resultClass, enumField); @@ -54,7 +54,7 @@ jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status) { jobject statusObject = NULL; - jclass statusClass = cache.findClass("com/zerotierone/sdk/VirtualNetworkStatus"); + jclass statusClass = cache.findClass("com/zerotier/sdk/VirtualNetworkStatus"); if(statusClass == NULL) { return NULL; // exception thrown @@ -83,7 +83,7 @@ jobject createVirtualNetworkStatus(JNIEnv *env, ZT1_VirtualNetworkStatus status) break; } - jfieldID enumField = cache.findStaticField(statusClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkStatus;"); + jfieldID enumField = cache.findStaticField(statusClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkStatus;"); statusObject = env->GetStaticObjectField(statusClass, enumField); @@ -95,7 +95,7 @@ jobject createEvent(JNIEnv *env, ZT1_Event event) jclass eventClass = NULL; jobject eventObject = NULL; - eventClass = cache.findClass("com/zerotierone/sdk/Event"); + eventClass = cache.findClass("com/zerotier/sdk/Event"); if(eventClass == NULL) { return NULL; @@ -133,7 +133,7 @@ jobject createEvent(JNIEnv *env, ZT1_Event event) break; } - jfieldID enumField = cache.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotierone/sdk/Event;"); + jfieldID enumField = cache.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotier/sdk/Event;"); eventObject = env->GetStaticObjectField(eventClass, enumField); @@ -145,7 +145,7 @@ jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role) jclass peerRoleClass = NULL; jobject peerRoleObject = NULL; - peerRoleClass = cache.findClass("com/zerotierone/sdk/PeerRole"); + peerRoleClass = cache.findClass("com/zerotier/sdk/PeerRole"); if(peerRoleClass == NULL) { return NULL; @@ -165,7 +165,7 @@ jobject createPeerRole(JNIEnv *env, ZT1_PeerRole role) break; } - jfieldID enumField = cache.findStaticField(peerRoleClass, fieldName.c_str(), "Lcom/zerotierone/sdk/PeerRole;"); + jfieldID enumField = cache.findStaticField(peerRoleClass, fieldName.c_str(), "Lcom/zerotier/sdk/PeerRole;"); peerRoleObject = env->GetStaticObjectField(peerRoleClass, enumField); @@ -177,7 +177,7 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type) jclass vntypeClass = NULL; jobject vntypeObject = NULL; - vntypeClass = cache.findClass("com/zerotierone/sdk/VirtualNetworkType"); + vntypeClass = cache.findClass("com/zerotier/sdk/VirtualNetworkType"); if(vntypeClass == NULL) { return NULL; @@ -194,7 +194,7 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT1_VirtualNetworkType type) break; } - jfieldID enumField = cache.findStaticField(vntypeClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkType;"); + jfieldID enumField = cache.findStaticField(vntypeClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkType;"); vntypeObject = env->GetStaticObjectField(vntypeClass, enumField); return vntypeObject; } @@ -204,7 +204,7 @@ jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfi jclass vnetConfigOpClass = NULL; jobject vnetConfigOpObject = NULL; - vnetConfigOpClass = cache.findClass("com/zerotierone/sdk/VirtualNetworkConfigOperation"); + vnetConfigOpClass = cache.findClass("com/zerotier/sdk/VirtualNetworkConfigOperation"); if(vnetConfigOpClass == NULL) { return NULL; @@ -227,7 +227,7 @@ jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT1_VirtualNetworkConfi break; } - jfieldID enumField = cache.findStaticField(vnetConfigOpClass, fieldName.c_str(), "Lcom/zerotierone/sdk/VirtualNetworkConfigOperation;"); + jfieldID enumField = cache.findStaticField(vnetConfigOpClass, fieldName.c_str(), "Lcom/zerotier/sdk/VirtualNetworkConfigOperation;"); vnetConfigOpObject = env->GetStaticObjectField(vnetConfigOpClass, enumField); return vnetConfigOpObject; } @@ -386,7 +386,7 @@ jobject newMulticastGroup(JNIEnv *env, const ZT1_MulticastGroup &mc) jfieldID macField = NULL; jfieldID adiField = NULL; - multicastGroupClass = cache.findClass("com/zerotierone/sdk/MulticastGroup"); + multicastGroupClass = cache.findClass("com/zerotier/sdk/MulticastGroup"); if(multicastGroupClass == NULL) { return NULL; @@ -442,7 +442,7 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT1_PeerPhysicalPath &ppp) jmethodID ppp_constructor = NULL; - pppClass = cache.findClass("com/zerotierone/sdk/PeerPhysicalPath"); + pppClass = cache.findClass("com/zerotier/sdk/PeerPhysicalPath"); if(pppClass == NULL) { return NULL; @@ -524,7 +524,7 @@ jobject newPeer(JNIEnv *env, const ZT1_Peer &peer) jmethodID peer_constructor = NULL; - peerClass = cache.findClass("com/zerotierone/sdk/Peer"); + peerClass = cache.findClass("com/zerotier/sdk/Peer"); if(peerClass == NULL) { return NULL; @@ -572,7 +572,7 @@ jobject newPeer(JNIEnv *env, const ZT1_Peer &peer) return NULL; } - roleField = cache.findField(peerClass, "role", "Lcom/zerotierone/sdk/PeerRole;"); + roleField = cache.findField(peerClass, "role", "Lcom/zerotier/sdk/PeerRole;"); if(roleField == NULL) { return NULL; @@ -636,10 +636,10 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig jfieldID multicastSubscriptionsField = NULL; jfieldID assignedAddressesField = NULL; - vnetConfigClass = cache.findClass("com/zerotierone/sdk/VirtualNetworkConfig"); + vnetConfigClass = cache.findClass("com/zerotier/sdk/VirtualNetworkConfig"); if(vnetConfigClass == NULL) { - LOGE("Couldn't find com.zerotierone.sdk.VirtualNetworkConfig"); + LOGE("Couldn't find com.zerotier.sdk.VirtualNetworkConfig"); return NULL; } @@ -679,14 +679,14 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig return NULL; } - statusField = cache.findField(vnetConfigClass, "status", "Lcom/zerotierone/sdk/VirtualNetworkStatus;"); + statusField = cache.findField(vnetConfigClass, "status", "Lcom/zerotier/sdk/VirtualNetworkStatus;"); if(statusField == NULL) { LOGE("Error getting status field"); return NULL; } - typeField = cache.findField(vnetConfigClass, "type", "Lcom/zerotierone/sdk/VirtualNetworkType;"); + typeField = cache.findField(vnetConfigClass, "type", "Lcom/zerotier/sdk/VirtualNetworkType;"); if(typeField == NULL) { LOGE("Error getting type field"); @@ -809,11 +809,11 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig jobject newVersion(JNIEnv *env, int major, int minor, int rev, long featureFlags) { - // create a com.zerotierone.sdk.Version object + // create a com.zerotier.sdk.Version object jclass versionClass = NULL; jmethodID versionConstructor = NULL; - versionClass = cache.findClass("com/zerotierone/sdk/Version"); + versionClass = cache.findClass("com/zerotier/sdk/Version"); if(versionClass == NULL) { return NULL; diff --git a/java/jni/com_zerotierone_sdk_Node.cpp b/java/jni/com_zerotierone_sdk_Node.cpp index d67b83a1..55eec9a6 100644 --- a/java/jni/com_zerotierone_sdk_Node.cpp +++ b/java/jni/com_zerotierone_sdk_Node.cpp @@ -105,7 +105,7 @@ namespace { jmethodID configListenerCallbackMethod = cache.findMethod(configListenerClass, "onNetworkConfigurationUpdated", - "(JLcom/zerotierone/sdk/VirtualNetworkConfigOperation;Lcom/zerotierone/sdk/VirtualNetworkConfig;)I"); + "(JLcom/zerotier/sdk/VirtualNetworkConfigOperation;Lcom/zerotier/sdk/VirtualNetworkConfig;)I"); if(configListenerCallbackMethod == NULL) { LOGE("Couldn't find onVirtualNetworkFrame() method"); @@ -186,7 +186,7 @@ namespace { } jmethodID onEventMethod = cache.findMethod(eventListenerClass, - "onEvent", "(Lcom/zerotierone/sdk/Event;)V"); + "onEvent", "(Lcom/zerotier/sdk/Event;)V"); if(onEventMethod == NULL) { LOGE("Couldn't find onEvent method"); @@ -195,7 +195,7 @@ namespace { jmethodID onOutOfDateMethod = cache.findMethod(eventListenerClass, - "onOutOfDate", "(Lcom/zerotierone/sdk/Version;)V"); + "onOutOfDate", "(Lcom/zerotier/sdk/Version;)V"); if(onOutOfDateMethod == NULL) { LOGE("Couldn't find onOutOfDate method"); @@ -204,7 +204,7 @@ namespace { jmethodID onNetworkErrorMethod = cache.findMethod(eventListenerClass, - "onNetworkError", "(Lcom/zerotierone/sdk/Event;Ljava/net/InetSocketAddress;)V"); + "onNetworkError", "(Lcom/zerotier/sdk/Event;Ljava/net/InetSocketAddress;)V"); if(onNetworkErrorMethod == NULL) { LOGE("Couldn't find onNetworkError method"); @@ -463,11 +463,11 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: node_init - * Signature: (J)Lcom/zerotierone/sdk/ResultCode; + * Signature: (J)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init( JNIEnv *env, jobject obj, jlong now) { LOGD("Creating ZT1_Node struct"); @@ -480,7 +480,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init( jclass cls = env->GetObjectClass(obj); jfieldID fid = cache.findField( - cls, "getListener", "Lcom/zerotierone/sdk/DataStoreGetListener;"); + cls, "getListener", "Lcom/zerotier/sdk/DataStoreGetListener;"); if(fid == NULL) { @@ -495,7 +495,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init( ref->dataStoreGetListener = env->NewGlobalRef(tmp); fid = cache.findField( - cls, "putListener", "Lcom/zerotierone/sdk/DataStorePutListener;"); + cls, "putListener", "Lcom/zerotier/sdk/DataStorePutListener;"); if(fid == NULL) { @@ -510,7 +510,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init( ref->dataStorePutListener = env->NewGlobalRef(tmp); fid = cache.findField( - cls, "sender", "Lcom/zerotierone/sdk/PacketSender;"); + cls, "sender", "Lcom/zerotier/sdk/PacketSender;"); if(fid == NULL) { return NULL; // exception already thrown @@ -524,7 +524,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init( ref->packetSender = env->NewGlobalRef(tmp); fid = cache.findField( - cls, "frameListener", "Lcom/zerotierone/sdk/VirtualNetworkFrameListener;"); + cls, "frameListener", "Lcom/zerotier/sdk/VirtualNetworkFrameListener;"); if(fid == NULL) { return NULL; // exception already thrown @@ -538,7 +538,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init( ref->frameListener = env->NewGlobalRef(tmp); fid = cache.findField( - cls, "configListener", "Lcom/zerotierone/sdk/VirtualNetworkConfigListener;"); + cls, "configListener", "Lcom/zerotier/sdk/VirtualNetworkConfigListener;"); if(fid == NULL) { return NULL; // exception already thrown @@ -552,7 +552,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init( ref->configListener = env->NewGlobalRef(tmp); fid = cache.findField( - cls, "eventListener", "Lcom/zerotierone/sdk/EventListener;"); + cls, "eventListener", "Lcom/zerotier/sdk/EventListener;"); if(fid == NULL) { return NULL; @@ -597,11 +597,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: node_delete * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_zerotierone_sdk_Node_node_1delete( +JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete( JNIEnv *env, jobject obj, jlong id) { LOGD("Destroying ZT1_Node struct"); @@ -625,11 +625,11 @@ JNIEXPORT void JNICALL Java_com_zerotierone_sdk_Node_node_1delete( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: processVirtualNetworkFrame - * Signature: (JJJJJII[B[J)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJJJJII[B[J)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processVirtualNetworkFrame( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame( JNIEnv *env, jobject obj, jlong id, jlong in_now, @@ -691,11 +691,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processVirtualNetworkFra } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: processWirePacket - * Signature: (JJLjava/net/InetSocketAddress;I[B[J)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJLjava/net/InetSocketAddress;I[B[J)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processWirePacket( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket( JNIEnv *env, jobject obj, jlong id, jlong in_now, @@ -817,11 +817,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processWirePacket( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: processBackgroundTasks - * Signature: (JJ[J)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJ[J)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processBackgroundTasks( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks( JNIEnv *env, jobject obj, jlong id, jlong in_now, @@ -854,11 +854,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processBackgroundTasks( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: join - * Signature: (JJ)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJ)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_join( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_join( JNIEnv *env, jobject obj, jlong id, jlong in_nwid) { uint64_t nodeId = (uint64_t) id; @@ -877,11 +877,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_join( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: leave - * Signature: (JJ)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJ)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_leave( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave( JNIEnv *env, jobject obj, jlong id, jlong in_nwid) { uint64_t nodeId = (uint64_t) id; @@ -900,11 +900,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_leave( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: multicastSubscribe - * Signature: (JJJJ)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastSubscribe( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe( JNIEnv *env, jobject obj, jlong id, jlong in_nwid, @@ -930,11 +930,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastSubscribe( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: multicastUnsubscribe - * Signature: (JJJJ)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastUnsubscribe( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastUnsubscribe( JNIEnv *env, jobject obj, jlong id, jlong in_nwid, @@ -960,11 +960,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastUnsubscribe( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: address * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_com_zerotierone_sdk_Node_address( +JNIEXPORT jlong JNICALL Java_com_zerotier_sdk_Node_address( JNIEnv *env , jobject obj, jlong id) { uint64_t nodeId = (uint64_t) id; @@ -980,11 +980,11 @@ JNIEXPORT jlong JNICALL Java_com_zerotierone_sdk_Node_address( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: status - * Signature: (J)Lcom/zerotierone/sdk/NodeStatus; + * Signature: (J)Lcom/zerotier/sdk/NodeStatus; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_status +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status (JNIEnv *env, jobject obj, jlong id) { uint64_t nodeId = (uint64_t) id; @@ -998,8 +998,8 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_status jclass nodeStatusClass = NULL; jmethodID nodeStatusConstructor = NULL; - // create a com.zerotierone.sdk.NodeStatus object - nodeStatusClass = cache.findClass("com/zerotierone/sdk/NodeStatus"); + // create a com.zerotier.sdk.NodeStatus object + nodeStatusClass = cache.findClass("com/zerotier/sdk/NodeStatus"); if(nodeStatusClass == NULL) { return NULL; @@ -1072,11 +1072,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_status } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: networkConfig - * Signature: (J)Lcom/zerotierone/sdk/VirtualNetworkConfig; + * Signature: (J)Lcom/zerotier/sdk/VirtualNetworkConfig; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_networkConfig( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networkConfig( JNIEnv *env, jobject obj, jlong id, jlong nwid) { uint64_t nodeId = (uint64_t) id; @@ -1097,11 +1097,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_networkConfig( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: version - * Signature: (J)Lcom/zerotierone/sdk/Version; + * Signature: (J)Lcom/zerotier/sdk/Version; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_version( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_version( JNIEnv *env, jobject obj) { int major = 0; @@ -1115,11 +1115,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_version( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: peers * Signature: (J)Ljava/util/ArrayList; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_peers( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_peers( JNIEnv *env, jobject obj, jlong id) { uint64_t nodeId = (uint64_t) id; @@ -1157,11 +1157,11 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_peers( } /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: networks * Signature: (J)Ljava/util/ArrayList; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_networks( +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networks( JNIEnv *env, jobject obj, jlong id) { uint64_t nodeId = (uint64_t) id; diff --git a/java/jni/com_zerotierone_sdk_Node.h b/java/jni/com_zerotierone_sdk_Node.h index eb88def5..a55c6702 100644 --- a/java/jni/com_zerotierone_sdk_Node.h +++ b/java/jni/com_zerotierone_sdk_Node.h @@ -1,6 +1,6 @@ /* DO NOT EDIT THIS FILE - it is machine generated */ #include -/* Header for class com_zerotierone_sdk_Node */ +/* Header for class com_zerotier_sdk_Node */ #ifndef _Included_com_zerotierone_sdk_Node #define _Included_com_zerotierone_sdk_Node @@ -8,123 +8,123 @@ extern "C" { #endif /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: node_init - * Signature: (J)Lcom/zerotierone/sdk/ResultCode; + * Signature: (J)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_node_1init +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init (JNIEnv *, jobject, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: node_delete * Signature: (J)V */ -JNIEXPORT void JNICALL Java_com_zerotierone_sdk_Node_node_1delete +JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete (JNIEnv *, jobject, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: processVirtualNetworkFrame - * Signature: (JJJJJII[B[J)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJJJJII[B[J)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processVirtualNetworkFrame +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame (JNIEnv *, jobject, jlong, jlong, jlong, jlong, jlong, jint, jint, jbyteArray, jlongArray); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: processWirePacket - * Signature: (JJLjava/net/InetSockAddress;I[B[J)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJLjava/net/InetSockAddress;I[B[J)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processWirePacket +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket (JNIEnv *, jobject, jlong, jlong, jobject, jint, jbyteArray, jlongArray); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: processBackgroundTasks - * Signature: (JJ[J)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJ[J)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processBackgroundTasks +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks (JNIEnv *, jobject, jlong, jlong, jlongArray); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: join - * Signature: (JJ)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJ)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_join +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_join (JNIEnv *, jobject, jlong, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: leave - * Signature: (JJ)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJ)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_leave +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave (JNIEnv *, jobject, jlong, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: multicastSubscribe - * Signature: (JJJJ)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastSubscribe +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe (JNIEnv *, jobject, jlong, jlong, jlong, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: multicastUnsubscribe - * Signature: (JJJJ)Lcom/zerotierone/sdk/ResultCode; + * Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastUnsubscribe +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastUnsubscribe (JNIEnv *, jobject, jlong, jlong, jlong, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: address * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_com_zerotierone_sdk_Node_address +JNIEXPORT jlong JNICALL Java_com_zerotier_sdk_Node_address (JNIEnv *, jobject, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: status - * Signature: (J)Lcom/zerotierone/sdk/NodeStatus; + * Signature: (J)Lcom/zerotier/sdk/NodeStatus; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_status +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status (JNIEnv *, jobject, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: networkConfig - * Signature: (JJ)Lcom/zerotierone/sdk/VirtualNetworkConfig; + * Signature: (JJ)Lcom/zerotier/sdk/VirtualNetworkConfig; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_networkConfig +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networkConfig (JNIEnv *, jobject, jlong, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: version - * Signature: ()Lcom/zerotierone/sdk/Version; + * Signature: ()Lcom/zerotier/sdk/Version; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_version +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_version (JNIEnv *, jobject); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: peers * Signature: (J)Ljava/util/ArrayList; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_peers +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_peers (JNIEnv *, jobject, jlong); /* - * Class: com_zerotierone_sdk_Node + * Class: com_zerotier_sdk_Node * Method: networks * Signature: (J)Ljava/util/ArrayList; */ -JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_networks +JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networks (JNIEnv *, jobject, jlong); #ifdef __cplusplus diff --git a/java/src/com/zerotier/sdk/DataStoreGetListener.java b/java/src/com/zerotier/sdk/DataStoreGetListener.java new file mode 100644 index 00000000..b525be63 --- /dev/null +++ b/java/src/com/zerotier/sdk/DataStoreGetListener.java @@ -0,0 +1,58 @@ +/* + * 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/ + */ +package com.zerotier.sdk; + +public interface DataStoreGetListener { + + /** + * Function to get an object from the data store + * + *

Object names can contain forward slash (/) path separators. They will + * never contain .. or backslash (\), so this is safe to map as a Unix-style + * path if the underlying storage permits. For security reasons we recommend + * returning errors if .. or \ are used.

+ * + *

The function must return the actual number of bytes read. If the object + * doesn't exist, it should return -1. -2 should be returned on other errors + * such as errors accessing underlying storage.

+ * + *

If the read doesn't fit in the buffer, the max number of bytes should be + * read. The caller may call the function multiple times to read the whole + * object.

+ * + * @param name Name of the object in the data store + * @param out_buffer buffer to put the object in + * @param bufferIndex index in the object to start reading + * @param out_objectSize long[1] to be set to the actual size of the object if it exists. + * @return the actual number of bytes read. + */ + public long onDataStoreGet( + String name, + byte[] out_buffer, + long bufferIndex, + long[] out_objectSize); +} diff --git a/java/src/com/zerotier/sdk/DataStorePutListener.java b/java/src/com/zerotier/sdk/DataStorePutListener.java new file mode 100644 index 00000000..77e55027 --- /dev/null +++ b/java/src/com/zerotier/sdk/DataStorePutListener.java @@ -0,0 +1,59 @@ +/* + * 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/ + */ +package com.zerotier.sdk; + +public interface DataStorePutListener { + + /** + * Function to store an object in the data store + * + *

If secure is true, the file should be set readable and writable only + * to the user running ZeroTier One. What this means is platform-specific.

+ * + *

Name semantics are the same as {@link DataStoreGetListener}. This must return + * zero on success. You can return any OS-specific error code on failure, as these + * may be visible in logs or error messages and might aid in debugging.

+ * + * @param name Object name + * @param buffer data to store + * @param secure set to user read/write only. + * @return 0 on success. + */ + public int onDataStorePut( + String name, + byte[] buffer, + boolean secure); + + /** + * Function to delete an object from the data store + * + * @param name Object name + * @return 0 on success. + */ + public int onDelete( + String name); +} diff --git a/java/src/com/zerotier/sdk/Event.java b/java/src/com/zerotier/sdk/Event.java new file mode 100644 index 00000000..d315990b --- /dev/null +++ b/java/src/com/zerotier/sdk/Event.java @@ -0,0 +1,123 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +public enum Event { + /** + * Node has been initialized + * + * This is the first event generated, and is always sent. It may occur + * before Node's constructor returns. + */ + EVENT_UP, + + /** + * Node is offline -- network does not seem to be reachable by any available strategy + */ + EVENT_OFFLINE, + + /** + * Node is online -- at least one upstream node appears reachable + * + * Meta-data: none + */ + EVENT_ONLINE, + + /** + * Node is shutting down + * + *

This is generated within Node's destructor when it is being shut down. + * It's done for convenience, since cleaning up other state in the event + * handler may appear more idiomatic.

+ */ + EVENT_DOWN, + + /** + * Your identity has collided with another node's ZeroTier address + * + *

This happens if two different public keys both hash (via the algorithm + * in Identity::generate()) to the same 40-bit ZeroTier address.

+ * + *

This is something you should "never" see, where "never" is defined as + * once per 2^39 new node initializations / identity creations. If you do + * see it, you're going to see it very soon after a node is first + * initialized.

+ * + *

This is reported as an event rather than a return code since it's + * detected asynchronously via error messages from authoritative nodes.

+ * + *

If this occurs, you must shut down and delete the node, delete the + * identity.secret record/file from the data store, and restart to generate + * a new identity. If you don't do this, you will not be able to communicate + * with other nodes.

+ * + *

We'd automate this process, but we don't think silently deleting + * private keys or changing our address without telling the calling code + * is good form. It violates the principle of least surprise.

+ * + *

You can technically get away with not handling this, but we recommend + * doing so in a mature reliable application. Besides, handling this + * condition is a good way to make sure it never arises. It's like how + * umbrellas prevent rain and smoke detectors prevent fires. They do, right?

+ */ + EVENT_FATAL_ERROR_IDENTITY_COLLISION, + + /** + * A more recent version was observed on the network + * + *

Right now this is only triggered if a hub or supernode 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 + * + *

These events are only generated if this is a TRACE-enabled build.

+ * + *

Meta-data: {@link String}, TRACE message

+ */ + EVENT_TRACE +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/EventListener.java b/java/src/com/zerotier/sdk/EventListener.java new file mode 100644 index 00000000..078023d9 --- /dev/null +++ b/java/src/com/zerotier/sdk/EventListener.java @@ -0,0 +1,67 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +import java.net.InetSocketAddress; +import java.lang.String; + +/** + * Interface to handle callbacks for ZeroTier One events. + */ +public interface EventListener { + /** + * Callback for events with no other associated metadata + * + * @param event {@link Event} enum + */ + 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 + * + *

These events are only generated if the underlying ZeroTierOne SDK is a TRACE-enabled build.

+ * + * @param message the trace message + */ + public void onTrace(String message); +} diff --git a/java/src/com/zerotier/sdk/MulticastGroup.java b/java/src/com/zerotier/sdk/MulticastGroup.java new file mode 100644 index 00000000..5c4df87a --- /dev/null +++ b/java/src/com/zerotier/sdk/MulticastGroup.java @@ -0,0 +1,49 @@ +/* + * 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/ + */ +package com.zerotier.sdk; + + +public final class MulticastGroup { + private MulticastGroup() {} + + private long mac; + private long adi; + + /** + * MAC address (least significant 48 bits) + */ + public final long getMacAddress() { + return mac; + } + + /** + * Additional distinguishing information (usually zero) + */ + public final long getAdi() { + return adi; + } +} diff --git a/java/src/com/zerotier/sdk/NativeUtils.java b/java/src/com/zerotier/sdk/NativeUtils.java new file mode 100644 index 00000000..07e1ef5b --- /dev/null +++ b/java/src/com/zerotier/sdk/NativeUtils.java @@ -0,0 +1,93 @@ +package com.zerotier.sdk; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * Simple library class for working with JNI (Java Native Interface) + * + * @see http://adamheinrich.com/2012/how-to-load-native-jni-library-from-jar + * + * @author Adam Heirnich , http://www.adamh.cz + */ +public class NativeUtils { + + /** + * Private constructor - this class will never be instanced + */ + private NativeUtils() { + } + + /** + * Loads library from current JAR archive + * + * The file from JAR is copied into system temporary directory and then loaded. The temporary file is deleted after exiting. + * Method uses String as filename because the pathname is "abstract", not system-dependent. + * + * @param filename The filename inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext + * @throws IOException If temporary file creation or read/write operation fails + * @throws IllegalArgumentException If source file (param path) does not exist + * @throws IllegalArgumentException If the path is not absolute or if the filename is shorter than three characters (restriction of {@see File#createTempFile(java.lang.String, java.lang.String)}). + */ + public static void loadLibraryFromJar(String path) throws IOException { + + if (!path.startsWith("/")) { + throw new IllegalArgumentException("The path has to be absolute (start with '/')."); + } + + // Obtain filename from path + String[] parts = path.split("/"); + String filename = (parts.length > 1) ? parts[parts.length - 1] : null; + + // Split filename to prexif and suffix (extension) + String prefix = ""; + String suffix = null; + if (filename != null) { + parts = filename.split("\\.", 2); + prefix = parts[0]; + suffix = (parts.length > 1) ? "."+parts[parts.length - 1] : null; // Thanks, davs! :-) + } + + // Check if the filename is okay + if (filename == null || prefix.length() < 3) { + throw new IllegalArgumentException("The filename has to be at least 3 characters long."); + } + + // Prepare temporary file + File temp = File.createTempFile(prefix, suffix); + temp.deleteOnExit(); + + if (!temp.exists()) { + throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist."); + } + + // Prepare buffer for data copying + byte[] buffer = new byte[1024]; + int readBytes; + + // Open and check input stream + InputStream is = NativeUtils.class.getResourceAsStream(path); + if (is == null) { + throw new FileNotFoundException("File " + path + " was not found inside JAR."); + } + + // Open output stream and copy data between source file in JAR and the temporary file + OutputStream os = new FileOutputStream(temp); + try { + while ((readBytes = is.read(buffer)) != -1) { + os.write(buffer, 0, readBytes); + } + } finally { + // If read/write fails, close streams safely before throwing an exception + os.close(); + is.close(); + } + + // Finally, load the library + System.load(temp.getAbsolutePath()); + } +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/Node.java b/java/src/com/zerotier/sdk/Node.java new file mode 100644 index 00000000..8484ab59 --- /dev/null +++ b/java/src/com/zerotier/sdk/Node.java @@ -0,0 +1,433 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.io.IOException; + +/** + * A ZeroTier One node + */ +public class Node { + static { + try { + System.loadLibrary("ZeroTierOneJNI"); + } catch (UnsatisfiedLinkError e) { + try { + if(System.getProperty("os.name").startsWith("Windows")) { + System.out.println("Arch: " + System.getProperty("sun.arch.data.model")); + if(System.getProperty("sun.arch.data.model").equals("64")) { + NativeUtils.loadLibraryFromJar("/lib/ZeroTierOneJNI_win64.dll"); + } else { + NativeUtils.loadLibraryFromJar("/lib/ZeroTierOneJNI_win32.dll"); + } + } else { + // TODO: Mac + } + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + } + + 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 long nodeId; + + private final DataStoreGetListener getListener; + private final DataStorePutListener putListener; + private final PacketSender sender; + private final EventListener eventListener; + private final VirtualNetworkFrameListener frameListener; + private final VirtualNetworkConfigListener configListener; + + /** + * Create a new ZeroTier One node + * + *

Note that this can take a few seconds the first time it's called, as it + * will generate an identity.

+ * + * @param now Current clock in milliseconds + * @param getListener User written instance of the {@link DataStoreGetListener} interface called to get objects from persistent storage. This instance must be unique per Node object. + * @param putListener User written intstance of the {@link DataStorePutListener} interface called to put objects in persistent storage. This instance must be unique per Node object. + * @param sender + * @param eventListener User written instance of the {@link EventListener} interface to receive status updates and non-fatal error notices. This instance must be unique per Node object. + * @param frameListener + * @param configListener User written instance of the {@link VirtualNetworkConfigListener} interface to be called when virtual LANs are created, deleted, or their config parameters change. This instance must be unique per Node object. + */ + public Node(long now, + DataStoreGetListener getListener, + DataStorePutListener putListener, + PacketSender sender, + EventListener eventListener, + VirtualNetworkFrameListener frameListener, + VirtualNetworkConfigListener configListener) throws NodeException + { + this.nodeId = now; + + this.getListener = getListener; + this.putListener = putListener; + this.sender = sender; + this.eventListener = eventListener; + this.frameListener = frameListener; + this.configListener = configListener; + + ResultCode rc = node_init(now); + if(rc != ResultCode.RESULT_OK) + { + // TODO: Throw Exception + throw new NodeException(rc.toString()); + } + } + + /** + * Close this Node. + * + *

The Node object can no longer be used once this method is called.

+ */ + public void close() { + if(nodeId != -1) { + node_delete(nodeId); + nodeId = -1; + } + } + + @Override + protected void finalize() { + close(); + } + + /** + * Process a frame from a virtual network port + * + * @param now Current clock in milliseconds + * @param nwid ZeroTier 64-bit virtual network ID + * @param sourceMac Source MAC address (least significant 48 bits) + * @param destMac Destination MAC address (least significant 48 bits) + * @param etherType 16-bit Ethernet frame type + * @param vlanId 10-bit VLAN ID or 0 if none + * @param frameData Frame payload data + * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode processVirtualNetworkFrame( + long now, + long nwid, + long sourceMac, + long destMac, + int etherType, + int vlanId, + byte[] frameData, + long[] nextBackgroundTaskDeadline) { + return processVirtualNetworkFrame( + nodeId, now, nwid, sourceMac, destMac, etherType, vlanId, + frameData, nextBackgroundTaskDeadline); + } + + /** + * Process a packet received from the physical wire + * + * @param now Current clock in milliseconds + * @param remoteAddress Origin of packet + * @param linkDesperation Link desperation metric for link or protocol over which packet arrived + * @param packetData Packet data + * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode processWirePacket( + long now, + InetSocketAddress remoteAddress, + int linkDesperation, + byte[] packetData, + long[] nextBackgroundTaskDeadline) { + return processWirePacket( + nodeId, now, remoteAddress, linkDesperation, packetData, + nextBackgroundTaskDeadline); + } + + /** + * Perform periodic background operations + * + * @param now Current clock in milliseconds + * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode processBackgroundTasks(long now, long[] nextBackgroundTaskDeadline) { + return processBackgroundTasks(nodeId, now, nextBackgroundTaskDeadline); + } + + /** + * Join a network + * + *

This may generate calls to the port config callback before it returns, + * or these may be deffered if a netconf is not available yet.

+ * + *

If we are already a member of the network, nothing is done and OK is + * returned.

+ * + * @param nwid 64-bit ZeroTier network ID + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode join(long nwid) { + return join(nodeId, nwid); + } + + /** + * Leave a network + * + *

If a port has been configured for this network this will generate a call + * to the port config callback with a NULL second parameter to indicate that + * the port is now deleted.

+ * + * @param nwid 64-bit network ID + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode leave(long nwid) { + return leave(nodeId, nwid); + } + + /** + * Subscribe to an Ethernet multicast group + * + *

For IPv4 ARP, the implementation must subscribe to 0xffffffffffff (the + * broadcast address) but with an ADI equal to each IPv4 address in host + * byte order. This converts ARP from a non-scalable broadcast protocol to + * a scalable multicast protocol with perfect address specificity.

+ * + *

If this is not done, ARP will not work reliably.

+ * + *

Multiple calls to subscribe to the same multicast address will have no + * effect. It is perfectly safe to do this.

+ * + *

This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.

+ * + * @param nwid 64-bit network ID + * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode multicastSubscribe( + long nwid, + long multicastGroup) { + return multicastSubscribe(nodeId, nwid, multicastGroup, 0); + } + + /** + * Subscribe to an Ethernet multicast group + * + *

ADI stands for additional distinguishing information. This defaults to zero + * and is rarely used. Right now its only use is to enable IPv4 ARP to scale, + * and this must be done.

+ * + *

For IPv4 ARP, the implementation must subscribe to 0xffffffffffff (the + * broadcast address) but with an ADI equal to each IPv4 address in host + * byte order. This converts ARP from a non-scalable broadcast protocol to + * a scalable multicast protocol with perfect address specificity.

+ * + *

If this is not done, ARP will not work reliably.

+ * + *

Multiple calls to subscribe to the same multicast address will have no + * effect. It is perfectly safe to do this.

+ * + *

This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.

+ * + * @param nwid 64-bit network ID + * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) + * @param multicastAdi Multicast ADI (least significant 32 bits only, default: 0) + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode multicastSubscribe( + long nwid, + long multicastGroup, + long multicastAdi) { + return multicastSubscribe(nodeId, nwid, multicastGroup, multicastAdi); + } + + + /** + * Unsubscribe from an Ethernet multicast group (or all groups) + * + *

If multicastGroup is zero (0), this will unsubscribe from all groups. If + * you are not subscribed to a group this has no effect.

+ * + *

This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.

+ * + * @param nwid 64-bit network ID + * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode multicastUnsubscribe( + long nwid, + long multicastGroup) { + return multicastUnsubscribe(nodeId, nwid, multicastGroup, 0); + } + + /** + * Unsubscribe from an Ethernet multicast group (or all groups) + * + *

If multicastGroup is zero (0), this will unsubscribe from all groups. If + * you are not subscribed to a group this has no effect.

+ * + *

This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.

+ * + *

ADI stands for additional distinguishing information. This defaults to zero + * and is rarely used. Right now its only use is to enable IPv4 ARP to scale, + * and this must be done.

+ * + * @param nwid 64-bit network ID + * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) + * @param multicastAdi Multicast ADI (least significant 32 bits only, default: 0) + * @return OK (0) or error code if a fatal error condition has occurred + */ + public ResultCode multicastUnsubscribe( + long nwid, + long multicastGroup, + long multicastAdi) { + return multicastUnsubscribe(nodeId, nwid, multicastGroup, multicastAdi); + } + + /** + * Get this node's 40-bit ZeroTier address + * + * @return ZeroTier address (least significant 40 bits of 64-bit int) + */ + public long address() { + return address(nodeId); + } + + /** + * Get the status of this node + * + * @return @{link NodeStatus} struct with the current node status. + */ + public NodeStatus status() { + return status(nodeId); + } + + /** + * Get a list of known peer nodes + * + * @return List of known peers or NULL on failure + */ + public ArrayList peers() { + return peers(nodeId); + } + + /** + * Get the status of a virtual network + * + * @param nwid 64-bit network ID + * @return {@link VirtualNetworkConfig} or NULL if we are not a member of this network + */ + public VirtualNetworkConfig networkConfig(long nwid) { + return networkConfig(nodeId, nwid); + } + + /** + * Enumerate and get status of all networks + * + * @return List of networks or NULL on failure + */ + public ArrayList networks() { + return networks(nodeId); + } + + /** + * Get ZeroTier One version + * + * @return {@link Version} object with ZeroTierOne version information. + */ + public Version getVersion() { + return version(); + } + + // + // function declarations for JNI + // + private native ResultCode node_init(long now); + + private native void node_delete(long nodeId); + + private native ResultCode processVirtualNetworkFrame( + long nodeId, + long now, + long nwid, + long sourceMac, + long destMac, + int etherType, + int vlanId, + byte[] frameData, + long[] nextBackgroundTaskDeadline); + + private native ResultCode processWirePacket( + long nodeId, + long now, + InetSocketAddress remoteAddress, + int linkDesperation, + byte[] packetData, + long[] nextBackgroundTaskDeadline); + + 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); + + private native NodeStatus status(long nodeId); + + private native VirtualNetworkConfig networkConfig(long nodeId, long nwid); + + private native Version version(); + + private native ArrayList peers(long nodeId); + + private native ArrayList networks(long nodeId); +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/NodeException.java b/java/src/com/zerotier/sdk/NodeException.java new file mode 100644 index 00000000..3071069a --- /dev/null +++ b/java/src/com/zerotier/sdk/NodeException.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 . + * + * -- + * + * 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.zerotier.sdk; + +import java.lang.RuntimeException; + +class NodeException extends RuntimeException { + NodeException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/NodeStatus.java b/java/src/com/zerotier/sdk/NodeStatus.java new file mode 100644 index 00000000..94376d85 --- /dev/null +++ b/java/src/com/zerotier/sdk/NodeStatus.java @@ -0,0 +1,69 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +public final class NodeStatus { + private long address; + private String publicIdentity; + private String secretIdentity; + private boolean online; + + private NodeStatus() {} + + /** + * 40-bit ZeroTier address of this node + */ + public final long getAddres() { + return address; + } + + /** + * Public identity in string-serialized form (safe to send to others) + * + *

This identity will remain valid as long as the node exists.

+ */ + public final String getPublicIdentity() { + return publicIdentity; + } + + /** + * Full identity including secret key in string-serialized form + * + *

This identity will remain valid as long as the node exists.

+ */ + public final String getSecretIdentity() { + return secretIdentity; + } + + /** + * True if some kind of connectivity appears available + */ + public final boolean isOnline() { + return online; + } +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/PacketSender.java b/java/src/com/zerotier/sdk/PacketSender.java new file mode 100644 index 00000000..d038b11d --- /dev/null +++ b/java/src/com/zerotier/sdk/PacketSender.java @@ -0,0 +1,49 @@ +/* + * 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/ + */ +package com.zerotier.sdk; + +import java.net.InetSocketAddress; + + +public interface PacketSender { + /** + * Function to send a ZeroTier packet out over the wire + * + *

The function must return zero on success and may return any error code + * 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 linkDesperation + * @param packetData data to send + * @return 0 on success, any error code on failure. + */ + public int onSendPacketRequested( + InetSocketAddress addr, + int linkDesperation, + byte[] packetData); +} diff --git a/java/src/com/zerotier/sdk/Peer.java b/java/src/com/zerotier/sdk/Peer.java new file mode 100644 index 00000000..407e6cd4 --- /dev/null +++ b/java/src/com/zerotier/sdk/Peer.java @@ -0,0 +1,110 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +import java.util.ArrayList; + +/** + * Peer status result + */ +public final class Peer { + private long address; + private long lastUnicastFrame; + private long lastMulticastFrame; + private int versionMajor; + private int versionMinor; + private int versionRev; + private int latency; + private PeerRole role; + private ArrayList paths; + + private Peer() {} + + /** + * ZeroTier address (40 bits) + */ + public final long address() { + return address; + } + + /** + * Time we last received a unicast frame from this peer + */ + public final long lastUnicastFrame() { + return lastUnicastFrame; + } + + /** + * Time we last received a multicast rame from this peer + */ + public final long lastMulticastFrame() { + return lastMulticastFrame; + } + + /** + * Remote major version or -1 if not known + */ + public final int versionMajor() { + return versionMajor; + } + + /** + * Remote minor version or -1 if not known + */ + public final int versionMinor() { + return versionMinor; + } + + /** + * Remote revision or -1 if not known + */ + public final int versionRev() { + return versionRev; + } + + /** + * Last measured latency in milliseconds or zero if unknown + */ + public final int latency() { + return latency; + } + + /** + * What trust hierarchy role does this device have? + */ + public final PeerRole role() { + return role; + } + + /** + * Known network paths to peer + */ + public final ArrayList paths() { + return paths; + } +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/PeerPhysicalPath.java b/java/src/com/zerotier/sdk/PeerPhysicalPath.java new file mode 100644 index 00000000..d64ea56b --- /dev/null +++ b/java/src/com/zerotier/sdk/PeerPhysicalPath.java @@ -0,0 +1,86 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +import java.net.InetSocketAddress; + +/** + * Physical network path to a peer + */ +public final class PeerPhysicalPath { + private InetSocketAddress address; + private long lastSend; + private long lastReceive; + private boolean fixed; + private boolean active; + private boolean preferred; + + private PeerPhysicalPath() {} + + /** + * Address of endpoint + */ + public final InetSocketAddress address() { + return address; + } + + /** + * Time of last send in milliseconds or 0 for never + */ + public final long lastSend() { + return lastSend; + } + + /** + * Time of last receive in milliseconds or 0 for never + */ + public final long lastReceive() { + return lastReceive; + } + + /** + * Is path fixed? (i.e. not learned, static) + */ + public final boolean isFixed() { + return fixed; + } + + /** + * Is path active? + */ + public final boolean isActive() { + return active; + } + + /** + * Is path preferred? + */ + public final boolean isPreferred() { + return preferred; + } +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/PeerRole.java b/java/src/com/zerotier/sdk/PeerRole.java new file mode 100644 index 00000000..56c3ac0c --- /dev/null +++ b/java/src/com/zerotier/sdk/PeerRole.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 . + * + * -- + * + * 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.zerotier.sdk; + +public enum PeerRole { + /** + * An ordinary node + */ + PEER_ROLE_LEAF, + + /** + * Locally federated hub + */ + PEER_ROLE_HUB, + + /** + * planetary supernode + */ + PEER_ROLE_SUPERNODE +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/ResultCode.java b/java/src/com/zerotier/sdk/ResultCode.java new file mode 100644 index 00000000..5da82b31 --- /dev/null +++ b/java/src/com/zerotier/sdk/ResultCode.java @@ -0,0 +1,74 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +/** + * Function return code: OK (0) or error results + * + *

Use {@link ResultCode#isFatal) to check for a fatal error. If a fatal error + * occurs, the node should be considered to not be working correctly. These + * indicate serious problems like an inaccessible data store or a compile + * problem.

+ */ +public enum ResultCode { + /** + * Operation completed normally + */ + RESULT_OK(0), + + // Fatal errors (> 0, < 1000) + /** + * Ran out of memory + */ + RESULT_FATAL_ERROR_OUT_OF_MEMORY(1), + + /** + * Data store is not writable or has failed + */ + RESULT_FATAL_ERROR_DATA_STORE_FAILED(2), + + /** + * Internal error (e.g. unexpected exception indicating bug or build problem) + */ + RESULT_FATAL_ERROR_INTERNAL(3), + + // non-fatal errors + + /** + * Network ID not valid + */ + 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/zerotier/sdk/Version.java b/java/src/com/zerotier/sdk/Version.java new file mode 100644 index 00000000..d7fa0ce4 --- /dev/null +++ b/java/src/com/zerotier/sdk/Version.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 . + * + * -- + * + * 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.zerotier.sdk; + +public final class Version { + private Version() {} + + public int major = 0; + public int minor = 0; + public int revision = 0; + public long featureFlags = 0; +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java new file mode 100644 index 00000000..032ba267 --- /dev/null +++ b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java @@ -0,0 +1,170 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +import java.lang.String; +import java.util.ArrayList; +import java.net.InetSocketAddress; + +public final class VirtualNetworkConfig { + public static final int MAX_MULTICAST_SUBSCRIPTIONS = 4096; + public static final int ZT1_MAX_ZT_ASSIGNED_ADDRESSES = 16; + + private long nwid; + private long mac; + private String name; + private VirtualNetworkStatus status; + private VirtualNetworkType type; + private int mtu; + private boolean dhcp; + private boolean bridge; + private boolean broadcastEnabled; + private int portError; + private boolean enabled; + private long netconfRevision; + private ArrayList multicastSubscriptions; + private ArrayList assignedAddresses; + + private VirtualNetworkConfig() { + + } + + /** + * 64-bit ZeroTier network ID + */ + public final long networkId() { + return nwid; + } + + /** + * Ethernet MAC (40 bits) that should be assigned to port + */ + public final long macAddress() { + return mac; + } + + /** + * Network name (from network configuration master) + */ + public final String name() { + return name; + } + + /** + * Network configuration request status + */ + public final VirtualNetworkStatus networkStatus() { + return status; + } + + /** + * Network type + */ + public final VirtualNetworkType networkType() { + return type; + } + + /** + * Maximum interface MTU + */ + public final int mtu() { + return mtu; + } + + /** + * If the network this port belongs to indicates DHCP availability + * + *

This is a suggestion. The underlying implementation is free to ignore it + * for security or other reasons. This is simply a netconf parameter that + * means 'DHCP is available on this network.'

+ */ + public final boolean isDhcpAvailable() { + return dhcp; + } + + /** + * If this port is allowed to bridge to other networks + * + *

This is informational. If this is false, bridged packets will simply + * be dropped and bridging won't work.

+ */ + public final boolean isBridgeEnabled() { + return bridge; + } + + /** + * If true, this network supports and allows broadcast (ff:ff:ff:ff:ff:ff) traffic + */ + public final boolean broadcastEnabled() { + return broadcastEnabled; + } + + /** + * If the network is in PORT_ERROR state, this is the error most recently returned by the port config callback + */ + public final int portError() { + return portError; + } + + /** + * Is this network enabled? If not, all frames to/from are dropped. + */ + public final boolean isEnabled() { + return enabled; + } + + /** + * Network config revision as reported by netconf master + * + *

If this is zero, it means we're still waiting for our netconf.

+ */ + public final long netconfRevision() { + return netconfRevision; + } + + /** + * Multicast group subscriptions + */ + public final ArrayList multicastSubscriptions() { + return multicastSubscriptions; + } + + /** + * ZeroTier-assigned addresses (in {@link java.net.InetSocketAddress} objects) + * + * For IP, the port number of the sockaddr_XX structure contains the number + * of bits in the address netmask. Only the IP address and port are used. + * Other fields like interface number can be ignored. + * + * This is only used for ZeroTier-managed address assignments sent by the + * virtual network's configuration master. + */ + public final ArrayList assignedAddresses() { + return assignedAddresses; + } +} diff --git a/java/src/com/zerotier/sdk/VirtualNetworkConfigListener.java b/java/src/com/zerotier/sdk/VirtualNetworkConfigListener.java new file mode 100644 index 00000000..15ae301c --- /dev/null +++ b/java/src/com/zerotier/sdk/VirtualNetworkConfigListener.java @@ -0,0 +1,60 @@ +/* + * 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/ + */ + + +package com.zerotier.sdk; + + +public interface VirtualNetworkConfigListener { + /** + * Callback called to update virtual network port configuration + * + *

This can be called at any time to update the configuration of a virtual + * network port. The parameter after the network ID specifies whether this + * port is being brought up, updated, brought down, or permanently deleted. + * + * This in turn should be used by the underlying implementation to create + * and configure tap devices at the OS (or virtual network stack) layer.

+ * + * This should not call {@link Node#multicastSubscribe} or other network-modifying + * methods, as this could cause a deadlock in multithreaded or interrupt + * driven environments. + * + * This must return 0 on success. It can return any OS-dependent error code + * on failure, and this results in the network being placed into the + * PORT_ERROR state. + * + * @param nwid network id + * @param op {@link VirtualNetworkConfigOperation} enum describing the configuration operation + * @param config {@link VirtualNetworkConfig} object with the new configuration + * @return 0 on success + */ + public int onNetworkConfigurationUpdated( + long nwid, + VirtualNetworkConfigOperation op, + VirtualNetworkConfig config); +} \ No newline at end of file diff --git a/java/src/com/zerotier/sdk/VirtualNetworkConfigOperation.java b/java/src/com/zerotier/sdk/VirtualNetworkConfigOperation.java new file mode 100644 index 00000000..b70eb478 --- /dev/null +++ b/java/src/com/zerotier/sdk/VirtualNetworkConfigOperation.java @@ -0,0 +1,49 @@ +/* + * 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/ + */ +package com.zerotier.sdk; + +public enum VirtualNetworkConfigOperation { + /** + * Network is coming up (either for the first time or after service restart) + */ + VIRTUAL_NETWORK_CONFIG_OPERATION_UP, + + /** + * Network configuration has been updated + */ + VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE, + + /** + * Network is going down (not permanently) + */ + VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN, + + /** + * Network is going down permanently (leave/delete) + */ + VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY +} diff --git a/java/src/com/zerotier/sdk/VirtualNetworkFrameListener.java b/java/src/com/zerotier/sdk/VirtualNetworkFrameListener.java new file mode 100644 index 00000000..17c6540d --- /dev/null +++ b/java/src/com/zerotier/sdk/VirtualNetworkFrameListener.java @@ -0,0 +1,48 @@ +/* + * 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/ + */ + +package com.zerotier.sdk; + +public interface VirtualNetworkFrameListener { + /** + * Function to send a frame out to a virtual network port + * + * @param nwid ZeroTier One network ID + * @param srcMac source MAC address + * @param destMac destination MAC address + * @param ethertype + * @param vlanId + * @param frameData data to send + */ + void onVirtualNetworkFrame( + long nwid, + long srcMac, + long destMac, + long etherType, + long vlanId, + byte[] frameData); +} diff --git a/java/src/com/zerotier/sdk/VirtualNetworkStatus.java b/java/src/com/zerotier/sdk/VirtualNetworkStatus.java new file mode 100644 index 00000000..2d00561a --- /dev/null +++ b/java/src/com/zerotier/sdk/VirtualNetworkStatus.java @@ -0,0 +1,59 @@ +/* + * 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/ + */ +package com.zerotier.sdk; + +public enum VirtualNetworkStatus { + /** + * Waiting for network configuration (also means revision == 0) + */ + NETWORK_STATUS_REQUESTING_CONFIGURATION, + + /** + * Configuration received and we are authorized + */ + NETWORK_STATUS_OK, + + /** + * Netconf master told us 'nope' + */ + NETWORK_STATUS_ACCESS_DENIED, + + /** + * Netconf master exists, but this virtual network does not + */ + NETWORK_STATUS_NOT_FOUND, + + /** + * Initialization of network failed or other internal error + */ + NETWORK_STATUS_PORT_ERROR, + + /** + * ZeroTier One version too old + */ + NETWORK_STATUS_CLIENT_TOO_OLD +} diff --git a/java/src/com/zerotier/sdk/VirtualNetworkType.java b/java/src/com/zerotier/sdk/VirtualNetworkType.java new file mode 100644 index 00000000..ab1f4e08 --- /dev/null +++ b/java/src/com/zerotier/sdk/VirtualNetworkType.java @@ -0,0 +1,39 @@ +/* + * 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/ + */ +package com.zerotier.sdk; + +public enum VirtualNetworkType { + /** + * Private networks are authorized via certificates of membership + */ + NETWORK_TYPE_PRIVATE, + + /** + * Public networks have no access control -- they'll always be AUTHORIZED + */ + NETWORK_TYPE_PUBLIC +} diff --git a/java/src/com/zerotierone/sdk/DataStoreGetListener.java b/java/src/com/zerotierone/sdk/DataStoreGetListener.java deleted file mode 100644 index c82f744f..00000000 --- a/java/src/com/zerotierone/sdk/DataStoreGetListener.java +++ /dev/null @@ -1,58 +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/ - */ -package com.zerotierone.sdk; - -public interface DataStoreGetListener { - - /** - * Function to get an object from the data store - * - *

Object names can contain forward slash (/) path separators. They will - * never contain .. or backslash (\), so this is safe to map as a Unix-style - * path if the underlying storage permits. For security reasons we recommend - * returning errors if .. or \ are used.

- * - *

The function must return the actual number of bytes read. If the object - * doesn't exist, it should return -1. -2 should be returned on other errors - * such as errors accessing underlying storage.

- * - *

If the read doesn't fit in the buffer, the max number of bytes should be - * read. The caller may call the function multiple times to read the whole - * object.

- * - * @param name Name of the object in the data store - * @param out_buffer buffer to put the object in - * @param bufferIndex index in the object to start reading - * @param out_objectSize long[1] to be set to the actual size of the object if it exists. - * @return the actual number of bytes read. - */ - public long onDataStoreGet( - String name, - byte[] out_buffer, - long bufferIndex, - long[] out_objectSize); -} diff --git a/java/src/com/zerotierone/sdk/DataStorePutListener.java b/java/src/com/zerotierone/sdk/DataStorePutListener.java deleted file mode 100644 index 277cfcc6..00000000 --- a/java/src/com/zerotierone/sdk/DataStorePutListener.java +++ /dev/null @@ -1,59 +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/ - */ -package com.zerotierone.sdk; - -public interface DataStorePutListener { - - /** - * Function to store an object in the data store - * - *

If secure is true, the file should be set readable and writable only - * to the user running ZeroTier One. What this means is platform-specific.

- * - *

Name semantics are the same as {@link DataStoreGetListener}. This must return - * zero on success. You can return any OS-specific error code on failure, as these - * may be visible in logs or error messages and might aid in debugging.

- * - * @param name Object name - * @param buffer data to store - * @param secure set to user read/write only. - * @return 0 on success. - */ - public int onDataStorePut( - String name, - byte[] buffer, - boolean secure); - - /** - * Function to delete an object from the data store - * - * @param name Object name - * @return 0 on success. - */ - public int onDelete( - String name); -} diff --git a/java/src/com/zerotierone/sdk/Event.java b/java/src/com/zerotierone/sdk/Event.java deleted file mode 100644 index 04249fd4..00000000 --- a/java/src/com/zerotierone/sdk/Event.java +++ /dev/null @@ -1,123 +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/ - */ - -package com.zerotierone.sdk; - -public enum Event { - /** - * Node has been initialized - * - * This is the first event generated, and is always sent. It may occur - * before Node's constructor returns. - */ - EVENT_UP, - - /** - * Node is offline -- network does not seem to be reachable by any available strategy - */ - EVENT_OFFLINE, - - /** - * Node is online -- at least one upstream node appears reachable - * - * Meta-data: none - */ - EVENT_ONLINE, - - /** - * Node is shutting down - * - *

This is generated within Node's destructor when it is being shut down. - * It's done for convenience, since cleaning up other state in the event - * handler may appear more idiomatic.

- */ - EVENT_DOWN, - - /** - * Your identity has collided with another node's ZeroTier address - * - *

This happens if two different public keys both hash (via the algorithm - * in Identity::generate()) to the same 40-bit ZeroTier address.

- * - *

This is something you should "never" see, where "never" is defined as - * once per 2^39 new node initializations / identity creations. If you do - * see it, you're going to see it very soon after a node is first - * initialized.

- * - *

This is reported as an event rather than a return code since it's - * detected asynchronously via error messages from authoritative nodes.

- * - *

If this occurs, you must shut down and delete the node, delete the - * identity.secret record/file from the data store, and restart to generate - * a new identity. If you don't do this, you will not be able to communicate - * with other nodes.

- * - *

We'd automate this process, but we don't think silently deleting - * private keys or changing our address without telling the calling code - * is good form. It violates the principle of least surprise.

- * - *

You can technically get away with not handling this, but we recommend - * doing so in a mature reliable application. Besides, handling this - * condition is a good way to make sure it never arises. It's like how - * umbrellas prevent rain and smoke detectors prevent fires. They do, right?

- */ - EVENT_FATAL_ERROR_IDENTITY_COLLISION, - - /** - * A more recent version was observed on the network - * - *

Right now this is only triggered if a hub or supernode 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 - * - *

These events are only generated if this is a TRACE-enabled build.

- * - *

Meta-data: {@link String}, TRACE message

- */ - 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 deleted file mode 100644 index 84b82615..00000000 --- a/java/src/com/zerotierone/sdk/EventListener.java +++ /dev/null @@ -1,67 +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/ - */ - -package com.zerotierone.sdk; - -import java.net.InetSocketAddress; -import java.lang.String; - -/** - * Interface to handle callbacks for ZeroTier One events. - */ -public interface EventListener { - /** - * Callback for events with no other associated metadata - * - * @param event {@link Event} enum - */ - 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 - * - *

These events are only generated if the underlying ZeroTierOne SDK is a TRACE-enabled build.

- * - * @param message the trace message - */ - public void onTrace(String message); -} diff --git a/java/src/com/zerotierone/sdk/MulticastGroup.java b/java/src/com/zerotierone/sdk/MulticastGroup.java deleted file mode 100644 index aa75ab85..00000000 --- a/java/src/com/zerotierone/sdk/MulticastGroup.java +++ /dev/null @@ -1,49 +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/ - */ -package com.zerotierone.sdk; - - -public final class MulticastGroup { - private MulticastGroup() {} - - private long mac; - private long adi; - - /** - * MAC address (least significant 48 bits) - */ - public final long getMacAddress() { - return mac; - } - - /** - * Additional distinguishing information (usually zero) - */ - public final long getAdi() { - return adi; - } -} diff --git a/java/src/com/zerotierone/sdk/NativeUtils.java b/java/src/com/zerotierone/sdk/NativeUtils.java deleted file mode 100644 index d761c68c..00000000 --- a/java/src/com/zerotierone/sdk/NativeUtils.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.zerotierone.sdk; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * Simple library class for working with JNI (Java Native Interface) - * - * @see http://adamheinrich.com/2012/how-to-load-native-jni-library-from-jar - * - * @author Adam Heirnich , http://www.adamh.cz - */ -public class NativeUtils { - - /** - * Private constructor - this class will never be instanced - */ - private NativeUtils() { - } - - /** - * Loads library from current JAR archive - * - * The file from JAR is copied into system temporary directory and then loaded. The temporary file is deleted after exiting. - * Method uses String as filename because the pathname is "abstract", not system-dependent. - * - * @param filename The filename inside JAR as absolute path (beginning with '/'), e.g. /package/File.ext - * @throws IOException If temporary file creation or read/write operation fails - * @throws IllegalArgumentException If source file (param path) does not exist - * @throws IllegalArgumentException If the path is not absolute or if the filename is shorter than three characters (restriction of {@see File#createTempFile(java.lang.String, java.lang.String)}). - */ - public static void loadLibraryFromJar(String path) throws IOException { - - if (!path.startsWith("/")) { - throw new IllegalArgumentException("The path has to be absolute (start with '/')."); - } - - // Obtain filename from path - String[] parts = path.split("/"); - String filename = (parts.length > 1) ? parts[parts.length - 1] : null; - - // Split filename to prexif and suffix (extension) - String prefix = ""; - String suffix = null; - if (filename != null) { - parts = filename.split("\\.", 2); - prefix = parts[0]; - suffix = (parts.length > 1) ? "."+parts[parts.length - 1] : null; // Thanks, davs! :-) - } - - // Check if the filename is okay - if (filename == null || prefix.length() < 3) { - throw new IllegalArgumentException("The filename has to be at least 3 characters long."); - } - - // Prepare temporary file - File temp = File.createTempFile(prefix, suffix); - temp.deleteOnExit(); - - if (!temp.exists()) { - throw new FileNotFoundException("File " + temp.getAbsolutePath() + " does not exist."); - } - - // Prepare buffer for data copying - byte[] buffer = new byte[1024]; - int readBytes; - - // Open and check input stream - InputStream is = NativeUtils.class.getResourceAsStream(path); - if (is == null) { - throw new FileNotFoundException("File " + path + " was not found inside JAR."); - } - - // Open output stream and copy data between source file in JAR and the temporary file - OutputStream os = new FileOutputStream(temp); - try { - while ((readBytes = is.read(buffer)) != -1) { - os.write(buffer, 0, readBytes); - } - } finally { - // If read/write fails, close streams safely before throwing an exception - os.close(); - is.close(); - } - - // Finally, load the library - System.load(temp.getAbsolutePath()); - } -} \ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/Node.java b/java/src/com/zerotierone/sdk/Node.java deleted file mode 100644 index 005147f3..00000000 --- a/java/src/com/zerotierone/sdk/Node.java +++ /dev/null @@ -1,433 +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/ - */ - -package com.zerotierone.sdk; - -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.io.IOException; - -/** - * A ZeroTier One node - */ -public class Node { - static { - try { - System.loadLibrary("ZeroTierOneJNI"); - } catch (UnsatisfiedLinkError e) { - try { - if(System.getProperty("os.name").startsWith("Windows")) { - System.out.println("Arch: " + System.getProperty("sun.arch.data.model")); - if(System.getProperty("sun.arch.data.model").equals("64")) { - NativeUtils.loadLibraryFromJar("/lib/ZeroTierOneJNI_win64.dll"); - } else { - NativeUtils.loadLibraryFromJar("/lib/ZeroTierOneJNI_win32.dll"); - } - } else { - // TODO: Mac - } - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - } - - 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 long nodeId; - - private final DataStoreGetListener getListener; - private final DataStorePutListener putListener; - private final PacketSender sender; - private final EventListener eventListener; - private final VirtualNetworkFrameListener frameListener; - private final VirtualNetworkConfigListener configListener; - - /** - * Create a new ZeroTier One node - * - *

Note that this can take a few seconds the first time it's called, as it - * will generate an identity.

- * - * @param now Current clock in milliseconds - * @param getListener User written instance of the {@link DataStoreGetListener} interface called to get objects from persistent storage. This instance must be unique per Node object. - * @param putListener User written intstance of the {@link DataStorePutListener} interface called to put objects in persistent storage. This instance must be unique per Node object. - * @param sender - * @param eventListener User written instance of the {@link EventListener} interface to receive status updates and non-fatal error notices. This instance must be unique per Node object. - * @param frameListener - * @param configListener User written instance of the {@link VirtualNetworkConfigListener} interface to be called when virtual LANs are created, deleted, or their config parameters change. This instance must be unique per Node object. - */ - public Node(long now, - DataStoreGetListener getListener, - DataStorePutListener putListener, - PacketSender sender, - EventListener eventListener, - VirtualNetworkFrameListener frameListener, - VirtualNetworkConfigListener configListener) throws NodeException - { - this.nodeId = now; - - this.getListener = getListener; - this.putListener = putListener; - this.sender = sender; - this.eventListener = eventListener; - this.frameListener = frameListener; - this.configListener = configListener; - - ResultCode rc = node_init(now); - if(rc != ResultCode.RESULT_OK) - { - // TODO: Throw Exception - throw new NodeException(rc.toString()); - } - } - - /** - * Close this Node. - * - *

The Node object can no longer be used once this method is called.

- */ - public void close() { - if(nodeId != -1) { - node_delete(nodeId); - nodeId = -1; - } - } - - @Override - protected void finalize() { - close(); - } - - /** - * Process a frame from a virtual network port - * - * @param now Current clock in milliseconds - * @param nwid ZeroTier 64-bit virtual network ID - * @param sourceMac Source MAC address (least significant 48 bits) - * @param destMac Destination MAC address (least significant 48 bits) - * @param etherType 16-bit Ethernet frame type - * @param vlanId 10-bit VLAN ID or 0 if none - * @param frameData Frame payload data - * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode processVirtualNetworkFrame( - long now, - long nwid, - long sourceMac, - long destMac, - int etherType, - int vlanId, - byte[] frameData, - long[] nextBackgroundTaskDeadline) { - return processVirtualNetworkFrame( - nodeId, now, nwid, sourceMac, destMac, etherType, vlanId, - frameData, nextBackgroundTaskDeadline); - } - - /** - * Process a packet received from the physical wire - * - * @param now Current clock in milliseconds - * @param remoteAddress Origin of packet - * @param linkDesperation Link desperation metric for link or protocol over which packet arrived - * @param packetData Packet data - * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode processWirePacket( - long now, - InetSocketAddress remoteAddress, - int linkDesperation, - byte[] packetData, - long[] nextBackgroundTaskDeadline) { - return processWirePacket( - nodeId, now, remoteAddress, linkDesperation, packetData, - nextBackgroundTaskDeadline); - } - - /** - * Perform periodic background operations - * - * @param now Current clock in milliseconds - * @param nextBackgroundTaskDeadline Value/result: set to deadline for next call to processBackgroundTasks() - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode processBackgroundTasks(long now, long[] nextBackgroundTaskDeadline) { - return processBackgroundTasks(nodeId, now, nextBackgroundTaskDeadline); - } - - /** - * Join a network - * - *

This may generate calls to the port config callback before it returns, - * or these may be deffered if a netconf is not available yet.

- * - *

If we are already a member of the network, nothing is done and OK is - * returned.

- * - * @param nwid 64-bit ZeroTier network ID - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode join(long nwid) { - return join(nodeId, nwid); - } - - /** - * Leave a network - * - *

If a port has been configured for this network this will generate a call - * to the port config callback with a NULL second parameter to indicate that - * the port is now deleted.

- * - * @param nwid 64-bit network ID - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode leave(long nwid) { - return leave(nodeId, nwid); - } - - /** - * Subscribe to an Ethernet multicast group - * - *

For IPv4 ARP, the implementation must subscribe to 0xffffffffffff (the - * broadcast address) but with an ADI equal to each IPv4 address in host - * byte order. This converts ARP from a non-scalable broadcast protocol to - * a scalable multicast protocol with perfect address specificity.

- * - *

If this is not done, ARP will not work reliably.

- * - *

Multiple calls to subscribe to the same multicast address will have no - * effect. It is perfectly safe to do this.

- * - *

This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.

- * - * @param nwid 64-bit network ID - * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode multicastSubscribe( - long nwid, - long multicastGroup) { - return multicastSubscribe(nodeId, nwid, multicastGroup, 0); - } - - /** - * Subscribe to an Ethernet multicast group - * - *

ADI stands for additional distinguishing information. This defaults to zero - * and is rarely used. Right now its only use is to enable IPv4 ARP to scale, - * and this must be done.

- * - *

For IPv4 ARP, the implementation must subscribe to 0xffffffffffff (the - * broadcast address) but with an ADI equal to each IPv4 address in host - * byte order. This converts ARP from a non-scalable broadcast protocol to - * a scalable multicast protocol with perfect address specificity.

- * - *

If this is not done, ARP will not work reliably.

- * - *

Multiple calls to subscribe to the same multicast address will have no - * effect. It is perfectly safe to do this.

- * - *

This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.

- * - * @param nwid 64-bit network ID - * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) - * @param multicastAdi Multicast ADI (least significant 32 bits only, default: 0) - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode multicastSubscribe( - long nwid, - long multicastGroup, - long multicastAdi) { - return multicastSubscribe(nodeId, nwid, multicastGroup, multicastAdi); - } - - - /** - * Unsubscribe from an Ethernet multicast group (or all groups) - * - *

If multicastGroup is zero (0), this will unsubscribe from all groups. If - * you are not subscribed to a group this has no effect.

- * - *

This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.

- * - * @param nwid 64-bit network ID - * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode multicastUnsubscribe( - long nwid, - long multicastGroup) { - return multicastUnsubscribe(nodeId, nwid, multicastGroup, 0); - } - - /** - * Unsubscribe from an Ethernet multicast group (or all groups) - * - *

If multicastGroup is zero (0), this will unsubscribe from all groups. If - * you are not subscribed to a group this has no effect.

- * - *

This does not generate an update call to the {@link VirtualNetworkConfigListener#onNetworkConfigurationUpdated} method.

- * - *

ADI stands for additional distinguishing information. This defaults to zero - * and is rarely used. Right now its only use is to enable IPv4 ARP to scale, - * and this must be done.

- * - * @param nwid 64-bit network ID - * @param multicastGroup Ethernet multicast or broadcast MAC (least significant 48 bits) - * @param multicastAdi Multicast ADI (least significant 32 bits only, default: 0) - * @return OK (0) or error code if a fatal error condition has occurred - */ - public ResultCode multicastUnsubscribe( - long nwid, - long multicastGroup, - long multicastAdi) { - return multicastUnsubscribe(nodeId, nwid, multicastGroup, multicastAdi); - } - - /** - * Get this node's 40-bit ZeroTier address - * - * @return ZeroTier address (least significant 40 bits of 64-bit int) - */ - public long address() { - return address(nodeId); - } - - /** - * Get the status of this node - * - * @return @{link NodeStatus} struct with the current node status. - */ - public NodeStatus status() { - return status(nodeId); - } - - /** - * Get a list of known peer nodes - * - * @return List of known peers or NULL on failure - */ - public ArrayList peers() { - return peers(nodeId); - } - - /** - * Get the status of a virtual network - * - * @param nwid 64-bit network ID - * @return {@link VirtualNetworkConfig} or NULL if we are not a member of this network - */ - public VirtualNetworkConfig networkConfig(long nwid) { - return networkConfig(nodeId, nwid); - } - - /** - * Enumerate and get status of all networks - * - * @return List of networks or NULL on failure - */ - public ArrayList networks() { - return networks(nodeId); - } - - /** - * Get ZeroTier One version - * - * @return {@link Version} object with ZeroTierOne version information. - */ - public Version getVersion() { - return version(); - } - - // - // function declarations for JNI - // - private native ResultCode node_init(long now); - - private native void node_delete(long nodeId); - - private native ResultCode processVirtualNetworkFrame( - long nodeId, - long now, - long nwid, - long sourceMac, - long destMac, - int etherType, - int vlanId, - byte[] frameData, - long[] nextBackgroundTaskDeadline); - - private native ResultCode processWirePacket( - long nodeId, - long now, - InetSocketAddress remoteAddress, - int linkDesperation, - byte[] packetData, - long[] nextBackgroundTaskDeadline); - - 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); - - private native NodeStatus status(long nodeId); - - private native VirtualNetworkConfig networkConfig(long nodeId, long nwid); - - private native Version version(); - - private native ArrayList peers(long nodeId); - - private native ArrayList networks(long nodeId); -} \ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/NodeException.java b/java/src/com/zerotierone/sdk/NodeException.java deleted file mode 100644 index 81111a58..00000000 --- a/java/src/com/zerotierone/sdk/NodeException.java +++ /dev/null @@ -1,36 +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/ - */ - -package com.zerotierone.sdk; - -import java.lang.RuntimeException; - -class NodeException extends RuntimeException { - NodeException(String message) { - super(message); - } -} \ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/NodeStatus.java b/java/src/com/zerotierone/sdk/NodeStatus.java deleted file mode 100644 index 163e3056..00000000 --- a/java/src/com/zerotierone/sdk/NodeStatus.java +++ /dev/null @@ -1,69 +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/ - */ - -package com.zerotierone.sdk; - -public final class NodeStatus { - private long address; - private String publicIdentity; - private String secretIdentity; - private boolean online; - - private NodeStatus() {} - - /** - * 40-bit ZeroTier address of this node - */ - public final long getAddres() { - return address; - } - - /** - * Public identity in string-serialized form (safe to send to others) - * - *

This identity will remain valid as long as the node exists.

- */ - public final String getPublicIdentity() { - return publicIdentity; - } - - /** - * Full identity including secret key in string-serialized form - * - *

This identity will remain valid as long as the node exists.

- */ - public final String getSecretIdentity() { - return secretIdentity; - } - - /** - * True if some kind of connectivity appears available - */ - public final boolean isOnline() { - return online; - } -} \ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/PacketSender.java b/java/src/com/zerotierone/sdk/PacketSender.java deleted file mode 100644 index a4cbb0e5..00000000 --- a/java/src/com/zerotierone/sdk/PacketSender.java +++ /dev/null @@ -1,49 +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/ - */ -package com.zerotierone.sdk; - -import java.net.InetSocketAddress; - - -public interface PacketSender { - /** - * Function to send a ZeroTier packet out over the wire - * - *

The function must return zero on success and may return any error code - * 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 linkDesperation - * @param packetData data to send - * @return 0 on success, any error code on failure. - */ - public int onSendPacketRequested( - InetSocketAddress addr, - int linkDesperation, - byte[] packetData); -} diff --git a/java/src/com/zerotierone/sdk/Peer.java b/java/src/com/zerotierone/sdk/Peer.java deleted file mode 100644 index f01755ba..00000000 --- a/java/src/com/zerotierone/sdk/Peer.java +++ /dev/null @@ -1,110 +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/ - */ - -package com.zerotierone.sdk; - -import java.util.ArrayList; - -/** - * Peer status result - */ -public final class Peer { - private long address; - private long lastUnicastFrame; - private long lastMulticastFrame; - private int versionMajor; - private int versionMinor; - private int versionRev; - private int latency; - private PeerRole role; - private ArrayList paths; - - private Peer() {} - - /** - * ZeroTier address (40 bits) - */ - public final long address() { - return address; - } - - /** - * Time we last received a unicast frame from this peer - */ - public final long lastUnicastFrame() { - return lastUnicastFrame; - } - - /** - * Time we last received a multicast rame from this peer - */ - public final long lastMulticastFrame() { - return lastMulticastFrame; - } - - /** - * Remote major version or -1 if not known - */ - public final int versionMajor() { - return versionMajor; - } - - /** - * Remote minor version or -1 if not known - */ - public final int versionMinor() { - return versionMinor; - } - - /** - * Remote revision or -1 if not known - */ - public final int versionRev() { - return versionRev; - } - - /** - * Last measured latency in milliseconds or zero if unknown - */ - public final int latency() { - return latency; - } - - /** - * What trust hierarchy role does this device have? - */ - public final PeerRole role() { - return role; - } - - /** - * Known network paths to peer - */ - public final ArrayList paths() { - return paths; - } -} \ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/PeerPhysicalPath.java b/java/src/com/zerotierone/sdk/PeerPhysicalPath.java deleted file mode 100644 index 15f04241..00000000 --- a/java/src/com/zerotierone/sdk/PeerPhysicalPath.java +++ /dev/null @@ -1,86 +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/ - */ - -package com.zerotierone.sdk; - -import java.net.InetSocketAddress; - -/** - * Physical network path to a peer - */ -public final class PeerPhysicalPath { - private InetSocketAddress address; - private long lastSend; - private long lastReceive; - private boolean fixed; - private boolean active; - private boolean preferred; - - private PeerPhysicalPath() {} - - /** - * Address of endpoint - */ - public final InetSocketAddress address() { - return address; - } - - /** - * Time of last send in milliseconds or 0 for never - */ - public final long lastSend() { - return lastSend; - } - - /** - * Time of last receive in milliseconds or 0 for never - */ - public final long lastReceive() { - return lastReceive; - } - - /** - * Is path fixed? (i.e. not learned, static) - */ - public final boolean isFixed() { - return fixed; - } - - /** - * Is path active? - */ - public final boolean isActive() { - return active; - } - - /** - * Is path preferred? - */ - public final boolean isPreferred() { - return preferred; - } -} \ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/PeerRole.java b/java/src/com/zerotierone/sdk/PeerRole.java deleted file mode 100644 index 7f507f6d..00000000 --- a/java/src/com/zerotierone/sdk/PeerRole.java +++ /dev/null @@ -1,45 +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/ - */ - -package com.zerotierone.sdk; - -public enum PeerRole { - /** - * An ordinary node - */ - PEER_ROLE_LEAF, - - /** - * Locally federated hub - */ - PEER_ROLE_HUB, - - /** - * planetary supernode - */ - PEER_ROLE_SUPERNODE -} \ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/ResultCode.java b/java/src/com/zerotierone/sdk/ResultCode.java deleted file mode 100644 index bb73f68c..00000000 --- a/java/src/com/zerotierone/sdk/ResultCode.java +++ /dev/null @@ -1,74 +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/ - */ - -package com.zerotierone.sdk; - -/** - * Function return code: OK (0) or error results - * - *

Use {@link ResultCode#isFatal) to check for a fatal error. If a fatal error - * occurs, the node should be considered to not be working correctly. These - * indicate serious problems like an inaccessible data store or a compile - * problem.

- */ -public enum ResultCode { - /** - * Operation completed normally - */ - RESULT_OK(0), - - // Fatal errors (> 0, < 1000) - /** - * Ran out of memory - */ - RESULT_FATAL_ERROR_OUT_OF_MEMORY(1), - - /** - * Data store is not writable or has failed - */ - RESULT_FATAL_ERROR_DATA_STORE_FAILED(2), - - /** - * Internal error (e.g. unexpected exception indicating bug or build problem) - */ - RESULT_FATAL_ERROR_INTERNAL(3), - - // non-fatal errors - - /** - * Network ID not valid - */ - 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 deleted file mode 100644 index 14e9f152..00000000 --- a/java/src/com/zerotierone/sdk/Version.java +++ /dev/null @@ -1,37 +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/ - */ - -package com.zerotierone.sdk; - -public final class Version { - private Version() {} - - public int major = 0; - public int minor = 0; - public int revision = 0; - public long featureFlags = 0; -} \ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java b/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java deleted file mode 100644 index 10d9f873..00000000 --- a/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java +++ /dev/null @@ -1,170 +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/ - */ - -package com.zerotierone.sdk; - -import java.lang.String; -import java.util.ArrayList; -import java.net.InetSocketAddress; - -public final class VirtualNetworkConfig { - public static final int MAX_MULTICAST_SUBSCRIPTIONS = 4096; - public static final int ZT1_MAX_ZT_ASSIGNED_ADDRESSES = 16; - - private long nwid; - private long mac; - private String name; - private VirtualNetworkStatus status; - private VirtualNetworkType type; - private int mtu; - private boolean dhcp; - private boolean bridge; - private boolean broadcastEnabled; - private int portError; - private boolean enabled; - private long netconfRevision; - private ArrayList multicastSubscriptions; - private ArrayList assignedAddresses; - - private VirtualNetworkConfig() { - - } - - /** - * 64-bit ZeroTier network ID - */ - public final long networkId() { - return nwid; - } - - /** - * Ethernet MAC (40 bits) that should be assigned to port - */ - public final long macAddress() { - return mac; - } - - /** - * Network name (from network configuration master) - */ - public final String name() { - return name; - } - - /** - * Network configuration request status - */ - public final VirtualNetworkStatus networkStatus() { - return status; - } - - /** - * Network type - */ - public final VirtualNetworkType networkType() { - return type; - } - - /** - * Maximum interface MTU - */ - public final int mtu() { - return mtu; - } - - /** - * If the network this port belongs to indicates DHCP availability - * - *

This is a suggestion. The underlying implementation is free to ignore it - * for security or other reasons. This is simply a netconf parameter that - * means 'DHCP is available on this network.'

- */ - public final boolean isDhcpAvailable() { - return dhcp; - } - - /** - * If this port is allowed to bridge to other networks - * - *

This is informational. If this is false, bridged packets will simply - * be dropped and bridging won't work.

- */ - public final boolean isBridgeEnabled() { - return bridge; - } - - /** - * If true, this network supports and allows broadcast (ff:ff:ff:ff:ff:ff) traffic - */ - public final boolean broadcastEnabled() { - return broadcastEnabled; - } - - /** - * If the network is in PORT_ERROR state, this is the error most recently returned by the port config callback - */ - public final int portError() { - return portError; - } - - /** - * Is this network enabled? If not, all frames to/from are dropped. - */ - public final boolean isEnabled() { - return enabled; - } - - /** - * Network config revision as reported by netconf master - * - *

If this is zero, it means we're still waiting for our netconf.

- */ - public final long netconfRevision() { - return netconfRevision; - } - - /** - * Multicast group subscriptions - */ - public final ArrayList multicastSubscriptions() { - return multicastSubscriptions; - } - - /** - * ZeroTier-assigned addresses (in {@link java.net.InetSocketAddress} objects) - * - * For IP, the port number of the sockaddr_XX structure contains the number - * of bits in the address netmask. Only the IP address and port are used. - * Other fields like interface number can be ignored. - * - * This is only used for ZeroTier-managed address assignments sent by the - * virtual network's configuration master. - */ - public final ArrayList assignedAddresses() { - return assignedAddresses; - } -} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java b/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java deleted file mode 100644 index 2a26d79d..00000000 --- a/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java +++ /dev/null @@ -1,60 +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/ - */ - - -package com.zerotierone.sdk; - - -public interface VirtualNetworkConfigListener { - /** - * Callback called to update virtual network port configuration - * - *

This can be called at any time to update the configuration of a virtual - * network port. The parameter after the network ID specifies whether this - * port is being brought up, updated, brought down, or permanently deleted. - * - * This in turn should be used by the underlying implementation to create - * and configure tap devices at the OS (or virtual network stack) layer.

- * - * This should not call {@link Node#multicastSubscribe} or other network-modifying - * methods, as this could cause a deadlock in multithreaded or interrupt - * driven environments. - * - * This must return 0 on success. It can return any OS-dependent error code - * on failure, and this results in the network being placed into the - * PORT_ERROR state. - * - * @param nwid network id - * @param op {@link VirtualNetworkConfigOperation} enum describing the configuration operation - * @param config {@link VirtualNetworkConfig} object with the new configuration - * @return 0 on success - */ - public int onNetworkConfigurationUpdated( - long nwid, - 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 deleted file mode 100644 index 989961b3..00000000 --- a/java/src/com/zerotierone/sdk/VirtualNetworkConfigOperation.java +++ /dev/null @@ -1,49 +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/ - */ -package com.zerotierone.sdk; - -public enum VirtualNetworkConfigOperation { - /** - * Network is coming up (either for the first time or after service restart) - */ - VIRTUAL_NETWORK_CONFIG_OPERATION_UP, - - /** - * Network configuration has been updated - */ - VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE, - - /** - * Network is going down (not permanently) - */ - VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN, - - /** - * Network is going down permanently (leave/delete) - */ - VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY -} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java b/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java deleted file mode 100644 index 07051a57..00000000 --- a/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java +++ /dev/null @@ -1,48 +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/ - */ - -package com.zerotierone.sdk; - -public interface VirtualNetworkFrameListener { - /** - * Function to send a frame out to a virtual network port - * - * @param nwid ZeroTier One network ID - * @param srcMac source MAC address - * @param destMac destination MAC address - * @param ethertype - * @param vlanId - * @param frameData data to send - */ - void onVirtualNetworkFrame( - long nwid, - long srcMac, - long destMac, - long etherType, - long vlanId, - byte[] frameData); -} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java b/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java deleted file mode 100644 index 78df06b9..00000000 --- a/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java +++ /dev/null @@ -1,59 +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/ - */ -package com.zerotierone.sdk; - -public enum VirtualNetworkStatus { - /** - * Waiting for network configuration (also means revision == 0) - */ - NETWORK_STATUS_REQUESTING_CONFIGURATION, - - /** - * Configuration received and we are authorized - */ - NETWORK_STATUS_OK, - - /** - * Netconf master told us 'nope' - */ - NETWORK_STATUS_ACCESS_DENIED, - - /** - * Netconf master exists, but this virtual network does not - */ - NETWORK_STATUS_NOT_FOUND, - - /** - * Initialization of network failed or other internal error - */ - NETWORK_STATUS_PORT_ERROR, - - /** - * ZeroTier One version too old - */ - NETWORK_STATUS_CLIENT_TOO_OLD -} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkType.java b/java/src/com/zerotierone/sdk/VirtualNetworkType.java deleted file mode 100644 index adc2eaff..00000000 --- a/java/src/com/zerotierone/sdk/VirtualNetworkType.java +++ /dev/null @@ -1,39 +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/ - */ -package com.zerotierone.sdk; - -public enum VirtualNetworkType { - /** - * Private networks are authorized via certificates of membership - */ - NETWORK_TYPE_PRIVATE, - - /** - * Public networks have no access control -- they'll always be AUTHORIZED - */ - NETWORK_TYPE_PUBLIC -} -- cgit v1.2.3