aboutsummaryrefslogtreecommitdiff
path: root/src/nng.c
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.c
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.c')
-rw-r--r--src/nng.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nng.c b/src/nng.c
index 32004895..ef821a50 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -19,6 +19,7 @@
// Pretty much every function calls the nni_platform_init to check against
// fork related activity.
+#include <stdio.h>
#include <string.h>
void
@@ -650,6 +651,7 @@ static const struct {
const char *
nng_strerror(int num)
{
+ static char unknownerrbuf[32];
for (int i = 0; nni_errors[i].msg != NULL; i++) {
if (nni_errors[i].code == num) {
return (nni_errors[i].msg);
@@ -660,7 +662,16 @@ nng_strerror(int num)
return (nni_plat_strerror(num & ~NNG_ESYSERR));
}
- return ("Unknown error");
+ if (num & NNG_ETRANERR) {
+ static char tranerrbuf[32];
+ (void) snprintf(tranerrbuf, sizeof(tranerrbuf),
+ "Transport error #%d", num & ~NNG_ETRANERR);
+ return (tranerrbuf);
+ }
+
+ (void) snprintf(
+ unknownerrbuf, sizeof(unknownerrbuf), "Unknown error #%d", num);
+ return (unknownerrbuf);
}
int