Added comment syntax for doxygen, fixed build flag which produced unnecessarily-large binaries, removed trailing whitespace
This commit is contained in:
3
Makefile
3
Makefile
@@ -120,11 +120,12 @@ ifeq ($(ZT_DEBUG),1)
|
|||||||
CFLAGS+=-Wall -g -pthread
|
CFLAGS+=-Wall -g -pthread
|
||||||
STRIP=echo
|
STRIP=echo
|
||||||
else
|
else
|
||||||
CFLAGS?=-Ofast -g -fstack-protector
|
CFLAGS?=-Ofast -fstack-protector
|
||||||
CFLAGS+=-Wall -fPIE -fvisibility=hidden -pthread
|
CFLAGS+=-Wall -fPIE -fvisibility=hidden -pthread
|
||||||
STRIP=strip
|
STRIP=strip
|
||||||
endif
|
endif
|
||||||
ifeq ($(LIBZT_DEBUG),1)
|
ifeq ($(LIBZT_DEBUG),1)
|
||||||
|
CFLAGS+=-g
|
||||||
LIBZT_DEFS+=-DLIBZT_DEBUG
|
LIBZT_DEFS+=-DLIBZT_DEBUG
|
||||||
endif
|
endif
|
||||||
ifeq ($(NS_DEBUG),1)
|
ifeq ($(NS_DEBUG),1)
|
||||||
|
|||||||
@@ -183,4 +183,4 @@ extern unsigned int gettid(); // defined in libzt.cpp
|
|||||||
#define DEBUG_EXTRA(fmt, args...)
|
#define DEBUG_EXTRA(fmt, args...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // LIBZT_DEBUG_HPP
|
#endif // _H
|
||||||
|
|||||||
142
include/Defs.h
142
include/Defs.h
@@ -33,6 +33,9 @@
|
|||||||
#ifndef LIBZT_DEFINES_H
|
#ifndef LIBZT_DEFINES_H
|
||||||
#define LIBZT_DEFINES_H
|
#define LIBZT_DEFINES_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum MTU size for ZeroTier
|
||||||
|
*/
|
||||||
#define ZT_MAX_MTU 10000
|
#define ZT_MAX_MTU 10000
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +44,7 @@
|
|||||||
#define ZTO_WRAPPER_CHECK_INTERVAL 50
|
#define ZTO_WRAPPER_CHECK_INTERVAL 50
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Length of buffer required to hold a ztAddress/nodeID
|
||||||
*/
|
*/
|
||||||
#define ZTO_ID_LEN 16
|
#define ZTO_ID_LEN 16
|
||||||
|
|
||||||
@@ -132,22 +135,22 @@ struct sockaddr_ll {
|
|||||||
|
|
||||||
typedef signed char err_t;
|
typedef signed char err_t;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
Specifies the polling interval and the callback function that should
|
Specifies the polling interval and the callback function that should
|
||||||
be called to poll the application. The interval is specified in
|
be called to poll the application. The interval is specified in
|
||||||
number of TCP coarse grained timer shots, which typically occurs
|
number of TCP coarse grained timer shots, which typically occurs
|
||||||
twice a second. An interval of 10 means that the application would
|
twice a second. An interval of 10 means that the application would
|
||||||
be polled every 5 seconds.
|
be polled every 5 seconds. (only for raw lwIP driver)
|
||||||
*/
|
*/
|
||||||
#define LWIP_APPLICATION_POLL_FREQ 2
|
#define LWIP_APPLICATION_POLL_FREQ 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* TCP timer interval in milliseconds (only for raw lwIP driver)
|
||||||
*/
|
*/
|
||||||
#define LWIP_TCP_TIMER_INTERVAL 25
|
#define LWIP_TCP_TIMER_INTERVAL 25
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How often we check VirtualSocket statuses (in ms)
|
* How often we check VirtualSocket statuses in milliseconds (only for raw lwIP driver)
|
||||||
*/
|
*/
|
||||||
#define LWIP_STATUS_TMR_INTERVAL 500
|
#define LWIP_STATUS_TMR_INTERVAL 500
|
||||||
|
|
||||||
@@ -166,12 +169,12 @@ typedef signed char err_t;
|
|||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maximum number of sockets that libzt can administer
|
||||||
*/
|
*/
|
||||||
#define ZT_MAX_SOCKETS 1024
|
#define ZT_MAX_SOCKETS 1024
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maximum MTU size for libzt (must be less than or equal to ZT_MAX_MTU)
|
||||||
*/
|
*/
|
||||||
#define ZT_SDK_MTU ZT_MAX_MTU
|
#define ZT_SDK_MTU ZT_MAX_MTU
|
||||||
|
|
||||||
@@ -186,52 +189,52 @@ typedef signed char err_t;
|
|||||||
#define ZT_ADDR_SZ 128
|
#define ZT_ADDR_SZ 128
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Size of message buffer for VirtualSockets
|
||||||
*/
|
*/
|
||||||
#define ZT_SOCKET_MSG_BUF_SZ ZT_SDK_MTU + ZT_LEN_SZ + ZT_ADDR_SZ
|
#define ZT_SOCKET_MSG_BUF_SZ ZT_SDK_MTU + ZT_LEN_SZ + ZT_ADDR_SZ
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Polling interval (in ms) for file descriptors wrapped in the Phy I/O loop (for raw drivers only)
|
||||||
*/
|
*/
|
||||||
#define ZT_PHY_POLL_INTERVAL 5 // ms
|
#define ZT_PHY_POLL_INTERVAL 5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* State check interval (in ms) for VirtualSocket state
|
||||||
*/
|
*/
|
||||||
#define ZT_ACCEPT_RECHECK_DELAY 100 // ms (for blocking zts_accept() calls)
|
#define ZT_ACCEPT_RECHECK_DELAY 50
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* State check interval (in ms) for VirtualSocket state
|
||||||
*/
|
*/
|
||||||
#define ZT_CONNECT_RECHECK_DELAY 100 // ms (for blocking zts_connect() calls)
|
#define ZT_CONNECT_RECHECK_DELAY 50
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* State check interval (in ms) for VirtualSocket state
|
||||||
*/
|
*/
|
||||||
#define ZT_API_CHECK_INTERVAL 100 // ms
|
#define ZT_API_CHECK_INTERVAL 50
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maximum size of guarded RX buffer (for picoTCP raw driver only)
|
||||||
*/
|
*/
|
||||||
#define MAX_PICO_FRAME_RX_BUF_SZ ZT_MAX_MTU * 128
|
#define MAX_PICO_FRAME_RX_BUF_SZ ZT_MAX_MTU * 128
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Size of TCP TX buffer for VirtualSockets used in raw network stack drivers
|
||||||
*/
|
*/
|
||||||
#define ZT_TCP_TX_BUF_SZ 1024 * 1024 * 128
|
#define ZT_TCP_TX_BUF_SZ 1024 * 1024 * 128
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Size of TCP RX buffer for VirtualSockets used in raw network stack drivers
|
||||||
*/
|
*/
|
||||||
#define ZT_TCP_RX_BUF_SZ 1024 * 1024 * 128
|
#define ZT_TCP_RX_BUF_SZ 1024 * 1024 * 128
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Size of UDP TX buffer for VirtualSockets used in raw network stack drivers
|
||||||
*/
|
*/
|
||||||
#define ZT_UDP_TX_BUF_SZ ZT_MAX_MTU
|
#define ZT_UDP_TX_BUF_SZ ZT_MAX_MTU
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Size of UDP RX buffer for VirtualSockets used in raw network stack drivers
|
||||||
*/
|
*/
|
||||||
#define ZT_UDP_RX_BUF_SZ ZT_MAX_MTU * 10
|
#define ZT_UDP_RX_BUF_SZ ZT_MAX_MTU * 10
|
||||||
|
|
||||||
@@ -255,93 +258,94 @@ typedef signed char err_t;
|
|||||||
// If you use another stack you can probably bump this up a bit.
|
// If you use another stack you can probably bump this up a bit.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maximum size of write operation to a network stack
|
||||||
*/
|
*/
|
||||||
#define ZT_STACK_SOCKET_WR_MAX 4096
|
#define ZT_STACK_SOCKET_WR_MAX 4096
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maximum size of read operation from a network stack
|
||||||
*/
|
*/
|
||||||
#define ZT_STACK_SOCKET_RD_MAX 4096*4
|
#define ZT_STACK_SOCKET_RD_MAX 4096*4
|
||||||
|
|
||||||
/**
|
#define ZT_CORE_VERSION "1.2.5"
|
||||||
*
|
#define ZT_LIB_VERSION "1.1.5"
|
||||||
*/
|
|
||||||
#define ZT_CORE_VERSION_MAJOR 1
|
|
||||||
#define ZT_CORE_VERSION_MINOR 2
|
|
||||||
#define ZT_CORE_VERSION_REVISION 5
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Maximum length of libzt/ZeroTier home path (where keys, and config files are stored)
|
||||||
*/
|
|
||||||
#define ZT_LIB_VERSION_MAJOR 1
|
|
||||||
#define ZT_LIB_VERSION_MINOR 1
|
|
||||||
#define ZT_LIB_VERSION_REVISION 4
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#define ZT_ID_LEN 16
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#define ZT_VER_STR_LEN 6
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#define ZT_HOME_PATH_MAX_LEN 128
|
#define ZT_HOME_PATH_MAX_LEN 128
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Length of human-readable MAC address string
|
||||||
*/
|
*/
|
||||||
#define ZT_MAC_ADDRSTRLEN 18
|
#define ZT_MAC_ADDRSTRLEN 18
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Everything is ok
|
||||||
*/
|
*/
|
||||||
#define ZT_ERR_OK 0
|
#define ZT_ERR_OK 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Value returned during an internal failure at the VirtualSocket/VirtualTap layer
|
||||||
*/
|
*/
|
||||||
#define ZT_ERR_GENERAL_FAILURE -88
|
#define ZT_ERR_GENERAL_FAILURE -88
|
||||||
|
|
||||||
// Since extra time is required to send a mesage via a socket through the
|
|
||||||
// stack and ZT service, calling a zts_close() immediately after a "successful"
|
|
||||||
// zts_write() might cause data loss, for this reason, sockets will SO_LINGER for
|
|
||||||
// a short period of time by default as a precaution.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Whether sockets created will have SO_LINGER set by default
|
||||||
*/
|
*/
|
||||||
#define ZT_SOCK_BEHAVIOR_LINGER true
|
#define ZT_SOCK_BEHAVIOR_LINGER false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Length of time that VirtualSockets should linger (in seconds)
|
||||||
*/
|
*/
|
||||||
#define ZT_SOCK_BEHAVIOR_LINGER_TIME 3 // s
|
#define ZT_SOCK_BEHAVIOR_LINGER_TIME 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait time for socket closure if data is still present in the write queue
|
* Maximum wait time for socket closure if data is still present in the write queue
|
||||||
*/
|
*/
|
||||||
#define ZT_SDK_CLTIME 60
|
#define ZT_SDK_CLTIME 60
|
||||||
|
|
||||||
// After closing a pico_socket, other threads might still try to use the
|
|
||||||
// VirtualSocket object for remaining data I/O, as a safety measure we will wait to
|
|
||||||
// delete this VirtualSocket object until the socket has been closed for some arbitrary
|
|
||||||
// amount of time and it is safe to assume any clients interacting with this
|
|
||||||
// socket have read some sort of error code from the API.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interval for performing cleanup tasks on Tap/Stack objects (in seconds)
|
* Interval for performing background tasks (such as adding routes) on VirtualTap objects (in seconds)
|
||||||
*/
|
*/
|
||||||
#define ZT_HOUSEKEEPING_INTERVAL 10
|
#define ZT_HOUSEKEEPING_INTERVAL 5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not we want libzt to exit on internal failure
|
* Whether or not we want libzt to exit on internal failure
|
||||||
*/
|
*/
|
||||||
#define ZT_EXIT_ON_GENERAL_FAIL false
|
#define ZT_EXIT_ON_GENERAL_FAIL false
|
||||||
|
|
||||||
#endif // LIBZT_DEFINES_H
|
|
||||||
|
/****************************************************************************/
|
||||||
|
/* Socket API Signatures */
|
||||||
|
/****************************************************************************/
|
||||||
|
|
||||||
|
#define ZT_SETSOCKOPT_SIG int fd, int level, int optname, const void *optval, socklen_t optlen
|
||||||
|
#define ZT_GETSOCKOPT_SIG int fd, int level, int optname, void *optval, socklen_t *optlen
|
||||||
|
#define ZT_SENDMSG_SIG int fd, const struct msghdr *msg, int flags
|
||||||
|
#define ZT_SENDTO_SIG int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen
|
||||||
|
#define ZT_RECV_SIG int fd, void *buf, size_t len, int flags
|
||||||
|
#define ZT_RECVFROM_SIG int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen
|
||||||
|
#define ZT_RECVMSG_SIG int fd, struct msghdr *msg,int flags
|
||||||
|
#define ZT_SEND_SIG int fd, const void *buf, size_t len, int flags
|
||||||
|
#define ZT_READ_SIG int fd, void *buf, size_t len
|
||||||
|
#define ZT_WRITE_SIG int fd, const void *buf, size_t len
|
||||||
|
#define ZT_SHUTDOWN_SIG int fd, int how
|
||||||
|
#define ZT_SOCKET_SIG int socket_family, int socket_type, int protocol
|
||||||
|
#define ZT_CONNECT_SIG int fd, const struct sockaddr *addr, socklen_t addrlen
|
||||||
|
#define ZT_BIND_SIG int fd, const struct sockaddr *addr, socklen_t addrlen
|
||||||
|
#define ZT_LISTEN_SIG int fd, int backlog
|
||||||
|
#define ZT_ACCEPT4_SIG int fd, struct sockaddr *addr, socklen_t *addrlen, int flags
|
||||||
|
#define ZT_ACCEPT_SIG int fd, struct sockaddr *addr, socklen_t *addrlen
|
||||||
|
#define ZT_CLOSE_SIG int fd
|
||||||
|
#define ZT_POLL_SIG struct pollfd *fds, nfds_t nfds, int timeout
|
||||||
|
#define ZT_SELECT_SIG int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout
|
||||||
|
#define ZT_GETSOCKNAME_SIG int fd, struct sockaddr *addr, socklen_t *addrlen
|
||||||
|
#define ZT_GETPEERNAME_SIG int fd, struct sockaddr *addr, socklen_t *addrlen
|
||||||
|
#define ZT_GETHOSTNAME_SIG char *name, size_t len
|
||||||
|
#define ZT_SETHOSTNAME_SIG const char *name, size_t len
|
||||||
|
#define ZT_FCNTL_SIG int fd, int cmd, int flags
|
||||||
|
#define ZT_IOCTL_SIG int fd, unsigned long request, void *argp
|
||||||
|
#define ZT_SYSCALL_SIG long number, ...
|
||||||
|
|
||||||
|
#endif // _H
|
||||||
|
|||||||
@@ -38,19 +38,17 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Used to perform a common action upon a failure in the VirtualSocket/VirtualTap layer.
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage For internal use only.
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void handle_general_failure();
|
void handle_general_failure();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Returns the thread-id. Used in debug traces.
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage For internal use only.
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
inline unsigned int gettid();
|
inline unsigned int gettid();
|
||||||
@@ -59,4 +57,4 @@ inline unsigned int gettid();
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif // _H
|
||||||
|
|||||||
@@ -39,9 +39,7 @@
|
|||||||
* @brief Returns masked address for subnet comparisons
|
* @brief Returns masked address for subnet comparisons
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage For internal use only.
|
||||||
*
|
* @param socket_type
|
||||||
* @param
|
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr);
|
bool ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr);
|
||||||
@@ -50,9 +48,7 @@ bool ipv6_in_subnet(ZeroTier::InetAddress *subnet, ZeroTier::InetAddress *addr);
|
|||||||
* @brief Convert protocol numbers to human-readable strings
|
* @brief Convert protocol numbers to human-readable strings
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage For internal use only.
|
||||||
*
|
* @param proto
|
||||||
* @param
|
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
char *beautify_eth_proto_nums(int proto);
|
char *beautify_eth_proto_nums(int proto);
|
||||||
@@ -61,9 +57,9 @@ char *beautify_eth_proto_nums(int proto);
|
|||||||
* @brief Convert a struct sockaddr to a ZeroTier::InetAddress
|
* @brief Convert a struct sockaddr to a ZeroTier::InetAddress
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage For internal use only.
|
||||||
*
|
* @param socket_family
|
||||||
* @param
|
* @param addr
|
||||||
*
|
* @param inet
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::InetAddress *inet);
|
void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::InetAddress *inet);
|
||||||
@@ -72,9 +68,9 @@ void sockaddr2inet(int socket_family, const struct sockaddr *addr, ZeroTier::Ine
|
|||||||
* @brief Convert a raw MAC address byte array into a human-readable string
|
* @brief Convert a raw MAC address byte array into a human-readable string
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage For internal use only.
|
||||||
*
|
* @param macbuf
|
||||||
* @param
|
* @param len
|
||||||
*
|
* @param addr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void mac2str(char *macbuf, int len, unsigned char* addr);
|
void mac2str(char *macbuf, int len, unsigned char* addr);
|
||||||
@@ -87,4 +83,4 @@ void mac2str(char *macbuf, int len, unsigned char* addr);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // UTILITIES_HPP
|
#endif // _H
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
#ifndef LIBZT_VIRTUALBINDINGPAIR_H
|
#ifndef LIBZT_VIRTUALBINDINGPAIR_H
|
||||||
#define LIBZT_VIRTUALBINDINGPAIR_H
|
#define LIBZT_VIRTUALBINDINGPAIR_H
|
||||||
|
|
||||||
@@ -44,5 +43,4 @@ struct VirtualBindingPair;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif // _H
|
||||||
*/
|
|
||||||
|
|||||||
@@ -48,4 +48,4 @@ class VirtualSocket;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif // _H
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ int zts_get_device_id_from_file(const char *filepath, char *devID);
|
|||||||
void *zts_start_service(void *thread_id);
|
void *zts_start_service(void *thread_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Stops all VirtualTap interfaces and associated I/O loops
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage For internal use only.
|
||||||
* @param
|
* @param
|
||||||
@@ -157,64 +157,51 @@ void zts_get_6plane_addr(char *addr, const char *nwid, const char *devID);
|
|||||||
void zts_get_rfc4193_addr(char *addr, const char *nwid, const char *devID);
|
void zts_get_rfc4193_addr(char *addr, const char *nwid, const char *devID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Join a network
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this from application thread. Only after zts_start() has succeeded
|
||||||
* @param
|
* @param nwid A 16-digit hexidecimal virtual network ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_join(const char * nwid);
|
void zts_join(const char * nwid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Leave a network
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage Call this from application thread. Only after zts_start() has succeeded
|
||||||
* @param
|
* @param nwid A 16-digit hexidecimal virtual network ID
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void zts_join_soft(const char * filepath, const char * nwid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @usage
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_leave(const char * nwid);
|
void zts_leave(const char * nwid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Return whether libzt (specifically the ZeroTier core service) is currently running
|
||||||
*
|
*
|
||||||
* @usage For internal use only.
|
* @usage Call this before, during, or after zts_start()
|
||||||
* @param
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void zts_leave_soft(const char * filepath, const char * nwid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @usage
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_running();
|
int zts_running();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Start an instance of libzt (ZeroTier core service, network stack drivers, network stack threads, etc)
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this when you anticipate needing to communicate over ZeroTier virtual networks. It is recommended
|
||||||
* @param
|
* that one call this at the beginning of your application code since it may take several seconds to fully
|
||||||
|
* come online.
|
||||||
|
* @param path Where this instance of ZeroTier will store its identity and configuration files
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_start(const char *path);
|
void zts_start(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Alternative to zts_start(). Start an instance of libzt, wait for an address to be issues, and join
|
||||||
|
* given network
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this when you anticipate needing to communicate over ZeroTier virtual networks. It is recommended
|
||||||
* @param
|
* that one call this at the beginning of your application code since it may take several seconds to fully
|
||||||
|
* come online.
|
||||||
|
* @param path
|
||||||
|
* @param nwid A 16-digit hexidecimal virtual network ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_simple_start(const char *path, const char *nwid);
|
void zts_simple_start(const char *path, const char *nwid);
|
||||||
@@ -237,110 +224,81 @@ void zts_stop();
|
|||||||
*/void zts_get_homepath(char *homePath, int len);
|
*/void zts_get_homepath(char *homePath, int len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Copies the hexidecimal representation of this nodeID into the provided buffer
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() and/or when zts_running() returns true
|
||||||
* @param
|
* @param devID Buffer to which id string is copied
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void zts_core_version(char *ver);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @usage
|
|
||||||
* @param
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void zts_lib_version(char *ver);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @usage
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_get_device_id(char *devID);
|
int zts_get_device_id(char *devID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Return the number of peers
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
unsigned long zts_get_peer_count();
|
unsigned long zts_get_peer_count();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Get the virtual address of a perr given it's ztAddress/nodeID
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_get_peer_address(char *peer, const char *devID);
|
int zts_get_peer_address(char *peer, const char *devID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Allow or disallow this instance of libzt to be controlled via HTTP requests
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param allowed True or false value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_enable_http_control_plane();
|
void zts_allow_http_control(bool allowed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Returns whether one can add a new socket or not. This depends on network stack in use.
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void zts_disable_http_control_plane();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Whether we can add a new socket or not. Depends on stack in use
|
|
||||||
*
|
|
||||||
* @usage
|
|
||||||
* @param socket_type
|
* @param socket_type
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool can_provision_new_socket(int socket_type);
|
bool can_provision_new_socket(int socket_type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the number of sockets either already provisioned or waiting to be
|
* @brief Returns the number of VirtualSockets either already provisioned or waiting to be
|
||||||
* Some network stacks may have a limit on the number of sockets that they can
|
* Some network stacks may have a limit on the number of sockets that they can
|
||||||
* safely handle due to timer construction, this is a way to check that we
|
* safely handle due to timer construction, this is a way to check that we
|
||||||
* haven't passed that limit. Someday if multiple stacks are used simultaneously
|
* haven't passed that limit. Someday if multiple stacks are used simultaneously
|
||||||
* the logic for this function should change accordingly.
|
* the logic for this function should change accordingly.
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_num_active_virt_sockets();
|
int zts_num_active_virt_sockets();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns maximum number of sockets allowed by network stack
|
* @brief Return the maximum number of sockets allowable by platform/stack configuration
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param socket_type
|
* @param socket_type
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_maxsockets(int socket_type);
|
int zts_maxsockets(int socket_type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Return the number of currently active picoTCP timers
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int pico_ntimers();
|
int pico_ntimers();
|
||||||
|
|
||||||
#endif // ZT1SERVICE_H
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // _H
|
||||||
|
|||||||
379
include/libzt.h
379
include/libzt.h
@@ -42,40 +42,7 @@
|
|||||||
#include "Defs.h"
|
#include "Defs.h"
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* Socket API Signatures */
|
/* ZeroTier Service Controls */
|
||||||
/****************************************************************************/
|
|
||||||
|
|
||||||
#define ZT_SETSOCKOPT_SIG int fd, int level, int optname, const void *optval, socklen_t optlen
|
|
||||||
#define ZT_GETSOCKOPT_SIG int fd, int level, int optname, void *optval, socklen_t *optlen
|
|
||||||
#define ZT_SENDMSG_SIG int fd, const struct msghdr *msg, int flags
|
|
||||||
#define ZT_SENDTO_SIG int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen
|
|
||||||
#define ZT_RECV_SIG int fd, void *buf, size_t len, int flags
|
|
||||||
#define ZT_RECVFROM_SIG int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen
|
|
||||||
#define ZT_RECVMSG_SIG int fd, struct msghdr *msg,int flags
|
|
||||||
#define ZT_SEND_SIG int fd, const void *buf, size_t len, int flags
|
|
||||||
#define ZT_READ_SIG int fd, void *buf, size_t len
|
|
||||||
#define ZT_WRITE_SIG int fd, const void *buf, size_t len
|
|
||||||
#define ZT_SHUTDOWN_SIG int fd, int how
|
|
||||||
#define ZT_SOCKET_SIG int socket_family, int socket_type, int protocol
|
|
||||||
#define ZT_CONNECT_SIG int fd, const struct sockaddr *addr, socklen_t addrlen
|
|
||||||
#define ZT_BIND_SIG int fd, const struct sockaddr *addr, socklen_t addrlen
|
|
||||||
#define ZT_LISTEN_SIG int fd, int backlog
|
|
||||||
#define ZT_ACCEPT4_SIG int fd, struct sockaddr *addr, socklen_t *addrlen, int flags
|
|
||||||
#define ZT_ACCEPT_SIG int fd, struct sockaddr *addr, socklen_t *addrlen
|
|
||||||
#define ZT_CLOSE_SIG int fd
|
|
||||||
#define ZT_POLL_SIG struct pollfd *fds, nfds_t nfds, int timeout
|
|
||||||
#define ZT_SELECT_SIG int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout
|
|
||||||
#define ZT_GETSOCKNAME_SIG int fd, struct sockaddr *addr, socklen_t *addrlen
|
|
||||||
#define ZT_GETPEERNAME_SIG int fd, struct sockaddr *addr, socklen_t *addrlen
|
|
||||||
#define ZT_GETHOSTNAME_SIG char *name, size_t len
|
|
||||||
#define ZT_SETHOSTNAME_SIG const char *name, size_t len
|
|
||||||
#define ZT_FCNTL_SIG int fd, int cmd, int flags
|
|
||||||
#define ZT_IOCTL_SIG int fd, unsigned long request, void *argp
|
|
||||||
#define ZT_SYSCALL_SIG long number, ...
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************/
|
|
||||||
/* SDK Socket API (ZeroTier Service Controls) */
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -88,32 +55,32 @@ int zts_get_device_id(char *devID);
|
|||||||
|
|
||||||
void init_network_stack();
|
void init_network_stack();
|
||||||
|
|
||||||
/** \brief Start core ZeroTier service (generates cryptographic identity).
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* ...
|
|
||||||
* Errno values:
|
|
||||||
* ~~~
|
|
||||||
* Value | Meaning
|
|
||||||
* ------ | ----------------
|
|
||||||
* EINVAL | Invalid argument
|
|
||||||
* ~~~
|
|
||||||
*/
|
|
||||||
void zts_start(const char *path);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Should be called at the beginning of your application
|
* @brief Starts libzt
|
||||||
*
|
*
|
||||||
* @usage Blocks until all of the following conditions are met:
|
* @usage Should be called at the beginning of your application. Will blocks until all of the following conditions are met:
|
||||||
* - ZeroTier core service has been initialized
|
* - ZeroTier core service has been initialized
|
||||||
* - Cryptographic identity has been generated or loaded from directory specified by `path`
|
* - Cryptographic identity has been generated or loaded from directory specified by `path`
|
||||||
* - Virtual network is successfully joined
|
* - Virtual network is successfully joined
|
||||||
* - IP address is assigned by network controller service
|
* - IP address is assigned by network controller service
|
||||||
*
|
* @param path path directory where cryptographic identities and network configuration files are stored and retrieved
|
||||||
* @param path directory where cryptographic identities and network configuration files are stored and retrieved
|
|
||||||
* (`identity.public`, `identity.secret`)
|
* (`identity.public`, `identity.secret`)
|
||||||
* @param nwid the 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`)
|
* @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`)
|
||||||
|
* @return 0 if successful; or 1 if failed
|
||||||
|
*/
|
||||||
|
void zts_start(const char *path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Starts libzt
|
||||||
*
|
*
|
||||||
|
* @usage Should be called at the beginning of your application. Will blocks until all of the following conditions are met:
|
||||||
|
* - ZeroTier core service has been initialized
|
||||||
|
* - Cryptographic identity has been generated or loaded from directory specified by `path`
|
||||||
|
* - Virtual network is successfully joined
|
||||||
|
* - IP address is assigned by network controller service
|
||||||
|
* @param path path directory where cryptographic identities and network configuration files are stored and retrieved
|
||||||
|
* (`identity.public`, `identity.secret`)
|
||||||
|
* @param nwid A 16-digit hexidecimal network identifier (e.g. Earth: `8056c2e21c000001`)
|
||||||
* @return 0 if successful; or 1 if failed
|
* @return 0 if successful; or 1 if failed
|
||||||
*/
|
*/
|
||||||
void zts_simple_start(const char *path, const char *nwid);
|
void zts_simple_start(const char *path, const char *nwid);
|
||||||
@@ -166,7 +133,7 @@ void zts_leave(const char * nwid);
|
|||||||
void zts_leave_soft(const char * filepath, const char * nwid);
|
void zts_leave_soft(const char * filepath, const char * nwid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return the home path for this instance of ZeroTier
|
* @brief Returns path used by ZeroTier/libzt for storing identity and config files
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* @param homePath
|
* @param homePath
|
||||||
@@ -175,24 +142,6 @@ void zts_leave_soft(const char * filepath, const char * nwid);
|
|||||||
*/
|
*/
|
||||||
void zts_get_homepath(char *homePath, const int len);
|
void zts_get_homepath(char *homePath, const int len);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @usage Copies ZeroTier core version string into `ver`
|
|
||||||
* @param ver
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void zts_core_version(char *ver);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Copies libzt version string into `ver`
|
|
||||||
*
|
|
||||||
* @usage
|
|
||||||
* @param ver
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
void zts_lib_version(char *ver);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get device ID (10-digit hex + NULL byte)
|
* @brief Get device ID (10-digit hex + NULL byte)
|
||||||
*
|
*
|
||||||
@@ -252,11 +201,9 @@ void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
|
|||||||
* @brief Get IPV6 Address for this device on a given network
|
* @brief Get IPV6 Address for this device on a given network
|
||||||
*
|
*
|
||||||
* @usage FIXME: Only returns first address found for given protocol and network (should be enough for now)
|
* @usage FIXME: Only returns first address found for given protocol and network (should be enough for now)
|
||||||
* @param
|
* @param nwid
|
||||||
* @param
|
* @param addrstr
|
||||||
* @param
|
* @param addrlen
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen);
|
void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen);
|
||||||
@@ -265,11 +212,9 @@ void zts_get_ipv6_address(const char *nwid, char *addrstr, const int addrlen);
|
|||||||
* @brief Returns a 6PLANE IPv6 address given a network ID and zerotier ID
|
* @brief Returns a 6PLANE IPv6 address given a network ID and zerotier ID
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* @param
|
* @param addr
|
||||||
* @param
|
* @param nwid
|
||||||
* @param
|
* @param devID
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_get_6plane_addr(char *addr, const char *nwid, const char *devID);
|
void zts_get_6plane_addr(char *addr, const char *nwid, const char *devID);
|
||||||
@@ -278,11 +223,9 @@ void zts_get_6plane_addr(char *addr, const char *nwid, const char *devID);
|
|||||||
* @brief Returns an RFC 4193 IPv6 address given a network ID and zerotier ID
|
* @brief Returns an RFC 4193 IPv6 address given a network ID and zerotier ID
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* @param
|
* @param addr
|
||||||
* @param
|
* @param nwid
|
||||||
* @param
|
* @param devID
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_get_rfc4193_addr(char *addr, const char *nwid, const char *devID);
|
void zts_get_rfc4193_addr(char *addr, const char *nwid, const char *devID);
|
||||||
@@ -291,11 +234,6 @@ void zts_get_rfc4193_addr(char *addr, const char *nwid, const char *devID);
|
|||||||
* @brief Return the number of peers on this network
|
* @brief Return the number of peers on this network
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
unsigned long zts_get_peer_count();
|
unsigned long zts_get_peer_count();
|
||||||
@@ -306,9 +244,6 @@ unsigned long zts_get_peer_count();
|
|||||||
* @usage
|
* @usage
|
||||||
* @param peer
|
* @param peer
|
||||||
* @param devID
|
* @param devID
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_get_peer_address(char *peer, const char *devID);
|
int zts_get_peer_address(char *peer, const char *devID);
|
||||||
@@ -319,11 +254,6 @@ int zts_get_peer_address(char *peer, const char *devID);
|
|||||||
* FIXME: Implement
|
* FIXME: Implement
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_enable_http_control_plane();
|
void zts_enable_http_control_plane();
|
||||||
@@ -334,30 +264,26 @@ void zts_enable_http_control_plane();
|
|||||||
* FIXME: Implement
|
* FIXME: Implement
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void zts_disable_http_control_plane();
|
void zts_disable_http_control_plane();
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* SDK Socket API (Socket User Controls) */
|
/* POSIX-like socket API */
|
||||||
/* - These functions are designed to work just like ordinary socket calls */
|
|
||||||
/* but are provisioned and handled by ZeroTier */
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create a socket
|
* @brief Create a socket
|
||||||
*
|
*
|
||||||
* @usage
|
* This function will return an integer which can be used in much the same way as a
|
||||||
* @param
|
* typical file descriptor, however it is only valid for use with libzt library calls
|
||||||
* @param
|
* as this is merely a facade which is associated with the internal socket representation
|
||||||
* @param
|
* of both the network stacks and drivers.
|
||||||
* @param
|
*
|
||||||
* @param
|
* @usage Call this after zts_start() has succeeded
|
||||||
|
* @param socket_family Address family (AF_INET, AF_INET6)
|
||||||
|
* @param socket_type Type of socket (SOCK_STREAM, SOCK_DGRAM, SOCK_RAW)
|
||||||
|
* @param protocol Protocols supported on this socket
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_socket(int socket_family, int socket_type, int protocol);
|
int zts_socket(int socket_family, int socket_type, int protocol);
|
||||||
@@ -365,64 +291,54 @@ int zts_socket(int socket_family, int socket_type, int protocol);
|
|||||||
/**
|
/**
|
||||||
* @brief Connect a socket to a remote host
|
* @brief Connect a socket to a remote host
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param addr Remote host address to connect to
|
||||||
* @param
|
* @param addrlen Length of address
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_connect(int fd, const struct sockaddr *addr, socklen_t addrlen);
|
int zts_connect(int fd, const struct sockaddr *addr, socklen_t addrlen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Bind a socket to a virtual interface
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param addr Local interface address to bind to
|
||||||
* @param
|
* @param addrlen Length of address
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
|
int zts_bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Listen for incoming VirtualSockets
|
* @brief Listen for incoming connections
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param backlog Number of backlogged connection allowed
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_listen(int fd, int backlog);
|
int zts_listen(int fd, int backlog);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Accept a VirtualSocket
|
* @brief Accept an incoming connection
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param addr Address of remote host for accepted connection
|
||||||
* @param
|
* @param addrlen Length of address
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_accept(int fd, struct sockaddr *addr, socklen_t *addrlen);
|
int zts_accept(int fd, struct sockaddr *addr, socklen_t *addrlen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Accept a VirtualSocket
|
* @brief Accept an incoming connection
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param addr Address of remote host for accepted connection
|
||||||
* @param
|
* @param addrlen Length of address
|
||||||
* @param
|
* @param flags
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
@@ -432,12 +348,12 @@ int zts_accept(int fd, struct sockaddr *addr, socklen_t *addrlen);
|
|||||||
/**
|
/**
|
||||||
* @brief Set socket options
|
* @brief Set socket options
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param level Protocol level to which option name should apply
|
||||||
* @param
|
* @param optname Option name to set
|
||||||
* @param
|
* @param optval Source of option value to set
|
||||||
* @param
|
* @param optlen Length of option value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen);
|
int zts_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen);
|
||||||
@@ -445,12 +361,12 @@ int zts_setsockopt(int fd, int level, int optname, const void *optval, socklen_t
|
|||||||
/**
|
/**
|
||||||
* @brief Get socket options
|
* @brief Get socket options
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param level Protocol level to which option name should apply
|
||||||
* @param
|
* @param optname Option name to get
|
||||||
* @param
|
* @param optval Where option value will be stored
|
||||||
* @param
|
* @param optlen Length of value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen);
|
int zts_getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen);
|
||||||
@@ -458,25 +374,21 @@ int zts_getsockopt(int fd, int level, int optname, void *optval, socklen_t *optl
|
|||||||
/**
|
/**
|
||||||
* @brief Get socket name
|
* @brief Get socket name
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param addr Name associated with this socket
|
||||||
* @param
|
* @param addrlen Length of name
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_getsockname(int fd, struct sockaddr *addr, socklen_t *addrlen);
|
int zts_getsockname(int fd, struct sockaddr *addr, socklen_t *addrlen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a peer name
|
* @brief Get the peer name for the remote end of a connected socket
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param
|
* @param addr Name associated with remote end of this socket
|
||||||
* @param
|
* @param addrlen Length of name
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_getpeername(int fd, struct sockaddr *addr, socklen_t *addrlen);
|
int zts_getpeername(int fd, struct sockaddr *addr, socklen_t *addrlen);
|
||||||
@@ -484,12 +396,9 @@ int zts_getpeername(int fd, struct sockaddr *addr, socklen_t *addrlen);
|
|||||||
/**
|
/**
|
||||||
* @brief Gets current hostname
|
* @brief Gets current hostname
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param name
|
||||||
* @param
|
* @param len
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_gethostname(char *name, size_t len);
|
int zts_gethostname(char *name, size_t len);
|
||||||
@@ -497,29 +406,26 @@ int zts_gethostname(char *name, size_t len);
|
|||||||
/**
|
/**
|
||||||
* @brief Sets current hostname
|
* @brief Sets current hostname
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param
|
* @param name
|
||||||
* @param
|
* @param len
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_sethostname(const char *name, size_t len);
|
int zts_sethostname(const char *name, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief close a socket
|
* @brief Close a socket
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_close(int fd);
|
int zts_close(int fd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief waits for one of a set of file descriptors to become ready to perform I/O.
|
* @brief Waits for one of a set of file descriptors to become ready to perform I/O.
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fds
|
* @param fds
|
||||||
* @param nfds
|
* @param nfds
|
||||||
* @param timeout
|
* @param timeout
|
||||||
@@ -528,9 +434,9 @@ int zts_close(int fd);
|
|||||||
int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
int zts_poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready"
|
* @brief Monitor multiple file descriptors, waiting until one or more of the file descriptors become "ready"
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param nfds
|
* @param nfds
|
||||||
* @param readfds
|
* @param readfds
|
||||||
* @param writefds
|
* @param writefds
|
||||||
@@ -543,8 +449,8 @@ int zts_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, s
|
|||||||
/**
|
/**
|
||||||
* @brief Issue file control commands on a socket
|
* @brief Issue file control commands on a socket
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param cmd
|
* @param cmd
|
||||||
* @param flags
|
* @param flags
|
||||||
* @return
|
* @return
|
||||||
@@ -554,8 +460,8 @@ int zts_fcntl(int fd, int cmd, int flags);
|
|||||||
/**
|
/**
|
||||||
* @brief Control a device
|
* @brief Control a device
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param request
|
* @param request
|
||||||
* @param argp
|
* @param argp
|
||||||
* @return
|
* @return
|
||||||
@@ -565,10 +471,10 @@ int zts_ioctl(int fd, unsigned long request, void *argp);
|
|||||||
/**
|
/**
|
||||||
* @brief Send data to remote host
|
* @brief Send data to remote host
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param buf
|
* @param buf Pointer to data buffer
|
||||||
* @param len
|
* @param len Length of data to write
|
||||||
* @param flags
|
* @param flags
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -577,13 +483,13 @@ ssize_t zts_send(int fd, const void *buf, size_t len, int flags);
|
|||||||
/**
|
/**
|
||||||
* @brief Send data to remote host
|
* @brief Send data to remote host
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param buf
|
* @param buf Pointer to data buffer
|
||||||
* @param len
|
* @param len Length of data to write
|
||||||
* @param flags
|
* @param flags
|
||||||
* @param addr
|
* @param addr Destination address
|
||||||
* @param addrlen
|
* @param addrlen Length of destination address
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ssize_t zts_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen);
|
ssize_t zts_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t addrlen);
|
||||||
@@ -591,8 +497,8 @@ ssize_t zts_sendto(int fd, const void *buf, size_t len, int flags, const struct
|
|||||||
/**
|
/**
|
||||||
* @brief Send message to remote host
|
* @brief Send message to remote host
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param msg
|
* @param msg
|
||||||
* @param flags
|
* @param flags
|
||||||
* @return
|
* @return
|
||||||
@@ -602,12 +508,11 @@ ssize_t zts_sendmsg(int fd, const struct msghdr *msg, int flags);
|
|||||||
/**
|
/**
|
||||||
* @brief Receive data from remote host
|
* @brief Receive data from remote host
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param buf
|
* @param buf Pointer to data buffer
|
||||||
* @param len
|
* @param len Length of data buffer
|
||||||
* @param flags
|
* @param flags
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ssize_t zts_recv(int fd, void *buf, size_t len, int flags);
|
ssize_t zts_recv(int fd, void *buf, size_t len, int flags);
|
||||||
@@ -615,10 +520,10 @@ ssize_t zts_recv(int fd, void *buf, size_t len, int flags);
|
|||||||
/**
|
/**
|
||||||
* @brief Receive data from remote host
|
* @brief Receive data from remote host
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param buf
|
* @param buf Pointer to data buffer
|
||||||
* @param len
|
* @param len Length of data buffer
|
||||||
* @param flags
|
* @param flags
|
||||||
* @param addr
|
* @param addr
|
||||||
* @param addrlen
|
* @param addrlen
|
||||||
@@ -629,8 +534,8 @@ ssize_t zts_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *
|
|||||||
/**
|
/**
|
||||||
* @brief Receive a message from remote host
|
* @brief Receive a message from remote host
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param msg
|
* @param msg
|
||||||
* @param flags
|
* @param flags
|
||||||
* @return
|
* @return
|
||||||
@@ -640,12 +545,10 @@ ssize_t zts_recvmsg(int fd, struct msghdr *msg,int flags);
|
|||||||
/**
|
/**
|
||||||
* @brief Read bytes from socket onto buffer
|
* @brief Read bytes from socket onto buffer
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param buf
|
* @param buf Pointer to data buffer
|
||||||
* @param len
|
* @param len Length of data buffer to receive data
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_read(int fd, void *buf, size_t len);
|
int zts_read(int fd, void *buf, size_t len);
|
||||||
@@ -653,22 +556,20 @@ int zts_read(int fd, void *buf, size_t len);
|
|||||||
/**
|
/**
|
||||||
* @brief Write bytes from buffer to socket
|
* @brief Write bytes from buffer to socket
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param buf
|
* @param buf Pointer to data buffer
|
||||||
* @param len
|
* @param len Length of buffer to write
|
||||||
* @param
|
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_write(int fd, const void *buf, size_t len);
|
int zts_write(int fd, const void *buf, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief Shut down some aspect of a socket (read, write, or both)
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param fd
|
* @param fd File descriptor (only valid for use with libzt calls)
|
||||||
* @param how
|
* @param how Which aspects of the socket should be shut down
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_shutdown(int fd, int how);
|
int zts_shutdown(int fd, int how);
|
||||||
@@ -676,8 +577,8 @@ int zts_shutdown(int fd, int how);
|
|||||||
/**
|
/**
|
||||||
* @brief Adds a DNS nameserver for the network stack to use
|
* @brief Adds a DNS nameserver for the network stack to use
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param addr
|
* @param addr Address for DNS nameserver
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_add_dns_nameserver(struct sockaddr *addr);
|
int zts_add_dns_nameserver(struct sockaddr *addr);
|
||||||
@@ -685,8 +586,8 @@ int zts_add_dns_nameserver(struct sockaddr *addr);
|
|||||||
/**
|
/**
|
||||||
* @brief Removes a DNS nameserver
|
* @brief Removes a DNS nameserver
|
||||||
*
|
*
|
||||||
* @usage
|
* @usage Call this after zts_start() has succeeded
|
||||||
* @param addr
|
* @param addr Address for DNS nameserver
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int zts_del_dns_nameserver(struct sockaddr *addr);
|
int zts_del_dns_nameserver(struct sockaddr *addr);
|
||||||
@@ -695,4 +596,4 @@ int zts_del_dns_nameserver(struct sockaddr *addr);
|
|||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // ZT_ZEROTIERSDK_H
|
#endif // _H
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
/**
|
/**
|
||||||
* @brief Initialize network stack semaphores, threads, and timers.
|
* @brief Initialize network stack semaphores, threads, and timers.
|
||||||
*
|
*
|
||||||
* @param
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void lwip_driver_init();
|
void lwip_driver_init();
|
||||||
@@ -49,6 +48,9 @@ void lwip_driver_init();
|
|||||||
* @brief Set up an interface in the network stack for the VirtualTap.
|
* @brief Set up an interface in the network stack for the VirtualTap.
|
||||||
*
|
*
|
||||||
* @param
|
* @param
|
||||||
|
* @param tapref Reference to VirtualTap that will be responsible for sending and receiving data
|
||||||
|
* @param mac Virtual hardware address for this ZeroTier VirtualTap interface
|
||||||
|
* @param ip Virtual IP address for this ZeroTier VirtualTap interface
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void lwip_init_interface(void *tapref, const ZeroTier::MAC &mac, const ZeroTier::InetAddress &ip);
|
void lwip_init_interface(void *tapref, const ZeroTier::MAC &mac, const ZeroTier::InetAddress &ip);
|
||||||
@@ -56,15 +58,23 @@ void lwip_init_interface(void *tapref, const ZeroTier::MAC &mac, const ZeroTier:
|
|||||||
/**
|
/**
|
||||||
* @brief Called from the stack, outbound ethernet frames from the network stack enter the ZeroTier virtual wire here.
|
* @brief Called from the stack, outbound ethernet frames from the network stack enter the ZeroTier virtual wire here.
|
||||||
*
|
*
|
||||||
* @param
|
* @usage This shall only be called from the stack or the stack driver. Not the application thread.
|
||||||
|
* @param netif Transmits an outgoing Ethernet fram from the network stack onto the ZeroTier virtual wire
|
||||||
|
* @param p A pointer to the beginning of a chain pf struct pbufs
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
err_t lwip_eth_tx(struct netif *netif, struct pbuf *p);
|
err_t lwip_eth_tx(struct netif *netif, struct pbuf *p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Packets from the ZeroTier virtual wire enter the stack here.
|
* @brief Receives incoming Ethernet frames from the ZeroTier virtual wire
|
||||||
*
|
*
|
||||||
* @param
|
* @usage This shall be called from the VirtualTap's I/O thread (via VirtualTap::put())
|
||||||
|
* @param tap Pointer to VirtualTap from which this data comes
|
||||||
|
* @param from Origin address (virtual ZeroTier hardware address)
|
||||||
|
* @param to Intended destination address (virtual ZeroTier hardware address)
|
||||||
|
* @param etherType Protocol type
|
||||||
|
* @param data Pointer to Ethernet frame
|
||||||
|
* @param len Length of Ethernet frame
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
void lwip_eth_rx(ZeroTier::VirtualTap *tap, const ZeroTier::MAC &from, const ZeroTier::MAC &to, unsigned int etherType,
|
void lwip_eth_rx(ZeroTier::VirtualTap *tap, const ZeroTier::MAC &from, const ZeroTier::MAC &to, unsigned int etherType,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ UNIXLIB=liblwip.a
|
|||||||
all: $(UNIXLIB)
|
all: $(UNIXLIB)
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
|
|
||||||
include ext/lwip/src/Filelists.mk
|
include $(LWIPDIR)/Filelists.mk
|
||||||
|
|
||||||
# ARCHFILES: Architecture specific files.
|
# ARCHFILES: Architecture specific files.
|
||||||
ARCHFILES=$(wildcard $(LWIPARCH)/port/*.c $(LWIPARCH)/*.c $(LWIPARCH)tapif.c $(LWIPARCH)/netif/list.c $(LWIPARCH)/netif/tcpdump.c)
|
ARCHFILES=$(wildcard $(LWIPARCH)/port/*.c $(LWIPARCH)/*.c $(LWIPARCH)tapif.c $(LWIPARCH)/netif/list.c $(LWIPARCH)/netif/tcpdump.c)
|
||||||
@@ -76,7 +76,7 @@ depend dep: .depend
|
|||||||
include .depend
|
include .depend
|
||||||
|
|
||||||
$(UNIXLIB): $(LWIPNOAPPSOBJS)
|
$(UNIXLIB): $(LWIPNOAPPSOBJS)
|
||||||
$(CCX) $(CFLAGS) -g -nostartfiles -shared -o $@ $^
|
$(CCX) $(CFLAGS) -g -nostartfiles -shared -o obj/$@ $^
|
||||||
|
|
||||||
.depend: $(LWIPNOAPPSFILES)
|
.depend: $(LWIPNOAPPSFILES)
|
||||||
$(CCX) $(CFLAGS) -MM $^ > .depend || rm -f .depend
|
$(CCX) $(CFLAGS) -MM $^ > .depend || rm -f .depend
|
||||||
@@ -190,7 +190,7 @@ namespace ZeroTier {
|
|||||||
std::string VirtualTap::nodeId() const
|
std::string VirtualTap::nodeId() const
|
||||||
{
|
{
|
||||||
if (zt1ServiceRef) {
|
if (zt1ServiceRef) {
|
||||||
char id[ZT_ID_LEN];
|
char id[ZTO_ID_LEN];
|
||||||
memset(id, 0, sizeof(id));
|
memset(id, 0, sizeof(id));
|
||||||
sprintf(id, "%lx",((ZeroTier::OneService *)zt1ServiceRef)->getNode()->address());
|
sprintf(id, "%lx",((ZeroTier::OneService *)zt1ServiceRef)->getNode()->address());
|
||||||
return std::string(id);
|
return std::string(id);
|
||||||
|
|||||||
@@ -286,4 +286,4 @@ namespace ZeroTier {
|
|||||||
|
|
||||||
} // namespace ZeroTier
|
} // namespace ZeroTier
|
||||||
|
|
||||||
#endif
|
#endif // _H
|
||||||
|
|||||||
@@ -439,16 +439,6 @@ void zts_get_homepath(char *homePath, int len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void zts_core_version(char *ver) {
|
|
||||||
int major, minor, revision;
|
|
||||||
ZT_version(&major, &minor, &revision);
|
|
||||||
sprintf(ver, "%d.%d.%d", major, minor, revision);
|
|
||||||
}
|
|
||||||
|
|
||||||
void zts_lib_version(char *ver) {
|
|
||||||
//sprintf(ver, "%d.%d.%d", ZT_LIB_VERSION_MAJOR, ZT_LIB_VERSION_MINOR, ZT_LIB_VERSION_REVISION);
|
|
||||||
}
|
|
||||||
|
|
||||||
int zts_get_device_id(char *devID) {
|
int zts_get_device_id(char *devID) {
|
||||||
if (ZeroTier::zt1Service) {
|
if (ZeroTier::zt1Service) {
|
||||||
char id[ZTO_ID_LEN];
|
char id[ZTO_ID_LEN];
|
||||||
@@ -493,12 +483,7 @@ int zts_get_peer_address(char *peer, const char *devID) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zts_enable_http_control_plane()
|
void zts_allow_http_control(bool allowed)
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
void zts_disable_http_control_plane()
|
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ err_t lwip_eth_tx(struct netif *netif, struct pbuf *p)
|
|||||||
if (ZT_MSG_TRANSFER == true) {
|
if (ZT_MSG_TRANSFER == true) {
|
||||||
char flagbuf[32];
|
char flagbuf[32];
|
||||||
memset(&flagbuf, 0, 32);
|
memset(&flagbuf, 0, 32);
|
||||||
char macBuf[ZT_MAC_ADDRSTRLEN], nodeBuf[ZT_ID_LEN];
|
char macBuf[ZT_MAC_ADDRSTRLEN], nodeBuf[ZTO_ID_LEN];
|
||||||
mac2str(macBuf, ZT_MAC_ADDRSTRLEN, ethhdr->dest.addr);
|
mac2str(macBuf, ZT_MAC_ADDRSTRLEN, ethhdr->dest.addr);
|
||||||
ZeroTier::MAC mac;
|
ZeroTier::MAC mac;
|
||||||
mac.setTo(ethhdr->dest.addr, 6);
|
mac.setTo(ethhdr->dest.addr, 6);
|
||||||
@@ -225,7 +225,7 @@ void lwip_eth_rx(ZeroTier::VirtualTap *tap, const ZeroTier::MAC &from, const Zer
|
|||||||
if (ZT_MSG_TRANSFER == true) {
|
if (ZT_MSG_TRANSFER == true) {
|
||||||
char flagbuf[32];
|
char flagbuf[32];
|
||||||
memset(&flagbuf, 0, 32);
|
memset(&flagbuf, 0, 32);
|
||||||
char macBuf[ZT_MAC_ADDRSTRLEN], nodeBuf[ZT_ID_LEN];
|
char macBuf[ZT_MAC_ADDRSTRLEN], nodeBuf[ZTO_ID_LEN];
|
||||||
mac2str(macBuf, ZT_MAC_ADDRSTRLEN, ethhdr.dest.addr);
|
mac2str(macBuf, ZT_MAC_ADDRSTRLEN, ethhdr.dest.addr);
|
||||||
ZeroTier::MAC mac;
|
ZeroTier::MAC mac;
|
||||||
mac.setTo(ethhdr.src.addr, 6);
|
mac.setTo(ethhdr.src.addr, 6);
|
||||||
|
|||||||
@@ -2448,7 +2448,7 @@ int main(int argc , char *argv[])
|
|||||||
|
|
||||||
DEBUG_TEST("Waiting for libzt to come online...\n");
|
DEBUG_TEST("Waiting for libzt to come online...\n");
|
||||||
zts_simple_start(path.c_str(), nwid.c_str());
|
zts_simple_start(path.c_str(), nwid.c_str());
|
||||||
char device_id[ZT_ID_LEN];
|
char device_id[ZTO_ID_LEN];
|
||||||
zts_get_device_id(device_id);
|
zts_get_device_id(device_id);
|
||||||
DEBUG_TEST("I am %s, %s", device_id, me.c_str());
|
DEBUG_TEST("I am %s, %s", device_id, me.c_str());
|
||||||
if (mode == TEST_MODE_SERVER) {
|
if (mode == TEST_MODE_SERVER) {
|
||||||
|
|||||||
Reference in New Issue
Block a user