aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-10-25 20:42:09 -0400
committerGarrett D'Amore <garrett@damore.org>2018-10-25 21:06:02 -0400
commit5c2973001e20132bb47dbd23a1c5e815c56e8cfb (patch)
treefc90779a27a6f9ef38b406a6621d14b6ed5ac382 /src/core
parent96b042b925ccc28c6cf179da20e582bf66c3302c (diff)
downloadnng-5c2973001e20132bb47dbd23a1c5e815c56e8cfb.tar.gz
nng-5c2973001e20132bb47dbd23a1c5e815c56e8cfb.tar.bz2
nng-5c2973001e20132bb47dbd23a1c5e815c56e8cfb.zip
Add local IP address tuning for ZeroTier.
These options are undocumented -- for now. We need to get some experience with them to ensure that they are worth keeping.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/options.c24
-rw-r--r--src/core/options.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/src/core/options.c b/src/core/options.c
index 3e35f44c..843b066d 100644
--- a/src/core/options.c
+++ b/src/core/options.c
@@ -202,6 +202,30 @@ nni_copyin_u64(uint64_t *up, const void *v, size_t sz, nni_opt_type t)
}
int
+nni_copyin_sockaddr(nng_sockaddr *ap, const void *v, size_t sz, nni_opt_type t)
+{
+ nng_sockaddr a;
+
+ switch (t) {
+ case NNI_TYPE_SOCKADDR:
+ a = *(nng_sockaddr *) v;
+ break;
+ case NNI_TYPE_OPAQUE:
+ if (sz != sizeof(nng_sockaddr)) {
+ return (NNG_EINVAL);
+ }
+ memcpy(&a, v, sz);
+ break;
+ default:
+ return (NNG_EBADTYPE);
+ }
+ if (ap != NULL) {
+ *ap = a;
+ }
+ return (0);
+}
+
+int
nni_copyout(const void *src, size_t srcsz, void *dst, size_t *dstszp)
{
int rv = 0;
diff --git a/src/core/options.h b/src/core/options.h
index 2a21a039..ac64f9e3 100644
--- a/src/core/options.h
+++ b/src/core/options.h
@@ -32,6 +32,8 @@ extern int nni_copyin_size(
extern int nni_copyin_str(char *, const void *, size_t, size_t, nni_opt_type);
extern int nni_copyin_ptr(void **, const void *, size_t, nni_opt_type);
extern int nni_copyin_u64(uint64_t *, const void *, size_t, nni_opt_type);
+extern int nni_copyin_sockaddr(
+ nng_sockaddr *, const void *, size_t, nni_opt_type);
// nni_copyout_xxx copies out a type of the named value. It assumes that
// the type is aligned and the size correct, unless NNI_TYPE_OPAQUE is passed.