mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 20:43:44 +02:00
Added implementation for Node.version()
Signed-off-by: Grant Limberg <glimberg@gmail.com>
This commit is contained in:
parent
f5bb57d5aa
commit
3ccaef88b7
4 changed files with 94 additions and 7 deletions
|
@ -639,6 +639,91 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastUnsubscribe
|
||||||
return createResultObject(env, rc);
|
return createResultObject(env, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: com_zerotierone_sdk_Node
|
||||||
|
* Method: version
|
||||||
|
* Signature: (J)Lcom/zerotierone/sdk/Version;
|
||||||
|
*/
|
||||||
|
JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_version
|
||||||
|
(JNIEnv *env, jobject obj)
|
||||||
|
{
|
||||||
|
// create a com.zerotierone.sdk.Version object
|
||||||
|
jclass versionClass = env->FindClass("com.zerotierone.sdk.Version");
|
||||||
|
if(versionClass == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
jmethodID versionConstructor = env->GetMethodID(
|
||||||
|
versionClass, "<init>", "()V");
|
||||||
|
if(versionConstructor == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
jobject versionObj = env->NewObject(versionClass, versionConstructor);
|
||||||
|
if(versionObj == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int major = 0;
|
||||||
|
int minor = 0;
|
||||||
|
int revision = 0;
|
||||||
|
unsigned long featureFlags = 0;
|
||||||
|
|
||||||
|
ZT1_version(&major, &minor, &revision, &featureFlags);
|
||||||
|
|
||||||
|
// copy data to Version object
|
||||||
|
static jfieldID majorField = NULL;
|
||||||
|
static jfieldID minorField = NULL;
|
||||||
|
static jfieldID revisionField = NULL;
|
||||||
|
static jfieldID featureFlagsField = NULL;
|
||||||
|
|
||||||
|
if(majorField == NULL)
|
||||||
|
{
|
||||||
|
majorField = env->GetFieldID(versionClass, "major", "Lcom.zerotierone.sdk.Version");
|
||||||
|
if(majorField = NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(minorField == NULL)
|
||||||
|
{
|
||||||
|
minorField = env->GetFieldID(versionClass, "minor", "Lcom.zerotierone.sdk.Version");
|
||||||
|
if(minorField == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(revisionField == NULL)
|
||||||
|
{
|
||||||
|
revisionField = env->GetFieldID(versionClass, "revision", "Lcom.zerotierone.sdk.Version");
|
||||||
|
if(revisionField == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(featureFlagsField == NULL)
|
||||||
|
{
|
||||||
|
featureFlagsField = env->GetFieldID(versionClass, "featureFlags", "Lcom.zerotierone.sdk.Version");
|
||||||
|
if(featureFlagsField == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
env->SetIntField(versionObj, majorField, (jint)major);
|
||||||
|
env->SetIntField(versionObj, minorField, (jint)minor);
|
||||||
|
env->SetIntField(versionObj, revisionField, (jint)revision);
|
||||||
|
env->SetLongField(versionObj, featureFlagsField, (jlong)featureFlags);
|
||||||
|
|
||||||
|
|
||||||
|
return versionObj;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
|
@ -109,7 +109,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_networkConfig
|
||||||
* Signature: (J)Lcom/zerotierone/sdk/Version;
|
* Signature: (J)Lcom/zerotierone/sdk/Version;
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_version
|
JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_version
|
||||||
(JNIEnv *, jobject, jlong);
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,11 +222,11 @@ public class Node {
|
||||||
|
|
||||||
// TODO: ZT1_Node_peers
|
// TODO: ZT1_Node_peers
|
||||||
|
|
||||||
private native VirtualNetworkConfig networkConfig(long nodeId);
|
private native VirtualNetworkConfig networkConfig(long nodeId, long nwid);
|
||||||
|
|
||||||
// TODO: ZT1_Node_networks
|
// TODO: ZT1_Node_networks
|
||||||
|
|
||||||
private native Version version(long nodeId);
|
private native Version version();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -28,8 +28,10 @@
|
||||||
package com.zerotierone.sdk;
|
package com.zerotierone.sdk;
|
||||||
|
|
||||||
public class Version {
|
public class Version {
|
||||||
public int major;
|
public Version() {}
|
||||||
public int minor;
|
|
||||||
public int revision;
|
public int major = 0;
|
||||||
public long featureFlags;
|
public int minor = 0;
|
||||||
|
public int revision = 0;
|
||||||
|
public long featureFlags = 0;
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue