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
STRIP=echo
else
CFLAGS?=-Ofast -g -fstack-protector
CFLAGS?=-Ofast -fstack-protector
CFLAGS+=-Wall -fPIE -fvisibility=hidden -pthread
STRIP=strip
endif
ifeq ($(LIBZT_DEBUG),1)
CFLAGS+=-g
LIBZT_DEFS+=-DLIBZT_DEBUG
endif
ifeq ($(NS_DEBUG),1)

View File

@@ -183,4 +183,4 @@ extern unsigned int gettid(); // defined in libzt.cpp
#define DEBUG_EXTRA(fmt, args...)
#endif
#endif // LIBZT_DEBUG_HPP
#endif // _H

View File

@@ -33,6 +33,9 @@
#ifndef LIBZT_DEFINES_H
#define LIBZT_DEFINES_H
/**
* Maximum MTU size for ZeroTier
*/
#define ZT_MAX_MTU 10000
/**
@@ -41,7 +44,7 @@
#define ZTO_WRAPPER_CHECK_INTERVAL 50
/**
*
* Length of buffer required to hold a ztAddress/nodeID
*/
#define ZTO_ID_LEN 16
@@ -132,22 +135,22 @@ struct sockaddr_ll {
typedef signed char err_t;
/*
/**
Specifies the polling interval and the callback function that should
be called to poll the application. The interval is specified in
number of TCP coarse grained timer shots, which typically occurs
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
/**
*
* TCP timer interval in milliseconds (only for raw lwIP driver)
*/
#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
@@ -166,12 +169,12 @@ typedef signed char err_t;
/****************************************************************************/
/**
*
* Maximum number of sockets that libzt can administer
*/
#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
@@ -186,52 +189,52 @@ typedef signed char err_t;
#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
/**
*
* 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
/**
*
* Size of TCP TX buffer for VirtualSockets used in raw network stack drivers
*/
#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
/**
*
* Size of UDP TX buffer for VirtualSockets used in raw network stack drivers
*/
#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
@@ -255,93 +258,94 @@ typedef signed char err_t;
// 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
/**
*
* Maximum size of read operation from a network stack
*/
#define ZT_STACK_SOCKET_RD_MAX 4096*4
/**
*
*/
#define ZT_CORE_VERSION_MAJOR 1
#define ZT_CORE_VERSION_MINOR 2
#define ZT_CORE_VERSION_REVISION 5
#define ZT_CORE_VERSION "1.2.5"
#define ZT_LIB_VERSION "1.1.5"
/**
*
*/
#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
/**
*
* Maximum length of libzt/ZeroTier home path (where keys, and config files are stored)
*/
#define ZT_HOME_PATH_MAX_LEN 128
/**
*
* Length of human-readable MAC address string
*/
#define ZT_MAC_ADDRSTRLEN 18
/**
*
* Everything is ok
*/
#define ZT_ERR_OK 0
/**
*
* Value returned during an internal failure at the VirtualSocket/VirtualTap layer
*/
#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
// 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
*/
#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,19 +38,17 @@ extern "C" {
#endif
/**
* @brief
* @brief Used to perform a common action upon a failure in the VirtualSocket/VirtualTap layer.
*
* @usage For internal use only.
* @param
* @return
*/
void handle_general_failure();
/**
* @brief
* @brief Returns the thread-id. Used in debug traces.
*
* @usage For internal use only.
* @param
* @return
*/
inline unsigned int gettid();
@@ -59,4 +57,4 @@ inline unsigned int gettid();
}
#endif
#endif
#endif // _H

View File

@@ -39,9 +39,7 @@
* @brief Returns masked address for subnet comparisons
*
* @usage For internal use only.
*
* @param
*
* @param socket_type
* @return
*/
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
*
* @usage For internal use only.
*
* @param
*
* @param proto
* @return
*/
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
*
* @usage For internal use only.
*
* @param
*
* @param socket_family
* @param addr
* @param inet
* @return
*/
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
*
* @usage For internal use only.
*
* @param
*
* @param macbuf
* @param len
* @param addr
* @return
*/
void mac2str(char *macbuf, int len, unsigned char* addr);
@@ -87,4 +83,4 @@ void mac2str(char *macbuf, int len, unsigned char* addr);
#endif
#endif // UTILITIES_HPP
#endif // _H

View File

