Added comment syntax for doxygen, fixed build flag which produced unnecessarily-large binaries, removed trailing whitespace

This commit is contained in:
Joseph Henry
2017-09-27 13:42:27 -07:00
parent 5f1e9fe795
commit 1afb2308b6
22 changed files with 562 additions and 711 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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,72 +169,72 @@ 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
/** /**
* *
*/ */
#define ZT_LEN_SZ 4 #define ZT_LEN_SZ 4
/** /**
* *
*/ */
#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
@@ -241,12 +244,12 @@ typedef signed char err_t;
// applications. // applications.
/** /**
* *
*/ */
#define ZT_STACK_TCP_SOCKET_TX_SZ ZT_TCP_TX_BUF_SZ #define ZT_STACK_TCP_SOCKET_TX_SZ ZT_TCP_TX_BUF_SZ
/** /**
* *
*/ */
#define ZT_STACK_TCP_SOCKET_RX_SZ ZT_TCP_RX_BUF_SZ #define ZT_STACK_TCP_SOCKET_RX_SZ ZT_TCP_RX_BUF_SZ
@@ -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

View File

@@ -38,20 +38,18 @@ 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

View File

@@ -36,46 +36,42 @@
#include "InetAddress.hpp" #include "InetAddress.hpp"
/** /**
* @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);
/** /**
* @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);
/** /**
* @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);
/** /**
* @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

View File

@@ -27,10 +27,9 @@
/** /**
* @file * @file
* *
* *
*/ */
/*
#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
*/

View File

@@ -38,7 +38,7 @@ extern "C" {
#endif #endif
/** /**
* An abstraction of a socket that operates between the application-exposed platform-sockets * An abstraction of a socket that operates between the application-exposed platform-sockets
* and the network stack's representation of a protocol control structure. This object is used by * and the network stack's representation of a protocol control structure. This object is used by
* the POSIX socket emulation layer and stack drivers. * the POSIX socket emulation layer and stack drivers.
*/ */
@@ -48,4 +48,4 @@ class VirtualSocket;
} }
#endif #endif
#endif #endif // _H

View File

