aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/tcp
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-11-15 17:47:54 -0800
committerGarrett D'Amore <garrett@damore.org>2020-11-15 17:47:54 -0800
commit249932f3a208260f6b9c99d778b22d51cfabe87b (patch)
tree4fd4826127e9c225d5232c39d4ae1db89b539689 /src/supplemental/tcp
parenteb328da56c3fc7167b536dcb206df0abb0f4a9b9 (diff)
downloadnng-249932f3a208260f6b9c99d778b22d51cfabe87b.tar.gz
nng-249932f3a208260f6b9c99d778b22d51cfabe87b.tar.bz2
nng-249932f3a208260f6b9c99d778b22d51cfabe87b.zip
fixes #1071 tran_chkopt can be cleaned up
This is a sweeping cleanup of the transport logic around options, and also harmonizes the names used when setting or getting options. Additionally, legacy methods are now moved into a separate file and can be elided via CMake or a preprocessor define. Fundamentally, the ability to set to transport options via the socket is deprecated; there are numerous problems with this and my earlier approaches to deal with this have been somewhat misguided. Further these approaches will not work with future protocol work that is planned (were some options need to be negotiated with peers at the time of connection establishment.) Documentation has been updated to reflect this. The test suites still make rather broad use of the older APIs, and will be converted later.
Diffstat (limited to 'src/supplemental/tcp')
-rw-r--r--src/supplemental/tcp/tcp.c58
1 files changed, 13 insertions, 45 deletions
diff --git a/src/supplemental/tcp/tcp.c b/src/supplemental/tcp/tcp.c
index cde79051..2b1bd987 100644
--- a/src/supplemental/tcp/tcp.c
+++ b/src/supplemental/tcp/tcp.c
@@ -186,19 +186,19 @@ tcp_dialer_dial(void *arg, nng_aio *aio)
}
static int
-tcp_dialer_getx(
+tcp_dialer_get(
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
tcp_dialer *d = arg;
- return (nni_tcp_dialer_getopt(d->d, name, buf, szp, t));
+ return (nni_tcp_dialer_get(d->d, name, buf, szp, t));
}
static int
-tcp_dialer_setx(
+tcp_dialer_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
tcp_dialer *d = arg;
- return (nni_tcp_dialer_setopt(d->d, name, buf, sz, t));
+ return (nni_tcp_dialer_set(d->d, name, buf, sz, t));
}
static int
@@ -224,8 +224,8 @@ tcp_dialer_alloc(tcp_dialer **dp)
d->ops.sd_close = tcp_dialer_close;
d->ops.sd_free = tcp_dialer_free;
d->ops.sd_dial = tcp_dialer_dial;
- d->ops.sd_getx = tcp_dialer_getx;
- d->ops.sd_setx = tcp_dialer_setx;
+ d->ops.sd_get = tcp_dialer_get;
+ d->ops.sd_set = tcp_dialer_set;
*dp = d;
return (0);
@@ -320,7 +320,7 @@ tcp_listener_get_port(void *arg, void *buf, size_t *szp, nni_type t)
uint8_t * paddr;
sz = sizeof(sa);
- rv = nni_tcp_listener_getopt(
+ rv = nni_tcp_listener_get(
l->l, NNG_OPT_LOCADDR, &sa, &sz, NNI_TYPE_SOCKADDR);
if (rv != 0) {
return (rv);
@@ -349,22 +349,22 @@ tcp_listener_get_port(void *arg, void *buf, size_t *szp, nni_type t)
}
static int
-tcp_listener_getx(
+tcp_listener_get(
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
tcp_listener *l = arg;
if (strcmp(name, NNG_OPT_TCP_BOUND_PORT) == 0) {
return (tcp_listener_get_port(l, buf, szp, t));
}
- return (nni_tcp_listener_getopt(l->l, name, buf, szp, t));
+ return (nni_tcp_listener_get(l->l, name, buf, szp, t));
}
static int
-tcp_listener_setx(
+tcp_listener_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
tcp_listener *l = arg;
- return (nni_tcp_listener_setopt(l->l, name, buf, sz, t));
+ return (nni_tcp_listener_set(l->l, name, buf, sz, t));
}
static int
@@ -386,8 +386,8 @@ tcp_listener_alloc_addr(nng_stream_listener **lp, const nng_sockaddr *sa)
l->ops.sl_close = tcp_listener_close;
l->ops.sl_listen = tcp_listener_listen;
l->ops.sl_accept = tcp_listener_accept;
- l->ops.sl_getx = tcp_listener_getx;
- l->ops.sl_setx = tcp_listener_setx;
+ l->ops.sl_get = tcp_listener_get;
+ l->ops.sl_set = tcp_listener_set;
*lp = (void *) l;
return (0);
@@ -434,35 +434,3 @@ nni_tcp_listener_alloc(nng_stream_listener **lp, const nng_url *url)
return (tcp_listener_alloc_addr(lp, &sa));
}
-
-static int
-tcp_check_bool(const void *val, size_t sz, nni_type t)
-{
- return (nni_copyin_bool(NULL, val, sz, t));
-}
-
-static const nni_chkoption tcp_chkopts[] = {
- {
- .o_name = NNG_OPT_TCP_KEEPALIVE,
- .o_check = tcp_check_bool,
- },
- {
- .o_name = NNG_OPT_TCP_NODELAY,
- .o_check = tcp_check_bool,
- },
- {
- .o_name = NNG_OPT_TCP_BOUND_PORT,
- },
- {
- .o_name = NNG_OPT_LOCADDR,
- },
- {
- .o_name = NULL,
- },
-};
-
-int
-nni_tcp_checkopt(const char *name, const void *data, size_t sz, nni_type t)
-{
- return (nni_chkopt(tcp_chkopts, name, data, sz, t));
-}