mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-19 03:06:26 +00:00
add VirtualNetworkConfigOperation.fromInt
This commit is contained in:
parent
acd8b95114
commit
7c2766096c
@ -106,6 +106,7 @@ jmethodID Event_fromInt_method;
|
||||
jmethodID InetAddress_getByAddress_method;
|
||||
jmethodID PeerRole_fromInt_method;
|
||||
jmethodID ResultCode_fromInt_method;
|
||||
jmethodID VirtualNetworkConfigOperation_fromInt_method;
|
||||
|
||||
//
|
||||
// Instance fields
|
||||
@ -161,10 +162,6 @@ jfieldID VirtualNetworkRoute_via_field;
|
||||
// Static fields
|
||||
//
|
||||
|
||||
jfieldID VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE_field;
|
||||
jfieldID VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY_field;
|
||||
jfieldID VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN_field;
|
||||
jfieldID VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_UP_field;
|
||||
jfieldID VirtualNetworkStatus_NETWORK_STATUS_ACCESS_DENIED_field;
|
||||
jfieldID VirtualNetworkStatus_NETWORK_STATUS_AUTHENTICATION_REQUIRED_field;
|
||||
jfieldID VirtualNetworkStatus_NETWORK_STATUS_CLIENT_TOO_OLD_field;
|
||||
@ -254,6 +251,7 @@ void setupJNICache(JavaVM *vm) {
|
||||
EXCEPTIONANDNULLCHECK(InetAddress_getByAddress_method = env->GetStaticMethodID(InetAddress_class, "getByAddress", "([B)Ljava/net/InetAddress;"));
|
||||
EXCEPTIONANDNULLCHECK(PeerRole_fromInt_method = env->GetStaticMethodID(PeerRole_class, "fromInt", "(I)Lcom/zerotier/sdk/PeerRole;"));
|
||||
EXCEPTIONANDNULLCHECK(ResultCode_fromInt_method = env->GetStaticMethodID(ResultCode_class, "fromInt", "(I)Lcom/zerotier/sdk/ResultCode;"));
|
||||
EXCEPTIONANDNULLCHECK(VirtualNetworkConfigOperation_fromInt_method = env->GetStaticMethodID(VirtualNetworkConfigOperation_class, "fromInt", "(I)Lcom/zerotier/sdk/VirtualNetworkConfigOperation;"));
|
||||
|
||||
//
|
||||
// Instance fields
|
||||
@ -309,10 +307,6 @@ void setupJNICache(JavaVM *vm) {
|
||||
// Static fields
|
||||
//
|
||||
|
||||
EXCEPTIONANDNULLCHECK(VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE_field = env->GetStaticFieldID(VirtualNetworkConfigOperation_class, "VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE", "Lcom/zerotier/sdk/VirtualNetworkConfigOperation;"));
|
||||
EXCEPTIONANDNULLCHECK(VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY_field = env->GetStaticFieldID(VirtualNetworkConfigOperation_class, "VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY", "Lcom/zerotier/sdk/VirtualNetworkConfigOperation;"));
|
||||
EXCEPTIONANDNULLCHECK(VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN_field = env->GetStaticFieldID(VirtualNetworkConfigOperation_class, "VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN", "Lcom/zerotier/sdk/VirtualNetworkConfigOperation;"));
|
||||
EXCEPTIONANDNULLCHECK(VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_UP_field = env->GetStaticFieldID(VirtualNetworkConfigOperation_class, "VIRTUAL_NETWORK_CONFIG_OPERATION_UP", "Lcom/zerotier/sdk/VirtualNetworkConfigOperation;"));
|
||||
EXCEPTIONANDNULLCHECK(VirtualNetworkStatus_NETWORK_STATUS_ACCESS_DENIED_field = env->GetStaticFieldID(VirtualNetworkStatus_class, "NETWORK_STATUS_ACCESS_DENIED", "Lcom/zerotier/sdk/VirtualNetworkStatus;"));
|
||||
EXCEPTIONANDNULLCHECK(VirtualNetworkStatus_NETWORK_STATUS_AUTHENTICATION_REQUIRED_field = env->GetStaticFieldID(VirtualNetworkStatus_class, "NETWORK_STATUS_AUTHENTICATION_REQUIRED", "Lcom/zerotier/sdk/VirtualNetworkStatus;"));
|
||||
EXCEPTIONANDNULLCHECK(VirtualNetworkStatus_NETWORK_STATUS_CLIENT_TOO_OLD_field = env->GetStaticFieldID(VirtualNetworkStatus_class, "NETWORK_STATUS_CLIENT_TOO_OLD", "Lcom/zerotier/sdk/VirtualNetworkStatus;"));
|
||||
|
@ -75,6 +75,7 @@ extern jmethodID Event_fromInt_method;
|
||||
extern jmethodID InetAddress_getByAddress_method;
|
||||
extern jmethodID PeerRole_fromInt_method;
|
||||
extern jmethodID ResultCode_fromInt_method;
|
||||
extern jmethodID VirtualNetworkConfigOperation_fromInt_method;
|
||||
|
||||
//
|
||||
// Instance fields
|
||||
@ -130,10 +131,6 @@ extern jfieldID VirtualNetworkRoute_via_field;
|
||||
// Static fields
|
||||
//
|
||||
|
||||
extern jfieldID VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE_field;
|
||||
extern jfieldID VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY_field;
|
||||
extern jfieldID VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN_field;
|
||||
extern jfieldID VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_UP_field;
|
||||
extern jfieldID VirtualNetworkStatus_NETWORK_STATUS_ACCESS_DENIED_field;
|
||||
extern jfieldID VirtualNetworkStatus_NETWORK_STATUS_AUTHENTICATION_REQUIRED_field;
|
||||
extern jfieldID VirtualNetworkStatus_NETWORK_STATUS_CLIENT_TOO_OLD_field;
|
||||
|
@ -120,26 +120,12 @@ jobject createVirtualNetworkType(JNIEnv *env, ZT_VirtualNetworkType type)
|
||||
|
||||
jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT_VirtualNetworkConfigOperation op)
|
||||
{
|
||||
jobject vnetConfigOpObject = NULL;
|
||||
|
||||
jfieldID field;
|
||||
switch(op)
|
||||
{
|
||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP:
|
||||
field = VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_UP_field;
|
||||
break;
|
||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE:
|
||||
field = VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE_field;
|
||||
break;
|
||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN:
|
||||
field = VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN_field;
|
||||
break;
|
||||
case ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY:
|
||||
field = VirtualNetworkConfigOperation_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY_field;
|
||||
break;
|
||||
jobject vnetConfigOpObject = env->CallStaticObjectMethod(VirtualNetworkConfigOperation_class, VirtualNetworkConfigOperation_fromInt_method, op);
|
||||
if (env->ExceptionCheck() || vnetConfigOpObject == NULL) {
|
||||
LOGE("Error creating VirtualNetworkConfigOperation object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vnetConfigOpObject = env->GetStaticObjectField(VirtualNetworkConfigOperation_class, field);
|
||||
return vnetConfigOpObject;
|
||||
}
|
||||
|
||||
|
@ -114,9 +114,8 @@ namespace {
|
||||
}
|
||||
|
||||
jobject operationObject = createVirtualNetworkConfigOperation(env, operation);
|
||||
if(operationObject == NULL)
|
||||
if(env->ExceptionCheck() || operationObject == NULL)
|
||||
{
|
||||
LOGE("Error creating VirtualNetworkConfigOperation object");
|
||||
return -101;
|
||||
}
|
||||
|
||||
|
@ -27,25 +27,52 @@
|
||||
|
||||
package com.zerotier.sdk;
|
||||
|
||||
/**
|
||||
* Virtual network configuration update type
|
||||
*
|
||||
* Defined in ZeroTierOne.h as ZT_VirtualNetworkConfigOperation
|
||||
*/
|
||||
public enum VirtualNetworkConfigOperation {
|
||||
|
||||
/**
|
||||
* Network is coming up (either for the first time or after service restart)
|
||||
*/
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_UP,
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_UP(0),
|
||||
|
||||
/**
|
||||
* Network configuration has been updated
|
||||
*/
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE,
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE(1),
|
||||
|
||||
/**
|
||||
* Network is going down (not permanently)
|
||||
*/
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN,
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN(2),
|
||||
|
||||
/**
|
||||
* Network is going down permanently (leave/delete)
|
||||
*/
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY
|
||||
VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY(3);
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "unused"})
|
||||
private final int id;
|
||||
|
||||
VirtualNetworkConfigOperation(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static VirtualNetworkConfigOperation fromInt(int id) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
return VIRTUAL_NETWORK_CONFIG_OPERATION_UP;
|
||||
case 1:
|
||||
return VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE;
|
||||
case 2:
|
||||
return VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN;
|
||||
case 3:
|
||||
return VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY;
|
||||
default:
|
||||
throw new RuntimeException("Unhandled value: " + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user