summaryrefslogtreecommitdiff
path: root/java/jni/com_zerotierone_sdk_Node.cpp
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2015-04-22 20:25:35 -0700
committerGrant Limberg <glimberg@gmail.com>2015-04-22 20:25:35 -0700
commite31e54483c0b7bd32d1122b7952c4f8a7315acf8 (patch)
treeacb4908365b3536c15cc4c15eefc3d92e8142eb0 /java/jni/com_zerotierone_sdk_Node.cpp
parent3c499777c827635d58288d04e6ddf43b9c3d9d8b (diff)
downloadinfinitytier-e31e54483c0b7bd32d1122b7952c4f8a7315acf8.tar.gz
infinitytier-e31e54483c0b7bd32d1122b7952c4f8a7315acf8.zip
added processBackgroundTasks function
Signed-off-by: Grant Limberg <glimberg@gmail.com>
Diffstat (limited to 'java/jni/com_zerotierone_sdk_Node.cpp')
-rw-r--r--java/jni/com_zerotierone_sdk_Node.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/java/jni/com_zerotierone_sdk_Node.cpp b/java/jni/com_zerotierone_sdk_Node.cpp
index d2c5d1ae..118e36d5 100644
--- a/java/jni/com_zerotierone_sdk_Node.cpp
+++ b/java/jni/com_zerotierone_sdk_Node.cpp
@@ -482,6 +482,42 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processWirePacket
return createResultObject(env, ZT1_RESULT_OK);
}
+/*
+ * Class: com_zerotierone_sdk_Node
+ * Method: processBackgroundTasks
+ * Signature: (JJ[J)Lcom/zerotierone/sdk/ResultCode;
+ */
+JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processBackgroundTasks
+ (JNIEnv *env, jobject obj,
+ jlong id,
+ jlong in_now,
+ jlongArray out_nextBackgroundTaskDeadline)
+{
+ uint64_t nodeId = (uint64_t) id;
+ ZT1_Node *node = findNode(nodeId);
+ if(node == NULL)
+ {
+ // cannot find valid node. We should never get here.
+ return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
+ }
+
+ unsigned int nbtd_len = env->GetArrayLength(out_nextBackgroundTaskDeadline);
+ if(nbtd_len < 1)
+ {
+ return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
+ }
+
+ uint64_t now = (uint64_t)in_now;
+ uint64_t nextBackgroundTaskDeadline = 0;
+
+ ZT1_ResultCode rc = ZT1_Node_processBackgroundTasks(node, now, &nextBackgroundTaskDeadline);
+
+ jlong *outDeadline = env->GetLongArrayElements(out_nextBackgroundTaskDeadline, NULL);
+ outDeadline[0] = (jlong)nextBackgroundTaskDeadline;
+ env->ReleaseLongArrayElements(out_nextBackgroundTaskDeadline, outDeadline, 0);
+
+ return createResultObject(env, rc);
+}
#ifdef __cplusplus
} // extern "C"