From 1ef883febf4ec7230b8b943af262d6549e33eb34 Mon Sep 17 00:00:00 2001
From: Steven McCoy <steven.mccoy@miru.hk>
Date: Mon, 8 Aug 2011 15:42:37 +0800
Subject: [PATCH 7/7] Wire up new option ZMQ_IPV4ONLY.


Signed-off-by: Steven McCoy <steven.mccoy@miru.hk>
---
 include/zmq.h   |    1 +
 src/options.cpp |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/include/zmq.h b/include/zmq.h
index d9e91ff..ed5d49c 100644
--- a/include/zmq.h
+++ b/include/zmq.h
@@ -185,6 +185,7 @@ ZMQ_EXPORT int zmq_term (void *context);
 #define ZMQ_RCVTIMEO 27
 #define ZMQ_SNDTIMEO 28
 #define ZMQ_RCVLABEL 29
+#define ZMQ_IPV4ONLY 30
 
 /*  Send/recv options.                                                        */
 #define ZMQ_DONTWAIT 1
diff --git a/src/options.cpp b/src/options.cpp
index 38002e3..f720787 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -194,6 +194,14 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
         sndtimeo = *((int*) optval_);
         return 0;
 
+    case ZMQ_IPV4ONLY:
+        if (optvallen_ != sizeof (int)) {
+            errno = EINVAL;
+            return -1;
+        }
+        ipv4only = *((int*) optval_);
+        return 0;
+
     }
 
     errno = EINVAL;
@@ -357,6 +365,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
         *optvallen_ = sizeof (int);
         return 0;
 
+    case ZMQ_IPV4ONLY:
+        if (*optvallen_ < sizeof (int)) {
+            errno = EINVAL;
+            return -1;
+        }
+        *((int*) optval_) = ipv4only;
+        *optvallen_ = sizeof (int);
+        return 0;
+
     }
 
     errno = EINVAL;
-- 
1.7.4.1

