From e31e54483c0b7bd32d1122b7952c4f8a7315acf8 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 22 Apr 2015 20:25:35 -0700 Subject: added processBackgroundTasks function Signed-off-by: Grant Limberg --- java/jni/com_zerotierone_sdk_Node.cpp | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'java/jni/com_zerotierone_sdk_Node.cpp') 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" -- cgit v1.2.3