2016-09-21 21:09:46 +00:00
|
|
|
/*
|
|
|
|
* ZeroTier One - Network Virtualization Everywhere
|
|
|
|
* Copyright (C) 2011-2016 ZeroTier, Inc. https://www.zerotier.com/
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-09-24 23:21:36 +00:00
|
|
|
#ifndef ZT_jniutils_h_
|
|
|
|
#define ZT_jniutils_h_
|
2015-05-01 04:50:28 +00:00
|
|
|
#include <stdio.h>
|
2015-04-24 04:36:33 +00:00
|
|
|
#include <jni.h>
|
|
|
|
#include <ZeroTierOne.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-04-26 03:46:56 +00:00
|
|
|
#define LOG_TAG "ZeroTierOneJNI"
|
|
|
|
|
2018-02-07 23:53:14 +00:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
|
2015-04-26 03:46:56 +00:00
|
|
|
#include <android/log.h>
|
2018-02-07 23:53:14 +00:00
|
|
|
|
|
|
|
#if !defined(NDEBUG)
|
|
|
|
#define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
|
|
|
|
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
|
|
|
#else
|
|
|
|
#define LOGV(...)
|
|
|
|
#define LOGD(...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
|
|
|
|
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
|
2015-04-26 03:46:56 +00:00
|
|
|
#else
|
2018-02-07 23:53:14 +00:00
|
|
|
#if !defined(NDEBUG)
|
|
|
|
#define LOGV(...) fprintf(stdout, __VA_ARGS__)
|
|
|
|
#define LOGD(...) fprintf(stdout, __VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define LOGV(...)
|
|
|
|
#define LOGD(...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LOGI(...) fprintf(stdout, __VA_ARGS__)
|
|
|
|
#define LOGE(...) fprintf(stdout, __VA_ARGS__)
|
2015-04-26 03:46:56 +00:00
|
|
|
#endif
|
|
|
|
|
2015-09-24 23:21:36 +00:00
|
|
|
jobject createResultObject(JNIEnv *env, ZT_ResultCode code);
|
|
|
|
jobject createVirtualNetworkStatus(JNIEnv *env, ZT_VirtualNetworkStatus status);
|
|
|
|
jobject createVirtualNetworkType(JNIEnv *env, ZT_VirtualNetworkType type);
|
|
|
|
jobject createEvent(JNIEnv *env, ZT_Event event);
|
|
|
|
jobject createPeerRole(JNIEnv *env, ZT_PeerRole role);
|
|
|
|
jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT_VirtualNetworkConfigOperation op);
|
2015-04-24 04:39:07 +00:00
|
|
|
|
2015-04-28 00:48:37 +00:00
|
|
|
jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr);
|
2015-04-24 05:48:56 +00:00
|
|
|
jobject newInetAddress(JNIEnv *env, const sockaddr_storage &addr);
|
2015-04-24 04:36:33 +00:00
|
|
|
|
2015-09-24 23:21:36 +00:00
|
|
|
jobject newMulticastGroup(JNIEnv *env, const ZT_MulticastGroup &mc);
|
2015-04-25 00:58:59 +00:00
|
|
|
|
2015-09-24 23:21:36 +00:00
|
|
|
jobject newPeer(JNIEnv *env, const ZT_Peer &peer);
|
|
|
|
jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp);
|
2015-04-25 00:58:59 +00:00
|
|
|
|
2015-09-24 23:21:36 +00:00
|
|
|
jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &config);
|
2015-04-25 01:20:10 +00:00
|
|
|
|
2016-07-08 03:07:07 +00:00
|
|
|
jobject newVersion(JNIEnv *env, int major, int minor, int rev);
|
2015-04-25 03:13:21 +00:00
|
|
|
|
2016-09-05 20:52:29 +00:00
|
|
|
jobject newVirtualNetworkRoute(JNIEnv *env, const ZT_VirtualNetworkRoute &route);
|
|
|
|
|
2015-04-24 04:36:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|