@@ -30,7 +30,6 @@
*
*/
/*
#ifndef LIBZT_VIRTUALBINDINGPAIR_H
#define LIBZT_VIRTUALBINDINGPAIR_H
@@ -44,5 +43,4 @@ struct VirtualBindingPair;
}
#endif
#endif
*/
#endif // _H

View File

@@ -48,4 +48,4 @@ class VirtualSocket;
}
#endif
#endif
#endif // _H

View File

@@ -85,7 +85,7 @@ int zts_get_device_id_from_file(const char *filepath, char *devID);
void *zts_start_service(void *thread_id);
/**
* @brief
* @brief Stops all VirtualTap interfaces and associated I/O loops
*
* @usage For internal use only.
* @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);
/**
* @brief
* @brief Join a network
*
* @usage
* @param
* @usage Call this from application thread. Only after zts_start() has succeeded
* @param nwid A 16-digit hexidecimal virtual network ID
* @return
*/
void zts_join(const char * nwid);
/**
* @brief
* @brief Leave a network
*
* @usage For internal use only.
* @param
* @return
*/
void zts_join_soft(const char * filepath, const char * nwid);
/**
* @brief
*
* @usage
* @param
* @usage Call this from application thread. Only after zts_start() has succeeded
* @param nwid A 16-digit hexidecimal virtual network ID
* @return
*/
void zts_leave(const char * nwid);
/**
* @brief
* @brief Return whether libzt (specifically the ZeroTier core service) is currently running
*
* @usage For internal use only.
* @param
* @return
*/
void zts_leave_soft(const char * filepath, const char * nwid);
/**
* @brief
*
* @usage
* @param
* @usage Call this before, during, or after zts_start()
* @return
*/
int zts_running();
/**
* @brief
* @brief Start an instance of libzt (ZeroTier core service, network stack drivers, network stack threads, etc)
*
* @usage
* @param
* @usage Call this when you anticipate needing to communicate over ZeroTier virtual networks. It is recommended
* 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
*/
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
* 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);
@@ -237,110 +224,81 @@ void zts_stop();
*/void zts_get_homepath(char *homePath, int len);
/**
* @brief
* @brief Copies the hexidecimal representation of this nodeID into the provided buffer
*
* @usage
* @param
* @return
*/
void zts_core_version(char *ver);
/**
* @brief
*
* @usage
* @param
* @return
*/
void zts_lib_version(char *ver);
/**
* @brief
*
* @usage
* @param
* @usage Call this after zts_start() and/or when zts_running() returns true
* @param devID Buffer to which id string is copied
* @return
*/
int zts_get_device_id(char *devID);
/**
* @brief
* @brief Return the number of peers
*
* @usage
* @usage Call this after zts_start() has succeeded
* @param
* @return
*/
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
* @return
*/
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
* @param
* @usage Call this after zts_start() has succeeded
* @param allowed True or false value
* @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
* @param
* @return
*/
void zts_disable_http_control_plane();
/**
* @brief Whether we can add a new socket or not. Depends on stack in use
*
* @usage
* @usage Call this after zts_start() has succeeded
* @param socket_type
* @return
*/
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
* 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
* the logic for this function should change accordingly.
*
* @usage
* @param
* @usage Call this after zts_start() has succeeded
* @return
*/
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
* @return
*/
int zts_maxsockets(int socket_type);
/**
* @brief
* @brief Return the number of currently active picoTCP timers
*
* @usage
* @param
* @usage Call this after zts_start() has succeeded
* @return
*/
int pico_ntimers();
#endif // ZT1SERVICE_H
#ifdef __cplusplus
}
#endif
#endif // _H

View File

