diff options
Diffstat (limited to 'java/src')
19 files changed, 1060 insertions, 0 deletions
diff --git a/java/src/com/zerotierone/sdk/DataStoreGetListener.java b/java/src/com/zerotierone/sdk/DataStoreGetListener.java new file mode 100644 index 00000000..60e1c3e8 --- /dev/null +++ b/java/src/com/zerotierone/sdk/DataStoreGetListener.java @@ -0,0 +1,38 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + +public interface DataStoreGetListener { + public int onDataStoreGet(Node node, + String name, + ByteBuffer buffer, + long bufferSize, + long index, + Long out_objectSize); +} diff --git a/java/src/com/zerotierone/sdk/DataStorePutListener.java b/java/src/com/zerotierone/sdk/DataStorePutListener.java new file mode 100644 index 00000000..4e9404d9 --- /dev/null +++ b/java/src/com/zerotierone/sdk/DataStorePutListener.java @@ -0,0 +1,37 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + +public interface DataStorePutListener { + public int onDataStorePut(Node node, + String name, + ByteBuffer buffer, + long bufferSize, + boolean secure); +} diff --git a/java/src/com/zerotierone/sdk/Event.java b/java/src/com/zerotierone/sdk/Event.java new file mode 100644 index 00000000..c5558676 --- /dev/null +++ b/java/src/com/zerotierone/sdk/Event.java @@ -0,0 +1,38 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +public enum Event { + EVENT_UP, + EVENT_OFFLINE, + EVENT_DOWN, + EVENT_FATAL_ERROR_IDENTITY_COLLISION, + EVENT_AUTHENTICATION_FAILURE, + EVENT_INVALID_PACKET, + EVENT_TRACE +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/EventListener.java b/java/src/com/zerotierone/sdk/EventListener.java new file mode 100644 index 00000000..9e3e4d24 --- /dev/null +++ b/java/src/com/zerotierone/sdk/EventListener.java @@ -0,0 +1,34 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + +public interface EventListener { + public void onEvent(Node node,Event event, ByteBuffer buffer); +} diff --git a/java/src/com/zerotierone/sdk/MulticastGroup.java b/java/src/com/zerotierone/sdk/MulticastGroup.java new file mode 100644 index 00000000..89ba206f --- /dev/null +++ b/java/src/com/zerotierone/sdk/MulticastGroup.java @@ -0,0 +1,35 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ +package com.zerotierone.sdk; + + +public class MulticastGroup { + private MulticastGroup() {} + + private long mac; + private long adi; +} diff --git a/java/src/com/zerotierone/sdk/Node.java b/java/src/com/zerotierone/sdk/Node.java new file mode 100644 index 00000000..34a67cb7 --- /dev/null +++ b/java/src/com/zerotierone/sdk/Node.java @@ -0,0 +1,235 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; +import java.lang.Long; +import java.net.InetAddress; +import java.util.ArrayList; + +public class Node { + static { + System.loadLibrary("ZeroTierOneJNI"); + } + + private static final String TAG = "NODE"; + + /** + * Node ID for JNI purposes. + * Currently set to the now value passed in at the constructor + * + * -1 if the node has already been closed + */ + private long nodeId; + + private final DataStoreGetListener getListener; + private final DataStorePutListener putListener; + private final PacketSender sender; + private final VirtualNetworkFrameListener frameListener; + private final VirtualNetworkConfigListener configListener; + + public Node(long now, + DataStoreGetListener getListener, + DataStorePutListener putListener, + PacketSender sender, + VirtualNetworkFrameListener frameListener, + VirtualNetworkConfigListener configListener) + { + this.nodeId = now; + + this.getListener = getListener; + this.putListener = putListener; + this.sender = sender; + this.frameListener = frameListener; + this.configListener = configListener; + + ResultCode rc = node_init(now); + if(rc != ResultCode.RESULT_OK) + { + // TODO: Throw Exception + } + } + + public void close() { + if(nodeId != -1) { + node_delete(nodeId); + nodeId = -1; + } + } + + @Override + protected void finalize() { + close(); + } + + public ResultCode processVirtualNetworkFrame( + long now, + long nwid, + long sourceMac, + long destMac, + int etherType, + int vlanId, + byte[] frameData, + long[] nextBackgroundTaskDeadline) { + return processVirtualNetworkFrame( + nodeId, now, nwid, sourceMac, destMac, etherType, vlanId, + frameData, nextBackgroundTaskDeadline); + } + + public ResultCode processWirePacket( + long now, + InetAddress remoteAddress, + int linkDesperation, + byte[] packetData, + long[] nextBackgroundTaskDeadline) { + return processWirePacket( + nodeId, now, remoteAddress, linkDesperation, packetData, + nextBackgroundTaskDeadline); + } + + public ResultCode processBackgroundTasks(long now, long[] nextBackgroundTaskDeadline) { + return processBackgroundTasks(nodeId, now, nextBackgroundTaskDeadline); + } + + public ResultCode join(long nwid) { + return join(nodeId, nwid); + } + + public ResultCode leave(long nwid) { + return leave(nodeId, nwid); + } + + public ResultCode multicastSubscribe( + long nwid, + long multicastGroup) { + return multicastSubscribe(nodeId, nwid, multicastGroup, 0); + } + + public ResultCode multicastSubscribe( + long nwid, + long multicastGroup, + long multicastAdi) { + return multicastSubscribe(nodeId, nwid, multicastGroup, multicastAdi); + } + + public ResultCode multicastUnsubscribe( + long nwid, + long multicastGroup) { + return multicastUnsubscribe(nodeId, nwid, multicastGroup, 0); + } + + public ResultCode multicastUnsubscribe( + long nwid, + long multicastGroup, + long multicastAdi) { + return multicastUnsubscribe(nodeId, nwid, multicastGroup, multicastAdi); + } + + public long address() { + return address(nodeId); + } + + public NodeStatus status() { + return status(nodeId); + } + + public ArrayList<Peer> peers() { + return peers(nodeId); + } + + public VirtualNetworkConfig networkConfig(long nwid) { + return networkConfig(nodeId, nwid); + } + + public ArrayList<VirtualNetworkConfig> networks() { + return networks(nodeId); + } + + public Version getVersion() { + return version(); + } + + /** + * function declarations for JNI + */ + private native ResultCode node_init(long now); + + private native void node_delete(long nodeId); + + private native ResultCode processVirtualNetworkFrame( + long nodeId, + long now, + long nwid, + long sourceMac, + long destMac, + int etherType, + int vlanId, + byte[] frameData, + long[] nextBackgroundTaskDeadline); + + private native ResultCode processWirePacket( + long nodeId, + long now, + InetAddress remoteAddress, + int linkDesperation, + byte[] packetData, + long[] nextBackgroundTaskDeadline); + + private native ResultCode processBackgroundTasks( + long nodeId, + long now, + long[] nextBackgroundTaskDeadline); + + private native ResultCode join(long nodeId, long nwid); + + private native ResultCode leave(long nodeId, long nwid); + + private native ResultCode multicastSubscribe( + long nodeId, + long nwid, + long multicastGroup, + long multicastAdi); + + private native ResultCode multicastUnsubscribe( + long nodeId, + long nwid, + long multicastGroup, + long multicastAdi); + + private native long address(long nodeId); + + private native NodeStatus status(long nodeId); + + private native VirtualNetworkConfig networkConfig(long nodeId, long nwid); + + private native Version version(); + + private native ArrayList<Peer> peers(long nodeId); + + private native ArrayList<VirtualNetworkConfig> networks(long nodeId); +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/NodeStatus.java b/java/src/com/zerotierone/sdk/NodeStatus.java new file mode 100644 index 00000000..fdf5284e --- /dev/null +++ b/java/src/com/zerotierone/sdk/NodeStatus.java @@ -0,0 +1,53 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +public class NodeStatus { + private long address; + private String publicIdentity; + private String secretIdentity; + private boolean online; + + private NodeStatus() {} + + public final long getAddres() { + return address; + } + + public final String getPublicIdentity() { + return publicIdentity; + } + + public final String getSecretIdentity() { + return secretIdentity; + } + + public final boolean isOnline() { + return online; + } +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/PacketSender.java b/java/src/com/zerotierone/sdk/PacketSender.java new file mode 100644 index 00000000..0e007ffb --- /dev/null +++ b/java/src/com/zerotierone/sdk/PacketSender.java @@ -0,0 +1,38 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + + +public interface PacketSender { + public int onSendPacketRequested(Node node, + String addr, + int linkDesc, + ByteBuffer packetData, + long dataLength); +} diff --git a/java/src/com/zerotierone/sdk/Peer.java b/java/src/com/zerotierone/sdk/Peer.java new file mode 100644 index 00000000..cd2268b4 --- /dev/null +++ b/java/src/com/zerotierone/sdk/Peer.java @@ -0,0 +1,80 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +import java.util.ArrayList; + +public class Peer { + private long address; + private long lastUnicastFrame; + private long lastMulticastFrame; + private int versionMajor; + private int versionMinor; + private int versionRev; + private int latency; + private PeerRole role; + private ArrayList<PhysicalPeerPath> paths; + + private Peer() {} + + public final long address() { + return address; + } + + public final long lastUnicastFrame() { + return lastUnicastFrame; + } + + public final long lastMulticastFrame() { + return lastMulticastFrame; + } + + public final int versionMajor() { + return versionMajor; + } + + public final int versionMinor() { + return versionMinor; + } + + public final int versionRev() { + return versionRev; + } + + public final int latency() { + return latency; + } + + public final PeerRole role() { + return role; + } + + public final ArrayList<PhysicalPeerPath> paths() { + return paths; + } +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/PeerRole.java b/java/src/com/zerotierone/sdk/PeerRole.java new file mode 100644 index 00000000..979b1a98 --- /dev/null +++ b/java/src/com/zerotierone/sdk/PeerRole.java @@ -0,0 +1,34 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +public enum PeerRole { + PEER_ROLE_LEAF, + PEER_ROLE_HUB, + PEER_ROLE_SUPERNODE +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/PhysicalPeerPath.java b/java/src/com/zerotierone/sdk/PhysicalPeerPath.java new file mode 100644 index 00000000..1eb69f65 --- /dev/null +++ b/java/src/com/zerotierone/sdk/PhysicalPeerPath.java @@ -0,0 +1,65 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +import java.net.InetAddress; + +public class PhysicalPeerPath { + private InetAddress address; + private long lastSend; + private long lastReceive; + private boolean fixed; + private boolean active; + private boolean preferred; + + private PhysicalPeerPath() {} + + public final InetAddress address() { + return address; + } + + public final long lastSend() { + return lastSend; + } + + public final long lastReceive() { + return lastReceive; + } + + public final boolean isFixed() { + return fixed; + } + + public final boolean isActive() { + return active; + } + + public final boolean isPreferred() { + return preferred; + } +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/ResultCode.java b/java/src/com/zerotierone/sdk/ResultCode.java new file mode 100644 index 00000000..7597c0f2 --- /dev/null +++ b/java/src/com/zerotierone/sdk/ResultCode.java @@ -0,0 +1,45 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +public enum ResultCode { + + RESULT_OK(0), + RESULT_FATAL_ERROR_OUT_OF_MEMORY(1), + RESULT_FATAL_ERROR_DATA_STORE_FAILED(2), + RESULT_FATAL_ERROR_INTERNAL(3), + RESULT_ERROR_NETWORK_NOT_FOUND(1000); + + private final int id; + ResultCode(int id) { this.id = id; } + public int getValue() { return id; } + + public boolean isFatal(int id) { + return (id > 0 && id < 1000); + } +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/Version.java b/java/src/com/zerotierone/sdk/Version.java new file mode 100644 index 00000000..abdaab9e --- /dev/null +++ b/java/src/com/zerotierone/sdk/Version.java @@ -0,0 +1,37 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +public class Version { + public Version() {} + + public int major = 0; + public int minor = 0; + public int revision = 0; + public long featureFlags = 0; +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java b/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java new file mode 100644 index 00000000..5e06b55f --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkConfig.java @@ -0,0 +1,111 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +package com.zerotierone.sdk; + +import java.lang.String; +import java.util.ArrayList; +import java.net.InetAddress; + +public class VirtualNetworkConfig { + public static final int MAX_MULTICAST_SUBSCRIPTIONS = 4096; + public static final int ZT1_MAX_ZT_ASSIGNED_ADDRESSES = 16; + + private long nwid; + private long mac; + private String name; + private VirtualNetworkStatus status; + private VirtualNetworkType type; + private int mtu; + private boolean dhcp; + private boolean bridge; + private boolean broadcastEnabled; + private boolean portError; + private boolean enabled; + private long netconfRevision; + private ArrayList<MulticastGroup> multicastSubscriptions; + private ArrayList<InetAddress> assignedAddresses; + + private VirtualNetworkConfig() { + + } + + public final long networkId() { + return nwid; + } + public final long macAddress() { + return mac; + } + + public final String name() { + return name; + } + + public final VirtualNetworkStatus networkStatus() { + return status; + } + + public final VirtualNetworkType networkType() { + return type; + } + + public final int mtu() { + return mtu; + } + + public final boolean isDhcpAvailable() { + return dhcp; + } + + public final boolean isBridgeEnabled() { + return bridge; + } + + public final boolean broadcastEnabled() { + return broadcastEnabled; + } + + public final boolean portError() { + return portError; + } + + public final boolean isEnabled() { + return enabled; + } + + public final long netconfRevision() { + return netconfRevision; + } + + public final ArrayList<MulticastGroup> multicastSubscriptions() { + return multicastSubscriptions; + } + + public final ArrayList<InetAddress> assignedAddresses() { + return assignedAddresses; + } +} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java b/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java new file mode 100644 index 00000000..78d11987 --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkConfigListener.java @@ -0,0 +1,38 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + + +package com.zerotierone.sdk; + + +public interface VirtualNetworkConfigListener { + public void onNetworkConfigurationUpdated( + Node node, + long someValue, + VirtualNetworkConfigOperation op, + VirtualNetworkConfig config); +}
\ No newline at end of file diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkConfigOperation.java b/java/src/com/zerotierone/sdk/VirtualNetworkConfigOperation.java new file mode 100644 index 00000000..2bf6ce09 --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkConfigOperation.java @@ -0,0 +1,34 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ +package com.zerotierone.sdk; + +public enum VirtualNetworkConfigOperation { + VIRTUAL_NETWORK_CONFIG_OPERATION_UP, + VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE, + VIRTUAL_NETWORK_CONFIG_OPERATION_DOWN, + VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY +} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java b/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java new file mode 100644 index 00000000..fed5d95c --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkFrameListener.java @@ -0,0 +1,40 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ +package com.zerotierone.sdk; + +import java.nio.ByteBuffer; + +public interface VirtualNetworkFrameListener { + void onVirtualNetworkFrame(Node node, + long nwid, + long srcMac, + long destMac, + long etherType, + long vlanId, + ByteBuffer frameData, + long len); +} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java b/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java new file mode 100644 index 00000000..1102d2ea --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkStatus.java @@ -0,0 +1,36 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ +package com.zerotierone.sdk; + +public enum VirtualNetworkStatus { + NETWORK_STATUS_REQUESTING_CONFIGURATION, + NETWORK_STATUS_OK, + NETWORK_STATUS_ACCESS_DENIED, + NETWORK_STATUS_NOT_FOUND, + NETWORK_STATUS_PORT_ERROR, + NETWORK_STATUS_CLIENT_TOO_OLD +} diff --git a/java/src/com/zerotierone/sdk/VirtualNetworkType.java b/java/src/com/zerotierone/sdk/VirtualNetworkType.java new file mode 100644 index 00000000..b4a8ce2f --- /dev/null +++ b/java/src/com/zerotierone/sdk/VirtualNetworkType.java @@ -0,0 +1,32 @@ +/* + * ZeroTier One - Network Virtualization Everywhere + * Copyright (C) 2011-2015 ZeroTier, Inc. + * + * 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/>. + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ +package com.zerotierone.sdk; + +public enum VirtualNetworkType { + NETWORK_TYPE_PRIVATE, + NETWORK_TYPE_PUBLIC +} |