12 #ifndef ZMQ_HAVE_WINDOWS
17 #define BINDDEVSIZ IFNAMSIZ
24 #if defined(ZMQ_ACT_MILITANT)
32 size_t *
const optvallen_,
40 size_t *
const optvallen_,
42 const size_t value_len_)
48 if (*optvallen_ < value_len_) {
51 memcpy (optval_,
value_, value_len_);
53 memset (
static_cast<char *
> (optval_) + value_len_, 0,
54 *optvallen_ - value_len_);
55 *optvallen_ = value_len_;
60 static int do_getsockopt_curve_key (
void *
const optval_,
61 const size_t *
const optvallen_,
79 const size_t optvallen_,
82 if (optvallen_ ==
sizeof (
T)) {
83 memcpy (out_value_, optval_,
sizeof (
T));
90 const size_t optvallen_,
91 bool *
const out_value_)
100 *out_value_ = (
value != 0);
107 const size_t optvallen_,
108 bool *
const out_value_)
113 *out_value_ = (
value != 0);
119 const size_t optvallen_,
121 const size_t max_len_)
125 if (optval_ ==
NULL && optvallen_ == 0) {
126 out_value_->clear ();
129 if (optval_ !=
NULL && optvallen_ > 0 && optvallen_ <= max_len_) {
130 out_value_->assign (
static_cast<const char *
> (optval_), optvallen_);
138 const size_t optvallen_,
140 const size_t max_len_)
144 if (optvallen_ > 0 && optvallen_ <= max_len_) {
145 out_value_->assign (
static_cast<const char *
> (optval_), optvallen_);
151 template <
typename T>
153 const size_t optvallen_,
154 std::set<T> *
const set_)
156 if (optvallen_ == 0 && optval_ ==
NULL) {
160 if (optvallen_ ==
sizeof (
T) && optval_ !=
NULL) {
161 set_->insert (*(
static_cast<const T *
> (optval_)));
176 recovery_ivl (10000),
178 multicast_maxtpdu (1500),
189 reconnect_ivl_max (0),
197 invert_matching (
false),
198 recv_routing_id (
false),
202 tcp_keepalive_cnt (-1),
203 tcp_keepalive_idle (-1),
204 tcp_keepalive_intvl (-1),
209 gss_plaintext (
false),
212 handshake_ivl (30000),
215 heartbeat_interval (0),
216 heartbeat_timeout (-1),
218 zap_enforce_domain (
false),
219 loopback_fastpath (
false),
220 multicast_loop (
true),
221 in_batch_size (8192),
222 out_batch_size (8192),
225 monitor_event_version (1),
226 wss_trust_system (
false),
228 can_send_hello_msg (
false),
230 can_recv_disconnect_msg (
false),
232 can_recv_hiccup_msg (
false),
234 norm_unicast_nacks (
false),
235 norm_buffer_size (2048),
236 norm_segment_size (1400),
237 norm_block_size (16),
239 norm_num_autoparity (0),
240 norm_push_enable (
false),
246 #if defined ZMQ_HAVE_VMCI
247 vmci_buffer_size = 0;
248 vmci_buffer_min_size = 0;
249 vmci_buffer_max_size = 0;
250 vmci_connect_timeout = -1;
258 switch (optvallen_) {
260 memcpy (destination_, optval_, optvallen_);
265 const std::string s (
static_cast<const char *
> (optval_),
277 memcpy (z85_key,
reinterpret_cast<const char *
> (optval_),
298 const bool is_int = (optvallen_ ==
sizeof (int));
301 memcpy (&
value, optval_,
sizeof (
int));
302 #if defined(ZMQ_ACT_MILITANT)
303 bool malformed =
true;
308 if (is_int &&
value >= 0) {
315 if (is_int &&
value >= 0) {
326 if (optvallen_ > 0 && optvallen_ <= UCHAR_MAX) {
327 routing_id_size =
static_cast<unsigned char> (optvallen_);
328 memcpy (routing_id, optval_, routing_id_size);
334 if (is_int &&
value > 0) {
341 if (is_int &&
value >= 0) {
342 recovery_ivl =
value;
348 if (is_int &&
value >= -1) {
355 if (is_int &&
value >= -1) {
362 if (is_int &&
value >= 0) {
369 if (is_int &&
value >= -1) {
370 linger.store (
value);
376 if (is_int &&
value >= 0) {
377 connect_timeout =
value;
383 if (is_int &&
value >= 0) {
391 reconnect_stop =
value;
397 if (is_int &&
value >= -1) {
398 reconnect_ivl =
value;
404 if (is_int &&
value >= 0) {
405 reconnect_ivl_max =
value;
411 if (is_int &&
value >= 0) {
421 if (is_int &&
value > 0) {
422 multicast_hops =
value;
428 if (is_int &&
value > 0) {
429 multicast_maxtpdu =
value;
435 if (is_int &&
value >= -1) {
442 if (is_int &&
value >= -1) {
465 optval_, optvallen_, &socks_proxy_address, SIZE_MAX);
469 if (optval_ ==
NULL || optvallen_ == 0) {
470 socks_proxy_username.clear ();
474 optval_, optvallen_, &socks_proxy_username, 255);
478 if (optval_ ==
NULL || optvallen_ == 0) {
479 socks_proxy_password.clear ();
483 optval_, optvallen_, &socks_proxy_password, 255);
487 tcp_keepalive =
value;
494 tcp_keepalive_cnt =
value;
501 tcp_keepalive_idle =
value;
508 tcp_keepalive_intvl =
value;
524 optval_, optvallen_, &filter_str, UCHAR_MAX);
526 if (filter_str.empty ()) {
527 tcp_accept_filters.clear ();
530 rc =
mask.resolve (filter_str.c_str (), ipv6);
532 tcp_accept_filters.push_back (
mask);
539 #if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
542 &ipc_uid_accept_filters);
547 &ipc_gid_accept_filters);
550 #if defined ZMQ_HAVE_SO_PEERCRED
553 &ipc_pid_accept_filters);
565 if (optvallen_ == 0 && optval_ ==
NULL) {
568 }
else if (optvallen_ > 0 && optvallen_ <= UCHAR_MAX
569 && optval_ !=
NULL) {
570 plain_username.assign (
static_cast<const char *
> (optval_),
579 if (optvallen_ == 0 && optval_ ==
NULL) {
582 }
else if (optvallen_ > 0 && optvallen_ <= UCHAR_MAX
583 && optval_ !=
NULL) {
584 plain_password.assign (
static_cast<const char *
> (optval_),
594 optval_, optvallen_, &zap_domain, UCHAR_MAX);
597 #ifdef ZMQ_HAVE_CURVE
607 if (0 == set_curve_key (curve_public_key, optval_, optvallen_)) {
613 if (0 == set_curve_key (curve_secret_key, optval_, optvallen_)) {
619 if (0 == set_curve_key (curve_server_key, optval_, optvallen_)) {
631 #ifdef HAVE_LIBGSSAPI_KRB5
641 if (optvallen_ > 0 && optvallen_ <= UCHAR_MAX && optval_ !=
NULL) {
642 gss_principal.assign ((
const char *) optval_, optvallen_);
649 if (optvallen_ > 0 && optvallen_ <= UCHAR_MAX && optval_ !=
NULL) {
650 gss_service_principal.assign ((
const char *) optval_,
667 gss_principal_nt =
value;
677 gss_service_principal_nt =
value;
684 if (is_int &&
value >= 0) {
685 handshake_ivl =
value;
695 if (is_int &&
value >= 0) {
696 heartbeat_interval =
value;
705 heartbeat_ttl =
static_cast<uint16_t
> (
value);
711 if (is_int &&
value >= 0) {
712 heartbeat_timeout =
value;
719 return do_setsockopt (optval_, optvallen_, &vmci_buffer_size);
722 return do_setsockopt (optval_, optvallen_, &vmci_buffer_min_size);
725 return do_setsockopt (optval_, optvallen_, &vmci_buffer_max_size);
728 return do_setsockopt (optval_, optvallen_, &vmci_connect_timeout);
732 if (is_int &&
value >= -1) {
740 optval_, optvallen_, &bound_device,
BINDDEVSIZ);
744 &zap_enforce_domain);
751 if (optvallen_ > 0 && !is_int) {
752 const std::string s (
static_cast<const char *
> (optval_),
754 const size_t pos =
s.find (
':');
755 if (pos != std::string::npos && pos != 0
756 && pos !=
s.length () - 1) {
758 if (
key.compare (0, 2,
"X-") == 0
759 &&
key.length () <= UCHAR_MAX) {
761 app_metadata.insert (
762 std::pair<std::string, std::string> (
key,
val));
774 #ifdef ZMQ_BUILD_DRAFT_API
776 if (is_int &&
value > 0) {
777 in_batch_size =
value;
783 if (is_int &&
value > 0) {
784 out_batch_size =
value;
798 wss_key_pem =
std::string ((
char *) optval_, optvallen_);
802 wss_cert_pem =
std::string ((
char *) optval_, optvallen_);
806 wss_trust_pem =
std::string ((
char *) optval_, optvallen_);
809 wss_hostname =
std::string ((
char *) optval_, optvallen_);
826 &norm_unicast_nacks);
829 if (is_int &&
value > 0) {
830 norm_buffer_size =
value;
836 if (is_int &&
value > 0) {
837 norm_segment_size =
value;
844 norm_block_size =
value;
851 norm_num_parity =
value;
858 norm_num_autoparity =
value;
866 #endif //ZMQ_HAVE_NORM
869 if (optvallen_ > 0) {
870 unsigned char *
bytes = (
unsigned char *) optval_;
872 std::vector<unsigned char> (
bytes,
bytes + optvallen_);
874 hello_msg = std::vector<unsigned char> ();
880 if (optvallen_ > 0) {
881 unsigned char *
bytes = (
unsigned char *) optval_;
883 std::vector<unsigned char> (
bytes,
bytes + optvallen_);
885 disconnect_msg = std::vector<unsigned char> ();
891 if (is_int &&
value >= 0) {
898 if (optvallen_ > 0) {
899 unsigned char *
bytes = (
unsigned char *) optval_;
901 std::vector<unsigned char> (
bytes,
bytes + optvallen_);
903 hiccup_msg = std::vector<unsigned char> ();
912 #if defined(ZMQ_ACT_MILITANT)
927 #if defined(ZMQ_ACT_MILITANT)
940 size_t *optvallen_)
const
942 const bool is_int = (*optvallen_ ==
sizeof (int));
943 int *
value =
static_cast<int *
> (optval_);
944 #if defined(ZMQ_ACT_MILITANT)
945 bool malformed =
true;
964 if (*optvallen_ ==
sizeof (uint64_t)) {
965 *(
static_cast<uint64_t *
> (optval_)) = affinity;
983 *
value = recovery_ivl;
1018 *
value = linger.load ();
1025 *
value = connect_timeout;
1039 *
value = reconnect_stop;
1046 *
value = reconnect_ivl;
1053 *
value = reconnect_ivl_max;
1066 if (*optvallen_ ==
sizeof (int64_t)) {
1067 *(
static_cast<int64_t *
> (optval_)) = maxmsgsize;
1068 *optvallen_ =
sizeof (int64_t);
1075 *
value = multicast_hops;
1082 *
value = multicast_maxtpdu;
1123 return do_getsockopt (optval_, optvallen_, socks_proxy_address);
1126 return do_getsockopt (optval_, optvallen_, socks_proxy_username);
1129 return do_getsockopt (optval_, optvallen_, socks_proxy_password);
1133 *
value = tcp_keepalive;
1140 *
value = tcp_keepalive_cnt;
1147 *
value = tcp_keepalive_idle;
1154 *
value = tcp_keepalive_intvl;
1183 #ifdef ZMQ_HAVE_CURVE
1192 return do_getsockopt_curve_key (optval_, optvallen_,
1196 return do_getsockopt_curve_key (optval_, optvallen_,
1200 return do_getsockopt_curve_key (optval_, optvallen_,
1212 #ifdef HAVE_LIBGSSAPI_KRB5
1224 return do_getsockopt (optval_, optvallen_, gss_service_principal);
1228 *
value = gss_plaintext;
1235 *
value = gss_principal_nt;
1241 *
value = gss_service_principal_nt;
1249 *
value = handshake_ivl;
1256 *
value = invert_matching;
1263 *
value = heartbeat_interval;
1271 *
value = heartbeat_ttl * 100;
1278 *
value = heartbeat_timeout;
1295 *
value = zap_enforce_domain;
1302 *
value = loopback_fastpath;
1309 *
value = multicast_loop;
1314 #ifdef ZMQ_BUILD_DRAFT_API
1317 *
value = router_notify;
1324 *
value = in_batch_size;
1331 *
value = out_batch_size;
1349 #ifdef ZMQ_HAVE_NORM
1359 *
value = norm_unicast_nacks;
1366 *
value = norm_buffer_size;
1373 *
value = norm_segment_size;
1380 *
value = norm_block_size;
1387 *
value = norm_num_parity;
1394 *
value = norm_num_autoparity;
1401 *
value = norm_push_enable;
1405 #endif //ZMQ_HAVE_NORM
1411 #if defined(ZMQ_ACT_MILITANT)
1416 #if defined(ZMQ_ACT_MILITANT)