diff options
| -rw-r--r-- | docs/man/nng_dialer_get.3.adoc | 24 | ||||
| -rw-r--r-- | docs/man/nng_dialer_set.3.adoc | 13 | ||||
| -rw-r--r-- | docs/man/nng_listener_get.3.adoc | 26 | ||||
| -rw-r--r-- | docs/man/nng_listener_set.3.adoc | 14 | ||||
| -rw-r--r-- | docs/man/nng_zerotier.7.adoc | 2 | ||||
| -rw-r--r-- | docs/ref/migrate/nng1.md | 4 | ||||
| -rw-r--r-- | include/nng/nng.h | 5 | ||||
| -rw-r--r-- | src/core/sock_test.c | 17 | ||||
| -rw-r--r-- | src/nng.c | 24 | ||||
| -rw-r--r-- | src/sp/transport/tcp/tcp_test.c | 9 | ||||
| -rw-r--r-- | src/sp/transport/tls/tls_tran_test.c | 9 | ||||
| -rw-r--r-- | src/tools/nngcat/nngcat.c | 26 | ||||
| -rw-r--r-- | tests/zt.c | 33 |
13 files changed, 39 insertions, 167 deletions
diff --git a/docs/man/nng_dialer_get.3.adoc b/docs/man/nng_dialer_get.3.adoc index e23ecd2c..29c0341a 100644 --- a/docs/man/nng_dialer_get.3.adoc +++ b/docs/man/nng_dialer_get.3.adoc @@ -1,6 +1,6 @@ = nng_dialer_get(3) // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This document is supplied under the terms of the MIT License, a @@ -19,8 +19,6 @@ nng_dialer_get - get dialer option ---- #include <nng/nng.h> -int nng_dialer_get(nng_dialer d, const char *opt, void *val, size_t *valszp); - int nng_dialer_get_bool(nng_dialer d, const char *opt, bool *bvalp); int nng_dialer_get_int(nng_dialer d, const char *opt, int *ivalp); @@ -57,26 +55,6 @@ The forms vary based on the type of the option they take. The details of the type, size, and semantics of the option will depend on the actual option, and will be documented with the option itself. -`nng_dialer_get()`:: -This function is untyped and can be used to retrieve the value of any option. -The caller must store a pointer to a buffer to receive the value in _val_, -and the size of the buffer shall be stored at the location referenced -by _valszp_. + - + -When the function returns, the actual size of the data copied (or that -would have been copied if sufficient space were present) is stored at -the location referenced by _valszp_. -If the caller's buffer is not large -enough to hold the entire object, then the copy is truncated. -Therefore the caller should validate that the returned size in _valszp_ does not -exceed the original buffer size to check for truncation. + - + -It is acceptable to pass `NULL` for _val_ if the value in _valszp_ is zero. -This can be used to determine the size of the buffer needed to receive -the object. - -TIP: It may be easier to use one of the typed forms of this function. - `nng_dialer_get_bool()`:: This function is for options which take a Boolean (`bool`). The value will be stored at _bvalp_. diff --git a/docs/man/nng_dialer_set.3.adoc b/docs/man/nng_dialer_set.3.adoc index 3363eae9..82673959 100644 --- a/docs/man/nng_dialer_set.3.adoc +++ b/docs/man/nng_dialer_set.3.adoc @@ -19,9 +19,6 @@ nng_dialer_set - set dialer option ---- #include <nng/nng.h> -int nng_dialer_set(nng_dialer d, const char *opt, const void *val, - size_t valsz); - int nng_dialer_set_bool(nng_dialer d, const char *opt, bool bval); int nng_dialer_set_int(nng_dialer d, const char *opt, int ival); @@ -35,13 +32,12 @@ int nng_dialer_set_size(nng_dialer d, const char *opt, size_t z); int nng_dialer_set_string(nng_dialer d, const char *opt, const char *str); int nng_dialer_set_uint64(nng_dialer d, const char *opt, uint64_t u64); - ---- == DESCRIPTION (((options, dialer))) -The `nng_dialer_set()` functions are used to configure options for +The `nng_dialer_set` functions are used to configure options for the xref:nng_dialer.5.adoc[dialer] _d_. The actual options that may be configured in this way vary, and many are documented in xref:nng_options.5.adoc[nng_options(5)]. @@ -58,13 +54,6 @@ In all of these forms, the option _opt_ is configured on the dialer _d_. The details of the type, size, and semantics of the option will depend on the actual option, and will be documented with the option itself. -`nng_dialer_set()`:: -This function is untyped, and can be used to configure any arbitrary data. -The _val_ pointer addresses the data to copy, and _valsz_ is the -size of the objected located at _val_. - -TIP: It may be easier to use one of the typed forms of this function. - `nng_dialer_set_bool()`:: This function is for options which take a Boolean (`bool`). The _bval_ is passed to the option. diff --git a/docs/man/nng_listener_get.3.adoc b/docs/man/nng_listener_get.3.adoc index 83ae6986..216a28f6 100644 --- a/docs/man/nng_listener_get.3.adoc +++ b/docs/man/nng_listener_get.3.adoc @@ -1,6 +1,6 @@ = nng_listener_get(3) // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This document is supplied under the terms of the MIT License, a @@ -19,8 +19,6 @@ nng_listener_get - get listener option ---- #include <nng/nng.h> -int nng_listener_get(nng_listener l, const char *opt, void *val, size_t *valszp); - int nng_listener_get_bool(nng_listener l, const char *opt, bool *bvalp); int nng_listener_get_int(nng_listener l, const char *opt, int *ivalp); @@ -42,7 +40,7 @@ int nng_listener_get_uint64(nng_listener l, const char *opt, uint64_t *u64p); == DESCRIPTION (((options, listener))) -The `nng_listener_get()` functions are used to retrieve option values for +The `nng_listener_get` functions are used to retrieve option values for the xref:nng_listener.5.adoc[listener] _l_. The actual options that may be retrieved in this way vary, and many are documented in xref:nng_options.5.adoc[nng_options(5)]. @@ -57,26 +55,6 @@ The forms vary based on the type of the option they take. The details of the type, size, and semantics of the option will depend on the actual option, and will be documented with the option itself. -`nng_listener_get()`:: -This function is untyped and can be used to retrieve the value of any option. -The caller must store a pointer to a buffer to receive the value in _val_, -and the size of the buffer shall be stored at the location referenced -by _valszp_. + - + -When the function returns, the actual size of the data copied (or that -would have been copied if sufficient space were present) is stored at -the location referenced by _valszp_. -If the caller's buffer is not large -enough to hold the entire object, then the copy is truncated. Therefore -the caller should validate that the returned size in _valszp_ does not -exceed the original buffer size to check for truncation. + - + -It is acceptable to pass `NULL` for _val_ if the value in _valszp_ is zero. -This can be used to determine the size of the buffer needed to receive -the object. - -TIP: It may be easier to use one of the typed forms of this function. - `nng_listener_get_bool()`:: This function is for options which take a Boolean (`bool`). The value will be stored at _bvalp_. diff --git a/docs/man/nng_listener_set.3.adoc b/docs/man/nng_listener_set.3.adoc index 0cfd2112..37c9b48e 100644 --- a/docs/man/nng_listener_set.3.adoc +++ b/docs/man/nng_listener_set.3.adoc @@ -1,6 +1,6 @@ = nng_listener_set(3) // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This document is supplied under the terms of the MIT License, a @@ -19,9 +19,6 @@ nng_listener_set - set listener option ---- #include <nng/nng.h> -int nng_listener_set(nng_listener l, const char *opt, const void *val, - size_t valsz); - int nng_listener_set_bool(nng_listener l, const char *opt, bool bval); int nng_listener_set_int(nng_listener l, const char *opt, int ival); @@ -41,7 +38,7 @@ int nng_listener_set_uint64(nng_listener l, const char *opt, uint64_t u64); == DESCRIPTION (((options, listener))) -The `nng_listener_set()` functions are used to configure options for +The `nng_listener_set` functions are used to configure options for the xref:nng_listener.5.adoc[listener] _l_. The actual options that may be configured in this way vary, and many are documented in xref:nng_options.5.adoc[nng_options(5)]. @@ -58,13 +55,6 @@ In all of these forms, the option _opt_ is configured on the listener _l_. The details of the type, size, and semantics of the option will depend on the actual option, and will be documented with the option itself. -TIP: It may be easier to use one of the typed forms of this function. - -`nng_listener_set()`:: -This function is untyped, and can be used to configure any arbitrary data. -The _val_ pointer addresses the data to copy, and _valsz_ is the -size of the objected located at _val_. - `nng_listener_set_bool()`:: This function is for options which take a Boolean (`bool`). The _bval_ is passed to the option. diff --git a/docs/man/nng_zerotier.7.adoc b/docs/man/nng_zerotier.7.adoc index 40c048d6..0f98b33d 100644 --- a/docs/man/nng_zerotier.7.adoc +++ b/docs/man/nng_zerotier.7.adoc @@ -64,7 +64,7 @@ the node's own node number. Listeners may use port 0 to indicate that a suitable port number be selected automatically. Applications using this must determine the selected port number using the -xref:nng_listener_get.3.adoc[`nng_listener_get()`] function. +xref:nng_listener_get.3.adoc[`nng_listener_get_int()`] function. === Socket Address diff --git a/docs/ref/migrate/nng1.md b/docs/ref/migrate/nng1.md index f4c9c9f5..1c01e429 100644 --- a/docs/ref/migrate/nng1.md +++ b/docs/ref/migrate/nng1.md @@ -61,6 +61,10 @@ such as one ending in a suffix like `_bool` (to access a `bool` typed option). - `nng_ctx_get` - `nng_ctx_set` +- `nng_dialer_get` +- `nng_dialer_set` +- `nng_listener_get` +- `nng_listener_set` - `nng_pipe_get` - `nng_stream_get` - `nng_stream_set` diff --git a/include/nng/nng.h b/include/nng/nng.h index 3cee1e53..11239468 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -350,7 +350,6 @@ NNG_DECL int nng_dialer_id(nng_dialer); // invalid. NNG_DECL int nng_listener_id(nng_listener); -NNG_DECL int nng_dialer_set(nng_dialer, const char *, const void *, size_t); NNG_DECL int nng_dialer_set_bool(nng_dialer, const char *, bool); NNG_DECL int nng_dialer_set_int(nng_dialer, const char *, int); NNG_DECL int nng_dialer_set_size(nng_dialer, const char *, size_t); @@ -361,7 +360,6 @@ NNG_DECL int nng_dialer_set_ms(nng_dialer, const char *, nng_duration); NNG_DECL int nng_dialer_set_addr( nng_dialer, const char *, const nng_sockaddr *); -NNG_DECL int nng_dialer_get(nng_dialer, const char *, void *, size_t *); NNG_DECL int nng_dialer_get_bool(nng_dialer, const char *, bool *); NNG_DECL int nng_dialer_get_int(nng_dialer, const char *, int *); NNG_DECL int nng_dialer_get_size(nng_dialer, const char *, size_t *); @@ -371,8 +369,6 @@ NNG_DECL int nng_dialer_get_ptr(nng_dialer, const char *, void **); NNG_DECL int nng_dialer_get_ms(nng_dialer, const char *, nng_duration *); NNG_DECL int nng_dialer_get_addr(nng_dialer, const char *, nng_sockaddr *); -NNG_DECL int nng_listener_set( - nng_listener, const char *, const void *, size_t); NNG_DECL int nng_listener_set_bool(nng_listener, const char *, bool); NNG_DECL int nng_listener_set_int(nng_listener, const char *, int); NNG_DECL int nng_listener_set_size(nng_listener, const char *, size_t); @@ -383,7 +379,6 @@ NNG_DECL int nng_listener_set_ms(nng_listener, const char *, nng_duration); NNG_DECL int nng_listener_set_addr( nng_listener, const char *, const nng_sockaddr *); -NNG_DECL int nng_listener_get(nng_listener, const char *, void *, size_t *); NNG_DECL int nng_listener_get_bool(nng_listener, const char *, bool *); NNG_DECL int nng_listener_get_int(nng_listener, const char *, int *); NNG_DECL int nng_listener_get_size(nng_listener, const char *, size_t *); diff --git a/src/core/sock_test.c b/src/core/sock_test.c index 5981a2e3..08ca8233 100644 --- a/src/core/sock_test.c +++ b/src/core/sock_test.c @@ -353,27 +353,24 @@ void test_url_option(void) { nng_socket s1; - char url[NNG_MAXADDRLEN]; + char *url; nng_listener l; nng_dialer d; - size_t sz; NUTS_OPEN(s1); // Listener NUTS_PASS(nng_listener_create(&l, s1, "inproc://url1")); - memset(url, 0, sizeof(url)); - sz = sizeof(url); - NUTS_PASS(nng_listener_get(l, NNG_OPT_URL, url, &sz)); + NUTS_PASS(nng_listener_get_string(l, NNG_OPT_URL, &url)); NUTS_MATCH(url, "inproc://url1"); - NUTS_FAIL(nng_listener_set(l, NNG_OPT_URL, url, sz), NNG_EREADONLY); - sz = sizeof(url); + NUTS_FAIL(nng_listener_set_string(l, NNG_OPT_URL, url), NNG_EREADONLY); + nng_strfree(url); // Dialer NUTS_PASS(nng_dialer_create(&d, s1, "inproc://url2")); - NUTS_PASS(nng_dialer_get(d, NNG_OPT_URL, url, &sz)); + NUTS_PASS(nng_dialer_get_string(d, NNG_OPT_URL, &url)); NUTS_MATCH(url, "inproc://url2"); - NUTS_FAIL(nng_dialer_set(d, NNG_OPT_URL, url, sz), NNG_EREADONLY); + NUTS_FAIL(nng_dialer_set_string(d, NNG_OPT_URL, url), NNG_EREADONLY); NUTS_CLOSE(s1); } @@ -396,7 +393,6 @@ test_listener_options(void) NUTS_FAIL(nng_listener_set_size(l, "BAD_OPT", 1), NNG_ENOTSUP); NUTS_FAIL( nng_listener_set_bool(l, NNG_OPT_RECVMAXSZ, true), NNG_EBADTYPE); - NUTS_FAIL(nng_listener_set(l, NNG_OPT_RECVMAXSZ, &sz, 1), NNG_EINVAL); // Cannot set inappropriate options NUTS_FAIL( @@ -431,7 +427,6 @@ test_dialer_options(void) NUTS_FAIL(nng_dialer_set_size(d, "BAD_OPT", 1), NNG_ENOTSUP); NUTS_FAIL( nng_dialer_set_bool(d, NNG_OPT_RECVMAXSZ, true), NNG_EBADTYPE); - NUTS_FAIL(nng_dialer_set(d, NNG_OPT_RECVMAXSZ, &sz, 1), NNG_EINVAL); // Cannot set inappropriate options NUTS_FAIL( @@ -674,12 +674,6 @@ dialer_set(nng_dialer id, const char *n, const void *v, size_t sz, nni_type t) } int -nng_dialer_set(nng_dialer id, const char *n, const void *v, size_t sz) -{ - return (dialer_set(id, n, v, sz, NNI_TYPE_OPAQUE)); -} - -int nng_dialer_set_int(nng_dialer id, const char *n, int v) { return (dialer_set(id, n, &v, sizeof(v), NNI_TYPE_INT32)); @@ -746,12 +740,6 @@ dialer_get(nng_dialer id, const char *n, void *v, size_t *szp, nni_type t) } int -nng_dialer_get(nng_dialer id, const char *n, void *v, size_t *szp) -{ - return (dialer_get(id, n, v, szp, NNI_TYPE_OPAQUE)); -} - -int nng_dialer_get_int(nng_dialer id, const char *n, int *v) { return (dialer_get(id, n, v, NULL, NNI_TYPE_INT32)); @@ -818,12 +806,6 @@ listener_set( } int -nng_listener_set(nng_listener id, const char *n, const void *v, size_t sz) -{ - return (listener_set(id, n, v, sz, NNI_TYPE_OPAQUE)); -} - -int nng_listener_set_int(nng_listener id, const char *n, int v) { return (listener_set(id, n, &v, sizeof(v), NNI_TYPE_INT32)); @@ -891,12 +873,6 @@ listener_get( } int -nng_listener_get(nng_listener id, const char *n, void *v, size_t *szp) -{ - return (listener_get(id, n, v, szp, NNI_TYPE_OPAQUE)); -} - -int nng_listener_get_int(nng_listener id, const char *n, int *v) { return (listener_get(id, n, v, NULL, NNI_TYPE_INT32)); diff --git a/src/sp/transport/tcp/tcp_test.c b/src/sp/transport/tcp/tcp_test.c index 5a4e5647..ac2d6be9 100644 --- a/src/sp/transport/tcp/tcp_test.c +++ b/src/sp/transport/tcp/tcp_test.c @@ -154,12 +154,6 @@ test_tcp_no_delay_option(void) nng_dialer_get_int(d, NNG_OPT_TCP_NODELAY, &x), NNG_EBADTYPE); x = 0; NUTS_FAIL(nng_dialer_set_int(d, NNG_OPT_TCP_NODELAY, x), NNG_EBADTYPE); - // This assumes sizeof (bool) != sizeof (int) - if (sizeof(bool) != sizeof(int)) { - NUTS_FAIL( - nng_dialer_set(d, NNG_OPT_TCP_NODELAY, &x, sizeof(x)), - NNG_EINVAL); - } NUTS_PASS(nng_listener_create(&l, s, addr)); NUTS_PASS(nng_listener_get_bool(l, NNG_OPT_TCP_NODELAY, &v)); @@ -167,9 +161,6 @@ test_tcp_no_delay_option(void) x = 0; NUTS_FAIL( nng_listener_set_int(l, NNG_OPT_TCP_NODELAY, x), NNG_EBADTYPE); - // This assumes sizeof (bool) != sizeof (int) - NUTS_FAIL(nng_listener_set(l, NNG_OPT_TCP_NODELAY, &x, sizeof(x)), - NNG_EINVAL); NUTS_PASS(nng_dialer_close(d)); NUTS_PASS(nng_listener_close(l)); diff --git a/src/sp/transport/tls/tls_tran_test.c b/src/sp/transport/tls/tls_tran_test.c index ee11d8b9..1965bdce 100644 --- a/src/sp/transport/tls/tls_tran_test.c +++ b/src/sp/transport/tls/tls_tran_test.c @@ -205,12 +205,6 @@ test_tls_no_delay_option(void) nng_dialer_get_int(d, NNG_OPT_TCP_NODELAY, &x), NNG_EBADTYPE); x = 0; NUTS_FAIL(nng_dialer_set_int(d, NNG_OPT_TCP_NODELAY, x), NNG_EBADTYPE); - // This assumes sizeof (bool) != sizeof (int) - if (sizeof(bool) != sizeof(int)) { - NUTS_FAIL( - nng_dialer_set(d, NNG_OPT_TCP_NODELAY, &x, sizeof(x)), - NNG_EINVAL); - } NUTS_PASS(nng_listener_create(&l, s, addr)); NUTS_PASS(nng_listener_set_ptr(l, NNG_OPT_TLS_CONFIG, lc)); @@ -219,9 +213,6 @@ test_tls_no_delay_option(void) x = 0; NUTS_FAIL( nng_listener_set_int(l, NNG_OPT_TCP_NODELAY, x), NNG_EBADTYPE); - // This assumes sizeof (bool) != sizeof (int) - NUTS_FAIL(nng_listener_set(l, NNG_OPT_TCP_NODELAY, &x, sizeof(x)), - NNG_EINVAL); NUTS_PASS(nng_dialer_close(d)); NUTS_PASS(nng_listener_close(l)); diff --git a/src/tools/nngcat/nngcat.c b/src/tools/nngcat/nngcat.c index da3bd6d6..547b336b 100644 --- a/src/tools/nngcat/nngcat.c +++ b/src/tools/nngcat/nngcat.c @@ -1112,8 +1112,8 @@ main(int ac, char **av) nng_strerror(rv)); } if (zthome != NULL) { - rv = nng_dialer_set(d, NNG_OPT_ZT_HOME, zthome, - strlen(zthome) + 1); + rv = nng_dialer_set_string( + d, NNG_OPT_ZT_HOME, zthome); if ((rv != 0) && (rv != NNG_ENOTSUP)) { fatal("Unable to set ZT home: %s", nng_strerror(rv)); @@ -1122,12 +1122,11 @@ main(int ac, char **av) rv = nng_dialer_start(d, async); act = "dial"; if ((rv == 0) && (verbose == OPT_VERBOSE)) { - char ustr[256]; - size_t sz; - sz = sizeof(ustr); - if (nng_dialer_get( - d, NNG_OPT_URL, ustr, &sz) == 0) { + char *ustr; + if (nng_dialer_get_string( + d, NNG_OPT_URL, &ustr) == 0) { printf("Connected to: %s\n", ustr); + nng_strfree(ustr); } } break; @@ -1148,8 +1147,8 @@ main(int ac, char **av) nng_strerror(rv)); } if (zthome != NULL) { - rv = nng_listener_set(l, NNG_OPT_ZT_HOME, - zthome, strlen(zthome) + 1); + rv = nng_listener_set_string( + l, NNG_OPT_ZT_HOME, zthome); if ((rv != 0) && (rv != NNG_ENOTSUP)) { fatal("Unable to set ZT home: %s", nng_strerror(rv)); @@ -1158,12 +1157,11 @@ main(int ac, char **av) rv = nng_listener_start(l, async); act = "listen"; if ((rv == 0) && (verbose == OPT_VERBOSE)) { - char ustr[256]; - size_t sz; - sz = sizeof(ustr); - if (nng_listener_get( - l, NNG_OPT_URL, ustr, &sz) == 0) { + char *ustr; + if (nng_listener_get_string( + l, NNG_OPT_URL, &ustr) == 0) { printf("Listening at: %s\n", ustr); + nng_strfree(ustr); } } break; @@ -131,16 +131,11 @@ TestMain("ZeroTier Transport", { port = 5555; - Convey("We can register the zero tier transport", - { So(nng_zt_register() == 0); }); - Convey("We can create a zt listener", { nng_listener l; nng_socket s; char addr[NNG_MAXADDRLEN]; - So(nng_zt_register() == 0); - snprintf(addr, sizeof(addr), "zt://*." NWID ":%u", port); So(nng_pair_open(&s) == 0); @@ -151,8 +146,8 @@ TestMain("ZeroTier Transport", { Convey("And it can be started...", { mkdir(path1, 0700); - So(nng_listener_set(l, NNG_OPT_ZT_HOME, path1, - strlen(path1) + 1) == 0); + So(nng_listener_set_string( + l, NNG_OPT_ZT_HOME, path1) == 0); So(nng_listener_start(l, 0) == 0); @@ -166,19 +161,18 @@ TestMain("ZeroTier Transport", { So(sa.s_zt.sa_nodeid != 0); }); Convey("And we can orbit a moon", { - uint64_t ids[2]; + uint64_t id; // Provided by Janjaap... - ids[0] = 0x622514484aull; - ids[1] = 0x622514484aull; + id = 0x622514484aull; - So(nng_listener_set(l, NNG_OPT_ZT_ORBIT, ids, - sizeof(ids)) == 0); + So(nng_listener_set_uint64( + l, NNG_OPT_ZT_ORBIT, id) == 0); }); Convey("And we can deorbit anything", { uint64_t id; id = 0x12345678; - So(nng_listener_set(l, NNG_OPT_ZT_DEORBIT, &id, - sizeof(id)) == 0); + So(nng_listener_set_uint64( + l, NNG_OPT_ZT_DEORBIT, id) == 0); }); }); }); @@ -190,8 +184,6 @@ TestMain("ZeroTier Transport", { // uint64_t node = 0xb000072fa6ull; // my personal host uint64_t node = 0x2d2f619cccull; // my personal host - So(nng_zt_register() == 0); - snprintf(addr, sizeof(addr), "zt://%llx." NWID ":%u", (unsigned long long) node, port); @@ -209,8 +201,6 @@ TestMain("ZeroTier Transport", { uint64_t node1 = 0; uint64_t node2 = 0; - So(nng_zt_register() == 0); - snprintf(addr, sizeof(addr), "zt://*." NWID ":%u", port); So(nng_pair_open(&s) == 0); @@ -242,7 +232,6 @@ TestMain("ZeroTier Transport", { uint64_t node; port = 9944; - So(nng_zt_register() == 0); snprintf(addr1, sizeof(addr1), "zt://*." NWID ":%u", port); @@ -256,8 +245,7 @@ TestMain("ZeroTier Transport", { }); So(nng_listener_create(&l, s1, addr1) == 0); - So(nng_listener_set( - l, NNG_OPT_ZT_HOME, path1, strlen(path1) + 1) == 0); + So(nng_listener_set_string(l, NNG_OPT_ZT_HOME, path1) == 0); So(nng_listener_start(l, 0) == 0); node = 0; @@ -268,8 +256,7 @@ TestMain("ZeroTier Transport", { (unsigned long long) node, port); So(nng_dialer_create(&d, s2, addr2) == 0); mkdir(path2, 0700); - So(nng_dialer_setopt( - d, NNG_OPT_ZT_HOME, path2, strlen(path2) + 1) == 0); + So(nng_dialer_set_string(d, NNG_OPT_ZT_HOME, path2) == 0); So(nng_dialer_start(d, 0) == 0); nng_msleep(2000); // to give dialer time to start up }); |
