mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-19 04:57:53 +00:00
Logging and adding .equals() methods to MulticastGroup and VirtualNetworkCofnig
This commit is contained in:
parent
7cc64c5cb6
commit
ced040c503
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
*/
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user