@@ -42,40 +42,7 @@
#include "Defs.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, ...
/****************************************************************************/
/* SDK Socket API (ZeroTier Service Controls) */
/* ZeroTier Service Controls */
/****************************************************************************/
#ifdef __cplusplus
@@ -88,32 +55,32 @@ int zts_get_device_id(char *devID);
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
* - 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 directory where cryptographic identities and network configuration files are stored and retrieved
* @param path path directory where cryptographic identities and network configuration files are stored and retrieved
* (`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
*/
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);
/**
* @brief Return the home path for this instance of ZeroTier
* @brief Returns path used by ZeroTier/libzt for storing identity and config files
*
* @usage
* @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);
/**
* @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)
*
@@ -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
*
* @usage FIXME: Only returns first address found for given protocol and network (should be enough for now)
* @param
* @param
* @param
* @param
* @param
* @param nwid
* @param addrstr
* @param addrlen
* @return
*/
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
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @param addr
* @param nwid
* @param devID
* @return
*/
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
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @param addr
* @param nwid
* @param devID
* @return
*/
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
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @return
*/
unsigned long zts_get_peer_count();
@@ -306,9 +244,6 @@ unsigned long zts_get_peer_count();
* @usage
* @param peer
* @param devID
* @param
* @param
* @param
* @return
*/
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
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @return
*/
void zts_enable_http_control_plane();
@@ -334,30 +264,26 @@ void zts_enable_http_control_plane();
* FIXME: Implement
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @return
*/
void zts_disable_http_control_plane();
/****************************************************************************/
/* SDK Socket API (Socket User Controls) */
/* - These functions are designed to work just like ordinary socket calls */
/* but are provisioned and handled by ZeroTier */
/* POSIX-like socket API */
/****************************************************************************/
/**
* @brief Create a socket
*
* @usage
* @param
* @param
* @param
* @param
* @param
* This function will return an integer which can be used in much the same way as a
* typical file descriptor, however it is only valid for use with libzt library calls
* as this is merely a facade which is associated with the internal socket representation
* of both the network stacks and drivers.
*
* @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
*/
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
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param addr Remote host address to connect to
* @param addrlen Length of address
* @return
*/
int zts_connect(int fd, const struct sockaddr *addr, socklen_t addrlen);
/**
* @brief
* @brief Bind a socket to a virtual interface
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param addr Local interface address to bind to
* @param addrlen Length of address
* @return
*/
int zts_bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
/**
* @brief Listen for incoming VirtualSockets
* @brief Listen for incoming connections
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param backlog Number of backlogged connection allowed
* @return
*/
int zts_listen(int fd, int backlog);
/**
* @brief Accept a VirtualSocket
* @brief Accept an incoming connection
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param addr Address of remote host for accepted connection
* @param addrlen Length of address
* @return
*/
int zts_accept(int fd, struct sockaddr *addr, socklen_t *addrlen);
/**
* @brief Accept a VirtualSocket
* @brief Accept an incoming connection
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param addr Address of remote host for accepted connection
* @param addrlen Length of address
* @param flags
* @return
*/
#if defined(__linux__)
@@ -432,12 +348,12 @@ int zts_accept(int fd, struct sockaddr *addr, socklen_t *addrlen);
/**
* @brief Set socket options
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param level Protocol level to which option name should apply
* @param optname Option name to set
* @param optval Source of option value to set
* @param optlen Length of option value
* @return
*/
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
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param level Protocol level to which option name should apply
* @param optname Option name to get
* @param optval Where option value will be stored
* @param optlen Length of value
* @return
*/
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
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param addr Name associated with this socket
* @param addrlen Length of name
* @return
*/
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
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param addr Name associated with remote end of this socket
* @param addrlen Length of name
* @return
*/
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
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param name
* @param len
* @return
*/
int zts_gethostname(char *name, size_t len);
@@ -497,29 +406,26 @@ int zts_gethostname(char *name, size_t len);
/**
* @brief Sets current hostname
*
* @usage
* @param
* @param
* @param
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param name
* @param len
* @return
*/
int zts_sethostname(const char *name, size_t len);
/**
* @brief close a socket
* @brief Close a socket
*
* @usage
* @param fd
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @return
*/
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 nfds
* @param timeout
@@ -528,9 +434,9 @@ int zts_close(int fd);
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 readfds
* @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
*
* @usage
* @param fd
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param cmd
* @param flags
* @return
@@ -554,8 +460,8 @@ int zts_fcntl(int fd, int cmd, int flags);
/**
* @brief Control a device
*
* @usage
* @param fd
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param request
* @param argp
* @return
@@ -565,10 +471,10 @@ int zts_ioctl(int fd, unsigned long request, void *argp);
/**
* @brief Send data to remote host
*
* @usage
* @param fd
* @param buf
* @param len
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param buf Pointer to data buffer
* @param len Length of data to write
* @param flags
* @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
*
* @usage
* @param fd
* @param buf
* @param len
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param buf Pointer to data buffer
* @param len Length of data to write
* @param flags
* @param addr
* @param addrlen
* @param addr Destination address
* @param addrlen Length of destination address
* @return
*/
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
*
* @usage
* @param fd
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param msg
* @param flags
* @return
@@ -602,12 +508,11 @@ ssize_t zts_sendmsg(int fd, const struct msghdr *msg, int flags);
/**
* @brief Receive data from remote host
*
* @usage
* @param fd
* @param buf
* @param len
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param buf Pointer to data buffer
* @param len Length of data buffer
* @param flags
* @param
* @return
*/
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
*
* @usage
* @param fd
* @param buf
* @param len
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param buf Pointer to data buffer
* @param len Length of data buffer
* @param flags
* @param addr
* @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
*
* @usage
* @param fd
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param msg
* @param flags
* @return
@@ -640,12 +545,10 @@ ssize_t zts_recvmsg(int fd, struct msghdr *msg,int flags);
/**
* @brief Read bytes from socket onto buffer
*
* @usage
* @param fd
* @param buf
* @param len
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param buf Pointer to data buffer
* @param len Length of data buffer to receive data
* @return
*/
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
*
* @usage
* @param fd
* @param buf
* @param len
* @param
* @param
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param buf Pointer to data buffer
* @param len Length of buffer to write
* @return
*/
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
* @param fd
* @param how
* @usage Call this after zts_start() has succeeded
* @param fd File descriptor (only valid for use with libzt calls)
* @param how Which aspects of the socket should be shut down
* @return
*/
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
*
* @usage
* @param addr
* @usage Call this after zts_start() has succeeded
* @param addr Address for DNS nameserver
* @return
*/
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
*
* @usage
* @param addr
* @usage Call this after zts_start() has succeeded
* @param addr Address for DNS nameserver
* @return
*/
int zts_del_dns_nameserver(struct sockaddr *addr);
@@ -695,4 +596,4 @@ int zts_del_dns_nameserver(struct sockaddr *addr);
} // extern "C"
#endif
#endif // ZT_ZEROTIERSDK_H
#endif // _H

View File

@@ -40,7 +40,6 @@
/**
* @brief Initialize network stack semaphores, threads, and timers.
*
* @param
* @return
*/
void lwip_driver_init();
@@ -49,6 +48,9 @@ void lwip_driver_init();
* @brief Set up an interface in the network stack for the VirtualTap.
*
* @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
*/
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.
*
* @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
*/
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
*/
void lwip_eth_rx(ZeroTier::VirtualTap *tap, const ZeroTier::MAC &from, const ZeroTier::MAC &to, unsigned int etherType,

View File

@@ -54,7 +54,7 @@ UNIXLIB=liblwip.a
all: $(UNIXLIB)
.PHONY: all
include ext/lwip/src/Filelists.mk
include $(LWIPDIR)/Filelists.mk
# ARCHFILES: Architecture specific files.
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
$(UNIXLIB): $(LWIPNOAPPSOBJS)
$(CCX) $(CFLAGS) -g -nostartfiles -shared -o $@ $^
$(CCX) $(CFLAGS) -g -nostartfiles -shared -o obj/$@ $^
.depend: $(LWIPNOAPPSFILES)
$(CCX) $(CFLAGS) -MM $^ > .depend || rm -f .depend

View File

@@ -190,7 +190,7 @@ namespace ZeroTier {
std::string VirtualTap::nodeId() const
{
if (zt1ServiceRef) {
char id[ZT_ID_LEN];
char id[ZTO_ID_LEN];
memset(id, 0, sizeof(id));
sprintf(id, "%lx",((ZeroTier::OneService *)zt1ServiceRef)->getNode()->address());
return std::string(id);

View File

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

View File

@@ -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) {
if (ZeroTier::zt1Service) {
char id[ZTO_ID_LEN];
@@ -493,12 +483,7 @@ int zts_get_peer_address(char *peer, const char *devID) {
return -1;
}
void zts_enable_http_control_plane()
{
// TODO
}
void zts_disable_http_control_plane()
void zts_allow_http_control(bool allowed)
{
// TODO
}

View File

@@ -147,7 +147,7 @@ err_t lwip_eth_tx(struct netif *netif, struct pbuf *p)
if (ZT_MSG_TRANSFER == true) {
char flagbuf[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);
ZeroTier::MAC mac;
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) {
char flagbuf[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);
ZeroTier::MAC mac;
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");
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);
DEBUG_TEST("I am %s, %s", device_id, me.c_str());
if (mode == TEST_MODE_SERVER) {