aboutsummaryrefslogtreecommitdiff
path: root/src/protocol
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-06-12 20:05:34 -0700
committerGarrett D'Amore <garrett@damore.org>2018-06-13 18:01:52 -0700
commitda2aac4a6eb10af88e3938068e24c58aea1832b1 (patch)
treefb0676be5426ed1510945b7e7fe3d09eb45333a7 /src/protocol
parent61ffae5e3649897776c26799ccaaa35d578ba816 (diff)
downloadnng-da2aac4a6eb10af88e3938068e24c58aea1832b1.tar.gz
nng-da2aac4a6eb10af88e3938068e24c58aea1832b1.tar.bz2
nng-da2aac4a6eb10af88e3938068e24c58aea1832b1.zip
fixes #540 nni_ep_opttype serves no purpose
fixes #538 setopt should have an explicit chkopt routine fixes #537 Internal TCP API needs better name separation fixes #524 Option types should be "typed" This is a rework of the option management code, to make it both clearer and to prepare for further work to break up endpoints. This reduces a certain amount of dead or redundant code, and actually saves cycles when setting options, as some loops were not terminated that should have been.
Diffstat (limited to 'src/protocol')
-rw-r--r--src/protocol/bus0/bus.c4
-rw-r--r--src/protocol/pair0/pair.c4
-rw-r--r--src/protocol/pair1/pair.c36
-rw-r--r--src/protocol/pipeline0/pull.c4
-rw-r--r--src/protocol/pipeline0/push.c4
-rw-r--r--src/protocol/pubsub0/pub.c4
-rw-r--r--src/protocol/pubsub0/sub.c26
-rw-r--r--src/protocol/reqrep0/rep.c42
-rw-r--r--src/protocol/reqrep0/req.c78
-rw-r--r--src/protocol/reqrep0/xrep.c20
-rw-r--r--src/protocol/reqrep0/xreq.c20
-rw-r--r--src/protocol/survey0/respond.c44
-rw-r--r--src/protocol/survey0/survey.c79
-rw-r--r--src/protocol/survey0/xrespond.c20
-rw-r--r--src/protocol/survey0/xsurvey.c20
15 files changed, 199 insertions, 206 deletions
diff --git a/src/protocol/bus0/bus.c b/src/protocol/bus0/bus.c
index 2427e836..ba719e49 100644
--- a/src/protocol/bus0/bus.c
+++ b/src/protocol/bus0/bus.c
@@ -439,10 +439,10 @@ static nni_proto_pipe_ops bus0_pipe_ops = {
.pipe_stop = bus0_pipe_stop,
};
-static nni_proto_sock_option bus0_sock_options[] = {
+static nni_proto_option bus0_sock_options[] = {
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/pair0/pair.c b/src/protocol/pair0/pair.c
index 87900793..4ab9f9e8 100644
--- a/src/protocol/pair0/pair.c
+++ b/src/protocol/pair0/pair.c
@@ -269,10 +269,10 @@ static nni_proto_pipe_ops pair0_pipe_ops = {
.pipe_stop = pair0_pipe_stop,
};
-static nni_proto_sock_option pair0_sock_options[] = {
+static nni_proto_option pair0_sock_options[] = {
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
}
};
diff --git a/src/protocol/pair1/pair.c b/src/protocol/pair1/pair.c
index 584c147d..0c6a4867 100644
--- a/src/protocol/pair1/pair.c
+++ b/src/protocol/pair1/pair.c
@@ -428,39 +428,39 @@ pair1_sock_close(void *arg)
}
static int
-pair1_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+pair1_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
pair1_sock *s = arg;
int rv;
nni_mtx_lock(&s->mtx); // Have to be locked against recv cb.
- rv = nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ);
+ rv = nni_copyin_int(&s->ttl, buf, sz, 1, 255, t);
nni_mtx_unlock(&s->mtx);
return (rv);
}
static int
-pair1_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+pair1_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
pair1_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static int
-pair1_sock_setopt_poly(void *arg, const void *buf, size_t sz, int typ)
+pair1_sock_set_poly(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
pair1_sock *s = arg;
int rv;
nni_mtx_lock(&s->mtx);
- rv = s->started ? NNG_ESTATE : nni_copyin_bool(&s->poly, buf, sz, typ);
+ rv = s->started ? NNG_ESTATE : nni_copyin_bool(&s->poly, buf, sz, t);
nni_mtx_unlock(&s->mtx);
return (rv);
}
static int
-pair1_sock_getopt_poly(void *arg, void *buf, size_t *szp, int typ)
+pair1_sock_get_poly(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
pair1_sock *s = arg;
- return (nni_copyout_bool(s->poly, buf, szp, typ));
+ return (nni_copyout_bool(s->poly, buf, szp, t));
}
static void
@@ -487,22 +487,22 @@ static nni_proto_pipe_ops pair1_pipe_ops = {
.pipe_stop = pair1_pipe_stop,
};
-static nni_proto_sock_option pair1_sock_options[] = {
+static nni_proto_option pair1_sock_options[] = {
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = pair1_sock_getopt_maxttl,
- .pso_setopt = pair1_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = pair1_sock_get_maxttl,
+ .o_set = pair1_sock_set_maxttl,
},
{
- .pso_name = NNG_OPT_PAIR1_POLY,
- .pso_type = NNI_TYPE_BOOL,
- .pso_getopt = pair1_sock_getopt_poly,
- .pso_setopt = pair1_sock_setopt_poly,
+ .o_name = NNG_OPT_PAIR1_POLY,
+ .o_type = NNI_TYPE_BOOL,
+ .o_get = pair1_sock_get_poly,
+ .o_set = pair1_sock_set_poly,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/pipeline0/pull.c b/src/protocol/pipeline0/pull.c
index f7d5d9a2..63243cb5 100644
--- a/src/protocol/pipeline0/pull.c
+++ b/src/protocol/pipeline0/pull.c
@@ -216,10 +216,10 @@ static nni_proto_pipe_ops pull0_pipe_ops = {
.pipe_stop = pull0_pipe_stop,
};
-static nni_proto_sock_option pull0_sock_options[] = {
+static nni_proto_option pull0_sock_options[] = {
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/pipeline0/push.c b/src/protocol/pipeline0/push.c
index e413cf46..9585b86c 100644
--- a/src/protocol/pipeline0/push.c
+++ b/src/protocol/pipeline0/push.c
@@ -228,10 +228,10 @@ static nni_proto_pipe_ops push0_pipe_ops = {
.pipe_stop = push0_pipe_stop,
};
-static nni_proto_sock_option push0_sock_options[] = {
+static nni_proto_option push0_sock_options[] = {
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/pubsub0/pub.c b/src/protocol/pubsub0/pub.c
index 4db48754..72cd1daa 100644
--- a/src/protocol/pubsub0/pub.c
+++ b/src/protocol/pubsub0/pub.c
@@ -304,10 +304,10 @@ static nni_proto_pipe_ops pub0_pipe_ops = {
.pipe_stop = pub0_pipe_stop,
};
-static nni_proto_sock_option pub0_sock_options[] = {
+static nni_proto_option pub0_sock_options[] = {
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/pubsub0/sub.c b/src/protocol/pubsub0/sub.c
index a7d6b9f5..2e8be4be 100644
--- a/src/protocol/pubsub0/sub.c
+++ b/src/protocol/pubsub0/sub.c
@@ -194,12 +194,12 @@ sub0_recv_cb(void *arg)
// to replace this with a patricia trie, like old nanomsg had.
static int
-sub0_subscribe(void *arg, const void *buf, size_t sz, int typ)
+sub0_subscribe(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
sub0_sock * s = arg;
sub0_topic *topic;
sub0_topic *newtopic;
- NNI_ARG_UNUSED(typ);
+ NNI_ARG_UNUSED(t);
nni_mtx_lock(&s->lk);
NNI_LIST_FOREACH (&s->topics, topic) {
@@ -245,12 +245,12 @@ sub0_subscribe(void *arg, const void *buf, size_t sz, int typ)
}
static int
-sub0_unsubscribe(void *arg, const void *buf, size_t sz, int typ)
+sub0_unsubscribe(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
sub0_sock * s = arg;
sub0_topic *topic;
int rv;
- NNI_ARG_UNUSED(typ);
+ NNI_ARG_UNUSED(t);
nni_mtx_lock(&s->lk);
NNI_LIST_FOREACH (&s->topics, topic) {
@@ -348,22 +348,20 @@ static nni_proto_pipe_ops sub0_pipe_ops = {
.pipe_stop = sub0_pipe_stop,
};
-static nni_proto_sock_option sub0_sock_options[] = {
+static nni_proto_option sub0_sock_options[] = {
{
- .pso_name = NNG_OPT_SUB_SUBSCRIBE,
- .pso_type = NNI_TYPE_OPAQUE,
- .pso_getopt = NULL,
- .pso_setopt = sub0_subscribe,
+ .o_name = NNG_OPT_SUB_SUBSCRIBE,
+ .o_type = NNI_TYPE_OPAQUE,
+ .o_set = sub0_subscribe,
},
{
- .pso_name = NNG_OPT_SUB_UNSUBSCRIBE,
- .pso_type = NNI_TYPE_OPAQUE,
- .pso_getopt = NULL,
- .pso_setopt = sub0_unsubscribe,
+ .o_name = NNG_OPT_SUB_UNSUBSCRIBE,
+ .o_type = NNI_TYPE_OPAQUE,
+ .o_set = sub0_unsubscribe,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c
index 33c9efcd..1f4f0b33 100644
--- a/src/protocol/reqrep0/rep.c
+++ b/src/protocol/reqrep0/rep.c
@@ -605,23 +605,23 @@ drop:
}
static int
-rep0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+rep0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
rep0_sock *s = arg;
- return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, t));
}
static int
-rep0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+rep0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
rep0_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static int
-rep0_sock_getopt_sendfd(void *arg, void *buf, size_t *szp, int typ)
+rep0_sock_get_sendfd(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
rep0_sock *s = arg;
int rv;
@@ -630,11 +630,11 @@ rep0_sock_getopt_sendfd(void *arg, void *buf, size_t *szp, int typ)
if ((rv = nni_pollable_getfd(s->sendable, &fd)) != 0) {
return (rv);
}
- return (nni_copyout_int(fd, buf, szp, typ));
+ return (nni_copyout_int(fd, buf, szp, t));
}
static int
-rep0_sock_getopt_recvfd(void *arg, void *buf, size_t *szp, int typ)
+rep0_sock_get_recvfd(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
rep0_sock *s = arg;
int rv;
@@ -644,7 +644,7 @@ rep0_sock_getopt_recvfd(void *arg, void *buf, size_t *szp, int typ)
return (rv);
}
- return (nni_copyout_int(fd, buf, szp, typ));
+ return (nni_copyout_int(fd, buf, szp, t));
}
static void
@@ -680,28 +680,26 @@ static nni_proto_ctx_ops rep0_ctx_ops = {
.ctx_recv = rep0_ctx_recv,
};
-static nni_proto_sock_option rep0_sock_options[] = {
+static nni_proto_option rep0_sock_options[] = {
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = rep0_sock_getopt_maxttl,
- .pso_setopt = rep0_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = rep0_sock_get_maxttl,
+ .o_set = rep0_sock_set_maxttl,
},
{
- .pso_name = NNG_OPT_RECVFD,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = rep0_sock_getopt_recvfd,
- .pso_setopt = NULL,
+ .o_name = NNG_OPT_RECVFD,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = rep0_sock_get_recvfd,
},
{
- .pso_name = NNG_OPT_SENDFD,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = rep0_sock_getopt_sendfd,
- .pso_setopt = NULL,
+ .o_name = NNG_OPT_SENDFD,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = rep0_sock_get_sendfd,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/reqrep0/req.c b/src/protocol/reqrep0/req.c
index fc9d7271..8a0dd4d8 100644
--- a/src/protocol/reqrep0/req.c
+++ b/src/protocol/reqrep0/req.c
@@ -479,17 +479,17 @@ req0_ctx_fini(void *arg)
}
static int
-req0_ctx_setopt_resendtime(void *arg, const void *buf, size_t sz, int typ)
+req0_ctx_set_resendtime(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
req0_ctx *ctx = arg;
- return (nni_copyin_ms(&ctx->retry, buf, sz, typ));
+ return (nni_copyin_ms(&ctx->retry, buf, sz, t));
}
static int
-req0_ctx_getopt_resendtime(void *arg, void *buf, size_t *szp, int typ)
+req0_ctx_get_resendtime(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
req0_ctx *ctx = arg;
- return (nni_copyout_ms(ctx->retry, buf, szp, typ));
+ return (nni_copyout_ms(ctx->retry, buf, szp, t));
}
static void
@@ -782,38 +782,38 @@ req0_sock_recv(void *arg, nni_aio *aio)
}
static int
-req0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+req0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
req0_sock *s = arg;
- return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, t));
}
static int
-req0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+req0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
req0_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static int
-req0_sock_setopt_resendtime(void *arg, const void *buf, size_t sz, int typ)
+req0_sock_set_resendtime(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
req0_sock *s = arg;
int rv;
- rv = req0_ctx_setopt_resendtime(s->ctx, buf, sz, typ);
+ rv = req0_ctx_set_resendtime(s->ctx, buf, sz, t);
s->retry = s->ctx->retry;
return (rv);
}
static int
-req0_sock_getopt_resendtime(void *arg, void *buf, size_t *szp, int typ)
+req0_sock_get_resendtime(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
req0_sock *s = arg;
- return (req0_ctx_getopt_resendtime(s->ctx, buf, szp, typ));
+ return (req0_ctx_get_resendtime(s->ctx, buf, szp, t));
}
static int
-req0_sock_getopt_sendfd(void *arg, void *buf, size_t *szp, int typ)
+req0_sock_get_sendfd(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
req0_sock *s = arg;
int rv;
@@ -822,11 +822,11 @@ req0_sock_getopt_sendfd(void *arg, void *buf, size_t *szp, int typ)
if ((rv = nni_pollable_getfd(s->sendable, &fd)) != 0) {
return (rv);
}
- return (nni_copyout_int(fd, buf, szp, typ));
+ return (nni_copyout_int(fd, buf, szp, t));
}
static int
-req0_sock_getopt_recvfd(void *arg, void *buf, size_t *szp, int typ)
+req0_sock_get_recvfd(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
req0_sock *s = arg;
int rv;
@@ -836,7 +836,7 @@ req0_sock_getopt_recvfd(void *arg, void *buf, size_t *szp, int typ)
return (rv);
}
- return (nni_copyout_int(fd, buf, szp, typ));
+ return (nni_copyout_int(fd, buf, szp, t));
}
static nni_proto_pipe_ops req0_pipe_ops = {
@@ -847,15 +847,15 @@ static nni_proto_pipe_ops req0_pipe_ops = {
.pipe_stop = req0_pipe_stop,
};
-static nni_proto_ctx_option req0_ctx_options[] = {
+static nni_proto_option req0_ctx_options[] = {
{
- .co_name = NNG_OPT_REQ_RESENDTIME,
- .co_type = NNI_TYPE_DURATION,
- .co_getopt = req0_ctx_getopt_resendtime,
- .co_setopt = req0_ctx_setopt_resendtime,
+ .o_name = NNG_OPT_REQ_RESENDTIME,
+ .o_type = NNI_TYPE_DURATION,
+ .o_get = req0_ctx_get_resendtime,
+ .o_set = req0_ctx_set_resendtime,
},
{
- .co_name = NULL,
+ .o_name = NULL,
},
};
@@ -867,34 +867,32 @@ static nni_proto_ctx_ops req0_ctx_ops = {
.ctx_options = req0_ctx_options,
};
-static nni_proto_sock_option req0_sock_options[] = {
+static nni_proto_option req0_sock_options[] = {
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = req0_sock_getopt_maxttl,
- .pso_setopt = req0_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = req0_sock_get_maxttl,
+ .o_set = req0_sock_set_maxttl,
},
{
- .pso_name = NNG_OPT_REQ_RESENDTIME,
- .pso_type = NNI_TYPE_DURATION,
- .pso_getopt = req0_sock_getopt_resendtime,
- .pso_setopt = req0_sock_setopt_resendtime,
+ .o_name = NNG_OPT_REQ_RESENDTIME,
+ .o_type = NNI_TYPE_DURATION,
+ .o_get = req0_sock_get_resendtime,
+ .o_set = req0_sock_set_resendtime,
},
{
- .pso_name = NNG_OPT_RECVFD,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = req0_sock_getopt_recvfd,
- .pso_setopt = NULL,
+ .o_name = NNG_OPT_RECVFD,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = req0_sock_get_recvfd,
},
{
- .pso_name = NNG_OPT_SENDFD,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = req0_sock_getopt_sendfd,
- .pso_setopt = NULL,
+ .o_name = NNG_OPT_SENDFD,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = req0_sock_get_sendfd,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/reqrep0/xrep.c b/src/protocol/reqrep0/xrep.c
index f6cd29eb..e3b9b605 100644
--- a/src/protocol/reqrep0/xrep.c
+++ b/src/protocol/reqrep0/xrep.c
@@ -369,17 +369,17 @@ xrep0_pipe_putq_cb(void *arg)
}
static int
-xrep0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+xrep0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
xrep0_sock *s = arg;
- return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, t));
}
static int
-xrep0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+xrep0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
xrep0_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static void
@@ -408,16 +408,16 @@ static nni_proto_pipe_ops xrep0_pipe_ops = {
.pipe_stop = xrep0_pipe_stop,
};
-static nni_proto_sock_option xrep0_sock_options[] = {
+static nni_proto_option xrep0_sock_options[] = {
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = xrep0_sock_getopt_maxttl,
- .pso_setopt = xrep0_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = xrep0_sock_get_maxttl,
+ .o_set = xrep0_sock_set_maxttl,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/reqrep0/xreq.c b/src/protocol/reqrep0/xreq.c
index 793411af..2f0a3652 100644
--- a/src/protocol/reqrep0/xreq.c
+++ b/src/protocol/reqrep0/xreq.c
@@ -268,17 +268,17 @@ xreq0_sock_recv(void *arg, nni_aio *aio)
}
static int
-xreq0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+xreq0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
xreq0_sock *s = arg;
- return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, t));
}
static int
-xreq0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+xreq0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
xreq0_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static nni_proto_pipe_ops xreq0_pipe_ops = {
@@ -289,16 +289,16 @@ static nni_proto_pipe_ops xreq0_pipe_ops = {
.pipe_stop = xreq0_pipe_stop,
};
-static nni_proto_sock_option xreq0_sock_options[] = {
+static nni_proto_option xreq0_sock_options[] = {
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = xreq0_sock_getopt_maxttl,
- .pso_setopt = xreq0_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = xreq0_sock_get_maxttl,
+ .o_set = xreq0_sock_set_maxttl,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/survey0/respond.c b/src/protocol/survey0/respond.c
index 569fd4ea..db18a4e8 100644
--- a/src/protocol/survey0/respond.c
+++ b/src/protocol/survey0/respond.c
@@ -587,21 +587,21 @@ drop:
}
static int
-resp0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+resp0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
resp0_sock *s = arg;
- return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, t));
}
static int
-resp0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+resp0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
resp0_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static int
-resp0_sock_getopt_sendfd(void *arg, void *buf, size_t *szp, int typ)
+resp0_sock_get_sendfd(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
resp0_sock *s = arg;
int rv;
@@ -610,11 +610,11 @@ resp0_sock_getopt_sendfd(void *arg, void *buf, size_t *szp, int typ)
if ((rv = nni_pollable_getfd(s->sendable, &fd)) != 0) {
return (rv);
}
- return (nni_copyout_int(fd, buf, szp, typ));
+ return (nni_copyout_int(fd, buf, szp, t));
}
static int
-resp0_sock_getopt_recvfd(void *arg, void *buf, size_t *szp, int typ)
+resp0_sock_get_recvfd(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
resp0_sock *s = arg;
int rv;
@@ -623,7 +623,7 @@ resp0_sock_getopt_recvfd(void *arg, void *buf, size_t *szp, int typ)
if ((rv = nni_pollable_getfd(s->recvable, &fd)) != 0) {
return (rv);
}
- return (nni_copyout_int(fd, buf, szp, typ));
+ return (nni_copyout_int(fd, buf, szp, t));
}
static void
@@ -657,28 +657,28 @@ static nni_proto_ctx_ops resp0_ctx_ops = {
.ctx_recv = resp0_ctx_recv,
};
-static nni_proto_sock_option resp0_sock_options[] = {
+static nni_proto_option resp0_sock_options[] = {
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = resp0_sock_getopt_maxttl,
- .pso_setopt = resp0_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = resp0_sock_get_maxttl,
+ .o_set = resp0_sock_set_maxttl,
},
{
- .pso_name = NNG_OPT_RECVFD,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = resp0_sock_getopt_recvfd,
- .pso_setopt = NULL,
+ .o_name = NNG_OPT_RECVFD,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = resp0_sock_get_recvfd,
+ .o_set = NULL,
},
{
- .pso_name = NNG_OPT_SENDFD,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = resp0_sock_getopt_sendfd,
- .pso_setopt = NULL,
+ .o_name = NNG_OPT_SENDFD,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = resp0_sock_get_sendfd,
+ .o_set = NULL,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/survey0/survey.c b/src/protocol/survey0/survey.c
index 24a35003..42d88f13 100644
--- a/src/protocol/survey0/survey.c
+++ b/src/protocol/survey0/survey.c
@@ -449,49 +449,50 @@ surv0_pipe_recv_cb(void *arg)
}
static int
-surv0_ctx_setopt_surveytime(void *arg, const void *buf, size_t sz, int typ)
+surv0_ctx_set_surveytime(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
surv0_ctx *ctx = arg;
- return (nni_copyin_ms(&ctx->survtime, buf, sz, typ));
+ return (nni_copyin_ms(&ctx->survtime, buf, sz, t));
}
static int
-surv0_ctx_getopt_surveytime(void *arg, void *buf, size_t *szp, int typ)
+surv0_ctx_get_surveytime(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
surv0_ctx *ctx = arg;
- return (nni_copyout_ms(ctx->survtime, buf, szp, typ));
+ return (nni_copyout_ms(ctx->survtime, buf, szp, t));
}
static int
-surv0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+surv0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
surv0_sock *s = arg;
- return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, t));
}
static int
-surv0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+surv0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
surv0_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static int
-surv0_sock_setopt_surveytime(void *arg, const void *buf, size_t sz, int typ)
+surv0_sock_set_surveytime(
+ void *arg, const void *buf, size_t sz, nni_opt_type t)
{
surv0_sock *s = arg;
- return (surv0_ctx_setopt_surveytime(s->ctx, buf, sz, typ));
+ return (surv0_ctx_set_surveytime(s->ctx, buf, sz, t));
}
static int
-surv0_sock_getopt_surveytime(void *arg, void *buf, size_t *szp, int typ)
+surv0_sock_get_surveytime(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
surv0_sock *s = arg;
- return (surv0_ctx_getopt_surveytime(s->ctx, buf, szp, typ));
+ return (surv0_ctx_get_surveytime(s->ctx, buf, szp, t));
}
static int
-surv0_sock_getopt_sendfd(void *arg, void *buf, size_t *szp, int typ)
+surv0_sock_get_sendfd(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
surv0_sock *sock = arg;
int rv;
@@ -510,11 +511,11 @@ surv0_sock_getopt_sendfd(void *arg, void *buf, size_t *szp, int typ)
if ((rv = nni_pollable_getfd(sock->sendable, &fd)) != 0) {
return (rv);
}
- return (nni_copyout_int(fd, buf, szp, typ));
+ return (nni_copyout_int(fd, buf, szp, t));
}
static int
-surv0_sock_getopt_recvfd(void *arg, void *buf, size_t *szp, int typ)
+surv0_sock_get_recvfd(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
surv0_sock * sock = arg;
nni_pollable *recvable;
@@ -525,7 +526,7 @@ surv0_sock_getopt_recvfd(void *arg, void *buf, size_t *szp, int typ)
((rv = nni_pollable_getfd(recvable, &fd)) != 0)) {
return (rv);
}
- return (nni_copyout_int(fd, buf, szp, typ));
+ return (nni_copyout_int(fd, buf, szp, t));
}
static void
@@ -550,15 +551,15 @@ static nni_proto_pipe_ops surv0_pipe_ops = {
.pipe_stop = surv0_pipe_stop,
};
-static nni_proto_ctx_option surv0_ctx_options[] = {
+static nni_proto_option surv0_ctx_options[] = {
{
- .co_name = NNG_OPT_SURVEYOR_SURVEYTIME,
- .co_type = NNI_TYPE_DURATION,
- .co_getopt = surv0_ctx_getopt_surveytime,
- .co_setopt = surv0_ctx_setopt_surveytime,
+ .o_name = NNG_OPT_SURVEYOR_SURVEYTIME,
+ .o_type = NNI_TYPE_DURATION,
+ .o_get = surv0_ctx_get_surveytime,
+ .o_set = surv0_ctx_set_surveytime,
},
{
- .co_name = NULL,
+ .o_name = NULL,
}
};
static nni_proto_ctx_ops surv0_ctx_ops = {
@@ -569,34 +570,32 @@ static nni_proto_ctx_ops surv0_ctx_ops = {
.ctx_options = surv0_ctx_options,
};
-static nni_proto_sock_option surv0_sock_options[] = {
+static nni_proto_option surv0_sock_options[] = {
{
- .pso_name = NNG_OPT_SURVEYOR_SURVEYTIME,
- .pso_type = NNI_TYPE_DURATION,
- .pso_getopt = surv0_sock_getopt_surveytime,
- .pso_setopt = surv0_sock_setopt_surveytime,
+ .o_name = NNG_OPT_SURVEYOR_SURVEYTIME,
+ .o_type = NNI_TYPE_DURATION,
+ .o_get = surv0_sock_get_surveytime,
+ .o_set = surv0_sock_set_surveytime,
},
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = surv0_sock_getopt_maxttl,
- .pso_setopt = surv0_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = surv0_sock_get_maxttl,
+ .o_set = surv0_sock_set_maxttl,
},
{
- .pso_name = NNG_OPT_RECVFD,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = surv0_sock_getopt_recvfd,
- .pso_setopt = NULL,
+ .o_name = NNG_OPT_RECVFD,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = surv0_sock_get_recvfd,
},
{
- .pso_name = NNG_OPT_SENDFD,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = surv0_sock_getopt_sendfd,
- .pso_setopt = NULL,
+ .o_name = NNG_OPT_SENDFD,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = surv0_sock_get_sendfd,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/survey0/xrespond.c b/src/protocol/survey0/xrespond.c
index 13a3d759..03a47e92 100644
--- a/src/protocol/survey0/xrespond.c
+++ b/src/protocol/survey0/xrespond.c
@@ -348,17 +348,17 @@ xresp0_putq_cb(void *arg)
}
static int
-xresp0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+xresp0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
xresp0_sock *s = arg;
- return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, t));
}
static int
-xresp0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+xresp0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
xresp0_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static void
@@ -385,16 +385,16 @@ static nni_proto_pipe_ops xresp0_pipe_ops = {
.pipe_stop = xresp0_pipe_stop,
};
-static nni_proto_sock_option xresp0_sock_options[] = {
+static nni_proto_option xresp0_sock_options[] = {
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = xresp0_sock_getopt_maxttl,
- .pso_setopt = xresp0_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = xresp0_sock_get_maxttl,
+ .o_set = xresp0_sock_set_maxttl,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};
diff --git a/src/protocol/survey0/xsurvey.c b/src/protocol/survey0/xsurvey.c
index db21e688..bad24042 100644
--- a/src/protocol/survey0/xsurvey.c
+++ b/src/protocol/survey0/xsurvey.c
@@ -280,17 +280,17 @@ xsurv0_recv_cb(void *arg)
}
static int
-xsurv0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
+xsurv0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t)
{
xsurv0_sock *s = arg;
- return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, t));
}
static int
-xsurv0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
+xsurv0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t)
{
xsurv0_sock *s = arg;
- return (nni_copyout_int(s->ttl, buf, szp, typ));
+ return (nni_copyout_int(s->ttl, buf, szp, t));
}
static void
@@ -356,16 +356,16 @@ static nni_proto_pipe_ops xsurv0_pipe_ops = {
.pipe_stop = xsurv0_pipe_stop,
};
-static nni_proto_sock_option xsurv0_sock_options[] = {
+static nni_proto_option xsurv0_sock_options[] = {
{
- .pso_name = NNG_OPT_MAXTTL,
- .pso_type = NNI_TYPE_INT32,
- .pso_getopt = xsurv0_sock_getopt_maxttl,
- .pso_setopt = xsurv0_sock_setopt_maxttl,
+ .o_name = NNG_OPT_MAXTTL,
+ .o_type = NNI_TYPE_INT32,
+ .o_get = xsurv0_sock_get_maxttl,
+ .o_set = xsurv0_sock_set_maxttl,
},
// terminate list
{
- .pso_name = NULL,
+ .o_name = NULL,
},
};