mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-21 18:06:39 +00:00
implemented VirtualNetworkFrameFunctionCallback
This commit is contained in:
parent
28168fa673
commit
4137246653
@ -65,7 +65,12 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int VirtualNetworkConfigFunctionCallback(ZT1_Node *node,void *userData,uint64_t nwid,enum ZT1_VirtualNetworkConfigOperation operation, const ZT1_VirtualNetworkConfig *config)
|
int VirtualNetworkConfigFunctionCallback(
|
||||||
|
ZT1_Node *node,
|
||||||
|
void *userData,
|
||||||
|
uint64_t nwid,
|
||||||
|
enum ZT1_VirtualNetworkConfigOperation operation,
|
||||||
|
const ZT1_VirtualNetworkConfig *config)
|
||||||
{
|
{
|
||||||
JniRef *ref = (JniRef*)userData;
|
JniRef *ref = (JniRef*)userData;
|
||||||
assert(ref->node == node);
|
assert(ref->node == node);
|
||||||
@ -110,14 +115,49 @@ namespace {
|
|||||||
return env->CallIntMethod(ref->configListener, callbackMethod, (jlong)nwid, operationObject, networkConfigObject);
|
return env->CallIntMethod(ref->configListener, callbackMethod, (jlong)nwid, operationObject, networkConfigObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VirtualNetworkFrameFunctionCallback(ZT1_Node *node,void *userData,uint64_t,uint64_t,uint64_t,unsigned int,unsigned int,const void *,unsigned int)
|
void VirtualNetworkFrameFunctionCallback(ZT1_Node *node,void *userData,
|
||||||
|
uint64_t nwid,
|
||||||
|
uint64_t sourceMac,
|
||||||
|
uint64_t destMac,
|
||||||
|
unsigned int etherType,
|
||||||
|
unsigned int vlanid,
|
||||||
|
const void *frameData,
|
||||||
|
unsigned int frameLength)
|
||||||
{
|
{
|
||||||
JniRef *ref = (JniRef*)userData;
|
JniRef *ref = (JniRef*)userData;
|
||||||
assert(ref->node == node);
|
assert(ref->node == node);
|
||||||
|
|
||||||
JNIEnv *env = ref->env;
|
JNIEnv *env = ref->env;
|
||||||
|
|
||||||
|
static jclass frameListenerClass = NULL;
|
||||||
|
static jmethodID callbackMethod = NULL;
|
||||||
|
|
||||||
|
if(frameListenerClass == NULL)
|
||||||
|
{
|
||||||
|
frameListenerClass = env->GetObjectClass(ref->frameListener);
|
||||||
|
if(frameListenerClass == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(callbackMethod == NULL)
|
||||||
|
{
|
||||||
|
callbackMethod = env->GetMethodID(frameListenerClass,
|
||||||
|
"onVirtualNetworkFrame", "(JJJJJ[B)V");
|
||||||
|
if(callbackMethod == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jbyteArray dataArray = env->NewByteArray(frameLength);
|
||||||
|
env->SetByteArrayRegion(dataArray, 0, frameLength, (jbyte*)frameData);
|
||||||
|
|
||||||
|
env->CallVoidMethod(ref->frameListener, callbackMethod, nwid, sourceMac, destMac, etherType, vlanid, dataArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EventCallback(ZT1_Node *node,void *userData,enum ZT1_Event,const void *)
|
void EventCallback(ZT1_Node *node,void *userData,enum ZT1_Event,const void *)
|
||||||
{
|
{
|
||||||
JniRef *ref = (JniRef*)userData;
|
JniRef *ref = (JniRef*)userData;
|
||||||
|
@ -24,17 +24,17 @@
|
|||||||
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
* redistribute it in a modified binary form, please contact ZeroTier Networks
|
||||||
* LLC. Start here: http://www.zerotier.com/
|
* LLC. Start here: http://www.zerotier.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.zerotierone.sdk;
|
package com.zerotierone.sdk;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
public interface VirtualNetworkFrameListener {
|
public interface VirtualNetworkFrameListener {
|
||||||
void onVirtualNetworkFrame(Node node,
|
void onVirtualNetworkFrame(
|
||||||
long nwid,
|
long nwid,
|
||||||
long srcMac,
|
long srcMac,
|
||||||
long destMac,
|
long destMac,
|
||||||
long etherType,
|
long etherType,
|
||||||
long vlanId,
|
long vlanId,
|
||||||
ByteBuffer frameData,
|
byte[] frameData);
|
||||||
long len);
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user