summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2017-03-29 13:29:02 -0700
committerGrant Limberg <grant.limberg@zerotier.com>2017-03-29 13:29:02 -0700
commit5f611dad51f8244b59a63ecdf48a2126c5995d74 (patch)
tree957c32101f1398b0a9a2507d9860a140bd614a3e /java
parent1c5fdb8a0a20654cdec57347647034357e0f92a4 (diff)
downloadinfinitytier-5f611dad51f8244b59a63ecdf48a2126c5995d74.tar.gz
infinitytier-5f611dad51f8244b59a63ecdf48a2126c5995d74.zip
added orbit/deorbit methods to java Node implementation
Diffstat (limited to 'java')
-rw-r--r--java/jni/com_zerotierone_sdk_Node.cpp48
-rw-r--r--java/src/com/zerotier/sdk/Node.java38
2 files changed, 86 insertions, 0 deletions
diff --git a/java/jni/com_zerotierone_sdk_Node.cpp b/java/jni/com_zerotierone_sdk_Node.cpp
index ac0453ba..defbe7f2 100644
--- a/java/jni/com_zerotierone_sdk_Node.cpp
+++ b/java/jni/com_zerotierone_sdk_Node.cpp
@@ -1286,6 +1286,54 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastUnsubscribe(
}
/*
+ * Class: com_zerotier_sdk_Node
+ * Method: orbit
+ * Signature: (JJJ)Lcom/zerotier/sdk/ResultCode;
+ */
+JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_orbit(
+ JNIEnv *env, jobject obj,
+ jlong id,
+ jlong in_moonWorldId,
+ jlong in_moonSeed)
+{
+ uint64_t nodeId = (uint64_t)id;
+ ZT_Node *node = findNode(nodeId);
+ if(node == NULL)
+ {
+ return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
+ }
+
+ uint64_t moonWorldId = (uint64_t)in_moonWorldId;
+ uint64_t moonSeed = (uint64_t)in_moonSeed;
+
+ ZT_ResultCode rc = ZT_Node_orbit(node, NULL, moonWorldId, moonSeed);
+ return createResultObject(env, rc);
+}
+
+/*
+ * Class: com_zerotier_sdk_Node
+ * Method: deorbit
+ * Signature: (JJ)L/com/zerotier/sdk/ResultCode;
+ */
+JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_deorbit(
+ JNIEnv *env, jobject obj,
+ jlong id,
+ jlong in_moonWorldId)
+{
+ uint64_t nodeId = (uint64_t)id;
+ ZT_Node *node = findNode(nodeId);
+ if(node == NULL)
+ {
+ return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
+ }
+
+ uint64_t moonWorldId = (uint64_t)in_moonWorldId;
+
+ ZT_ResultCode rc = ZT_Node_deorbit(node, NULL, moonWorldId);
+ return createResultObject(env, rc);
+}
+
+/*
* Class: com_zerotier_sdk_Node
* Method: address
* Signature: (J)J
diff --git a/java/src/com/zerotier/sdk/Node.java b/java/src/com/zerotier/sdk/Node.java
index 7b111f74..8e7d44e7 100644
--- a/java/src/com/zerotier/sdk/Node.java
+++ b/java/src/com/zerotier/sdk/Node.java
@@ -89,6 +89,7 @@ public class Node {
* @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.
+ * @param pathChecker User written instance of the {@link PathChecker} interface. Not required and can be null.
*/
public Node(long now,
DataStoreGetListener getListener,
@@ -322,6 +323,34 @@ public class Node {
}
/**
+ * Add or update a moon
+ *
+ * Moons are persisted in the data store in moons.d/, so this can persist
+ * across invocations if the contents of moon.d are scanned and orbit is
+ * called for each on startup.
+ *
+ * @param moonWorldId Moon's world ID
+ * @param moonSeed If non-zero, the ZeroTier address of any member of the moon to query for moon definition
+ * @return Error if moon was invalid or failed to be added
+ */
+ public ResultCode orbit(
+ long moonWorldId,
+ long moonSeed) {
+ return orbit(nodeId, moonWorldId, moonSeed);
+ }
+
+ /**
+ * Remove a moon (does nothing if not present)
+ *
+ * @param moonWorldId World ID of moon to remove
+ * @return Error if anything bad happened
+ */
+ public ResultCode deorbit(
+ long moonWorldId) {
+ return deorbit(nodeId, moonWorldId);
+ }
+
+ /**
* Get this node's 40-bit ZeroTier address
*
* @return ZeroTier address (least significant 40 bits of 64-bit int)
@@ -423,6 +452,15 @@ public class Node {
long multicastGroup,
long multicastAdi);
+ private native ResultCode orbit(
+ long nodeId,
+ long moonWorldId,
+ long moonSeed);
+
+ private native ResultCode deorbit(
+ long nodeId,
+ long moonWorldId);
+
private native long address(long nodeId);
private native NodeStatus status(long nodeId);