@@ -42,7 +42,7 @@
extern "C" { extern "C" {
#endif #endif
namespace ZeroTier namespace ZeroTier
{ {
extern std::vector<void*> vtaps; extern std::vector<void*> vtaps;
@@ -59,288 +59,246 @@ namespace ZeroTier
/** /**
* @brief Returns a vector of network routes { target, via, metric, etc... } * @brief Returns a vector of network routes { target, via, metric, etc... }
* *
* @usage * @usage
* @param nwid * @param nwid
* @return * @return
*/ */
std::vector<ZT_VirtualNetworkRoute> *zts_get_network_routes(char *nwid); std::vector<ZT_VirtualNetworkRoute> *zts_get_network_routes(char *nwid);
/** /**
* @brief * @brief
* *
* @usage For internal use only. * @usage For internal use only.
* @param * @param
* @return * @return
*/ */
int zts_get_device_id_from_file(const char *filepath, char *devID); int zts_get_device_id_from_file(const char *filepath, char *devID);
/** /**
* @brief Starts a ZeroTier service in the background * @brief Starts a ZeroTier service in the background
* *
* @usage For internal use only. * @usage For internal use only.
* @param * @param
* @return * @return
*/ */
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
* @return * @return
*/ */
void disableTaps(); void disableTaps();
/** /**
* @brief * @brief
* *
* @usage For internal use only. * @usage For internal use only.
* @param * @param
* @return * @return
*/ */
void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen); void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen);
/** /**
* @brief * @brief
* *
* @usage For internal use only. * @usage For internal use only.
* @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);
/** /**
* @brief * @brief
* *
* @usage For internal use only. * @usage For internal use only.
* @param * @param
* @return * @return
*/ */
int zts_has_ipv4_address(const char *nwid); int zts_has_ipv4_address(const char *nwid);
/** /**
* @brief * @brief
* *
* @usage For internal use only. * @usage For internal use only.
* @param * @param
* @return * @return
*/ */
int zts_has_ipv6_address(const char *nwid); int zts_has_ipv6_address(const char *nwid);
/** /**
* @brief * @brief
* *
* @usage For internal use only. * @usage For internal use only.
* @param * @param
* @return * @return
*/ */
int zts_has_address(const char *nwid); int zts_has_address(const char *nwid);
/** /**
* @brief * @brief
* *
* @usage * @usage
* @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);
/** /**
* @brief * @brief
* *
* @usage * @usage
* @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);
/** /**
* @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 * @return
*/ */
void zts_join_soft(const char * filepath, const char * nwid); void zts_leave(const char * nwid);
/** /**
* @brief * @brief Return whether libzt (specifically the ZeroTier core service) is currently running
* *
* @usage * @usage Call this before, during, or after zts_start()
* @param * @return
* @return
*/
void zts_leave(const char * nwid);
/**
* @brief
*
* @usage For internal use only.
* @param
* @return
*/
void zts_leave_soft(const char * filepath, const char * nwid);
/**
* @brief
*
* @usage
* @param
* @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
* @return * come online.
* @param path Where this instance of ZeroTier will store its identity and configuration files
* @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 *
* @param * @usage Call this when you anticipate needing to communicate over ZeroTier virtual networks. It is recommended
* @return * 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
*/ */
void zts_simple_start(const char *path, const char *nwid); void zts_simple_start(const char *path, const char *nwid);
/** /**
* @brief * @brief
* *
* @usage * @usage
* @param * @param
* @return * @return
*/ */
void zts_stop(); void zts_stop();
/** /**
* @brief * @brief
* *
* @usage * @usage
* @param * @param
* @return * @return
*/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 * @return
*/ */
void zts_core_version(char *ver); 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
*/
void zts_lib_version(char *ver);
/**
* @brief
*
* @usage
* @param
* @return
*/
int zts_get_device_id(char *devID);
/**
* @brief
*
* @usage
* @param
* @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

View File

@@ -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
@@ -84,232 +51,200 @@ extern "C" {
// forward declarations from ZT1Service.h // forward declarations from ZT1Service.h
void zts_simple_start(const char *path, const char *nwid); void zts_simple_start(const char *path, const char *nwid);
int zts_get_device_id(char *devID); int zts_get_device_id(char *devID);
void init_network_stack(); void init_network_stack();
/** \brief Start core ZeroTier service (generates cryptographic identity). /**
* * @brief Starts libzt
* *
* ... * @usage Should be called at the beginning of your application. Will blocks until all of the following conditions are met:
* Errno values: * - ZeroTier core service has been initialized
* ~~~ * - Cryptographic identity has been generated or loaded from directory specified by `path`
* Value | Meaning * - Virtual network is successfully joined
* ------ | ---------------- * - IP address is assigned by network controller service
* EINVAL | Invalid argument * @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
*/ */
void zts_start(const char *path); 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
* @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);
/** /**
* @brief Stops the ZeroTier core service and disconnects from all virtual networks * @brief Stops the ZeroTier core service and disconnects from all virtual networks
* *
* @usage Called at the end of your application. This call will block until everything is shut down * @usage Called at the end of your application. This call will block until everything is shut down
* @return * @return
*/ */
void zts_stop(); void zts_stop();
/** /**
* @brief Joins a virtual network * @brief Joins a virtual network
* *
* @usage Called after zts_start() or zts_simple_start() * @usage Called after zts_start() or zts_simple_start()
* @param nwid the 16-digit hexidecimal network identifier * @param nwid the 16-digit hexidecimal network identifier
* @return * @return
*/ */
void zts_join(const char * nwid); void zts_join(const char * nwid);
/** /**
* @brief Joins a network (eventually), this will create the dir and conf file required, don't instruct the core * @brief Joins a network (eventually), this will create the dir and conf file required, don't instruct the core
* to do anything * to do anything
* *
* @usage Candidate for deletion * @usage Candidate for deletion
* @param filepath path to the `*.conf` file named after the network * @param filepath path to the `*.conf` file named after the network
* @param nwid * @param nwid
* @return * @return
*/ */
void zts_join_soft(const char * filepath, const char * nwid); void zts_join_soft(const char * filepath, const char * nwid);
/** /**
* @brief Leaves a virtual network. * @brief Leaves a virtual network.
* *
* @usage * @usage
* @param nwid * @param nwid
* @return * @return
*/ */
void zts_leave(const char * nwid); void zts_leave(const char * nwid);
/** /**
* @brief Leave a network - Only delete the .conf file, this will prevent the service from joining upon next startup * @brief Leave a network - Only delete the .conf file, this will prevent the service from joining upon next startup
* *
* @usage * @usage
* @param filepath * @param filepath
* @param nwid * @param nwid
* @return * @return
*/ */
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
* @param len * @param len
* @return * @return
*/ */
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)
* *
* @usage * @usage
* @param devID * @param devID
* @return * @return
*/ */
int zts_get_device_id(char *devID); int zts_get_device_id(char *devID);
/** /**
* @brief Check whether the service is running * @brief Check whether the service is running
* *
* @usage * @usage
* @return * @return
*/ */
int zts_running(); int zts_running();
/** /**
* @brief Returns whether any IPv6 address has been assigned to the SockTap for this network * @brief Returns whether any IPv6 address has been assigned to the SockTap for this network
* *
* @usage This is used as an indicator of readiness for service for the ZeroTier core and stack * @usage This is used as an indicator of readiness for service for the ZeroTier core and stack
* @param nwid * @param nwid
* @return * @return
*/ */
int zts_has_ipv4_address(const char *nwid); int zts_has_ipv4_address(const char *nwid);
/** /**
* @brief Returns whether any IPv4 address has been assigned to the SockTap for this network * @brief Returns whether any IPv4 address has been assigned to the SockTap for this network
* *
* @usage This is used as an indicator of readiness for service for the ZeroTier core and stack * @usage This is used as an indicator of readiness for service for the ZeroTier core and stack
* @param nwid * @param nwid
* @return * @return
*/ */
int zts_has_ipv6_address(const char *nwid); int zts_has_ipv6_address(const char *nwid);
/** /**
* @brief Returns whether any address has been assigned to the SockTap for this network * @brief Returns whether any address has been assigned to the SockTap for this network
* *
* @usage This is used as an indicator of readiness for service for the ZeroTier core and stack * @usage This is used as an indicator of readiness for service for the ZeroTier core and stack
* @param nwid * @param nwid
* @return * @return
*/ */
int zts_has_address(const char *nwid); int zts_has_address(const char *nwid);
/** /**
* @brief Get IPV4 Address for this device on a given network * @brief Get IPV4 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 nwid * @param nwid
* @param addrstr * @param addrstr
* @param addrlen * @param addrlen
* @return * @return
*/ */
void zts_get_ipv4_address(const char *nwid, char *addrstr, const int addrlen); 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 * @return
* @param
* @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);
/** /**
* @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 * @return
* @param
* @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);
/** /**
* @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 * @return
* @param
* @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);
/** /**
* @brief Return the number of peers on this network * @brief Return the number of peers on this network
* *
* @usage * @usage
* @param * @return
* @param
* @param
* @param
* @param
* @return
*/ */
unsigned long zts_get_peer_count(); unsigned long zts_get_peer_count();
/** /**
* @brief Get the IP address of a peer if a direct path is available * @brief Get the IP address of a peer if a direct path is available
* *
* @usage * @usage
* @param peer * @param peer
* @param devID * @param devID
* @param * @return
* @param
* @param
* @return
*/ */
int zts_get_peer_address(char *peer, const char *devID); int zts_get_peer_address(char *peer, const char *devID);
@@ -317,14 +252,9 @@ int zts_get_peer_address(char *peer, const char *devID);
* @brief Enable HTTP control plane (traditionally used by zerotier-cli) * @brief Enable HTTP control plane (traditionally used by zerotier-cli)
* - Allows one to control the ZeroTier core via HTTP requests * - Allows one to control the ZeroTier core via HTTP requests
* FIXME: Implement * FIXME: Implement
* *
* @usage * @usage
* @param * @return
* @param
* @param
* @param
* @param
* @return
*/ */
void zts_enable_http_control_plane(); void zts_enable_http_control_plane();
@@ -332,98 +262,84 @@ void zts_enable_http_control_plane();
* @brief Disable HTTP control plane (traditionally used by zerotier-cli) * @brief Disable HTTP control plane (traditionally used by zerotier-cli)
* - Allows one to control the ZeroTier core via HTTP requests * - Allows one to control the ZeroTier core via HTTP requests
* FIXME: Implement * FIXME: Implement
* *
* @usage * @usage
* @param * @return
* @param
* @param
* @param
* @param
* @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
* @return * @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
*/ */
int zts_socket(int socket_family, int socket_type, int protocol); 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 * @return
* @param
* @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 * @return
* @param
* @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 * @return
* @param
* @param
* @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 * @return
* @param
* @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__)
int zts_accept4(int fd, struct sockaddr *addr, socklen_t *addrlen, int flags); int zts_accept4(int fd, struct sockaddr *addr, socklen_t *addrlen, int flags);
@@ -431,263 +347,248 @@ 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);
/** /**
* @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);
/** /**
* @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 * @return
* @param
* @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 * @return
* @param
* @return
*/ */
int zts_getpeername(int fd, struct sockaddr *addr, socklen_t *addrlen); 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 * @return
* @param
* @param
* @return
*/ */
int zts_gethostname(char *name, size_t len); 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 * @return
* @param
* @param
* @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
* @return * @return
*/ */
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
* @param exceptfds * @param exceptfds
* @param timeout * @param timeout
* @return * @return
*/ */
int zts_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); int zts_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
/** /**
* @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
*/ */
int zts_fcntl(int fd, int cmd, int flags); 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
*/ */
int zts_ioctl(int fd, unsigned long request, void *argp); 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
*/ */
ssize_t zts_send(int fd, const void *buf, size_t len, int flags); 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);
/** /**
* @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
*/ */
ssize_t zts_sendmsg(int fd, const struct msghdr *msg, int flags); 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);
/** /**
* @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
* @return * @return
*/ */
ssize_t zts_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen); ssize_t zts_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *addrlen);
/** /**
* @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
*/ */
ssize_t zts_recvmsg(int fd, struct msghdr *msg,int flags); 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 * @return
* @param
* @return
*/ */
int zts_read(int fd, void *buf, size_t len); 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 * @return
* @param
* @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);
/** /**
* @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);
/** /**
* @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

View File

@@ -40,34 +40,44 @@
/** /**
* @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();
/** /**
* @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
* @return * @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
*/ */
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);
/** /**
* @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.
* @return * @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
*/ */
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())
* @return * @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
*/ */
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,
const void *data, unsigned int len); const void *data, unsigned int len);
#endif #endif

