This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-libzt/examples/java/zerotier/ZeroTier.java

81 lines
3.7 KiB
Java
Raw Normal View History

2017-05-04 13:06:39 -07:00
/*
2017-10-13 13:14:28 -07:00
* ZeroTier SDK - Network Virtualization Everywhere
2018-07-19 17:35:42 -07:00
* Copyright (C) 2011-2018 ZeroTier, Inc. https://www.zerotier.com/
2017-05-04 13:06:39 -07:00
*
* 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/>.
*
* --
*
2017-10-13 13:14:28 -07:00
* You can be released from the requirements of the license by purchasing
* a commercial license. Buying such a license is mandatory as soon as you
* develop commercial closed-source software that incorporates or links
* directly against ZeroTier software without disclosing the source code
* of your own application.
2017-05-04 13:06:39 -07:00
*/
2017-10-16 13:10:20 -07:00
package zerotier;
import java.net.*;
2017-05-04 13:06:39 -07:00
public class ZeroTier {
2018-07-19 17:35:42 -07:00
2017-05-04 13:06:39 -07:00
public static int AF_INET = 2;
2017-11-21 15:24:51 -08:00
public static int AF_INET6 = 30;
2017-05-04 13:06:39 -07:00
public static int SOCK_STREAM = 1;
public static int SOCK_DGRAM = 2;
public static int O_APPEND = 1024;
public static int O_NONBLOCK = 2048;
public static int O_ASYNC = 8192;
public static int O_DIRECT = 65536;
public static int O_NOATIME = 262144;
public static int F_GETFL = 3;
public static int F_SETFL = 4;
2018-07-19 17:35:42 -07:00
2017-11-21 15:24:51 -08:00
public native void start(String homePath, boolean blocking);
public native void startjoin(String homePath, long nwid);
public native void stop();
2017-11-21 15:24:51 -08:00
public native boolean core_running();
public native boolean stack_running();
public native boolean ready();
public native int join(long nwid);
public native int leave(long nwid);
public native String get_path();
public native long get_node_id();
public native int get_num_assigned_addresses(long nwid);
2018-07-19 17:35:42 -07:00
public native boolean get_address_at_index(long nwid, int index, ZTSocketAddress addr);
2017-11-21 15:24:51 -08:00
public native boolean has_address(long nwid);
2018-07-19 17:35:42 -07:00
public native boolean get_address(long nwid, int address_family, ZTSocketAddress 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);
2018-07-19 17:35:42 -07:00
public native int socket(int family, int type, int protocol);
2018-07-19 17:35:42 -07:00
public native int connect(int fd, ZTSocketAddress addr);
public native int bind(int fd, ZTSocketAddress addr);
public native int listen(int fd, int backlog);
2018-07-19 17:35:42 -07:00
public native int accept(int fd, ZTSocketAddress addr);
public native int accept4(int fd, String addr, int port);
public native int close(int fd);
2018-07-19 17:35:42 -07:00
public native int setsockopt(int fd, int level, int optname, int optval, int optlen);
public native int getsockopt(int fd, int level, int optname, int optval, int optlen);
public native int sendto(int fd, byte[] buf, int len, int flags, ZTSocketAddress addr);
2017-11-21 15:24:51 -08:00
public native int send(int fd, byte[] buf, int len, int flags);
2018-07-19 17:35:42 -07:00
public native int recv(int fd, byte[] buf, int len, int flags);
public native int recvfrom(int fd, byte[] buf, int len, int flags, ZTSocketAddress addr);
public native int read(int fd, byte[] buf, int len);
public native int write(int fd, byte[] buf, int len);
public native int shutdown(int fd, int how);
2018-07-19 17:35:42 -07:00
public native boolean getsockname(int fd, ZTSocketAddress addr);
public native int getpeername(int fd, ZTSocketAddress addr);
public native int fcntl(int sock, int cmd, int flag);
2017-05-04 13:06:39 -07:00
}