diff options
author | Grant Limberg <glimberg@gmail.com> | 2015-06-09 19:38:05 -0700 |
---|---|---|
committer | Grant Limberg <glimberg@gmail.com> | 2015-06-09 19:38:05 -0700 |
commit | ced040c5033bd61a963e65e8e8525459c4b8b59d (patch) | |
tree | cb975050b40cfe488c82a875a619575af6abf37d /java | |
parent | 7cc64c5cb69f2962d32ca41f6dc12499964d22a7 (diff) | |
download | infinitytier-ced040c5033bd61a963e65e8e8525459c4b8b59d.tar.gz infinitytier-ced040c5033bd61a963e65e8e8525459c4b8b59d.zip |
Logging and adding .equals() methods to MulticastGroup and VirtualNetworkCofnig
Diffstat (limited to 'java')
-rw-r--r-- | java/jni/ZT1_jniutils.cpp | 10 | ||||
-rw-r--r-- | java/jni/com_zerotierone_sdk_Node.cpp | 12 | ||||
-rw-r--r-- | java/src/com/zerotier/sdk/MulticastGroup.java | 4 | ||||
-rw-r--r-- | java/src/com/zerotier/sdk/VirtualNetworkConfig.java | 38 |
4 files changed, 54 insertions, 10 deletions
diff --git a/java/jni/ZT1_jniutils.cpp b/java/jni/ZT1_jniutils.cpp index 36f68f9e..1e8a48bf 100644 --- a/java/jni/ZT1_jniutils.cpp +++ b/java/jni/ZT1_jniutils.cpp @@ -343,18 +343,18 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr) { case AF_INET6: { - LOGD("IPV6 Address"); + LOGV("IPV6 Address"); sockaddr_in6 *ipv6 = (sockaddr_in6*)&addr; port = ntohs(ipv6->sin6_port); - LOGD("Port %d", port); + LOGV("Port %d", port); } break; case AF_INET: { - LOGD("IPV4 Address"); + LOGV("IPV4 Address"); sockaddr_in *ipv4 = (sockaddr_in*)&addr; port = ntohs(ipv4->sin_port); - LOGD("Port: %d", port); + LOGV("Port: %d", port); } break; default: @@ -818,7 +818,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT1_VirtualNetworkConfig &vnetConfig } env->SetObjectField(vnetConfigObj, typeField, typeObject); - env->SetIntField(vnetConfigObj, mtuField, vnetConfig.mtu); + env->SetIntField(vnetConfigObj, mtuField, (int)vnetConfig.mtu); env->SetBooleanField(vnetConfigObj, dhcpField, vnetConfig.dhcp); env->SetBooleanField(vnetConfigObj, bridgeField, vnetConfig.bridge); env->SetBooleanField(vnetConfigObj, broadcastEnabledField, vnetConfig.broadcastEnabled); diff --git a/java/jni/com_zerotierone_sdk_Node.cpp b/java/jni/com_zerotierone_sdk_Node.cpp index c84524fa..2a90bb85 100644 --- a/java/jni/com_zerotierone_sdk_Node.cpp +++ b/java/jni/com_zerotierone_sdk_Node.cpp @@ -92,7 +92,7 @@ namespace { enum ZT1_VirtualNetworkConfigOperation operation, const ZT1_VirtualNetworkConfig *config) { - LOGD("VritualNetworkConfigFunctionCallback"); + LOGV("VritualNetworkConfigFunctionCallback"); JniRef *ref = (JniRef*)userData; JNIEnv *env = NULL; ref->jvm->GetEnv((void**)&env, JNI_VERSION_1_6); @@ -142,7 +142,9 @@ namespace { const void *frameData, unsigned int frameLength) { - LOGD("VirtualNetworkFrameFunctionCallback"); + LOGV("VirtualNetworkFrameFunctionCallback"); + unsigned char* local = (unsigned char*)frameData; + LOGV("Type Bytes: 0x%02x%02x", local[12], local[13]); JniRef *ref = (JniRef*)userData; assert(ref->node == node); JNIEnv *env = NULL; @@ -188,7 +190,7 @@ namespace { void EventCallback(ZT1_Node *node,void *userData,enum ZT1_Event event, const void *data) { - LOGD("EventCallback"); + LOGV("EventCallback"); JniRef *ref = (JniRef*)userData; assert(ref->node == node); JNIEnv *env = NULL; @@ -436,7 +438,7 @@ namespace { const void *buffer, unsigned int bufferSize) { - LOGD("WirePacketSendFunction(%p, %p, %d)", address, buffer, bufferSize); + LOGV("WirePacketSendFunction(%p, %p, %d)", address, buffer, bufferSize); JniRef *ref = (JniRef*)userData; assert(ref->node == node); @@ -464,7 +466,7 @@ namespace { env->SetByteArrayRegion(bufferObj, 0, bufferSize, (jbyte*)buffer); int retval = env->CallIntMethod(ref->packetSender, packetSenderCallbackMethod, addressObj, bufferObj); - LOGD("JNI Packet Sender returned: %d", retval); + LOGV("JNI Packet Sender returned: %d", retval); return retval; } diff --git a/java/src/com/zerotier/sdk/MulticastGroup.java b/java/src/com/zerotier/sdk/MulticastGroup.java index 5c4df87a..68114424 100644 --- a/java/src/com/zerotier/sdk/MulticastGroup.java +++ b/java/src/com/zerotier/sdk/MulticastGroup.java @@ -33,6 +33,10 @@ public final class MulticastGroup { private long mac; private long adi; + public boolean equals(MulticastGroup other) { + return mac == other.mac && adi == other.adi; + } + /** * MAC address (least significant 48 bits) */ diff --git a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java index 2be03acb..35453ddc 100644 --- a/java/src/com/zerotier/sdk/VirtualNetworkConfig.java +++ b/java/src/com/zerotier/sdk/VirtualNetworkConfig.java @@ -54,6 +54,44 @@ public final class VirtualNetworkConfig { } + public boolean equals(VirtualNetworkConfig cfg) { + boolean mcgEqual = true; + if(multicastSubscriptions.length == cfg.multicastSubscriptions.length) { + for(int i = 0; i < multicastSubscriptions.length; ++i) { + if(!multicastSubscriptions[i].equals(cfg.multicastSubscriptions[i])) + { + return false; + } + } + } else { + mcgEqual = false; + } + + boolean aaEqual = true; + if(assignedAddresses.length == cfg.assignedAddresses.length) { + for(int i = 0; i < assignedAddresses.length; ++i) { + if(!assignedAddresses[i].equals(cfg.assignedAddresses[i])) { + return false; + } + } + } else { + aaEqual = false; + } + + return nwid == cfg.nwid && + mac == cfg.mac && + name.equals(cfg.name) && + status.equals(cfg.status) && + type.equals(cfg.type) && + mtu == cfg.mtu && + dhcp == cfg.dhcp && + bridge == cfg.bridge && + broadcastEnabled == cfg.broadcastEnabled && + portError == cfg.portError && + enabled == cfg.enabled && + mcgEqual && aaEqual; + } + /** * 64-bit ZeroTier network ID */ |