aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix
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/platform/posix
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/platform/posix')
-rw-r--r--src/platform/posix/posix_ipcconn.c8
-rw-r--r--src/platform/posix/posix_ipcdial.c12
-rw-r--r--src/platform/posix/posix_ipclisten.c39
-rw-r--r--src/platform/posix/posix_tcpconn.c8
-rw-r--r--src/platform/posix/posix_tcpdial.c4
-rw-r--r--src/platform/posix/posix_tcplisten.c4
6 files changed, 22 insertions, 53 deletions
diff --git a/src/platform/posix/posix_ipcconn.c b/src/platform/posix/posix_ipcconn.c
index e77d54a4..825ecd4b 100644
--- a/src/platform/posix/posix_ipcconn.c
+++ b/src/platform/posix/posix_ipcconn.c
@@ -531,14 +531,14 @@ static const nni_option ipc_options[] = {
};
static int
-ipc_getx(void *arg, const char *name, void *val, size_t *szp, nni_type t)
+ipc_get(void *arg, const char *name, void *val, size_t *szp, nni_type t)
{
ipc_conn *c = arg;
return (nni_getopt(ipc_options, name, c, val, szp, t));
}
static int
-ipc_setx(void *arg, const char *name, const void *val, size_t sz, nni_type t)
+ipc_set(void *arg, const char *name, const void *val, size_t sz, nni_type t)
{
ipc_conn *c = arg;
return (nni_setopt(ipc_options, name, c, val, sz, t));
@@ -559,8 +559,8 @@ nni_posix_ipc_alloc(nni_ipc_conn **cp, nni_sockaddr *sa, nni_ipc_dialer *d)
c->stream.s_close = ipc_close;
c->stream.s_send = ipc_send;
c->stream.s_recv = ipc_recv;
- c->stream.s_getx = ipc_getx;
- c->stream.s_setx = ipc_setx;
+ c->stream.s_get = ipc_get;
+ c->stream.s_set = ipc_set;
c->sa = *sa;
nni_mtx_init(&c->mtx);
diff --git a/src/platform/posix/posix_ipcdial.c b/src/platform/posix/posix_ipcdial.c
index b25f7340..69ed4f77 100644
--- a/src/platform/posix/posix_ipcdial.c
+++ b/src/platform/posix/posix_ipcdial.c
@@ -244,15 +244,15 @@ static const nni_option ipc_dialer_options[] = {
},
};
-int
-ipc_dialer_getx(void *arg, const char *nm, void *buf, size_t *szp, nni_type t)
+static int
+ipc_dialer_get(void *arg, const char *nm, void *buf, size_t *szp, nni_type t)
{
ipc_dialer *d = arg;
return (nni_getopt(ipc_dialer_options, nm, d, buf, szp, t));
}
-int
-ipc_dialer_setx(
+static int
+ipc_dialer_set(
void *arg, const char *nm, const void *buf, size_t sz, nni_type t)
{
ipc_dialer *d = arg;
@@ -306,8 +306,8 @@ nni_ipc_dialer_alloc(nng_stream_dialer **dp, const nng_url *url)
d->sd.sd_free = ipc_dialer_free;
d->sd.sd_close = ipc_dialer_close;
d->sd.sd_dial = ipc_dialer_dial;
- d->sd.sd_getx = ipc_dialer_getx;
- d->sd.sd_setx = ipc_dialer_setx;
+ d->sd.sd_get = ipc_dialer_get;
+ d->sd.sd_set = ipc_dialer_set;
nni_atomic_init_bool(&d->fini);
nni_atomic_init64(&d->ref);
nni_atomic_inc64(&d->ref);
diff --git a/src/platform/posix/posix_ipclisten.c b/src/platform/posix/posix_ipclisten.c
index 9c0b55db..f2511487 100644
--- a/src/platform/posix/posix_ipclisten.c
+++ b/src/platform/posix/posix_ipclisten.c
@@ -269,7 +269,7 @@ static const nni_option ipc_listener_options[] = {
};
static int
-ipc_listener_getx(
+ipc_listener_get(
void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
ipc_listener *l = arg;
@@ -277,7 +277,7 @@ ipc_listener_getx(
}
static int
-ipc_listener_setx(
+ipc_listener_set(
void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
ipc_listener *l = arg;
@@ -527,40 +527,9 @@ nni_ipc_listener_alloc(nng_stream_listener **lp, const nng_url *url)
l->sl.sl_close = ipc_listener_close;
l->sl.sl_listen = ipc_listener_listen;
l->sl.sl_accept = ipc_listener_accept;
- l->sl.sl_getx = ipc_listener_getx;
- l->sl.sl_setx = ipc_listener_setx;
+ l->sl.sl_get = ipc_listener_get;
+ l->sl.sl_set = ipc_listener_set;
*lp = (void *) l;
return (0);
}
-
-static int
-ipc_check_perms(const void *buf, size_t sz, nni_type t)
-{
- int32_t mode;
- int rv;
-
- if ((rv = nni_copyin_int(&mode, buf, sz, 0, S_IFMT, t)) != 0) {
- return (rv);
- }
- if ((mode & S_IFMT) != 0) {
- return (NNG_EINVAL);
- }
- return (0);
-}
-
-static const nni_chkoption ipc_chkopts[] = {
- {
- .o_name = NNG_OPT_IPC_PERMISSIONS,
- .o_check = ipc_check_perms,
- },
- {
- .o_name = NULL,
- },
-};
-
-int
-nni_ipc_checkopt(const char *name, const void *data, size_t sz, nni_type t)
-{
- return (nni_chkopt(ipc_chkopts, name, data, sz, t));
-}
diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c
index 3c8c3715..9684fe27 100644
--- a/src/platform/posix/posix_tcpconn.c
+++ b/src/platform/posix/posix_tcpconn.c
@@ -463,14 +463,14 @@ static const nni_option tcp_options[] = {
};
static int
-tcp_getx(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
+tcp_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t)
{
nni_tcp_conn *c = arg;
return (nni_getopt(tcp_options, name, c, buf, szp, t));
}
static int
-tcp_setx(void *arg, const char *name, const void *buf, size_t sz, nni_type t)
+tcp_set(void *arg, const char *name, const void *buf, size_t sz, nni_type t)
{
nni_tcp_conn *c = arg;
return (nni_setopt(tcp_options, name, c, buf, sz, t));
@@ -495,8 +495,8 @@ nni_posix_tcp_alloc(nni_tcp_conn **cp, nni_tcp_dialer *d)
c->stream.s_close = tcp_close;
c->stream.s_recv = tcp_recv;
c->stream.s_send = tcp_send;
- c->stream.s_getx = tcp_getx;
- c->stream.s_setx = tcp_setx;
+ c->stream.s_get = tcp_get;
+ c->stream.s_set = tcp_set;
*cp = c;
return (0);
diff --git a/src/platform/posix/posix_tcpdial.c b/src/platform/posix/posix_tcpdial.c
index 767717af..f7568db3 100644
--- a/src/platform/posix/posix_tcpdial.c
+++ b/src/platform/posix/posix_tcpdial.c
@@ -398,14 +398,14 @@ static const nni_option tcp_dialer_options[] = {
};
int
-nni_tcp_dialer_getopt(
+nni_tcp_dialer_get(
nni_tcp_dialer *d, const char *name, void *buf, size_t *szp, nni_type t)
{
return (nni_getopt(tcp_dialer_options, name, d, buf, szp, t));
}
int
-nni_tcp_dialer_setopt(nni_tcp_dialer *d, const char *name, const void *buf,
+nni_tcp_dialer_set(nni_tcp_dialer *d, const char *name, const void *buf,
size_t sz, nni_type t)
{
return (nni_setopt(tcp_dialer_options, name, d, buf, sz, t));
diff --git a/src/platform/posix/posix_tcplisten.c b/src/platform/posix/posix_tcplisten.c
index 3a2ea62b..e1c0b90c 100644
--- a/src/platform/posix/posix_tcplisten.c
+++ b/src/platform/posix/posix_tcplisten.c
@@ -416,14 +416,14 @@ static const nni_option tcp_listener_options[] = {
};
int
-nni_tcp_listener_getopt(
+nni_tcp_listener_get(
nni_tcp_listener *l, const char *name, void *buf, size_t *szp, nni_type t)
{
return (nni_getopt(tcp_listener_options, name, l, buf, szp, t));
}
int
-nni_tcp_listener_setopt(nni_tcp_listener *l, const char *name, const void *buf,
+nni_tcp_listener_set(nni_tcp_listener *l, const char *name, const void *buf,
size_t sz, nni_type t)
{
return (nni_setopt(tcp_listener_options, name, l, buf, sz, t));