ZT_jniutils.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef ZT_jniutils_h_
  2. #define ZT_jniutils_h_
  3. #include <stdio.h>
  4. #include <jni.h>
  5. #include <ZeroTierOne.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #define LOG_TAG "ZeroTierOneJNI"
  10. #if __ANDROID__
  11. #include <android/log.h>
  12. #define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
  13. #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
  14. #define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
  15. #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
  16. #else
  17. #define LOGV(...) fprintf(stdout, __VA_ARGS__)
  18. #define LOGI(...) fprintf(stdout, __VA_ARGS__)
  19. #define LOGD(...) fprintf(stdout, __VA_ARGS__)
  20. #define LOGE(...) fprintf(stdout, __VA_ARGS__)
  21. #endif
  22. jobject createResultObject(JNIEnv *env, ZT_ResultCode code);
  23. jobject createVirtualNetworkStatus(JNIEnv *env, ZT_VirtualNetworkStatus status);
  24. jobject createVirtualNetworkType(JNIEnv *env, ZT_VirtualNetworkType type);
  25. jobject createEvent(JNIEnv *env, ZT_Event event);
  26. jobject createPeerRole(JNIEnv *env, ZT_PeerRole role);
  27. jobject createVirtualNetworkConfigOperation(JNIEnv *env, ZT_VirtualNetworkConfigOperation op);
  28. jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr);
  29. jobject newInetAddress(JNIEnv *env, const sockaddr_storage &addr);
  30. jobject newMulticastGroup(JNIEnv *env, const ZT_MulticastGroup &mc);
  31. jobject newPeer(JNIEnv *env, const ZT_Peer &peer);
  32. jobject newPeerPhysicalPath(JNIEnv *env, const ZT_PeerPhysicalPath &ppp);
  33. jobject newNetworkConfig(JNIEnv *env, const ZT_VirtualNetworkConfig &config);
  34. jobject newVersion(JNIEnv *env, int major, int minor, int rev, long featureFlags);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif