aboutsummaryrefslogtreecommitdiff
path: root/src/nng.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-07-21 16:11:16 -0700
committerGarrett D'Amore <garrett@damore.org>2017-09-26 13:26:18 -0700
commit86a96e5bf1b207a8b1aa925e1d9f73ce834505b8 (patch)
tree53e7d9042cf8d72c723767cf31ef950594cbf736 /src/nng.h
parent52118e4dcbc105d2b83c774e001926aceb978488 (diff)
downloadnng-86a96e5bf1b207a8b1aa925e1d9f73ce834505b8.tar.gz
nng-86a96e5bf1b207a8b1aa925e1d9f73ce834505b8.tar.bz2
nng-86a96e5bf1b207a8b1aa925e1d9f73ce834505b8.zip
ZeroTier transport implementation (work funded by Capitar IT Group BV)
The ZeroTier transport is experimental at this point, and not enabled by default. It does not work with Windows yet (the Windows platform needs UDP support first.) Configure with -DNNG_ENABLE_ZEROTIER=yes -DNNG_ZEROTIER_SOUCE=<path> The <path> must point to a dev branch of the ZeroTierOne source tree, checked out, and built with a libzerotiercore.a in the top directory, and a ZeroTierOne.h header located at include. The build will add -lc++ to the compile, as the ZeroTier core functionality is written in C++ and needs some runtime support (e.g. new, delete, etc.)
Diffstat (limited to 'src/nng.h')
-rw-r--r--src/nng.h43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/nng.h b/src/nng.h
index 492ba091..ef8cdddd 100644
--- a/src/nng.h
+++ b/src/nng.h
@@ -557,6 +557,23 @@ NNG_DECL void nng_thread_destroy(void *);
// Error codes. These may happen to align to errnos used on your platform,
// but do not count on this.
+//
+// NNG_SYSERR is a special code, which allows us to wrap errors from the
+// underlying operating system. We generally prefer to map errors to one
+// of the above, but if we cannot, then we just encode an error this way.
+// The bit is large enough to accommodate all known UNIX and Win32 error
+// codes. We try hard to match things semantically to one of our standard
+// errors. For example, a connection reset or aborted we treat as a
+// closed connection, because that's basically what it means. (The remote
+// peer closed the connection.) For certain kinds of resource exhaustion
+// we treat it the same as memory. But for files, etc. that's OS-specific,
+// and we use the generic below. Some of the above error codes we use
+// internally, and the application should never see (e.g. NNG_EINTR).
+//
+// NNG_ETRANERR is like ESYSERR, but is used to wrap transport specific
+// errors, from different transports. It should only be used when none
+// of the other options are available.
+
enum nng_errno_enum {
NNG_EINTR = 1,
NNG_ENOMEM = 2,
@@ -582,21 +599,11 @@ enum nng_errno_enum {
NNG_ENOSPC = 22,
NNG_EEXIST = 23,
NNG_EINTERNAL = 24,
+ NNG_ETRANSPORT = 25,
+ NNG_ESYSERR = 0x10000000,
+ NNG_ETRANERR = 0x20000000,
};
-// NNG_SYSERR is a special code, which allows us to wrap errors from the
-// underlyuing operating system. We generally prefer to map errors to one
-// of the above, but if we cannot, then we just encode an error this way.
-// The bit is large enough to accommodate all known UNIX and Win32 error
-// codes. We try hard to match things semantically to one of our standard
-// errors. For example, a connection reset or aborted we treat as a
-// closed connection, because that's basically what it means. (The remote
-// peer closed the connection.) For certain kinds of resource exhaustion
-// we treat it the same as memory. But for files, etc. that's OS-specific,
-// and we use the generic below. Some of the above error codes we use
-// internally, and the application should never see (e.g. NNG_EINTR).
-#define NNG_ESYSERR (0x10000000)
-
// Maximum length of a socket address. This includes the terminating NUL.
// This limit is built into other implementations, so do not change it.
#define NNG_MAXADDRLEN (128)
@@ -627,9 +634,17 @@ struct nng_sockaddr_in {
uint16_t sa_port;
uint32_t sa_addr;
};
+
+struct nng_sockaddr_zt {
+ uint64_t sa_nwid;
+ uint64_t sa_nodeid;
+ uint32_t sa_port;
+};
+
typedef struct nng_sockaddr_in nng_sockaddr_in;
typedef struct nng_sockaddr_in nng_sockaddr_udp;
typedef struct nng_sockaddr_in nng_sockaddr_tcp;
+typedef struct nng_sockaddr_zt nng_sockaddr_zt;
typedef struct nng_sockaddr {
union {
@@ -637,6 +652,7 @@ typedef struct nng_sockaddr {
nng_sockaddr_path s_path;
nng_sockaddr_in6 s_in6;
nng_sockaddr_in s_in;
+ nng_sockaddr_zt s_zt;
} s_un;
} nng_sockaddr;
@@ -646,6 +662,7 @@ enum nng_sockaddr_family {
NNG_AF_IPC = 2,
NNG_AF_INET = 3,
NNG_AF_INET6 = 4,
+ NNG_AF_ZT = 5, // ZeroTier
};
#ifdef __cplusplus