Updated example Android project and JNI layer

This commit is contained in:
Joseph Henry
2018-07-20 13:10:24 -07:00
parent ac1f0e32ca
commit 643e04a825
5 changed files with 40 additions and 21 deletions

View File

@@ -53,7 +53,7 @@ public class ExampleApp {
public void run()
{
String path = "/Users/joseph/op/zt/libzt/ztjni"; // Where node's config files are stored
long nwid = 0xf0b9acf0833f4b071L;
long nwid = 0xa09acf0233e4b070L;
// Test modes
boolean blocking_start_call = true;
@@ -105,18 +105,20 @@ public class ExampleApp {
}
}
System.out.println("ZT service ready.");
// Device/Node address info
System.out.println("path=" + libzt.get_path());
System.out.println("nodeId=" + Long.toHexString(libzt.get_node_id()));
int numAddresses = libzt.get_num_assigned_addresses(nwid);
System.out.println("this node has (" + numAddresses + ") assigned addresses on network " + Long.toHexString(nwid));
for (int i=0; i<numAddresses; i++) {
libzt.get_address_at_index(nwid, i, sockname);
//System.out.println("address[" + i + "] = " + sockname.toString()); // ip:port
System.out.println("address[" + i + "] = " + sockname.toCIDR());
// Device/Node address info
System.out.println("path=" + libzt.get_path());
long nodeId = libzt.get_node_id();
System.out.println("nodeId=" + Long.toHexString(nodeId));
int numAddresses = libzt.get_num_assigned_addresses(nwid);
System.out.println("this node has (" + numAddresses + ") assigned addresses on network " + Long.toHexString(nwid));
for (int i=0; i<numAddresses; i++) {
libzt.get_address_at_index(nwid, i, sockname);
//System.out.println("address[" + i + "] = " + sockname.toString()); // ip:port
System.out.println("address[" + i + "] = " + sockname.toCIDR());
}
}
libzt.get_6plane_addr(nwid, nodeId, sockname);
System.out.println("6PLANE address = " + sockname.toCIDR());
// Idle loop test
while(idle) { try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } }

View File

@@ -56,8 +56,8 @@ public class ZeroTier {
public native boolean get_address_at_index(long nwid, int index, ZTSocketAddress addr);
public native boolean has_address(long nwid);
public native boolean get_address(long nwid, int address_family, ZTSocketAddress addr);
public native void get_6plane_addr();
public native void get_rfc4193_addr();
public native void get_6plane_addr(long nwid, long nodeId, ZTSocketAddress addr);
public native void get_rfc4193_addr(long nwid, long nodeId, ZTSocketAddress addr);
public native int socket(int family, int type, int protocol);
public native int connect(int fd, ZTSocketAddress addr);