From 86a96e5bf1b207a8b1aa925e1d9f73ce834505b8 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 21 Jul 2017 16:11:16 -0700 Subject: 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= The 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.) --- src/nng.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/nng.c') 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 #include 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 -- cgit v1.2.3-70-g09d2