2017-10-12 13:26:52 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
|
|
namespace ZeroTier
|
|
|
|
|
|
{
|
|
|
|
|
|
static class libzt
|
|
|
|
|
|
{
|
2017-10-12 13:54:25 -07:00
|
|
|
|
/****************************************************************************/
|
|
|
|
|
|
/* ZeroTier Service Controls */
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
|
|
|
2017-10-12 13:51:57 -07:00
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_start(string path);
|
|
|
|
|
|
|
2017-10-12 13:26:52 -07:00
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern int zts_startjoin(string path, ulong nwid);
|
2017-10-12 13:26:52 -07:00
|
|
|
|
|
2017-10-12 13:51:57 -07:00
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern void zts_stop();
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern void zts_join(ulong nwid);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern void zts_leave(ulong nwid);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern void zts_get_homepath(string homePath, int len);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern int zts_get_id(string nodeId);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_running();
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern int zts_has_address(ulong nwid);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern int zts_has_address(ulong nwid);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern void zts_get_address(ulong nwid, System.IntPtr addr, int addrlen);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern void zts_get_6plane_addr(System.IntPtr addr addr, string nwid, string nodeId);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern void zts_get_rfc4193_addr(System.IntPtr addr addr, string nwid, string nodeId);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern long zts_get_peer_count();
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-11-06 13:50:20 -08:00
|
|
|
|
public static extern int zts_get_peer_address(string peer, ulong nodeId);
|
2017-10-12 13:51:57 -07:00
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern void zts_enable_http_control_plane();
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern void zts_disable_http_control_plane();
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
|
|
/* POSIX-like socket API */
|
|
|
|
|
|
/****************************************************************************/
|
|
|
|
|
|
|
2017-10-12 13:26:52 -07:00
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_socket(int socket_family, int socket_type, int protocol);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
2017-10-12 13:51:57 -07:00
|
|
|
|
public static extern int zts_connect(int fd, System.IntPtr addr, int addrlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_bind(int fd, System.IntPtr addr, int addrlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_listen(int fd, int backlog);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_accept(int fd, System.IntPtr addr, IntPtr addrlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_setsockopt(int fd, int level, int optname, IntPtr optval, int optlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_getsockopt(int fd, int level, int optname, IntPtr optval, IntPtr optlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_getsockname(int fd, System.IntPtr addr, IntPtr addrlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_getpeername(int fd, System.IntPtr addr, IntPtr addrlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_gethostname(string name, int len);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_sethostname(string name, int len);
|
|
|
|
|
|
|
|
|
|
|
|
//[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
//unsafe public static extern IntPtr *zts_gethostbyname(string name);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_close(int fd);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_select(int nfds, IntPtr readfds, IntPtr writefds, IntPtr exceptfds, IntPtr timeout);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_fcntl(int fd, int cmd, int flags);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_ioctl(int fd, ulong request, IntPtr argp);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_send(int fd, IntPtr buf, int len, int flags);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_sendto(int fd, IntPtr buf, int len, int flags, System.IntPtr addr, int addrlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_sendmsg(int fd, IntPtr msg, int flags);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_recv(int fd, IntPtr buf, int len, int flags);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_recvfrom(int fd, IntPtr buf, int len, int flags, System.IntPtr addr, IntPtr addrlen);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_recvmsg(int fd, IntPtr msg, int flags);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_read(int fd, IntPtr buf, int len);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_write(int fd, IntPtr buf, int len);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_shutdown(int fd, int how);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_add_dns_nameserver(System.IntPtr addr);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("libzt.dll", CallingConvention = CallingConvention.StdCall)]
|
|
|
|
|
|
public static extern int zts_del_dns_nameserver(System.IntPtr addr);
|
2017-10-12 13:26:52 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|