This commit is contained in:
Adam Ierymenko 2016-09-20 21:21:43 -07:00
commit 29711e123f

View File

@ -162,7 +162,7 @@ jobject createPeerRole(JNIEnv *env, ZT_PeerRole role)
case ZT_PEER_ROLE_LEAF: case ZT_PEER_ROLE_LEAF:
fieldName = "PEER_ROLE_LEAF"; fieldName = "PEER_ROLE_LEAF";
break; break;
case ZT_PEER_ROLE_RELAY: case ZT_PEER_ROLE_UPSTREAM:
fieldName = "PEER_ROLE_RELAY"; fieldName = "PEER_ROLE_RELAY";
break; break;
case ZT_PEER_ROLE_ROOT: case ZT_PEER_ROLE_ROOT:
@ -313,13 +313,22 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
return NULL; return NULL;
} }
jobject inetAddressObject = newInetAddress(env, addr); jobject inetAddressObject = NULL;
if(addr.ss_family != 0)
{
inetAddressObject = newInetAddress(env, addr);
if(env->ExceptionCheck() || inetAddressObject == NULL) if(env->ExceptionCheck() || inetAddressObject == NULL)
{ {
LOGE("Error creating new inet address"); LOGE("Error creating new inet address");
return NULL; return NULL;
} }
}
else
{
return NULL;
}
inetSocketAddress_constructor = lookup.findMethod( inetSocketAddress_constructor = lookup.findMethod(
inetSocketAddressClass, "<init>", "(Ljava/net/InetAddress;I)V"); inetSocketAddressClass, "<init>", "(Ljava/net/InetAddress;I)V");
@ -350,10 +359,9 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
break; break;
default: default:
{ {
LOGE("ERROR: addr.ss_family is not set or unknown");
break; break;
} }
}; }
jobject inetSocketAddressObject = env->NewObject(inetSocketAddressClass, inetSocketAddress_constructor, inetAddressObject, port); jobject inetSocketAddressObject = env->NewObject(inetSocketAddressClass, inetSocketAddress_constructor, inetAddressObject, port);
@ -889,14 +897,14 @@ jobject newVirtualNetworkRoute(JNIEnv *env, const ZT_VirtualNetworkRoute &route)
jfieldID metricField = NULL; jfieldID metricField = NULL;
targetField = lookup.findField(virtualNetworkRouteClass, "target", targetField = lookup.findField(virtualNetworkRouteClass, "target",
"Ljava/net/InetSocketAddress"); "Ljava/net/InetSocketAddress;");
if(env->ExceptionCheck() || targetField == NULL) if(env->ExceptionCheck() || targetField == NULL)
{ {
return NULL; return NULL;
} }
viaField = lookup.findField(virtualNetworkRouteClass, "via", viaField = lookup.findField(virtualNetworkRouteClass, "via",
"Ljava/net/InetSocketAddress"); "Ljava/net/InetSocketAddress;");
if(env->ExceptionCheck() || targetField == NULL) if(env->ExceptionCheck() || targetField == NULL)
{ {
return NULL; return NULL;