summaryrefslogtreecommitdiff
path: root/src/options.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-03-02 09:00:36 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-03-02 09:00:36 +0100
commit5fcef1cac4d9faf0279b83ba48899b0e17b8e2d5 (patch)
treecce0cb9223e29ba38c909cccaac828bc59f7557a /src/options.cpp
parent4c7446211a02937f3e2522aece163d417b4ad0b9 (diff)
ZMQ_MAXMSGSIZE option added
The new option allows user to guard against peers sending oversized messages. Connection to peer sending oversized message is dropped. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/options.cpp')
-rw-r--r--src/options.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/options.cpp b/src/options.cpp
index c6d5760..9271b88 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -39,6 +39,7 @@ zmq::options_t::options_t () :
reconnect_ivl (100),
reconnect_ivl_max (0),
backlog (100),
+ maxmsgsize (-1),
requires_in (false),
requires_out (false),
immediate_connect (true)
@@ -182,6 +183,14 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
backlog = *((int*) optval_);
return 0;
+ case ZMQ_MAXMSGSIZE:
+ if (optvallen_ != sizeof (int64_t)) {
+ errno = EINVAL;
+ return -1;
+ }
+ maxmsgsize = *((int64_t*) optval_);
+ return 0;
+
}
errno = EINVAL;
@@ -328,6 +337,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
*optvallen_ = sizeof (int);
return 0;
+ case ZMQ_MAXMSGSIZE:
+ if (*optvallen_ < sizeof (int64_t)) {
+ errno = EINVAL;
+ return -1;
+ }
+ *((int64_t*) optval_) = maxmsgsize;
+ *optvallen_ = sizeof (int64_t);
+ return 0;
+
}
errno = EINVAL;