Minor change to API (renamed get_device_id to get_id). More complete Scala binding
This commit is contained in:
@@ -38,7 +38,7 @@ int main(int argc, char **argv)
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
zts_startjoin(path.c_str(), nwid.c_str());
|
||||
char device_id[11];
|
||||
zts_get_device_id(device_id);
|
||||
zts_get_id(device_id);
|
||||
DEBUG_TEST("I am %s", device_id);
|
||||
sleep(2);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ int main(int argc, char **argv)
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
zts_startjoin(path.c_str(), nwid.c_str());
|
||||
char device_id[11];
|
||||
zts_get_device_id(device_id);
|
||||
zts_get_id(device_id);
|
||||
DEBUG_TEST("I am %s", device_id);
|
||||
sleep(2);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace ZeroTier
|
||||
public static extern void zts_get_homepath(string homePath, int len);
|
||||
|
||||
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int zts_get_device_id(string devID);
|
||||
public static extern int zts_get_id(string devID);
|
||||
|
||||
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int zts_running();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
// Simple Java example for libzt using JNI
|
||||
|
||||
import zerotier.*;
|
||||
import zerotier.ZeroTier;
|
||||
|
||||
public class ExampleApp {
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ struct ZT {
|
||||
|
||||
static char* getDeviceId() {
|
||||
char* id = new char [ZT_ID_LEN + 1];
|
||||
zts_get_device_id(id);
|
||||
zts_get_id(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ struct ZT {
|
||||
return addr_str;
|
||||
}
|
||||
|
||||
static int socket() {
|
||||
static int socket() {åå
|
||||
return zts_socket(AF_INET, SOCK_STREAM, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,44 @@
|
||||
package zerotier;
|
||||
|
||||
class ZeroTier {
|
||||
@native def ztjni_socket(socket_family: Int, socket_type: Int, protocol: Int): Int
|
||||
|
||||
@native def ztjni_start(path: String): Int
|
||||
@native def ztjni_startjoin(path: String, nwid: String): Int
|
||||
@native def ztjni_stop(): Unit
|
||||
@native def ztjni_running(): Int
|
||||
@native def ztjni_join(nwid: String): Unit
|
||||
@native def ztjni_leave(nwid: String): Unit
|
||||
//@native def ztjni_path():
|
||||
//@native def ztjni_id(): Int
|
||||
//@native def ztjni_get_6plane_addr(): Unit
|
||||
//@native def ztjni_get_rfc4193_addr(): Unit
|
||||
@native def ztjni_socket(socket_family: Int, socket_type: Int, protocol: Int): Int
|
||||
@native def ztjni_connect(fd: Int, addr: Object, addrlen: Int): Int
|
||||
@native def ztjni_bind(fd: Int, addr: Object, addrlen: Int): Int
|
||||
@native def ztjni_listen(fd: Int, backlog: Int): Int
|
||||
@native def ztjni_accept(fd: Int, addr: Object, addrlen: Int): Int
|
||||
@native def ztjni_accept4(fd: Int, addr: Object, addrlen: Int, flags: Int): Int
|
||||
@native def ztjni_setsockopt(fd: Int, level: Int, optname: Int, optval: Object, optlen: Int): Int
|
||||
@native def ztjni_getsockopt(fd: Int, level: Int, optname: Int, optval: Object, optlen: Int): Int
|
||||
//@native def ztjni_getsockname(): Int
|
||||
//@native def ztjni_getpeername(): Int
|
||||
//@native def ztjni_gethostname(): Int
|
||||
//@native def ztjni_sethostname(): Int
|
||||
//@native def ztjni_gethostbyname(): Object
|
||||
@native def ztjni_close(fd: Int): Int
|
||||
//@native def ztjni_poll(): Int
|
||||
//@native def ztjni_select(): Int
|
||||
@native def ztjni_fcntl(fd: Int, cmd: Int, flags: Int): Int
|
||||
@native def ztjni_ioctl(fd: Int, request: Long, argp: Object): Int
|
||||
@native def ztjni_send(fd: Int, buf: Object, len: Int, flags: Int): Int
|
||||
@native def ztjni_sendto(fd: Int, buf: Object, len: Int, addr: Object, addrlen: Int): Int
|
||||
@native def ztjni_sendmsg(fd: Int, msg: Object, flags: Int): Int
|
||||
@native def ztjni_recv(fd: Int, buf: Object, len: Int, flags: Int): Int
|
||||
@native def ztjni_recvfrom(fd: Int, buf: Object, len: Int, addr: Object, addrlen: Int): Int
|
||||
@native def ztjni_recvmsg(fd: Int, msg: Object, flags: Int): Int
|
||||
@native def ztjni_read(fd: Int, buf: Object, len: Int): Int
|
||||
@native def ztjni_write(fd: Int, buf: Object, len: Int): Int
|
||||
@native def ztjni_shutdown(fd: Int, how: Int): Int
|
||||
//@native def ztjni_add_dns(): Int
|
||||
//@native def ztjni_del_dns(): Int
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ std::vector<ZT_VirtualNetworkRoute> *zts_get_network_routes(char *nwid);
|
||||
* @param devID buffer to which the device ID (nodeID, ztAddress) should be copied
|
||||
* @return
|
||||
*/
|
||||
int zts_get_device_id_from_file(const char *filepath, char *devID);
|
||||
int zts_getid_from_file(const char *filepath, char *devID);
|
||||
|
||||
/**
|
||||
* @brief Starts a ZeroTier service in the background
|
||||
@@ -240,7 +240,7 @@ void zts_get_homepath(char *homePath, size_t len);
|
||||
* @param devID Buffer to which id string is copied
|
||||
* @return
|
||||
*/
|
||||
int zts_get_device_id(char *devID);
|
||||
int zts_get_id(char *devID);
|
||||
|
||||
/**
|
||||
* @brief Return the number of peers
|
||||
|
||||
165
include/ZeroTier.h
Normal file
165
include/ZeroTier.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class ZeroTier */
|
||||
|
||||
#ifndef _Included_ZeroTier
|
||||
#define _Included_ZeroTier
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_start
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_ZeroTier_ztjni_1start
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_startjoin
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_ZeroTier_ztjni_1startjoin
|
||||
(JNIEnv *, jobject, jstring, jstring);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_join
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_ZeroTier_ztjni_1join
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_leave
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_ZeroTier_ztjni_1leave
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_get_addresses
|
||||
* Signature: (Ljava/lang/String;)Ljava/util/ArrayList;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_ZeroTier_ztjni_1get_1addresses
|
||||
(JNIEnv *, jobject, jstring);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_running
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_ZeroTier_ztjni_1running
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_socket
|
||||
* Signature: (III)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1socket
|
||||
(JNIEnv *, jobject, jint, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_connect
|
||||
* Signature: (ILjava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1connect
|
||||
(JNIEnv *, jobject, jint, jstring, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_bind
|
||||
* Signature: (ILjava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1bind
|
||||
(JNIEnv *, jobject, jint, jstring, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_accept4
|
||||
* Signature: (ILjava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1accept4
|
||||
(JNIEnv *, jobject, jint, jstring, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_accept
|
||||
* Signature: (ILAddress;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1accept
|
||||
(JNIEnv *, jobject, jint, jobject);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_listen
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1listen
|
||||
(JNIEnv *, jobject, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_close
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1close
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_read
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1read
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_write
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1write
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_sendto
|
||||
* Signature: (I[BIILAddress;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1sendto
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint, jint, jobject);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_send
|
||||
* Signature: (I[BII)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1send
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_recvfrom
|
||||
* Signature: (I[BIILAddress;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1recvfrom
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint, jint, jobject);
|
||||
|
||||
/*
|
||||
* Class: ZeroTier
|
||||
* Method: ztjni_fcntl
|
||||
* Signature: (III)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_ZeroTier_ztjni_1fcntl
|
||||
(JNIEnv *, jobject, jint, jint, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -73,7 +73,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// forward declarations from ZT1Service.h
|
||||
ZT_SOCKET_API int ZTCALL zts_get_device_id(char *devID);
|
||||
ZT_SOCKET_API int ZTCALL zts_get_id(char *devID);
|
||||
ZT_SOCKET_API void ZTCALL init_network_stack();
|
||||
|
||||
/**
|
||||
@@ -114,6 +114,14 @@ ZT_SOCKET_API int ZTCALL zts_startjoin(const char *path, const char *nwid);
|
||||
*/
|
||||
ZT_SOCKET_API void ZTCALL zts_stop();
|
||||
|
||||
/**
|
||||
* @brief Check whether the service is running
|
||||
*
|
||||
* @usage
|
||||
* @return
|
||||
*/
|
||||
ZT_SOCKET_API int ZTCALL zts_running();
|
||||
|
||||
/**
|
||||
* @brief Joins a virtual network
|
||||
*
|
||||
@@ -170,15 +178,7 @@ ZT_SOCKET_API void ZTCALL zts_get_homepath(char *homePath, const size_t len);
|
||||
* @param devID
|
||||
* @return
|
||||
*/
|
||||
ZT_SOCKET_API int ZTCALL zts_get_device_id(char *devID);
|
||||
|
||||
/**
|
||||
* @brief Check whether the service is running
|
||||
*
|
||||
* @usage
|
||||
* @return
|
||||
*/
|
||||
ZT_SOCKET_API int ZTCALL zts_running();
|
||||
ZT_SOCKET_API int ZTCALL zts_get_id(char *devID);
|
||||
|
||||
/**
|
||||
* @brief Returns whether any IPv6 address has been assigned to the SockTap for this network
|
||||
|
||||
@@ -163,7 +163,7 @@ ZeroTier::VirtualTap *getAnyTap()
|
||||
return vtap;
|
||||
}
|
||||
|
||||
int zts_get_device_id_from_file(const char *filepath, char *devID)
|
||||
int zts_get_id_from_file(const char *filepath, char *devID)
|
||||
{
|
||||
DEBUG_EXTRA();
|
||||
std::string fname("identity.public");
|
||||
@@ -480,7 +480,7 @@ void zts_get_homepath(char *homePath, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
int zts_get_device_id(char *devID)
|
||||
int zts_get_id(char *devID)
|
||||
{
|
||||
DEBUG_EXTRA();
|
||||
if (ZeroTier::zt1Service) {
|
||||
|
||||
107
src/libztJNI.cpp
107
src/libztJNI.cpp
@@ -47,7 +47,7 @@ namespace ZeroTier {
|
||||
#include <jni.h>
|
||||
|
||||
/****************************************************************************/
|
||||
/* Java JNI Wrapper for ZeroTier Socket API */
|
||||
/* ZeroTier Socket API (for JNI wrapper) */
|
||||
/****************************************************************************/
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1sendto(
|
||||
@@ -122,24 +122,15 @@ namespace ZeroTier {
|
||||
return read_bytes;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1setsockopt(
|
||||
JNIEnv *env, jobject thisObj,
|
||||
jint fd, jint level, jint optname, jint optval, jint optlen) {
|
||||
return zts_setsockopt(fd, level, optname, (const void*)optval, optlen);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1getsockopt(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jint level, jint optname, jint optval, jint optlen) {
|
||||
return zts_getsockopt(fd, level, optname, (void*)optval, (socklen_t *)optlen);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1socket(JNIEnv *env, jobject thisObj,
|
||||
jint family, jint type, jint protocol) {
|
||||
jint family, jint type, jint protocol)
|
||||
{
|
||||
return zts_socket(family, type, protocol);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1connect(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jstring addrstr, jint port) {
|
||||
jint fd, jstring addrstr, jint port)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
const char *str = (*env).GetStringUTFChars( addrstr, 0);
|
||||
addr.sin_addr.s_addr = inet_addr(str);
|
||||
@@ -150,7 +141,8 @@ namespace ZeroTier {
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1bind(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jstring addrstr, jint port) {
|
||||
jint fd, jstring addrstr, jint port)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
const char *str = (*env).GetStringUTFChars( addrstr, 0);
|
||||
DEBUG_INFO("fd=%d, addr=%s, port=%d", fd, str, port);
|
||||
@@ -163,7 +155,8 @@ namespace ZeroTier {
|
||||
|
||||
#if defined(__linux__)
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1accept4(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jstring addrstr, jint port, jint flags) {
|
||||
jint fd, jstring addrstr, jint port, jint flags)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
char *str;
|
||||
// = env->GetStringUTFChars(addrstr, NULL);
|
||||
@@ -176,7 +169,8 @@ namespace ZeroTier {
|
||||
#endif
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1accept(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jstring addrstr, jint port) {
|
||||
jint fd, jstring addrstr, jint port)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
// TODO: Send addr info back to Javaland
|
||||
addr.sin_addr.s_addr = inet_addr("");
|
||||
@@ -186,17 +180,33 @@ namespace ZeroTier {
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1listen(JNIEnv *env, jobject thisObj,
|
||||
jint fd, int backlog) {
|
||||
jint fd, int backlog)
|
||||
{
|
||||
return zts_listen(fd, backlog);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1close(JNIEnv *env, jobject thisObj,
|
||||
jint fd) {
|
||||
jint fd)
|
||||
{
|
||||
return zts_close(fd);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1setsockopt(
|
||||
JNIEnv *env, jobject thisObj,
|
||||
jint fd, jint level, jint optname, jint optval, jint optlen)
|
||||
{
|
||||
return zts_setsockopt(fd, level, optname, (const void*)optval, optlen);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1getsockopt(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jint level, jint optname, jint optval, jint optlen)
|
||||
{
|
||||
return zts_getsockopt(fd, level, optname, (void*)optval, (socklen_t *)optlen);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1getsockname(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jobject ztaddr) {
|
||||
jint fd, jobject ztaddr)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
int err = zts_getsockname(fd, (struct sockaddr *)&addr, (socklen_t *)sizeof(struct sockaddr));
|
||||
jfieldID fid;
|
||||
@@ -209,7 +219,8 @@ namespace ZeroTier {
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1getpeername(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jobject ztaddr) {
|
||||
jint fd, jobject ztaddr)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
int err = zts_getpeername(fd, (struct sockaddr *)&addr, (socklen_t *)sizeof(struct sockaddr));
|
||||
jfieldID fid;
|
||||
@@ -222,27 +233,31 @@ namespace ZeroTier {
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_zerotier_ZeroTier_ztjni_1fcntl(JNIEnv *env, jobject thisObj,
|
||||
jint fd, jint cmd, jint flags) {
|
||||
jint fd, jint cmd, jint flags)
|
||||
{
|
||||
return zts_fcntl(fd,cmd,flags);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* Java JNI Wrapper for ZeroTier service controls */
|
||||
/* ZeroTier service controls (for JNI wrapper) */
|
||||
/****************************************************************************/
|
||||
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1start(JNIEnv *env, jobject thisObj, jstring path) {
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1start(JNIEnv *env, jobject thisObj, jstring path)
|
||||
{
|
||||
if (path) {
|
||||
zts_start(env->GetStringUTFChars(path, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1startjoin(JNIEnv *env, jobject thisObj, jstring path, jstring nwid) {
|
||||
if (path) {
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1startjoin(JNIEnv *env, jobject thisObj, jstring path, jstring nwid)
|
||||
{
|
||||
if (path && nwid) {
|
||||
zts_startjoin(env->GetStringUTFChars(path, NULL), env->GetStringUTFChars(nwid, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1stop(JNIEnv *env, jobject thisObj) {
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1stop(JNIEnv *env, jobject thisObj)
|
||||
{
|
||||
zts_stop();
|
||||
}
|
||||
|
||||
@@ -252,6 +267,20 @@ namespace ZeroTier {
|
||||
return zts_running();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1join(JNIEnv *env, jobject thisObj, jstring nwid)
|
||||
{
|
||||
if (nwid) {
|
||||
zts_join(env->GetStringUTFChars(nwid, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1leave(JNIEnv *env, jobject thisObj, jstring nwid)
|
||||
{
|
||||
if (nwid) {
|
||||
zts_leave(env->GetStringUTFChars(nwid, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_zerotier_ZeroTier_ztjni_1homepath(
|
||||
JNIEnv *env, jobject thisObj)
|
||||
{
|
||||
@@ -260,26 +289,6 @@ namespace ZeroTier {
|
||||
return (*env).NewStringUTF("");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1join(
|
||||
JNIEnv *env, jobject thisObj, jstring nwid)
|
||||
{
|
||||
const char *nwidstr;
|
||||
if (nwid) {
|
||||
nwidstr = env->GetStringUTFChars(nwid, NULL);
|
||||
zts_join(nwidstr);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_zerotier_ZeroTier_ztjni_1leave(
|
||||
JNIEnv *env, jobject thisObj, jstring nwid)
|
||||
{
|
||||
const char *nwidstr;
|
||||
if (nwid) {
|
||||
nwidstr = env->GetStringUTFChars(nwid, NULL);
|
||||
zts_leave(nwidstr);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_zerotier_ZeroTier_ztjni_1get_1ipv4_1address(
|
||||
JNIEnv *env, jobject thisObj, jstring nwid)
|
||||
{
|
||||
@@ -308,9 +317,9 @@ namespace ZeroTier {
|
||||
return addresses;
|
||||
}
|
||||
|
||||
JNIEXPORT jint Java_zerotier_ZeroTier_ztjni_1get_1device_1id()
|
||||
JNIEXPORT jint Java_zerotier_ZeroTier_ztjni_1get_1id()
|
||||
{
|
||||
return zts_get_device_id(NULL); // TODO
|
||||
return zts_get_id(NULL); // TODO
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ int main(int argc , char *argv[])
|
||||
printf("Starting libzt...\n");
|
||||
zts_startjoin(argv[1], argv[2]);
|
||||
char device_id[11];
|
||||
zts_get_device_id(device_id);
|
||||
zts_get_id(device_id);
|
||||
fprintf(stderr, "Complete. I am %s\n", device_id);
|
||||
|
||||
// create socket
|
||||
|
||||
@@ -1888,7 +1888,7 @@ int ZT_control_semantics_test(bool *passed)
|
||||
|
||||
/*
|
||||
std::vector<ZT_VirtualNetworkRoute> *zts_get_network_routes(char *nwid);
|
||||
int zts_get_device_id_from_file(const char *filepath, char *devID);
|
||||
int zts_get_id_from_file(const char *filepath, char *devID);
|
||||
void *zts_start_service(void *thread_id);
|
||||
void disableTaps();
|
||||
void zts_get_ipv4_address(const char *nwid, char *addrstr, const size_t addrlen);
|
||||
@@ -1905,7 +1905,7 @@ int ZT_control_semantics_test(bool *passed)
|
||||
int zts_start(const char *path, const char *nwid);
|
||||
void zts_stop();
|
||||
void zts_get_homepath(char *homePath, size_t len);
|
||||
int zts_get_device_id(char *devID);
|
||||
int zts_get_id(char *devID);
|
||||
unsigned long zts_get_peer_count();
|
||||
int zts_get_peer_address(char *peer, const char *devID);
|
||||
*/
|
||||
@@ -2706,7 +2706,7 @@ int main(int argc , char *argv[])
|
||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||
zts_startjoin(path.c_str(), nwid.c_str());
|
||||
char device_id[ZTO_ID_LEN];
|
||||
zts_get_device_id(device_id);
|
||||
zts_get_id(device_id);
|
||||
DEBUG_TEST("I am %s, %s", device_id, me.c_str());
|
||||
if (mode == TEST_MODE_SERVER) {
|
||||
DEBUG_TEST("Ready. You should start selftest program on second host now...\n\n");
|
||||
|
||||
Reference in New Issue
Block a user