View File

@@ -40,7 +40,7 @@
#define __LWIPOPTS_H__ #define __LWIPOPTS_H__
/* /*
* Provides its own errno * Provides its own errno
*/ */
#define LWIP_PROVIDE_ERRNO 0 #define LWIP_PROVIDE_ERRNO 0
@@ -51,11 +51,11 @@
/* /*
* Provides a macro to spoof the names of the lwip socket functions * Provides a macro to spoof the names of the lwip socket functions
*/ */
#define LWIP_POSIX_SOCKETS_IO_NAMES 0 #define LWIP_POSIX_SOCKETS_IO_NAMES 0
/* /*
* *
*/ */
#define LWIP_TIMERS 1 #define LWIP_TIMERS 1
@@ -65,7 +65,7 @@
//#define LWIP_COMPAT_MUTEX 1 //#define LWIP_COMPAT_MUTEX 1
//#define LWIP_COMPAT_MUTEX_ALLOWED 1 //#define LWIP_COMPAT_MUTEX_ALLOWED 1
/* /*
* Provides network/host byte transformation macros * Provides network/host byte transformation macros
*/ */
#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1 #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1

View File

@@ -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

View File

@@ -65,4 +65,4 @@ inline unsigned int gettid()
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -163,4 +163,4 @@ inline void in6_to_ip6(ip6_addr_t *ba, struct sockaddr_in6 *in6)
(((ip[14] & 0xffff) << 8) | ((ip[15]) & 0xffff)) (((ip[14] & 0xffff) << 8) | ((ip[15]) & 0xffff))
); );
} }
*/ */

