mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
added implementation for processVirtualNetworkFrame
Signed-off-by: Grant Limberg <glimberg@gmail.com>
This commit is contained in:
parent
3a6807d584
commit
5df253fa69
1 changed files with 252 additions and 186 deletions
|
@ -25,7 +25,7 @@
|
|||
* LLC. Start here: http://www.zerotier.com/
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include "com_zerotierone_sdk_Node.h"
|
||||
|
||||
#include <ZeroTierOne.h>
|
||||
|
||||
|
@ -291,6 +291,72 @@ JNIEXPORT void JNICALL Java_com_zerotierone_sdk_Node_node_1delete
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_zerotierone_sdk_Node
|
||||
* Method: processVirtualNetworkFrame
|
||||
* Signature: (JJJJJII[B[J)Lcom/zerotierone/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_processVirtualNetworkFrame
|
||||
(JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
jlong in_now,
|
||||
jlong in_nwid,
|
||||
jlong in_sourceMac,
|
||||
jlong in_destMac,
|
||||
jint in_etherType,
|
||||
jint in_vlanId,
|
||||
jbyteArray in_frameData,
|
||||
jlongArray out_nextBackgroundTaskDeadline)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
NodeMap::iterator found = nodeMap.find(nodeId);
|
||||
if(found == nodeMap.end())
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
// array for next background task length has 0 elements!
|
||||
return createResultObject(env, ZT1_RESULT_FATAL_ERROR_INTERNAL);
|
||||
}
|
||||
|
||||
ZT1_Node *node = found->second;
|
||||
|
||||
uint64_t now = (uint64_t)in_now;
|
||||
uint64_t nwid = (uint64_t)in_nwid;
|
||||
uint64_t sourceMac = (uint64_t)in_sourceMac;
|
||||
uint64_t destMac = (uint64_t)in_destMac;
|
||||
unsigned int etherType = (unsigned int)in_etherType;
|
||||
unsigned int vlanId = (unsigned int)in_vlanId;
|
||||
|
||||
unsigned int frameLength = env->GetArrayLength(in_frameData);
|
||||
jbyte *frameData =env->GetByteArrayElements(in_frameData, NULL);
|
||||
|
||||
uint64_t nextBackgroundTaskDeadline = 0;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_processVirtualNetworkFrame(
|
||||
node,
|
||||
now,
|
||||
nwid,
|
||||
sourceMac,
|
||||
destMac,
|
||||
etherType,
|
||||
vlanId,
|
||||
(const void*)frameData,
|
||||
frameLength,
|
||||
&nextBackgroundTaskDeadline);
|
||||
|
||||
jlong *outDeadline = env->GetLongArrayElements(out_nextBackgroundTaskDeadline, NULL);
|
||||
outDeadline[0] = (jlong)nextBackgroundTaskDeadline;
|
||||
env->ReleaseLongArrayElements(out_nextBackgroundTaskDeadline, outDeadline, 0);
|
||||
|
||||
env->ReleaseByteArrayElements(in_frameData, frameData, 0);
|
||||
|
||||
return createResultObject(env, rc);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Add table
Reference in a new issue