summaryrefslogtreecommitdiff
path: root/src/protocol
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-04 11:07:56 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-04 11:07:56 -0700
commit505a9bce029e51540739c853a6c9eef0ecfb2e90 (patch)
treed907679b6ab99bcb5da919db3d005d4976590c21 /src/protocol
parent0aa1de1316b46bb4af23fdf26759bca08008eaf5 (diff)
downloadnng-505a9bce029e51540739c853a6c9eef0ecfb2e90.tar.gz
nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.tar.bz2
nng-505a9bce029e51540739c853a6c9eef0ecfb2e90.zip
fixes #329 type checking not done for setopt
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.c12
-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.c10
-rw-r--r--src/protocol/reqrep0/rep.c8
-rw-r--r--src/protocol/reqrep0/req.c12
-rw-r--r--src/protocol/survey0/respond.c8
-rw-r--r--src/protocol/survey0/survey.c12
11 files changed, 42 insertions, 40 deletions
diff --git a/src/protocol/bus0/bus.c b/src/protocol/bus0/bus.c
index 00a9ca02..57fad341 100644
--- a/src/protocol/bus0/bus.c
+++ b/src/protocol/bus0/bus.c
@@ -334,10 +334,10 @@ bus0_pipe_recv(bus0_pipe *p)
}
static int
-bus0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+bus0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
bus0_sock *s = arg;
- return (nni_setopt_bool(&s->raw, buf, sz));
+ return (nni_copyin_bool(&s->raw, buf, sz, typ));
}
static int
diff --git a/src/protocol/pair0/pair.c b/src/protocol/pair0/pair.c
index bc8be866..ccece972 100644
--- a/src/protocol/pair0/pair.c
+++ b/src/protocol/pair0/pair.c
@@ -232,10 +232,10 @@ pair0_sock_close(void *arg)
}
static int
-pair0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+pair0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
pair0_sock *s = arg;
- return (nni_setopt_bool(&s->raw, buf, sz));
+ return (nni_copyin_bool(&s->raw, buf, sz, typ));
}
static int
diff --git a/src/protocol/pair1/pair.c b/src/protocol/pair1/pair.c
index ee67cf7b..becbbfa7 100644
--- a/src/protocol/pair1/pair.c
+++ b/src/protocol/pair1/pair.c
@@ -397,12 +397,12 @@ pair1_sock_close(void *arg)
}
static int
-pair1_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+pair1_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
pair1_sock *s = arg;
int rv;
nni_mtx_lock(&s->mtx);
- rv = s->started ? NNG_ESTATE : nni_setopt_bool(&s->raw, buf, sz);
+ rv = s->started ? NNG_ESTATE : nni_copyin_bool(&s->raw, buf, sz, typ);
nni_mtx_unlock(&s->mtx);
return (rv);
}
@@ -415,12 +415,12 @@ pair1_sock_getopt_raw(void *arg, void *buf, size_t *szp, int typ)
}
static int
-pair1_sock_setopt_maxttl(void *arg, const void *buf, size_t sz)
+pair1_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
{
pair1_sock *s = arg;
int rv;
nni_mtx_lock(&s->mtx); // Have to be locked against recv cb.
- rv = nni_setopt_int(&s->ttl, buf, sz, 1, 255);
+ rv = nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ);
nni_mtx_unlock(&s->mtx);
return (rv);
}
@@ -433,12 +433,12 @@ pair1_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
}
static int
-pair1_sock_setopt_poly(void *arg, const void *buf, size_t sz)
+pair1_sock_setopt_poly(void *arg, const void *buf, size_t sz, int typ)
{
pair1_sock *s = arg;
int rv;
nni_mtx_lock(&s->mtx);
- rv = s->started ? NNG_ESTATE : nni_setopt_bool(&s->poly, buf, sz);
+ rv = s->started ? NNG_ESTATE : nni_copyin_bool(&s->poly, buf, sz, typ);
nni_mtx_unlock(&s->mtx);
return (rv);
}
diff --git a/src/protocol/pipeline0/pull.c b/src/protocol/pipeline0/pull.c
index d8f4641f..9aa7bea9 100644
--- a/src/protocol/pipeline0/pull.c
+++ b/src/protocol/pipeline0/pull.c
@@ -181,10 +181,10 @@ pull0_sock_close(void *arg)
}
static int
-pull0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+pull0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
pull0_sock *s = arg;
- return (nni_setopt_bool(&s->raw, buf, sz));
+ return (nni_copyin_bool(&s->raw, buf, sz, typ));
}
static int
diff --git a/src/protocol/pipeline0/push.c b/src/protocol/pipeline0/push.c
index bbffb433..8c8fa13e 100644
--- a/src/protocol/pipeline0/push.c
+++ b/src/protocol/pipeline0/push.c
@@ -198,10 +198,10 @@ push0_getq_cb(void *arg)
}
static int
-push0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+push0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
push0_sock *s = arg;
- return (nni_setopt_bool(&s->raw, buf, sz));
+ return (nni_copyin_bool(&s->raw, buf, sz, typ));
}
static int
diff --git a/src/protocol/pubsub0/pub.c b/src/protocol/pubsub0/pub.c
index 3f4ecea6..aaa22801 100644
--- a/src/protocol/pubsub0/pub.c
+++ b/src/protocol/pubsub0/pub.c
@@ -274,10 +274,10 @@ pub0_pipe_send_cb(void *arg)
}
static int
-pub0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+pub0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
pub0_sock *s = arg;
- return (nni_setopt_bool(&s->raw, buf, sz));
+ return (nni_copyin_bool(&s->raw, buf, sz, typ));
}
static int
diff --git a/src/protocol/pubsub0/sub.c b/src/protocol/pubsub0/sub.c
index d7e9aea4..6b1f1173 100644
--- a/src/protocol/pubsub0/sub.c
+++ b/src/protocol/pubsub0/sub.c
@@ -190,11 +190,12 @@ sub0_putq_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)
+sub0_subscribe(void *arg, const void *buf, size_t sz, int typ)
{
sub0_sock * s = arg;
sub0_topic *topic;
sub0_topic *newtopic;
+ NNI_ARG_UNUSED(typ);
nni_mtx_lock(&s->lk);
NNI_LIST_FOREACH (&s->topics, topic) {
@@ -240,11 +241,12 @@ sub0_subscribe(void *arg, const void *buf, size_t sz)
}
static int
-sub0_unsubscribe(void *arg, const void *buf, size_t sz)
+sub0_unsubscribe(void *arg, const void *buf, size_t sz, int typ)
{
sub0_sock * s = arg;
sub0_topic *topic;
int rv;
+ NNI_ARG_UNUSED(typ);
nni_mtx_lock(&s->lk);
NNI_LIST_FOREACH (&s->topics, topic) {
@@ -276,10 +278,10 @@ sub0_unsubscribe(void *arg, const void *buf, size_t sz)
}
static int
-sub0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+sub0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
sub0_sock *s = arg;
- return (nni_setopt_bool(&s->raw, buf, sz));
+ return (nni_copyin_bool(&s->raw, buf, sz, typ));
}
static int
diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c
index 5ee6c1be..f62406cd 100644
--- a/src/protocol/reqrep0/rep.c
+++ b/src/protocol/reqrep0/rep.c
@@ -353,13 +353,13 @@ rep0_pipe_putq_cb(void *arg)
}
static int
-rep0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+rep0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
rep0_sock *s = arg;
int rv;
nni_mtx_lock(&s->lk);
- rv = nni_setopt_bool(&s->raw, buf, sz);
+ rv = nni_copyin_bool(&s->raw, buf, sz, typ);
nni_mtx_unlock(&s->lk);
return (rv);
}
@@ -372,10 +372,10 @@ rep0_sock_getopt_raw(void *arg, void *buf, size_t *szp, int typ)
}
static int
-rep0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz)
+rep0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
{
rep0_sock *s = arg;
- return (nni_setopt_int(&s->ttl, buf, sz, 1, 255));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
}
static int
diff --git a/src/protocol/reqrep0/req.c b/src/protocol/reqrep0/req.c
index 659578d4..0a5b566a 100644
--- a/src/protocol/reqrep0/req.c
+++ b/src/protocol/reqrep0/req.c
@@ -250,10 +250,10 @@ req0_pipe_stop(void *arg)
}
static int
-req0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+req0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
req0_sock *s = arg;
- return (nni_setopt_bool(&s->raw, buf, sz));
+ return (nni_copyin_bool(&s->raw, buf, sz, typ));
}
static int
@@ -264,10 +264,10 @@ req0_sock_getopt_raw(void *arg, void *buf, size_t *szp, int typ)
}
static int
-req0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz)
+req0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
{
req0_sock *s = arg;
- return (nni_setopt_int(&s->ttl, buf, sz, 1, 255));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
}
static int
@@ -278,10 +278,10 @@ req0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
}
static int
-req0_sock_setopt_resendtime(void *arg, const void *buf, size_t sz)
+req0_sock_setopt_resendtime(void *arg, const void *buf, size_t sz, int typ)
{
req0_sock *s = arg;
- return (nni_setopt_ms(&s->retry, buf, sz));
+ return (nni_copyin_ms(&s->retry, buf, sz, typ));
}
static int
diff --git a/src/protocol/survey0/respond.c b/src/protocol/survey0/respond.c
index 035e51b1..eeb09d2a 100644
--- a/src/protocol/survey0/respond.c
+++ b/src/protocol/survey0/respond.c
@@ -347,13 +347,13 @@ resp0_putq_cb(void *arg)
}
static int
-resp0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+resp0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
resp0_sock *s = arg;
int rv;
nni_mtx_lock(&s->mtx);
- rv = nni_setopt_bool(&s->raw, buf, sz);
+ rv = nni_copyin_bool(&s->raw, buf, sz, typ);
nni_mtx_unlock(&s->mtx);
return (rv);
}
@@ -366,10 +366,10 @@ resp0_sock_getopt_raw(void *arg, void *buf, size_t *szp, int typ)
}
static int
-resp0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz)
+resp0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
{
resp0_sock *s = arg;
- return (nni_setopt_int(&s->ttl, buf, sz, 1, 255));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
}
static int
diff --git a/src/protocol/survey0/survey.c b/src/protocol/survey0/survey.c
index 161a5002..a5909015 100644
--- a/src/protocol/survey0/survey.c
+++ b/src/protocol/survey0/survey.c
@@ -275,13 +275,13 @@ failed:
}
static int
-surv0_sock_setopt_raw(void *arg, const void *buf, size_t sz)
+surv0_sock_setopt_raw(void *arg, const void *buf, size_t sz, int typ)
{
surv0_sock *s = arg;
int rv;
nni_mtx_lock(&s->mtx);
- if ((rv = nni_setopt_bool(&s->raw, buf, sz)) == 0) {
+ if ((rv = nni_copyin_bool(&s->raw, buf, sz, typ)) == 0) {
s->survid = 0;
nni_timer_cancel(&s->timer);
}
@@ -297,10 +297,10 @@ surv0_sock_getopt_raw(void *arg, void *buf, size_t *szp, int typ)
}
static int
-surv0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz)
+surv0_sock_setopt_maxttl(void *arg, const void *buf, size_t sz, int typ)
{
surv0_sock *s = arg;
- return (nni_setopt_int(&s->ttl, buf, sz, 1, 255));
+ return (nni_copyin_int(&s->ttl, buf, sz, 1, 255, typ));
}
static int
@@ -311,10 +311,10 @@ surv0_sock_getopt_maxttl(void *arg, void *buf, size_t *szp, int typ)
}
static int
-surv0_sock_setopt_surveytime(void *arg, const void *buf, size_t sz)
+surv0_sock_setopt_surveytime(void *arg, const void *buf, size_t sz, int typ)
{
surv0_sock *s = arg;
- return (nni_setopt_ms(&s->survtime, buf, sz));
+ return (nni_copyin_ms(&s->survtime, buf, sz, typ));
}
static int