View File

@@ -27,7 +27,7 @@
/** /**
* @file * @file
* *
* *
*/ */
/* /*
@@ -48,4 +48,4 @@ struct VirtualBindingPair
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
*/ */

View File

@@ -41,7 +41,7 @@
#include "RingBuffer.hpp" #include "RingBuffer.hpp"
#define VS_STATE_INACTIVE 0x000000u // Default value for newly created VirtualSocket #define VS_STATE_INACTIVE 0x000000u // Default value for newly created VirtualSocket
#define VS_STATE_ACTIVE 0x000001u // VirtualSocket is RX'ing or TX'ing without issue #define VS_STATE_ACTIVE 0x000001u // VirtualSocket is RX'ing or TX'ing without issue
#define VS_STATE_SHOULD_SHUTDOWN 0x000002u // Application, stack driver, or stack marked this VirtualSocket for death #define VS_STATE_SHOULD_SHUTDOWN 0x000002u // Application, stack driver, or stack marked this VirtualSocket for death
#define VS_STATE_SHUTDOWN 0x000004u // VirtualSocket and underlying protocol control structures will not RX/TX #define VS_STATE_SHUTDOWN 0x000004u // VirtualSocket and underlying protocol control structures will not RX/TX
#define VS_STATE_CLOSED 0x000008u // VirtualSocket and underlying protocol control structures are closed #define VS_STATE_CLOSED 0x000008u // VirtualSocket and underlying protocol control structures are closed
@@ -52,10 +52,10 @@
#define VS_OPT_TCP_NODELAY 0x000000u // Nagle's algorithm #define VS_OPT_TCP_NODELAY 0x000000u // Nagle's algorithm
#define VS_OPT_SO_LINGER 0x000001u // VirtualSocket waits for data transmission before closure #define VS_OPT_SO_LINGER 0x000001u // VirtualSocket waits for data transmission before closure
/* /*
#define VS_RESERVED 0x000002u // #define VS_RESERVED 0x000002u //
#define VS_RESERVED 0x000004u // #define VS_RESERVED 0x000004u //
#define VS_RESERVED 0x000008u // #define VS_RESERVED 0x000008u //
#define VS_RESERVED 0x000010u // #define VS_RESERVED 0x000010u //
#define VS_RESERVED 0x000020u // #define VS_RESERVED 0x000020u //
#define VS_RESERVED 0x000040u // #define VS_RESERVED 0x000040u //
*/ */
@@ -75,8 +75,8 @@
#define VS_RESERVED 0x080000u // #define VS_RESERVED 0x080000u //
#define VS_RESERVED 0x100000u // #define VS_RESERVED 0x100000u //
#define VS_RESERVED 0x200000u // #define VS_RESERVED 0x200000u //
#define VS_RESERVED 0x400000u // #define VS_RESERVED 0x400000u //
#define VS_RESERVED 0x800000u // #define VS_RESERVED 0x800000u //
*/ */
#define vs_is_nonblocking(vs) (((vs)->optflags & VS_OPT_FD_NONBLOCKING) != 0) #define vs_is_nonblocking(vs) (((vs)->optflags & VS_OPT_FD_NONBLOCKING) != 0)
@@ -95,19 +95,19 @@ namespace ZeroTier {
* Sets the VirtualSocket's state value * Sets the VirtualSocket's state value
*/ */
void apply_state(int state) { void apply_state(int state) {
_state &= state; _state &= state;
} }
/** /**
* Sets the VirtualSocket's state value * Sets the VirtualSocket's state value
*/ */
void set_state(int state) { void set_state(int state) {
_state = state; _state = state;
} }
/** /**
* Gets the VirtualSocket's state value * Gets the VirtualSocket's state value
*/ */
int get_state() { int get_state() {
return _state; return _state;
} }
VirtualSocket() { VirtualSocket() {

View File

@@ -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);
@@ -302,41 +302,41 @@ namespace ZeroTier {
/****************************************************************************/ /****************************************************************************/
// Connect // Connect
int VirtualTap::Connect(const struct sockaddr *addr, socklen_t addrlen) int VirtualTap::Connect(const struct sockaddr *addr, socklen_t addrlen)
{ {
DEBUG_EXTRA(); DEBUG_EXTRA();
return -1; return -1;
} }
// Bind VirtualSocket to a network stack's interface // Bind VirtualSocket to a network stack's interface
int VirtualTap::Bind(const struct sockaddr *addr, socklen_t addrlen) int VirtualTap::Bind(const struct sockaddr *addr, socklen_t addrlen)
{ {
DEBUG_EXTRA(); DEBUG_EXTRA();
return -1; return -1;
} }
// Listen for an incoming VirtualSocket // Listen for an incoming VirtualSocket
int VirtualTap::Listen(int backlog) int VirtualTap::Listen(int backlog)
{ {
DEBUG_EXTRA(); DEBUG_EXTRA();
return -1; return -1;
} }
// Accept a VirtualSocket // Accept a VirtualSocket
void VirtualTap::Accept() void VirtualTap::Accept()
{ {
DEBUG_EXTRA(); DEBUG_EXTRA();
} }
// Read from stack/buffers into the app's socket // Read from stack/buffers into the app's socket
int VirtualTap::Read(PhySocket *sock,void **uptr,bool stack_invoked) int VirtualTap::Read(PhySocket *sock,void **uptr,bool stack_invoked)
{ {
DEBUG_EXTRA(); DEBUG_EXTRA();
return -1; return -1;
} }
// Write data from app socket to the virtual wire, either raw over VL2, or via network stack // Write data from app socket to the virtual wire, either raw over VL2, or via network stack
int VirtualTap::Write(void *data, ssize_t len) int VirtualTap::Write(void *data, ssize_t len)
{ {
DEBUG_EXTRA("data=%p, len=%d", data, len); DEBUG_EXTRA("data=%p, len=%d", data, len);
return -1; return -1;
@@ -351,7 +351,7 @@ namespace ZeroTier {
// Remove VritualSocket from VirtualTap, and instruct network stacks to dismantle their // Remove VritualSocket from VirtualTap, and instruct network stacks to dismantle their
// respective protocol control structures // respective protocol control structures
int VirtualTap::Close() int VirtualTap::Close()
{ {
DEBUG_EXTRA(); DEBUG_EXTRA();
return -1; return -1;
@@ -441,4 +441,4 @@ namespace ZeroTier {
void VirtualTap::phyOnTcpData(PhySocket *sock,void **uptr,void *data,unsigned long len) {} void VirtualTap::phyOnTcpData(PhySocket *sock,void **uptr,void *data,unsigned long len) {}
void VirtualTap::phyOnTcpWritable(PhySocket *sock,void **uptr) {} void VirtualTap::phyOnTcpWritable(PhySocket *sock,void **uptr) {}
} // namespace ZeroTier } // namespace ZeroTier

View File

@@ -286,4 +286,4 @@ namespace ZeroTier {
} // namespace ZeroTier } // namespace ZeroTier
#endif #endif // _H

View File

@@ -172,7 +172,7 @@ int zts_get_device_id_from_file(const char *filepath, char *devID) {
} }
// Starts a ZeroTier service in the background // Starts a ZeroTier service in the background
void *zts_start_service(void *thread_id) void *zts_start_service(void *thread_id)
{ {
DEBUG_INFO("homeDir=%s", ZeroTier::homeDir.c_str()); DEBUG_INFO("homeDir=%s", ZeroTier::homeDir.c_str());
// Where network .conf files will be stored // Where network .conf files will be stored
@@ -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,16 +483,11 @@ 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
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -43,7 +43,7 @@ extern "C" {
#endif #endif
void sys2lwip(int fd, const struct sockaddr *orig, struct sockaddr *modified) { void sys2lwip(int fd, const struct sockaddr *orig, struct sockaddr *modified) {
/* Inelegant fix for lwIP 'sequential' API address error check (in sockets.c). For some reason /* Inelegant fix for lwIP 'sequential' API address error check (in sockets.c). For some reason
lwIP seems to lose track of the sa_family for the socket internally, when lwip_connect() lwIP seems to lose track of the sa_family for the socket internally, when lwip_connect()
is called, it thus receives an AF_UNSPEC socket which fails. Here we use lwIP's own facilities is called, it thus receives an AF_UNSPEC socket which fails. Here we use lwIP's own facilities
@@ -59,7 +59,7 @@ void sys2lwip(int fd, const struct sockaddr *orig, struct sockaddr *modified) {
} }
if (ss.ss_family == AF_INET) { if (ss.ss_family == AF_INET) {
#if defined(__linux__) #if defined(__linux__)
struct sockaddr_in *modified_ptr = (struct sockaddr_in *)modified; struct sockaddr_in *modified_ptr = (struct sockaddr_in *)modified;
struct sockaddr_in *addr4 = (struct sockaddr_in*)orig; struct sockaddr_in *addr4 = (struct sockaddr_in*)orig;
modified_ptr->sin_len = sizeof(struct sockaddr_in); modified_ptr->sin_len = sizeof(struct sockaddr_in);
@@ -71,19 +71,19 @@ void sys2lwip(int fd, const struct sockaddr *orig, struct sockaddr *modified) {
#endif #endif
} }
if (ss.ss_family == AF_INET) { if (ss.ss_family == AF_INET) {
#if defined(__linux__) #if defined(__linux__)
#else #else
#endif #endif
} }
} }
int zts_socket(int socket_family, int socket_type, int protocol) int zts_socket(int socket_family, int socket_type, int protocol)
{ {
DEBUG_EXTRA("family=%d, type=%d, proto=%d", socket_family, socket_type, protocol); DEBUG_EXTRA("family=%d, type=%d, proto=%d", socket_family, socket_type, protocol);
return lwip_socket(socket_family, socket_type, protocol); return lwip_socket(socket_family, socket_type, protocol);
} }
int zts_connect(int fd, const struct sockaddr *addr, socklen_t addrlen) int zts_connect(int fd, const struct sockaddr *addr, socklen_t addrlen)
{ {
DEBUG_EXTRA("fd=%d",fd); DEBUG_EXTRA("fd=%d",fd);
struct sockaddr_storage ss; struct sockaddr_storage ss;
@@ -91,21 +91,21 @@ int zts_connect(int fd, const struct sockaddr *addr, socklen_t addrlen)
return lwip_connect(fd, (struct sockaddr*)&ss, addrlen); return lwip_connect(fd, (struct sockaddr*)&ss, addrlen);
} }
int zts_bind(int fd, const struct sockaddr *addr, socklen_t addrlen) int zts_bind(int fd, const struct sockaddr *addr, socklen_t addrlen)
{ {
DEBUG_EXTRA("fd=%d", fd); DEBUG_EXTRA("fd=%d", fd);
struct sockaddr_storage ss; struct sockaddr_storage ss;
sys2lwip(fd, addr, (struct sockaddr*)&ss); sys2lwip(fd, addr, (struct sockaddr*)&ss);
return lwip_bind(fd, (struct sockaddr*)&ss, addrlen); return lwip_bind(fd, (struct sockaddr*)&ss, addrlen);
} }
int zts_listen(int fd, int backlog) int zts_listen(int fd, int backlog)
{ {
DEBUG_EXTRA("fd=%d", fd); DEBUG_EXTRA("fd=%d", fd);
return lwip_listen(fd, backlog); return lwip_listen(fd, backlog);
} }
int zts_accept(int fd, struct sockaddr *addr, socklen_t *addrlen) int zts_accept(int fd, struct sockaddr *addr, socklen_t *addrlen)
{ {
DEBUG_EXTRA("fd=%d", fd); DEBUG_EXTRA("fd=%d", fd);
return lwip_accept(fd, addr, addrlen); return lwip_accept(fd, addr, addrlen);
@@ -257,4 +257,4 @@ int zts_del_dns_nameserver(struct sockaddr *addr)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -68,9 +68,9 @@ static void tcp_timeout(void *data)
{ {
DEBUG_EXTRA(); DEBUG_EXTRA();
LWIP_UNUSED_ARG(data); LWIP_UNUSED_ARG(data);
#if TCP_DEBUG && LWIP_TCP #if TCP_DEBUG && LWIP_TCP
// tcp_debug_print_pcbs(); // tcp_debug_print_pcbs();
#endif #endif
sys_timeout(5000, tcp_timeout, NULL); sys_timeout(5000, tcp_timeout, NULL);
} }
*/ */
@@ -113,7 +113,7 @@ void lwip_driver_init()
else { else {
return; return;
} }
sys_thread_new("main_network_stack_thread", main_network_stack_thread, sys_thread_new("main_network_stack_thread", main_network_stack_thread,
NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO); NULL, DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
} }
@@ -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);

View File

@@ -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) {