include/ZeroTierSockets.h
#
ClassesName | |
---|---|
struct | zts_in_addr |
struct | zts_in6_addr |
union | zts_in6_addr::un |
struct | zts_sockaddr_in |
struct | zts_sockaddr_in6 |
struct | zts_sockaddr |
struct | zts_sockaddr_storage |
struct | zts_node_info_t |
struct | zts_addr_info_t |
struct | zts_route_info_t |
struct | zts_multicast_group_t |
struct | zts_net_info_t |
struct | zts_path_t |
struct | zts_peer_info_t |
struct | zts_root_set_t |
struct | zts_netif_info_t |
struct | zts_event_msg_t |
struct | zts_stats_counter_t |
struct | zts_linger |
struct | zts_ip_mreq |
struct | zts_in_pktinfo |
struct | zts_ipv6_mreq |
struct | zts_fd_set |
struct | zts_timeval |
struct | zts_pollfd |
struct | zts_iovec |
struct | zts_msghdr |
struct | zts_hostent |
struct | zts_ip4_addr |
struct | zts_ip6_addr |
struct | zts_ip_addr |
#
TypesName | |
---|---|
enum | zts_error_t { ZTS_ERR_OK = 0, ZTS_ERR_SOCKET = -1, ZTS_ERR_SERVICE = -2, ZTS_ERR_ARG = -3, ZTS_ERR_NO_RESULT = -4, ZTS_ERR_GENERAL = -5} |
enum | zts_event_t { ZTS_EVENT_NODE_UP = 200, ZTS_EVENT_NODE_ONLINE = 201, ZTS_EVENT_NODE_OFFLINE = 202, ZTS_EVENT_NODE_DOWN = 203, ZTS_EVENT_NODE_FATAL_ERROR = 204, ZTS_EVENT_NETWORK_NOT_FOUND = 210, ZTS_EVENT_NETWORK_CLIENT_TOO_OLD = 211, ZTS_EVENT_NETWORK_REQ_CONFIG = 212, ZTS_EVENT_NETWORK_OK = 213, ZTS_EVENT_NETWORK_ACCESS_DENIED = 214, ZTS_EVENT_NETWORK_READY_IP4 = 215, ZTS_EVENT_NETWORK_READY_IP6 = 216, ZTS_EVENT_NETWORK_READY_IP4_IP6 = 217, ZTS_EVENT_NETWORK_DOWN = 218, ZTS_EVENT_NETWORK_UPDATE = 219, ZTS_EVENT_STACK_UP = 220, ZTS_EVENT_STACK_DOWN = 221, ZTS_EVENT_NETIF_UP = 230, ZTS_EVENT_NETIF_DOWN = 231, ZTS_EVENT_NETIF_REMOVED = 232, ZTS_EVENT_NETIF_LINK_UP = 233, ZTS_EVENT_NETIF_LINK_DOWN = 234, ZTS_EVENT_PEER_DIRECT = 240, ZTS_EVENT_PEER_RELAY = 241, ZTS_EVENT_PEER_UNREACHABLE = 242, ZTS_EVENT_PEER_PATH_DISCOVERED = 243, ZTS_EVENT_PEER_PATH_DEAD = 244, ZTS_EVENT_ROUTE_ADDED = 250, ZTS_EVENT_ROUTE_REMOVED = 251, ZTS_EVENT_ADDR_ADDED_IP4 = 260, ZTS_EVENT_ADDR_REMOVED_IP4 = 261, ZTS_EVENT_ADDR_ADDED_IP6 = 262, ZTS_EVENT_ADDR_REMOVED_IP6 = 263, ZTS_EVENT_STORE_IDENTITY_SECRET = 270, ZTS_EVENT_STORE_IDENTITY_PUBLIC = 271, ZTS_EVENT_STORE_PLANET = 272, ZTS_EVENT_STORE_PEER = 273, ZTS_EVENT_STORE_NETWORK = 274} |
enum | zts_errno_t { ZTS_EPERM = 1, ZTS_ENOENT = 2, ZTS_ESRCH = 3, ZTS_EINTR = 4, ZTS_EIO = 5, ZTS_ENXIO = 6, ZTS_EBADF = 9, ZTS_EAGAIN = 11, ZTS_EWOULDBLOCK = ZTS_EAGAIN, ZTS_ENOMEM = 12, ZTS_EACCES = 13, ZTS_EFAULT = 14, ZTS_EBUSY = 16, ZTS_EEXIST = 17, ZTS_ENODEV = 19, ZTS_EINVAL = 22, ZTS_ENFILE = 23, ZTS_EMFILE = 24, ZTS_ENOSYS = 38, ZTS_ENOTSOCK = 88, ZTS_EDESTADDRREQ = 89, ZTS_EMSGSIZE = 90, ZTS_EPROTOTYPE = 91, ZTS_ENOPROTOOPT = 92, ZTS_EPROTONOSUPPORT = 93, ZTS_ESOCKTNOSUPPORT = 94, ZTS_EOPNOTSUPP = 95, ZTS_EPFNOSUPPORT = 96, ZTS_EAFNOSUPPORT = 97, ZTS_EADDRINUSE = 98, ZTS_EADDRNOTAVAIL = 99, ZTS_ENETDOWN = 100, ZTS_ENETUNREACH = 101, ZTS_ECONNABORTED = 103, ZTS_ECONNRESET = 104, ZTS_ENOBUFS = 105, ZTS_EISCONN = 106, ZTS_ENOTCONN = 107, ZTS_ETIMEDOUT = 110, ZTS_EHOSTUNREACH = 113, ZTS_EALREADY = 114, ZTS_EINPROGRESS = 115} |
enum | zts_network_status_t { ZTS_NETWORK_STATUS_REQUESTING_CONFIGURATION = 0, ZTS_NETWORK_STATUS_OK = 1, ZTS_NETWORK_STATUS_ACCESS_DENIED = 2, ZTS_NETWORK_STATUS_NOT_FOUND = 3, ZTS_NETWORK_STATUS_PORT_ERROR = 4, ZTS_NETWORK_STATUS_CLIENT_TOO_OLD = 5} |
enum | zts_net_info_type_t { ZTS_NETWORK_TYPE_PRIVATE = 0, ZTS_NETWORK_TYPE_PUBLIC = 1} |
enum | zts_peer_role_t { ZTS_PEER_ROLE_LEAF = 0, ZTS_PEER_ROLE_MOON = 1, ZTS_PEER_ROLE_PLANET = 2} |
typedef uint32_t | zts_socklen_t |
typedef uint32_t | zts_in_addr_t |
typedef uint16_t | zts_in_port_t |
typedef uint8_t | zts_sa_family_t |
typedef struct zts_ip_mreq | zts_ip_mreq |
typedef struct zts_ipv6_mreq | zts_ipv6_mreq |
typedef struct zts_fd_set | zts_fd_set |
typedef struct zts_timeval | zts_timeval |
typedef unsigned int | zts_nfds_t |
typedef struct zts_ip_addr | zts_ip_addr |
#
FunctionsName | |
---|---|
int | zts_id_new(char key, unsigned int key_buf_len) Generates a node identity (public/secret key-pair) and stores it in a user-provided buffer. |
int | zts_id_pair_is_valid(const char * key, unsigned int len) Verifies that a key-pair is valid. Checks formatting and pairing of key to address. |
int | zts_init_from_storage(const char * path) Instruct ZeroTier to look for node identity files at the given location. This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_from_memory(const char * key, unsigned int len) Instruct ZeroTier to use the identity provided in key . This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_set_event_handler(void()(void ) callback) Set the event handler function. This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_blacklist_if(const char * prefix, unsigned int len) Blacklist an interface prefix (or name). This prevents ZeroTier from sending traffic over matching interfaces. This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_set_roots(const void * roots_data, unsigned int len) Present a root set definition for ZeroTier to use instead of the default. This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_set_port(unsigned short port) Set the port to which the node should bind. This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_set_random_port_range(unsigned short start_port, unsigned short end_port) Set range that random ports will be selected from. This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_allow_secondary_port(unsigned int allowed) Allow or disallow ZeroTier from automatically selecting a backup port to help get through buggy NAT. This is enabled by default. This port is randomly chosen and should be disabled if you want to control exactly which ports ZeroTier talks on and (iff) you know with absolute certainty that traffic on your chosen primary port is allowed. This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_allow_port_mapping(unsigned int allowed) Allow or disallow the use of port-mapping. This is enabled by default. This is an initialization function that can only be called before zts_node_start() . |
int | zts_init_allow_net_cache(unsigned int allowed) Enable or disable whether the node will cache network details (enabled by default when zts_init_from_storage() is used.) Must be called before zts_node_start() . |
int | zts_init_allow_peer_cache(unsigned int allowed) Enable or disable whether the node will cache peer details (enabled by default when zts_init_from_storage() is used.) Must be called before zts_node_start() . |
int | zts_init_allow_roots_cache(unsigned int allowed) Enable or disable whether the node will cache root definitions (enabled by default when zts_init_from_storage() is used.) Must be called before zts_node_start() . |
int | zts_init_allow_id_cache(unsigned int allowed) Enable or disable whether the node will cache identities (enabled by default when zts_init_from_storage() is used.) Must be called before zts_node_start() . |
int | zts_addr_is_assigned(uint64_t net_id, unsigned int family) Return whether an address of the given family has been assigned by the network. |
int | zts_addr_get(uint64_t net_id, unsigned int family, struct zts_sockaddr_storage * addr) Get the first-assigned IP on the given network. |
int | zts_addr_get_str(uint64_t net_id, unsigned int family, char * dst, unsigned int len) Get the first-assigned IP on the given network as a null-terminated human-readable string. |
int | zts_addr_get_all(uint64_t net_id, struct zts_sockaddr_storage addr, unsigned int count) Get all IP addresses assigned to this node by the given network. |
int | zts_addr_compute_6plane(const uint64_t net_id, const uint64_t node_id, struct zts_sockaddr_storage * addr) Compute a 6PLANE IPv6 address for the given Network ID and Node ID. |
int | zts_addr_compute_rfc4193(const uint64_t net_id, const uint64_t node_id, struct zts_sockaddr_storage * addr) Compute RFC4193 IPv6 address for the given Network ID and Node ID. |
int | zts_addr_compute_rfc4193_str(uint64_t net_id, uint64_t node_id, char * dst, unsigned int len) Compute RFC4193 IPv6 address for the given Network ID and Node ID and copy its null-terminated human-readable string representation into destination buffer. |
int | zts_addr_compute_6plane_str(uint64_t net_id, uint64_t node_id, char * dst, unsigned int len) Compute 6PLANE IPv6 address for the given Network ID and Node ID and copy its null-terminated human-readable string representation into destination buffer. |
uint64_t | zts_net_compute_adhoc_id(uint16_t start_port, uint16_t end_port) Compute RFC4193 IPv6 address for the given Network ID and Node ID. |
int | zts_net_join(uint64_t net_id) Join a network. |
int | zts_net_leave(uint64_t net_id) Leave a network. |
int | zts_net_transport_is_ready(const uint64_t net_id) Return whether this network is ready to send and receive traffic. |
uint64_t | zts_net_get_mac(uint64_t net_id) Get the MAC Address for this node on the given network. |
int | zts_net_get_mac_str(uint64_t net_id, char * dst, unsigned int len) Get the MAC Address for this node on the given network. |
int | zts_net_get_broadcast(uint64_t net_id) Return whether broadcast is enabled on this network. |
int | zts_net_get_mtu(uint64_t net_id) Get the MTU of the given network. |
int | zts_net_get_name(uint64_t net_id, char * dst, unsigned int len) Get the nickname of the network. |
int | zts_net_get_status(uint64_t net_id) Get the status of the network. |
int | zts_net_get_type(uint64_t net_id) Get the type of network (public or private.) |
int | zts_route_is_assigned(uint64_t net_id, unsigned int family) Return whether a managed route of the given address family has been assigned by the network. |
int | zts_node_start() Start the ZeroTier node. Should be called after calling the relevant zts_init_* functions for your application. To enable storage call zts_init_from_storage() before this function. To enable event callbacks call zts_init_set_event_handler() before this function. |
int | zts_node_is_online() Return whether the node is online (Can reach the Internet) |
uint64_t | zts_node_get_id() Get the public node identity (aka node_id ). Callable only after the node has been started. |
int | zts_node_get_id_pair(char key, unsigned int key_dst_len) Copy the current node's public (and secret!) identity into a buffer. |
int | zts_node_get_port() Get the primary port to which the node is bound. Callable only after the node has been started. |
int | zts_node_stop() Stop the ZeroTier node and bring down all virtual network transport services. Callable only after the node has been started. |
int | zts_node_free() Stop all background threads, bring down all transport services, free all resources. After calling this function an application restart will be required before the library can be used again. Callable only after the node has been started. |
int | zts_moon_orbit(uint64_t moon_roots_id, uint64_t moon_seed) Orbit a given moon (user-defined root server) |
int | zts_moon_deorbit(uint64_t moon_roots_id) De-orbit a given moon (user-defined root server) |
int | zts_stats_get_all(zts_stats_counter_t * dst) Get all statistical counters for all protocols and levels. See also: lwip/stats.h. |
int | zts_bsd_socket(int family, int type, int protocol) Create a socket. |
int | zts_bsd_connect(int fd, const struct zts_sockaddr * addr, zts_socklen_t addrlen) Connect a socket to a remote host. |
int | zts_bsd_bind(int fd, const struct zts_sockaddr * addr, zts_socklen_t addrlen) Bind a socket to a local address. |
int | zts_bsd_listen(int fd, int backlog) Listen for incoming connections on socket. |
int | zts_bsd_accept(int fd, struct zts_sockaddr addr, zts_socklen_t addrlen) Accept an incoming connection. |
int | zts_bsd_setsockopt(int fd, int level, int optname, const void * optval, zts_socklen_t optlen) Set socket options. |
int | zts_bsd_getsockopt(int fd, int level, int optname, void optval, zts_socklen_t optlen) Get socket options. |
int | zts_bsd_getsockname(int fd, struct zts_sockaddr addr, zts_socklen_t addrlen) Get the name (address) of the local end of the socket. |
int | zts_bsd_getpeername(int fd, struct zts_sockaddr addr, zts_socklen_t addrlen) Get the name (address) of the remote end of the socket. |
int | zts_bsd_close(int fd) Close socket. |
int | zts_bsd_select(int nfds, zts_fd_set readfds, zts_fd_set writefds, zts_fd_set exceptfds, struct zts_timeval timeout) Monitor multiple file descriptors for "readiness". |
int | zts_bsd_fcntl(int fd, int cmd, int flags) Issue file control commands on a socket. |
int | zts_bsd_poll(struct zts_pollfd * fds, zts_nfds_t nfds, int timeout) Wait for some event on a file descriptor. |
int | zts_bsd_ioctl(int fd, unsigned long request, void * argp) Control a device. |
ssize_t | zts_bsd_send(int fd, const void * buf, size_t len, int flags) Send data to remote host. |
ssize_t | zts_bsd_sendto(int fd, const void buf, size_t len, int flags, const struct zts_sockaddr addr, zts_socklen_t addrlen) Send data to remote host. |
ssize_t | zts_bsd_sendmsg(int fd, const struct zts_msghdr * msg, int flags) Send message to remote host. |
ssize_t | zts_bsd_recv(int fd, void * buf, size_t len, int flags) Receive data from remote host. |
ssize_t | zts_bsd_recvfrom(int fd, void buf, size_t len, int flags, struct zts_sockaddr addr, zts_socklen_t * addrlen) Receive data from remote host. |
ssize_t | zts_bsd_recvmsg(int fd, struct zts_msghdr * msg, int flags) Receive a message from remote host. |
ssize_t | zts_bsd_read(int fd, void * buf, size_t len) Read data from socket onto buffer. |
ssize_t | zts_bsd_readv(int fd, const struct zts_iovec * iov, int iovcnt) Read data from socket into multiple buffers. |
ssize_t | zts_bsd_write(int fd, const void * buf, size_t len) Write data from buffer to socket. |
ssize_t | zts_bsd_writev(int fd, const struct zts_iovec * iov, int iovcnt) Write data from multiple buffers to socket. |
int | zts_bsd_shutdown(int fd, int how) Shut down some aspect of a socket. |
int | zts_socket(int family, int type, int protocol) Create a socket. |
int | zts_connect(int fd, const char * ipstr, unsigned short port, int timeout_ms) Connect a socket to a remote host. |
int | zts_bind(int fd, const char * ipstr, unsigned short port) Bind a socket to a local address. |
int | zts_listen(int fd, int backlog) Listen for incoming connections on socket. |
int | zts_accept(int fd, char remote_addr, int len, unsigned short port) Accept an incoming connection. |
ssize_t | zts_send(int fd, const void * buf, size_t len, int flags) Send data to remote host. |
ssize_t | zts_recv(int fd, void * buf, size_t len, int flags) Receive data from remote host. |
ssize_t | zts_read(int fd, void * buf, size_t len) Read data from socket onto buffer. |
ssize_t | zts_write(int fd, const void * buf, size_t len) Write data from buffer to socket. |
int | zts_shutdown_rd(int fd) Shut down read aspect of a socket. |
int | zts_shutdown_wr(int fd) Shut down write aspect of a socket. |
int | zts_shutdown_rdwr(int fd) Shut down both read and write aspect of a socket. |
int | zts_close(int fd) Close socket. |
int | zts_getpeername(int fd, char remote_addr_str, int len, unsigned short port) Get the name (address) of the remote end of the socket. |
int | zts_getsockname(int fd, char local_addr_str, int len, unsigned short port) Get the name (address) of the local end of the socket. |
int | zts_tcp_client(const char * remote_ipstr, unsigned short remote_port) A convenience function that takes a remote address IP string and creates the appropriate type of socket, and uses it to connect to a remote host. |
int | zts_tcp_server(const char local_ipstr, unsigned short local_port, char remote_ipstr, int len, unsigned short * remote_port) A convenience function that takes a remote address IP string and creates the appropriate type of socket, binds, listens, and then accepts on it. |
int | zts_udp_server(const char * local_ipstr, unsigned short local_port) A convenience function that takes a remote address IP string and creates the appropriate type of socket, and binds to it. |
int | zts_udp_client(const char * remote_ipstr) This function doesn't really do anything other than be a namespace counterpart to zts_udp_server . All this function does is create a ZTS_SOCK_DGRAM socket and return its file descriptor. |
int | zts_set_no_delay(int fd, int enabled) Enable or disable TCP_NODELAY . Enabling this is equivalent to turning off Nagle's algorithm. |
int | zts_get_last_socket_error(int fd) Get the last error for the given socket. |
size_t | zts_get_data_available(int fd) Return amount of data available to read from socket. |
int | zts_get_no_delay(int fd) Return whether TCP_NODELAY is enabled. |
int | zts_set_linger(int fd, int enabled, int value) Enable or disable SO_LINGER while also setting its value. |
int | zts_get_linger_enabled(int fd) Return whether SO_LINGER is enabled. |
int | zts_get_linger_value(int fd) Return the value of SO_LINGER |
int | zts_get_pending_data_size(int fd) Return the number of bytes available to read from the network buffer. |
int | zts_set_reuse_addr(int fd, int enabled) Enable or disable SO_REUSEADDR |
int | zts_get_reuse_addr(int fd) Return whether SO_REUSEADDR is enabled. |
int | zts_set_recv_timeout(int fd, int seconds, int microseconds) Set the value of SO_RCVTIMEO |
int | zts_get_recv_timeout(int fd) Return the value of SO_RCVTIMEO |
int | zts_set_send_timeout(int fd, int seconds, int microseconds) Set the value of SO_SNDTIMEO |
int | zts_get_send_timeout(int fd) Return the value of SO_SNDTIMEO |
int | zts_set_send_buf_size(int fd, int size) Set the value of SO_SNDBUF |
int | zts_get_send_buf_size(int fd) Return the value of SO_SNDBUF |
int | zts_set_recv_buf_size(int fd, int size) Set the value of SO_RCVBUF |
int | zts_get_recv_buf_size(int fd) Return the value of SO_RCVBUF |
int | zts_set_ttl(int fd, int ttl) Set the value of IP_TTL |
int | zts_get_ttl(int fd) Return the value of IP_TTL |
int | zts_set_blocking(int fd, int enabled) Change blocking behavior O_NONBLOCK |
int | zts_get_blocking(int fd) Return whether blocking mode O_NONBLOCK is enabled. |
int | zts_set_keepalive(int fd, int enabled) Enable or disable SO_KEEPALIVE |
int | zts_get_keepalive(int fd) Return whether SO_KEEPALIVE is enabled. |
struct zts_hostent * | zts_bsd_gethostbyname(const char * name) Resolve a host-name. |
int | zts_dns_set_server(uint8_t index, const zts_ip_addr * addr) |
const zts_ip_addr * | zts_dns_get_server(uint8_t index) |
int | zts_core_lock_obtain() Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_lock_release() Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_query_addr_count(uint64_t net_id) Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_query_addr(uint64_t net_id, unsigned int idx, char * addr, unsigned int len) Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_query_route_count(uint64_t net_id) Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_query_route(uint64_t net_id, unsigned int idx, char target, char via, unsigned int len, uint16_t flags, uint16_t metric) Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_query_path_count(uint64_t peer_id) Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_query_path(uint64_t peer_id, unsigned int idx, char * dst, unsigned int len) Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_query_mc_count(uint64_t net_id) Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_core_query_mc(uint64_t net_id, unsigned int idx, uint64_t mac, uint32_t adi) Lock the core service so that queries about addresses, routes, paths, etc. can be performed. |
int | zts_util_sign_root_set(char roots_out, unsigned int roots_len, char prev_key, unsigned int prev_key_len, char curr_key, unsigned int curr_key_len, uint64_t id, uint64_t ts, zts_root_set_t * roots_spec) Generates a new root set definition. |
void | zts_util_delay(unsigned long milliseconds) Platform-agnostic delay. |
int | zts_util_get_ip_family(const char * ipstr) Return the family type of the IP string. |
int | zts_util_ipstr_to_saddr(const char src_ipstr, unsigned short port, struct zts_sockaddr dstaddr, zts_socklen_t * addrlen) |
int | zts_util_ntop(struct zts_sockaddr addr, zts_socklen_t addrlen, char dst_str, int len, unsigned short * port) Similar to inet_ntop but determines family automatically and returns port as a value result parameter. |
char * | zts_ipaddr_ntoa(const zts_ip_addr * addr) |
int | zts_ipaddr_aton(const char cp, zts_ip_addr addr) |
const char * | zts_inet_ntop(int family, const void src, char dst, zts_socklen_t size) |
int | zts_inet_pton(int family, const char src, void dst) |
#
AttributesName | |
---|---|
int | zts_errno |
#
Defines#
Detailed DescriptionThis defines the external C API for ZeroTier Sockets
#
Types Documentation#
enum zts_error_tEnumerator | Value | Description |
---|---|---|
ZTS_ERR_OK | 0 | No error |
ZTS_ERR_SOCKET | -1 | Socket error, see zts_errno |
ZTS_ERR_SERVICE | -2 | This operation is not allowed at this time. Or possibly the node hasn't been started |
ZTS_ERR_ARG | -3 | Invalid argument |
ZTS_ERR_NO_RESULT | -4 | No result (not necessarily an error) |
ZTS_ERR_GENERAL | -5 | Consider filing a bug report |
Common error return values
#
enum zts_event_tEnumerator | Value | Description |
---|---|---|
ZTS_EVENT_NODE_UP | 200 | Node has been initialized |
This is the first event generated, and is always sent. It may occur before node's constructor returns. | | ZTS_EVENT_NODE_ONLINE | 201| Node is online – at least one upstream node appears reachable | | ZTS_EVENT_NODE_OFFLINE | 202| Node is offline – network does not seem to be reachable by any available strategy | | ZTS_EVENT_NODE_DOWN | 203| Node is shutting down
This is generated within Node's destructor when it is being shut down. It's done for convenience, since cleaning up other state in the event handler may appear more idiomatic. | | ZTS_EVENT_NODE_FATAL_ERROR | 204| A fatal error has occurred. One possible reason is:
Your identity has collided with another node's ZeroTier address
This happens if two different public keys both hash (via the algorithm in Identity::generate()) to the same 40-bit ZeroTier address.
This is something you should "never" see, where "never" is defined as once per 2^39 new node initializations / identity creations. If you do see it, you're going to see it very soon after a node is first initialized.
This is reported as an event rather than a return code since it's detected asynchronously via error messages from authoritative nodes.
If this occurs, you must shut down and delete the node, delete the identity.secret record/file from the data store, and restart to generate a new identity. If you don't do this, you will not be able to communicate with other nodes.
We'd automate this process, but we don't think silently deleting private keys or changing our address without telling the calling code is good form. It violates the principle of least surprise.
You can technically get away with not handling this, but we recommend doing so in a mature reliable application. Besides, handling this condition is a good way to make sure it never arises. It's like how umbrellas prevent rain and smoke detectors prevent fires. They do, right?
Meta-data: none | | ZTS_EVENT_NETWORK_NOT_FOUND | 210| Network ID does not correspond to a known network | | ZTS_EVENT_NETWORK_CLIENT_TOO_OLD | 211| The version of ZeroTier inside libzt is too old | | ZTS_EVENT_NETWORK_REQ_CONFIG | 212| The configuration for a network has been requested (no action needed) | | ZTS_EVENT_NETWORK_OK | 213| The node joined the network successfully (no action needed) | | ZTS_EVENT_NETWORK_ACCESS_DENIED | 214| The node is not allowed to join the network (you must authorize node) | | ZTS_EVENT_NETWORK_READY_IP4 | 215| The node has received an IPv4 address from the network controller | | ZTS_EVENT_NETWORK_READY_IP6 | 216| The node has received an IPv6 address from the network controller | | ZTS_EVENT_NETWORK_READY_IP4_IP6 | 217| Deprecated | | ZTS_EVENT_NETWORK_DOWN | 218| Network controller is unreachable | | ZTS_EVENT_NETWORK_UPDATE | 219| Network change received from controller | | ZTS_EVENT_STACK_UP | 220| TCP/IP stack (lwIP) is up (for debug purposes) | | ZTS_EVENT_STACK_DOWN | 221| TCP/IP stack (lwIP) id down (for debug purposes) | | ZTS_EVENT_NETIF_UP | 230| lwIP netif up (for debug purposes) | | ZTS_EVENT_NETIF_DOWN | 231| lwIP netif down (for debug purposes) | | ZTS_EVENT_NETIF_REMOVED | 232| lwIP netif removed (for debug purposes) | | ZTS_EVENT_NETIF_LINK_UP | 233| lwIP netif link up (for debug purposes) | | ZTS_EVENT_NETIF_LINK_DOWN | 234| lwIP netif link down (for debug purposes) | | ZTS_EVENT_PEER_DIRECT | 240| A direct P2P path to peer is known | | ZTS_EVENT_PEER_RELAY | 241| A direct P2P path to peer is NOT known. Traffic is now relayed | | ZTS_EVENT_PEER_UNREACHABLE | 242| A peer is unreachable. Check NAT/Firewall settings | | ZTS_EVENT_PEER_PATH_DISCOVERED | 243| A new path to a peer was discovered | | ZTS_EVENT_PEER_PATH_DEAD | 244| A known path to a peer is now considered dead | | ZTS_EVENT_ROUTE_ADDED | 250| A new managed network route was added | | ZTS_EVENT_ROUTE_REMOVED | 251| A managed network route was removed | | ZTS_EVENT_ADDR_ADDED_IP4 | 260| A new managed IPv4 address was assigned to this peer | | ZTS_EVENT_ADDR_REMOVED_IP4 | 261| A managed IPv4 address assignment was removed from this peer | | ZTS_EVENT_ADDR_ADDED_IP6 | 262| A new managed IPv4 address was assigned to this peer | | ZTS_EVENT_ADDR_REMOVED_IP6 | 263| A managed IPv6 address assignment was removed from this peer | | ZTS_EVENT_STORE_IDENTITY_SECRET | 270| The node's secret key (identity) | | ZTS_EVENT_STORE_IDENTITY_PUBLIC | 271| The node's public key (identity) | | ZTS_EVENT_STORE_PLANET | 272| The node has received an updated planet config | | ZTS_EVENT_STORE_PEER | 273| New reachability hints and peer configuration | | ZTS_EVENT_STORE_NETWORK | 274| New network config |
Event codes used by the (optional) callback API
#
enum zts_errno_tEnumerator | Value | Description |
---|---|---|
ZTS_EPERM | 1 | Operation not permitted (zts_errno value) |
ZTS_ENOENT | 2 | No such file or directory |
ZTS_ESRCH | 3 | No such process |
ZTS_EINTR | 4 | Interrupted system call |
ZTS_EIO | 5 | I/O error |
ZTS_ENXIO | 6 | No such device or address |
ZTS_EBADF | 9 | Bad file number |
ZTS_EAGAIN | 11 | Try again |
ZTS_EWOULDBLOCK | ZTS_EAGAIN | Operation would block |
ZTS_ENOMEM | 12 | Out of memory |
ZTS_EACCES | 13 | Permission denied |
ZTS_EFAULT | 14 | Bad address |
ZTS_EBUSY | 16 | Device or resource busy |
ZTS_EEXIST | 17 | File exists |
ZTS_ENODEV | 19 | No such device |
ZTS_EINVAL | 22 | Invalid argument |
ZTS_ENFILE | 23 | File table overflow |
ZTS_EMFILE | 24 | Too many open files |
ZTS_ENOSYS | 38 | Function not implemented |
ZTS_ENOTSOCK | 88 | Socket operation on non-socket |
ZTS_EDESTADDRREQ | 89 | Destination address required |
ZTS_EMSGSIZE | 90 | Message too long |
ZTS_EPROTOTYPE | 91 | Protocol wrong type for socket |
ZTS_ENOPROTOOPT | 92 | Protocol not available |
ZTS_EPROTONOSUPPORT | 93 | Protocol not supported |
ZTS_ESOCKTNOSUPPORT | 94 | Socket type not supported |
ZTS_EOPNOTSUPP | 95 | Operation not supported on transport endpoint |
ZTS_EPFNOSUPPORT | 96 | Protocol family not supported |
ZTS_EAFNOSUPPORT | 97 | Address family not supported by protocol |
ZTS_EADDRINUSE | 98 | Address already in use |
ZTS_EADDRNOTAVAIL | 99 | Cannot assign requested address |
ZTS_ENETDOWN | 100 | Network is down |
ZTS_ENETUNREACH | 101 | Network is unreachable |
ZTS_ECONNABORTED | 103 | Software caused connection abort |
ZTS_ECONNRESET | 104 | Connection reset by peer |
ZTS_ENOBUFS | 105 | No buffer space available |
ZTS_EISCONN | 106 | Transport endpoint is already connected |
ZTS_ENOTCONN | 107 | Transport endpoint is not connected |
ZTS_ETIMEDOUT | 110 | Connection timed out |
ZTS_EHOSTUNREACH | 113 | No route to host |
ZTS_EALREADY | 114 | Operation already in progress |
ZTS_EINPROGRESS | 115 | Operation now in progress |
#
enum zts_network_status_tEnumerator | Value | Description |
---|---|---|
ZTS_NETWORK_STATUS_REQUESTING_CONFIGURATION | 0 | Waiting for network configuration (also means revision == 0) |
ZTS_NETWORK_STATUS_OK | 1 | Configuration received and we are authorized |
ZTS_NETWORK_STATUS_ACCESS_DENIED | 2 | Netconf master told us 'nope' |
ZTS_NETWORK_STATUS_NOT_FOUND | 3 | Netconf master exists, but this virtual network does not |
ZTS_NETWORK_STATUS_PORT_ERROR | 4 | Initialization of network failed or other internal error |
ZTS_NETWORK_STATUS_CLIENT_TOO_OLD | 5 | ZeroTier core version too old |
Virtual network status codes
#
enum zts_net_info_type_tEnumerator | Value | Description |
---|---|---|
ZTS_NETWORK_TYPE_PRIVATE | 0 | Private networks are authorized via certificates of membership |
ZTS_NETWORK_TYPE_PUBLIC | 1 | Public networks have no access control – they'll always be AUTHORIZED |
Virtual network type codes
#
enum zts_peer_role_tEnumerator | Value | Description |
---|---|---|
ZTS_PEER_ROLE_LEAF | 0 | Ordinary node |
ZTS_PEER_ROLE_MOON | 1 | Moon root |
ZTS_PEER_ROLE_PLANET | 2 | Planetary root |
The peer's trust hierarchy role
#
typedef zts_socklen_t#
typedef zts_in_addr_t#
typedef zts_in_port_t#
typedef zts_sa_family_t#
typedef zts_ip_mreq#
typedef zts_ipv6_mreq#
typedef zts_fd_set#
typedef zts_timeval#
typedef zts_nfds_t#
typedef zts_ip_addrA union struct for both IP version's addresses. ATTENTION: watch out for its size when adding IPv6 address scope!
#
Functions Documentation#
function zts_id_newGenerates a node identity (public/secret key-pair) and stores it in a user-provided buffer.
Parameters:
- key User-provided destination buffer
- key_buf_len Length of user-provided destination buffer. Will be set to the number of bytes copied.
Return: ZTS_ERR_OK
if successful, ZTS_ERR_ARG
if invalid argument.
#
function zts_id_pair_is_validVerifies that a key-pair is valid. Checks formatting and pairing of key to address.
Parameters:
- key Buffer containing key-pair
- len Length of key-pair buffer
Return: 1
if true, 0
if false.
#
function zts_init_from_storageInstruct ZeroTier to look for node identity files at the given location. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- port Path Null-terminated file-system path string
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
Note that calling this function is not mandatory and if it is not called the node's keys will be kept in memory and retrievable via zts_node_get_id_pair() .
See also: zts_init_from_memory()
#
function zts_init_from_memoryInstruct ZeroTier to use the identity provided in key
. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- key Path Null-terminated file-system path string
- len Length of
key
buffer
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
Note that calling this function is not mandatory and if it is not called the node's keys will be kept in memory and retrievable via zts_node_get_id_pair() .
See also: zts_init_from_storage()
#
function zts_init_set_event_handlerSet the event handler function. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- callback A function pointer to the event handler function
- family
ZTS_AF_INET
, orZTS_AF_INET6
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_init_blacklist_ifBlacklist an interface prefix (or name). This prevents ZeroTier from sending traffic over matching interfaces. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- prefix Null-terminated interface prefix string
- len Length of prefix string
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_init_set_rootsPresent a root set definition for ZeroTier to use instead of the default. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- roots_data Array of roots definition data (binary)
- len Length of binary data
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_init_set_portSet the port to which the node should bind. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- port Port number
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_init_set_random_port_rangeSet range that random ports will be selected from. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- start_port Start of port range
- end_port End of port range
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_init_allow_secondary_portAllow or disallow ZeroTier from automatically selecting a backup port to help get through buggy NAT. This is enabled by default. This port is randomly chosen and should be disabled if you want to control exactly which ports ZeroTier talks on and (iff) you know with absolute certainty that traffic on your chosen primary port is allowed. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- port Port number
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_init_allow_port_mappingAllow or disallow the use of port-mapping. This is enabled by default. This is an initialization function that can only be called before zts_node_start() .
Parameters:
- port Port number
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_init_allow_net_cacheEnable or disable whether the node will cache network details (enabled by default when zts_init_from_storage() is used.) Must be called before zts_node_start() .
Parameters:
- enabled Whether or not this feature is enabled
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
This can potentially shorten (startup) times between node restarts. This allows the service to nearly instantly inform the network stack of an address to use for this peer so that it can create a transport service. This can be disabled for cases where one may not want network config details to be written to storage. This is especially useful for situations where address assignments do not change often.
See also: zts_init_allow_peer_cache()
#
function zts_init_allow_peer_cacheEnable or disable whether the node will cache peer details (enabled by default when zts_init_from_storage() is used.) Must be called before zts_node_start() .
Parameters:
- enabled Whether or not this feature is enabled
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
This can potentially shorten (connection) times between node restarts. This allows the service to re-use previously discovered paths to a peer, this prevents the service from having to go through the entire transport-triggered link provisioning process. This is especially useful for situations where paths to peers do not change often. This is enabled by default and can be disabled for cases where one may not want peer details to be written to storage.
See also: zts_init_allow_net_cache()
#
function zts_init_allow_roots_cacheEnable or disable whether the node will cache root definitions (enabled by default when zts_init_from_storage() is used.) Must be called before zts_node_start() .
Parameters:
- enabled Whether or not this feature is enabled
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_init_allow_id_cacheEnable or disable whether the node will cache identities (enabled by default when zts_init_from_storage() is used.) Must be called before zts_node_start() .
Parameters:
- enabled Whether or not this feature is enabled
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_addr_is_assignedReturn whether an address of the given family has been assigned by the network.
Parameters:
- net_id Network ID
- family
ZTS_AF_INET
, orZTS_AF_INET6
Return: 1
if true, 0
if false.
#
function zts_addr_getGet the first-assigned IP on the given network.
Parameters:
- net_id Network ID
- family
ZTS_AF_INET
, orZTS_AF_INET6
- addr Destination buffer to hold address
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
To get all assigned addresses on a given network, use zts_addr_get_all() .
#
function zts_addr_get_strGet the first-assigned IP on the given network as a null-terminated human-readable string.
Parameters:
- net_id Network ID
- family
ZTS_AF_INET
, orZTS_AF_INET6
- dst Destination buffer
- len Length of destination buffer (must be exactly
ZTS_IP_MAX_STR_LEN
)
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
To get all assigned addresses on a given network, use zts_addr_get_all() .
#
function zts_addr_get_allGet all IP addresses assigned to this node by the given network.
Parameters:
- net_id Network ID
- addr Destination buffer to hold address
- count Number of addresses returned
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_addr_compute_6planeCompute a 6PLANE
IPv6 address for the given Network ID and Node ID.
Parameters:
- net_id Network ID
- node_id Node ID
- addr Destination structure for address
Return: ZTS_ERR_OK
if successful, ZTS_ERR_ARG
if invalid argument.
#
function zts_addr_compute_rfc4193Compute RFC4193
IPv6 address for the given Network ID and Node ID.
Parameters:
- net_id Network ID
- node_id Node ID
- addr Destination structure for address
Return: ZTS_ERR_OK
if successful, ZTS_ERR_ARG
if invalid argument.
#
function zts_addr_compute_rfc4193_strCompute RFC4193
IPv6 address for the given Network ID and Node ID and copy its null-terminated human-readable string representation into destination buffer.
Parameters:
- net_id Network ID
- node_id Node ID
- dst Destination string buffer
- len Length of destination string buffer (must be exactly
ZTS_IP_MAX_STR_LEN
)
Return: ZTS_ERR_OK
if successful, ZTS_ERR_ARG
if invalid argument.
#
function zts_addr_compute_6plane_strCompute 6PLANE
IPv6 address for the given Network ID and Node ID and copy its null-terminated human-readable string representation into destination buffer.
Parameters:
- net_id Network ID
- node_id Node ID
- dst Destination string buffer
- len Length of destination string buffer (must be exactly
ZTS_IP_MAX_STR_LEN
)
Return: ZTS_ERR_OK
if successful, ZTS_ERR_ARG
if invalid argument.
#
function zts_net_compute_adhoc_idCompute RFC4193
IPv6 address for the given Network ID and Node ID.
Parameters:
- start_port Start of port allowed port range
- end_port End of allowed port range
Return: An Ad-hoc network ID
Ad-hoc Network:
Ad-hoc networks are public (no access control) networks that have no network controller. Instead their configuration and other credentials are generated locally. Ad-hoc networks permit only IPv6 UDP and TCP unicast traffic (no multicast or broadcast) using 6plane format NDP-emulated IPv6 addresses. In addition an ad-hoc network ID encodes an IP port range. UDP packets and TCP SYN (connection open) packets are only allowed to destination ports within the encoded range.
For example ff00160016000000
is an ad-hoc network allowing only SSH, while ff0000ffff000000
is an ad-hoc network allowing any UDP or TCP port.
Keep in mind that these networks are public and anyone in the entire world can join them. Care must be taken to avoid exposing vulnerable services or sharing unwanted files or other resources.
#
function zts_net_joinJoin a network.
Parameters:
- net_id Network ID
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_net_leaveLeave a network.
Parameters:
- net_id Network ID
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_net_transport_is_readyReturn whether this network is ready to send and receive traffic.
Return: 1
if true, 0
if false.
#
function zts_net_get_macGet the MAC Address for this node on the given network.
Parameters:
- net_id Network ID
Return: MAC address in numerical format
#
function zts_net_get_mac_strGet the MAC Address for this node on the given network.
Parameters:
- net_id Network ID
- dst Destination string buffer
- len Length of destination string buffer. Must be exactly
ZTS_MAC_ADDRSTRLEN
Return: MAC address in string format
#
function zts_net_get_broadcastReturn whether broadcast is enabled on this network.
Parameters:
- net_id Network ID
Return: 1
if true, 0
if false.
#
function zts_net_get_mtuGet the MTU of the given network.
Parameters:
- net_id Network ID
Return: MTU
#
function zts_net_get_nameGet the nickname of the network.
Parameters:
- net_id Network ID
- dst Destination string buffer
- len Length of destination string buffer
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_net_get_statusGet the status of the network.
Parameters:
- net_id Network ID
Return: Status
#
function zts_net_get_typeGet the type of network (public or private.)
Parameters:
- net_id Network ID
Return: Type
#
function zts_route_is_assignedReturn whether a managed route of the given address family has been assigned by the network.
Parameters:
- net_id Network ID
- family
ZTS_AF_INET
, orZTS_AF_INET6
Return: 1
if true, 0
if false.
#
function zts_node_startStart the ZeroTier node. Should be called after calling the relevant zts_init_*
functions for your application. To enable storage call zts_init_from_storage() before this function. To enable event callbacks call zts_init_set_event_handler() before this function.
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem.
Note: If neither zts_init_from_storage() or zts_init_from_memory() are called a new identity will be generated and will be retrievable via zts_node_get_id_pair() after the node has started.
#
function zts_node_is_onlineReturn whether the node is online (Can reach the Internet)
Return: 1
if true, 0
if false.
#
function zts_node_get_idGet the public node identity (aka node_id
). Callable only after the node has been started.
Return: Identity in numerical form
#
function zts_node_get_id_pairCopy the current node's public (and secret!) identity into a buffer.
Parameters:
- key User-provided destination buffer
- key_dst_len Length of user-provided destination buffer. Will be set to number of bytes copied.
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
WARNING
: This function exports your secret key and should be used carefully.#
function zts_node_get_portGet the primary port to which the node is bound. Callable only after the node has been started.
Return: Port number
#
function zts_node_stopStop the ZeroTier node and bring down all virtual network transport services. Callable only after the node has been started.
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem.
While the ZeroTier will stop, the stack driver (with associated timers) will remain active in case future traffic processing is required. To stop all activity and free all resources use zts_free()
instead.
#
function zts_node_freeStop all background threads, bring down all transport services, free all resources. After calling this function an application restart will be required before the library can be used again. Callable only after the node has been started.
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem.
This should be called at the end of your program or when you do not anticipate communicating over ZeroTier again.
#
function zts_moon_orbitOrbit a given moon (user-defined root server)
Parameters:
- moon_roots_id World ID
- moon_seed Seed ID
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_moon_deorbitDe-orbit a given moon (user-defined root server)
Parameters:
- moon_roots_id World ID
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument.
#
function zts_stats_get_allGet all statistical counters for all protocols and levels. See also: lwip/stats.h.
Parameters:
- dst Pointer to structure that will be populated with statistics
Return: ZTS_ERR_OK on success. ZTS_ERR_ARG or ZTS_ERR_NO_RESULT on failure.
This function can only be used in debug builds.
#
function zts_bsd_socketCreate a socket.
Parameters:
- family
ZTS_AF_INET
orZTS_AF_INET6
- type
ZTS_SOCK_STREAM
orZTS_SOCK_DGRAM
- protocol Protocols supported on this socket
Return: Numbered file descriptor on success, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_connectConnect a socket to a remote host.
Parameters:
- fd Socket file descriptor
- addr Remote host address to connect to
- addrlen Length of address
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_bindBind a socket to a local address.
Parameters:
- fd Socket file descriptor
- addr Local interface address to bind to
- addrlen Length of address
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_listenListen for incoming connections on socket.
Parameters:
- fd Socket file descriptor
- backlog Number of backlogged connections allowed
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_acceptAccept an incoming connection.
Parameters:
- fd Socket file descriptor
- addr Address of remote host for accepted connection
- addrlen Length of address
Return: New file descriptor if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_setsockoptSet socket options.
Parameters:
- fd Socket file descriptor
- level Protocol level to which option name should apply
- optname Option name to set
- optval Source of option value to set
- optlen Length of option value
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_getsockoptGet socket options.
Parameters:
- fd Socket file descriptor
- level Protocol level to which option name should apply
- optname Option name to get
- optval Where option value will be stored
- optlen Length of value
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_getsocknameGet the name (address) of the local end of the socket.
Parameters:
- fd Socket file descriptor
- addr Name associated with this socket
- addrlen Length of name
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_getpeernameGet the name (address) of the remote end of the socket.
Parameters:
- fd Socket file descriptor
- addr Name associated with remote end of this socket
- addrlen Length of name
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_closeClose socket.
Parameters:
- fd Socket file descriptor
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_selectMonitor multiple file descriptors for "readiness".
Parameters:
- nfds Set to the highest numbered file descriptor in any of the given sets
- readfds Set of file descriptors to monitor for READ readiness
- writefds Set of file descriptors to monitor for WRITE readiness
- exceptfds Set of file descriptors to monitor for exceptional conditions
- timeout How long this call should block
Return: Number of ready file descriptors on success. ZTS_ERR_SOCKET
, ZTS_ERR_SERVICE
on failure. Sets zts_errno
#
function zts_bsd_fcntlIssue file control commands on a socket.
Parameters:
- fd Socket file descriptor
- cmd Operation to be performed
- flags Flags
Return:
#
function zts_bsd_pollWait for some event on a file descriptor.
Parameters:
- fds Set of file descriptors to monitor
- nfds Number of elements in the fds array
- timeout How long this call should block
Return: Number of ready file descriptors if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_ioctlControl a device.
Parameters:
- fd Socket file descriptor
- request Selects the control function to be performed
- argp Additional information
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_sendSend data to remote host.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of data to write
- flags (e.g.
ZTS_MSG_DONTWAIT
,ZTS_MSG_MORE
)
Return: Number of bytes sent if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_sendtoSend data to remote host.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of data to write
- flags Specifies type of message transmission
- addr Destination address
- addrlen Length of destination address
Return: Number of bytes sent if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_sendmsgSend message to remote host.
Parameters:
- fd Socket file descriptor
- msg Message to send
- flags Specifies type of message transmission
Return: Number of bytes sent if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_recvReceive data from remote host.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of data buffer
- flags Specifies the type of message receipt
Return: Number of bytes received if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_recvfromReceive data from remote host.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of data buffer
- flags Specifies the type of message receipt
- addr Destination address buffer
- addrlen Length of destination address buffer
Return: Number of bytes received if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_recvmsgReceive a message from remote host.
Parameters:
- fd Socket file descriptor
- msg Message that was received
- flags Specifies the type of message receipt
Return: Number of bytes received if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_readRead data from socket onto buffer.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of data buffer to receive data
Return: Number of bytes read if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_readvRead data from socket into multiple buffers.
Parameters:
- fd Socket file descriptor
- iov Array of destination buffers
- iovcnt Number of buffers to read into
Return: Number of bytes read if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_writeWrite data from buffer to socket.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of buffer to write
Return: Number of bytes written if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_writevWrite data from multiple buffers to socket.
Parameters:
- fd Socket file descriptor
- iov Array of source buffers
- iovcnt Number of buffers to read from
Return: Number of bytes written if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_shutdownShut down some aspect of a socket.
Parameters:
- fd Socket file descriptor
- how Which aspects of the socket should be shut down. Options are
ZTS_SHUT_RD
,ZTS_SHUT_WR
, orZTS_SHUT_RDWR
.
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_socketCreate a socket.
Parameters:
- family
ZTS_AF_INET
orZTS_AF_INET6
- type
ZTS_SOCK_STREAM
orZTS_SOCK_DGRAM
- protocol Protocols supported on this socket
Return: Numbered file descriptor on success, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
A subset (and) extension of the traditional BSD-style socket API that simplifies API wrapper generation and usage in other non-C-like languages. Uses simple integer types instead of bit flags, limit the number of operations each function performs, prevent the user from needing to manipulate the contents of structures in a non-native language.
#
function zts_connectConnect a socket to a remote host.
Parameters:
- fd Socket file descriptor
- ipstr Human-readable IP string
- port Port
- timeout_ms (Approximate) amount of time in milliseconds before connection attempt is aborted. Will block for
30 seconds
if timeout is set to0
.
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SOCKET
if the function times out with no connection made, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
This convenience function exists because ZeroTier uses transport-triggered links. This means that links between peers do not exist until peers try to talk to each other. This can be a problem during connection procedures since some of the initial packets are lost. To alleviate the need to try zts_bsd_connect
many times, this function will keep re-trying for you, even if no known routes exist. However, if the socket is set to non-blocking
mode it will behave identically to zts_bsd_connect
and return immediately upon failure.
#
function zts_bindBind a socket to a local address.
Parameters:
- fd Socket file descriptor
- ipstr Human-readable IP string
- port Port
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_listenListen for incoming connections on socket.
Parameters:
- fd Socket file descriptor
- backlog Number of backlogged connections allowed
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_acceptAccept an incoming connection.
Parameters:
- fd Socket file descriptor
- remote_addr Buffer that will receive remote host IP string
- len Size of buffer that will receive remote host IP string (must be exactly
ZTS_IP_MAX_STR_LEN
) - port Port number of the newly connected remote host (value-result)
Return: New file descriptor if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_sendSend data to remote host.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of data to write
- flags (e.g.
ZTS_MSG_DONTWAIT
,ZTS_MSG_MORE
)
Return: Number of bytes sent if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_recvReceive data from remote host.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of data buffer
- flags Specifies the type of message receipt
Return: Number of bytes received if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_readRead data from socket onto buffer.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of data buffer to receive data
Return: Number of bytes read if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_writeWrite data from buffer to socket.
Parameters:
- fd Socket file descriptor
- buf Pointer to data buffer
- len Length of buffer to write
Return: Number of bytes written if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_shutdown_rdShut down read
aspect of a socket.
Parameters:
- fd Socket file descriptor
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_shutdown_wrShut down write
aspect of a socket.
Parameters:
- fd Socket file descriptor
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_shutdown_rdwrShut down both read
and write
aspect of a socket.
Parameters:
- fd Socket file descriptor
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_closeClose socket.
Parameters:
- fd Socket file descriptor
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_getpeernameGet the name (address) of the remote end of the socket.
Parameters:
- fd Socket file descriptor
- remote_addr_str Destination buffer to contain name (address) of the remote end of the socket
- len Length of destination buffer
- port Value-result parameter that will contain resultant port number
Return: ZTS_ERR_OK
if successful, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_getsocknameGet the name (address) of the local end of the socket.
Parameters:
- fd Socket file descriptor
- local_addr_str Destination buffer to contain name (address) of the local end of the socket
- len Length of destination buffer
- port Value-result parameter that will contain resultant port number
Return: ZTS_ERR_OK
if successful, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_tcp_clientA convenience function that takes a remote address IP string and creates the appropriate type of socket, and uses it to connect to a remote host.
Parameters:
- remote_ipstr Remote address string. IPv4 or IPv6
- remote_port Port to
Return: New file descriptor if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_tcp_serverA convenience function that takes a remote address IP string and creates the appropriate type of socket, binds, listens, and then accepts on it.
Parameters:
- local_ipstr Local address to bind
- local_port Local port to bind
- remote_ipstr String-format IP address of newly connected remote host
- len Length of
remote_ipstr
- remote_port Port of remote host
Return: New file descriptor if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_udp_serverA convenience function that takes a remote address IP string and creates the appropriate type of socket, and binds to it.
Parameters:
- local_ipstr Local address to bind
- local_port Local port to bind
Return: New file descriptor if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_udp_clientThis function doesn't really do anything other than be a namespace counterpart to zts_udp_server
. All this function does is create a ZTS_SOCK_DGRAM
socket and return its file descriptor.
Parameters:
- remote_ipstr Remote address string. IPv4 or IPv6
Return: New file descriptor if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_no_delayEnable or disable TCP_NODELAY
. Enabling this is equivalent to turning off Nagle's algorithm.
Parameters:
- fd Socket file descriptor
- enabled
[0, 1]
integer value
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_last_socket_errorGet the last error for the given socket.
Parameters:
- fd Socket file descriptor
Return: Error number defined in zts_errno_t
. ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_data_availableReturn amount of data available to read from socket.
Parameters:
- fd Socket file descriptor
Return: Number of bytes available to read. ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_no_delayReturn whether TCP_NODELAY
is enabled.
Parameters:
- fd Socket file descriptor
Return: 1
if enabled, 0
if disabled, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_lingerEnable or disable SO_LINGER
while also setting its value.
Parameters:
- fd Socket file descriptor
- enabled
[0, 1]
integer value - value How long socket should linger
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_linger_enabledReturn whether SO_LINGER
is enabled.
Parameters:
- fd Socket file descriptor
Return: 1
if enabled, 0
if disabled, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_linger_valueReturn the value of SO_LINGER
Parameters:
- fd Socket file descriptor
Return: Value of SO_LINGER
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_pending_data_sizeReturn the number of bytes available to read from the network buffer.
Parameters:
- fd Socket file descriptor
Return: Number of bytes to read if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_reuse_addrEnable or disable SO_REUSEADDR
Parameters:
- fd Socket file descriptor
- enabled
[0, 1]
integer value
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_reuse_addrReturn whether SO_REUSEADDR
is enabled.
Parameters:
- fd Socket file descriptor
Return: 1
if enabled, 0
if disabled, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_recv_timeoutSet the value of SO_RCVTIMEO
Parameters:
- fd Socket file descriptor
- seconds Number of seconds for timeout
- microseconds Number of microseconds for timeout
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_recv_timeoutReturn the value of SO_RCVTIMEO
Parameters:
- fd Socket file descriptor
Return: Value of SO_RCVTIMEO
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_send_timeoutSet the value of SO_SNDTIMEO
Parameters:
- fd Socket file descriptor
- seconds Number of seconds for timeout
- microseconds Number of microseconds for timeout
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_send_timeoutReturn the value of SO_SNDTIMEO
Parameters:
- fd Socket file descriptor
Return: Value of SO_SNDTIMEO
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_send_buf_sizeSet the value of SO_SNDBUF
Parameters:
- fd Socket file descriptor
- size Size of buffer
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_send_buf_sizeReturn the value of SO_SNDBUF
Parameters:
- fd Socket file descriptor
Return: Value of SO_SNDBUF
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_recv_buf_sizeSet the value of SO_RCVBUF
Parameters:
- fd Socket file descriptor
- size Size of buffer
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_recv_buf_sizeReturn the value of SO_RCVBUF
Parameters:
- fd Socket file descriptor
Return: Value of SO_RCVBUF
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_ttlSet the value of IP_TTL
Parameters:
- fd Socket file descriptor
- ttl Value of
IP_TTL
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_ttlReturn the value of IP_TTL
Parameters:
- fd Socket file descriptor
Return: Value of IP_TTL
[0,255]
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_blockingChange blocking behavior O_NONBLOCK
Parameters:
- fd Socket file descriptor
- enabled
[0, 1]
integer value,1
maintains default behavior,0
sets to non-blocking mode
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_blockingReturn whether blocking mode O_NONBLOCK
is enabled.
Parameters:
- fd Socket file descriptor
Return: 1
if enabled, 0
if disabled, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_set_keepaliveEnable or disable SO_KEEPALIVE
Parameters:
- fd Socket file descriptor
- enabled
[0, 1]
integer value
Return: ZTS_ERR_OK
if successful, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_get_keepaliveReturn whether SO_KEEPALIVE
is enabled.
Parameters:
- fd Socket file descriptor
Return: 1
if enabled, 0
if disabled, ZTS_ERR_SERVICE
if the node experiences a problem, ZTS_ERR_ARG
if invalid argument. Sets zts_errno
#
function zts_bsd_gethostbynameResolve a host-name.
Parameters:
- name A null-terminated string representing the name of the host
Return: Pointer to struct zts_hostent if successful, NULL otherwise
#
function zts_dns_set_serverParameters:
- index the index of the DNS server to set must be
< DNS_MAX_SERVERS
- addr IP address of the DNS server to set
Initialize one of the DNS servers.
#
function zts_dns_get_serverParameters:
- index the index of the DNS server
Return: IP address of the indexed DNS server or ip_addr_any
if the DNS server has not been configured.
Obtain one of the currently configured DNS server.
#
function zts_core_lock_obtainLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing.
#
function zts_core_lock_releaseLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing.
#
function zts_core_query_addr_countLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing. zts_core_lock_obtain() and zts_core_lock_release() must be called before and after this function.
#
function zts_core_query_addrLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing. zts_core_lock_obtain() and zts_core_lock_release() must be called before and after this function.
#
function zts_core_query_route_countLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing. zts_core_lock_obtain() and zts_core_lock_release() must be called before and after this function.
#
function zts_core_query_routeLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing. zts_core_lock_obtain() and zts_core_lock_release() must be called before and after this function.
#
function zts_core_query_path_countLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing. zts_core_lock_obtain() and zts_core_lock_release() must be called before and after this function.
#
function zts_core_query_pathLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing. zts_core_lock_obtain() and zts_core_lock_release() must be called before and after this function.
#
function zts_core_query_mc_countLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing. zts_core_lock_obtain() and zts_core_lock_release() must be called before and after this function.
#
function zts_core_query_mcLock the core service so that queries about addresses, routes, paths, etc. can be performed.
Return: ZTS_ERR_OK
if successful. ZTS_ERR_SERVICE
if the core service is unavailable.
Notice: Core locking functions are intended to be used by high-level language wrappers. Only lock the core if you know exactly what you are doing. zts_core_lock_obtain() and zts_core_lock_release() must be called before and after this function.
#
function zts_util_sign_root_setGenerates a new root set definition.
Parameters:
- roots_id The desired World ID (arbitrary)
- ts Timestamp indicating when this generation took place
#
function zts_util_delayPlatform-agnostic delay.
Parameters:
- milliseconds How long to delay
#
function zts_util_get_ip_familyReturn the family type of the IP string.
Parameters:
- ipstr Either IPv4 or IPv6 string
Return: Either ZTS_AF_INET
or ZTS_AF_INET6
#
function zts_util_ipstr_to_saddrParameters:
- src_ipstr Source IP string
- port Port
- dstaddr Pointer to destination structure zts_sockaddr_in or zts_sockaddr_in6
- addrlen Size of destination structure. Value-result: Will be set to actual size of data available
Return: return ZTS_ERR_OK
on success, ZTS_ERR_ARG
if invalid argument
Convert human-friendly IP string to zts_sockaddr_in or zts_sockaddr_in6 .
#
function zts_util_ntopSimilar to inet_ntop
but determines family automatically and returns port as a value result parameter.
Parameters:
- addr Pointer to address structure
- addrlen Length of address structure
- dst_str Destination buffer
- len Length of destination buffer
- port Value-result parameter that will contain resultant port number
Return: return ZTS_ERR_OK
on success, ZTS_ERR_ARG
if invalid argument
#
function zts_ipaddr_ntoaParameters:
- addr IP address in network order to convert
Return: Pointer to a global static (!) buffer that holds the ASCII
representation of addr
Convert numeric IP address (both versions) into ASCII
representation. returns ptr to static buffer. Not reentrant.
#
function zts_ipaddr_atonParameters:
- cp IP address string to convert
- addr conversion result is stored here
Return: 1
on success, 0
on error
Convert IP address string (both versions) to numeric. The version is auto-detected from the string.
#
function zts_inet_ntopParameters:
- family Address family:
ZTS_AF_INET
orZTS_AF_INET6
- src Pointer to source address structure
- dst Pointer to destination character array
- size Size of the destination buffer
Return: On success, returns a non-null pointer to the destination character array
Convert IPv4 and IPv6 address structures to human-readable text form.
#
function zts_inet_ptonParameters:
- family Address family:
ZTS_AF_INET
orZTS_AF_INET6
- src Pointer to source character array
- dst Pointer to destination address structure
Return: return 1
on success. 0
or -1
on failure. (Does not follow regular zts_*
conventions)
Convert C-string IPv4 and IPv6 addresses to binary form.
#
Attributes Documentation#
variable zts_errnoError variable set after each zts_*
socket call. Provides additional error context.
#
Macro Documentation#
define ZTS_MAC_ADDRSTRLENLength of human-readable MAC address string
#
define ZTS_INET_ADDRSTRLENMax length of human-readable IPv4 string
#
define ZTS_INET6_ADDRSTRLENMax length of human-readable IPv6 string
#
define ZTS_IP_MAX_STR_LENMaximum (and required) length of string buffers used to receive string-format IP addresses from the API. This is set to ZTS_INET6_ADDRSTRLEN
to handle all cases: ZTS_AF_INET
and ZTS_AF_INET6
#
define ZTS_STORE_DATA_LENRequired buffer length to safely receive data store items
#
define ZTS_MAX_NETWORK_SHORT_NAME_LENGTHMaximum length of network short name
#
define ZTS_MAX_NETWORK_ROUTESMaximum number of pushed routes on a network
#
define ZTS_MAX_ASSIGNED_ADDRESSESMaximum number of statically assigned IP addresses per network endpoint using ZT address management (not DHCP)
#
define ZTS_MAX_PEER_NETWORK_PATHSMaximum number of direct network paths to a given peer
#
define ZTS_MAX_MULTICAST_SUBSCRIPTIONSMaximum number of multicast groups a device / network interface can be subscribed to at once
#
define ZTS_MAX_ENDPOINT_STR_LEN#
define ZTS_C_API_ONLY#
define ZTS_IPADDR_NONE255.255.255.255
#
define ZTS_IPADDR_LOOPBACK127.0.0.1
#
define ZTS_IPADDR_ANY0.0.0.0
#
define ZTS_IPADDR_BROADCAST255.255.255.255
#
define ZTS_INADDR_NONE255.255.255.255
#
define ZTS_INADDR_LOOPBACK127.0.0.1
#
define ZTS_INADDR_ANY0.0.0.0
#
define ZTS_INADDR_BROADCAST255.255.255.255
#
define ZTS_SOCK_STREAM#
define ZTS_SOCK_DGRAM#
define ZTS_SOCK_RAW#
define ZTS_AF_UNSPEC#
define ZTS_AF_INET#
define ZTS_AF_INET6#
define ZTS_PF_INET#
define ZTS_PF_INET6#
define ZTS_PF_UNSPEC#
define ZTS_IPPROTO_IP#
define ZTS_IPPROTO_ICMP#
define ZTS_IPPROTO_TCP#
define ZTS_IPPROTO_UDP#
define ZTS_IPPROTO_IPV6#
define ZTS_IPPROTO_ICMPV6#
define ZTS_IPPROTO_UDPLITE#
define ZTS_IPPROTO_RAW#
define ZTS_MSG_PEEK#
define ZTS_MSG_WAITALL#
define ZTS_MSG_OOB#
define ZTS_MSG_DONTWAIT#
define ZTS_MSG_MORE#
define ZTS_IOCPARM_MASK#
define ZTS_IOC_VOID#
define ZTS_IOC_OUT#
define ZTS_IOC_IN#
define ZTS_IOC_INOUT#
define ZTS_IO#
define ZTS_IOR#
define ZTS_IOW#
define ZTS_FIONREAD#
define ZTS_FIONBIO#
define SIN_ZERO_LEN#
define ZTS_MAX_NUM_ROOTS#
define ZTS_MAX_ENDPOINTS_PER_ROOT#
define ZTS_API#
define ZTCALL#
define ZTS_DISABLE_CENTRAL_API#
define ZTS_ID_STR_BUF_LENThe length of a human-friendly identity key pair string