mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-29 15:43:52 +00:00
fix Android NDK build
This commit is contained in:
parent
e7bab66d29
commit
f149dd9401
@ -35,9 +35,9 @@ LOCAL_SRC_FILES := \
|
||||
$(ZT1)/node/Switch.cpp \
|
||||
$(ZT1)/node/Tag.cpp \
|
||||
$(ZT1)/node/Topology.cpp \
|
||||
$(ZT1)/node/Utils.cpp \
|
||||
$(ZT1)/osdep/Http.cpp \
|
||||
$(ZT1)/osdep/OSUtils.cpp
|
||||
$(ZT1)/node/Utils.cpp
|
||||
# $(ZT1)/osdep/Http.cpp \
|
||||
# $(ZT1)/osdep/OSUtils.cpp
|
||||
|
||||
# JNI Files
|
||||
LOCAL_SRC_FILES += \
|
||||
|
@ -15,7 +15,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "ZT_jniutils.h"
|
||||
#include "ZT_jnilookup.h"
|
||||
#include <string>
|
||||
@ -30,7 +30,7 @@ extern "C" {
|
||||
jobject createResultObject(JNIEnv *env, ZT_ResultCode code)
|
||||
{
|
||||
jclass resultClass = NULL;
|
||||
|
||||
|
||||
jobject resultObject = NULL;
|
||||
|
||||
resultClass = lookup.findClass("com/zerotier/sdk/ResultCode");
|
||||
@ -67,14 +67,14 @@ jobject createResultObject(JNIEnv *env, ZT_ResultCode code)
|
||||
}
|
||||
|
||||
jfieldID enumField = lookup.findStaticField(resultClass, fieldName.c_str(), "Lcom/zerotier/sdk/ResultCode;");
|
||||
if(env->ExceptionCheck() || enumField == NULL)
|
||||
if(env->ExceptionCheck() || enumField == NULL)
|
||||
{
|
||||
LOGE("Error on FindStaticField");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
resultObject = env->GetStaticObjectField(resultClass, enumField);
|
||||
if(env->ExceptionCheck() || resultObject == NULL)
|
||||
if(env->ExceptionCheck() || resultObject == NULL)
|
||||
{
|
||||
LOGE("Error on GetStaticObjectField");
|
||||
}
|
||||
@ -154,6 +154,8 @@ jobject createEvent(JNIEnv *env, ZT_Event event)
|
||||
case ZT_EVENT_TRACE:
|
||||
fieldName = "EVENT_TRACE";
|
||||
break;
|
||||
case ZT_EVENT_USER_MESSAGE:
|
||||
break;
|
||||
}
|
||||
|
||||
jfieldID enumField = lookup.findStaticField(eventClass, fieldName.c_str(), "Lcom/zerotier/sdk/Event;");
|
||||
@ -332,7 +334,7 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
|
||||
}
|
||||
|
||||
jobject inetAddressObject = NULL;
|
||||
|
||||
|
||||
if(addr.ss_family != 0)
|
||||
{
|
||||
inetAddressObject = newInetAddress(env, addr);
|
||||
@ -468,7 +470,7 @@ jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp)
|
||||
return pppObject;
|
||||
}
|
||||
|
||||
jobject newPeer(JNIEnv *env, const ZT_Peer &peer)
|
||||
jobject newPeer(JNIEnv *env, const ZT_Peer &peer)
|
||||
{
|
||||
LOGV("newPeer called");
|
||||
|
||||
@ -570,7 +572,7 @@ jobject newPeer(JNIEnv *env, const ZT_Peer &peer)
|
||||
|
||||
jobjectArray arrayObject = env->NewObjectArray(
|
||||
peer.pathCount, peerPhysicalPathClass, NULL);
|
||||
if(env->ExceptionCheck() || arrayObject == NULL)
|
||||
if(env->ExceptionCheck() || arrayObject == NULL)
|
||||
{
|
||||
LOGE("Error creating PeerPhysicalPath[] array");
|
||||
return NULL;
|
||||
@ -709,7 +711,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assignedAddressesField = lookup.findField(vnetConfigClass, "assignedAddresses",
|
||||
assignedAddressesField = lookup.findField(vnetConfigClass, "assignedAddresses",
|
||||
"[Ljava/net/InetSocketAddress;");
|
||||
if(env->ExceptionCheck() || assignedAddressesField == NULL)
|
||||
{
|
||||
@ -717,7 +719,7 @@ jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &vnetConfig)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
routesField = lookup.findField(vnetConfigClass, "routes",
|
||||
routesField = lookup.findField(vnetConfigClass, "routes",
|
||||
"[Lcom/zerotier/sdk/VirtualNetworkRoute;");
|
||||
if(env->ExceptionCheck() || routesField == NULL)
|
||||
{
|
||||
|
@ -139,8 +139,8 @@ namespace {
|
||||
}
|
||||
|
||||
return env->CallIntMethod(
|
||||
ref->configListener,
|
||||
configListenerCallbackMethod,
|
||||
ref->configListener,
|
||||
configListenerCallbackMethod,
|
||||
(jlong)nwid, operationObject, networkConfigObject);
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ namespace {
|
||||
|
||||
void EventCallback(ZT_Node *node,
|
||||
void *userData,
|
||||
enum ZT_Event event,
|
||||
enum ZT_Event event,
|
||||
const void *data)
|
||||
{
|
||||
LOGV("EventCallback");
|
||||
@ -291,6 +291,8 @@ namespace {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ZT_EVENT_USER_MESSAGE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -348,7 +350,7 @@ namespace {
|
||||
objectName, buffer, bufferIndex, objectSizeObj);
|
||||
|
||||
long retval = (long)env->CallLongMethod(
|
||||
ref->dataStoreGetListener, dataStoreGetCallbackMethod,
|
||||
ref->dataStoreGetListener, dataStoreGetCallbackMethod,
|
||||
nameStr, bufferObj, (jlong)bufferIndex, objectSizeObj);
|
||||
|
||||
if(retval > 0)
|
||||
@ -463,7 +465,7 @@ namespace {
|
||||
LOGE("Couldn't find onSendPacketRequested method");
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
jobject localAddressObj = NULL;
|
||||
if(memcmp(localAddress, &ZT_SOCKADDR_NULL, sizeof(sockaddr_storage)) != 0)
|
||||
{
|
||||
@ -496,7 +498,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
{
|
||||
lookup.setJavaVM(vm);
|
||||
return JNI_VERSION_1_6;
|
||||
@ -641,7 +643,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_node_1init(
|
||||
ZeroTier::Mutex::Lock lock(nodeMapMutex);
|
||||
ref->node = node;
|
||||
nodeMap.insert(std::make_pair(ref->id, ref));
|
||||
|
||||
|
||||
|
||||
return resultObject;
|
||||
}
|
||||
@ -659,7 +661,7 @@ JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete(
|
||||
|
||||
NodeMap::iterator found;
|
||||
{
|
||||
ZeroTier::Mutex::Lock lock(nodeMapMutex);
|
||||
ZeroTier::Mutex::Lock lock(nodeMapMutex);
|
||||
found = nodeMap.find(nodeId);
|
||||
}
|
||||
|
||||
@ -685,9 +687,9 @@ JNIEXPORT void JNICALL Java_com_zerotier_sdk_Node_node_1delete(
|
||||
* Signature: (JJJJJII[B[J)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame(
|
||||
JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
jlong in_now,
|
||||
JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
jlong in_now,
|
||||
jlong in_nwid,
|
||||
jlong in_sourceMac,
|
||||
jlong in_destMac,
|
||||
@ -697,7 +699,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame(
|
||||
jlongArray out_nextBackgroundTaskDeadline)
|
||||
{
|
||||
uint64_t nodeId = (uint64_t) id;
|
||||
|
||||
|
||||
ZT_Node *node = findNode(nodeId);
|
||||
if(node == NULL)
|
||||
{
|
||||
@ -752,9 +754,9 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processVirtualNetworkFrame(
|
||||
* Signature: (JJLjava/net/InetSocketAddress;I[B[J)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
||||
JNIEnv *env, jobject obj,
|
||||
JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
jlong in_now,
|
||||
jlong in_now,
|
||||
jobject in_localAddress,
|
||||
jobject in_remoteAddress,
|
||||
jbyteArray in_packetData,
|
||||
@ -820,7 +822,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
||||
jmethodID inetSock_getPort = lookup.findMethod(
|
||||
InetSocketAddressClass, "getPort", "()I");
|
||||
|
||||
if(env->ExceptionCheck() || inetSock_getPort == NULL)
|
||||
if(env->ExceptionCheck() || inetSock_getPort == NULL)
|
||||
{
|
||||
LOGE("Couldn't find getPort method on InetSocketAddress");
|
||||
return createResultObject(env, ZT_RESULT_FATAL_ERROR_INTERNAL);
|
||||
@ -844,10 +846,10 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
||||
}
|
||||
|
||||
unsigned int addrSize = env->GetArrayLength(remoteAddressArray);
|
||||
|
||||
|
||||
|
||||
sockaddr_storage localAddress = {};
|
||||
|
||||
|
||||
if(localAddrObj == NULL)
|
||||
{
|
||||
localAddress = ZT_SOCKADDR_NULL;
|
||||
@ -939,7 +941,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
||||
localData,
|
||||
packetLength,
|
||||
&nextBackgroundTaskDeadline);
|
||||
if(rc != ZT_RESULT_OK)
|
||||
if(rc != ZT_RESULT_OK)
|
||||
{
|
||||
LOGE("ZT_Node_processWirePacket returned: %d", rc);
|
||||
}
|
||||
@ -959,7 +961,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processWirePacket(
|
||||
* Signature: (JJ[J)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_processBackgroundTasks(
|
||||
JNIEnv *env, jobject obj,
|
||||
JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
jlong in_now,
|
||||
jlongArray out_nextBackgroundTaskDeadline)
|
||||
@ -1032,7 +1034,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave(
|
||||
uint64_t nwid = (uint64_t)in_nwid;
|
||||
|
||||
ZT_ResultCode rc = ZT_Node_leave(node, nwid, NULL);
|
||||
|
||||
|
||||
return createResultObject(env, rc);
|
||||
}
|
||||
|
||||
@ -1042,8 +1044,8 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_leave(
|
||||
* Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe(
|
||||
JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
jlong in_nwid,
|
||||
jlong in_multicastGroup,
|
||||
jlong in_multicastAdi)
|
||||
@ -1072,8 +1074,8 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastSubscribe(
|
||||
* Signature: (JJJJ)Lcom/zerotier/sdk/ResultCode;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_multicastUnsubscribe(
|
||||
JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
JNIEnv *env, jobject obj,
|
||||
jlong id,
|
||||
jlong in_nwid,
|
||||
jlong in_multicastGroup,
|
||||
jlong in_multicastAdi)
|
||||
@ -1141,7 +1143,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_status
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
nodeStatusConstructor = lookup.findMethod(
|
||||
nodeStatusClass, "<init>", "()V");
|
||||
if(nodeStatusConstructor == NULL)
|
||||
@ -1225,7 +1227,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotier_sdk_Node_networkConfig(
|
||||
}
|
||||
|
||||
ZT_VirtualNetworkConfig *vnetConfig = ZT_Node_networkConfig(node, nwid);
|
||||
|
||||
|
||||
jobject vnetConfigObject = newNetworkConfig(env, *vnetConfig);
|
||||
|
||||
ZT_Node_freeQueryResult(node, vnetConfig);
|
||||
@ -1267,7 +1269,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers(
|
||||
}
|
||||
|
||||
ZT_PeerList *peerList = ZT_Node_peers(node);
|
||||
|
||||
|
||||
if(peerList == NULL)
|
||||
{
|
||||
LOGE("ZT_Node_peers returned NULL");
|
||||
@ -1306,7 +1308,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_zerotier_sdk_Node_peers(
|
||||
{
|
||||
jobject peerObj = newPeer(env, peerList->peers[i]);
|
||||
env->SetObjectArrayElement(peerArrayObj, i, peerObj);
|
||||
if(env->ExceptionCheck())
|
||||
if(env->ExceptionCheck())
|
||||
{
|
||||
LOGE("Error assigning Peer object to array");
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user