libzmq  master
ZeroMQ C++ Core Engine (LIBZMQ)
options.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
3 
4  This file is part of libzmq, the ZeroMQ core engine in C++.
5 
6  libzmq is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License (LGPL) as published
8  by the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  As a special exception, the Contributors give you permission to link
12  this library with independent modules to produce an executable,
13  regardless of the license terms of these independent modules, and to
14  copy and distribute the resulting executable under terms of your choice,
15  provided that you also meet, for each linked independent module, the
16  terms and conditions of the license of that module. An independent
17  module is a module which is not derived from or based on this library.
18  If you modify this library, you must extend this exception to your
19  version of the library.
20 
21  libzmq is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24  License for more details.
25 
26  You should have received a copy of the GNU Lesser General Public License
27  along with this program. If not, see <http://www.gnu.org/licenses/>.
28 */
29 
30 #ifndef __ZMQ_OPTIONS_HPP_INCLUDED__
31 #define __ZMQ_OPTIONS_HPP_INCLUDED__
32 
33 #include <string>
34 #include <vector>
35 #include <set>
36 
37 #include "stddef.h"
38 #include "stdint.hpp"
39 #include "tcp_address.hpp"
40 #include "../include/zmq.h"
41 
42 #if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
43 #include <sys/types.h>
44 #endif
45 #ifdef ZMQ_HAVE_LOCAL_PEERCRED
46 #include <sys/ucred.h>
47 #endif
48 
49 // Normal base 256 key is 32 bytes
50 #define CURVE_KEYSIZE 32
51 // Key encoded using Z85 is 40 bytes
52 #define CURVE_KEYSIZE_Z85 40
53 
54 namespace zmq
55 {
56  struct options_t
57  {
58  options_t ();
59 
60  int setsockopt (int option_, const void *optval_, size_t optvallen_);
61  int getsockopt (int option_, void *optval_, size_t *optvallen_) const;
62 
63  bool is_valid (int option_) const;
64 
65  // High-water marks for message pipes.
66  int sndhwm;
67  int rcvhwm;
68 
69  // I/O thread affinity.
70  uint64_t affinity;
71 
72  // Socket identity
73  unsigned char identity_size;
74  unsigned char identity [256];
75 
76  // Maximum transfer rate [kb/s]. Default 100kb/s.
77  int rate;
78 
79  // Reliability time interval [ms]. Default 10 seconds.
81 
82  // Sets the time-to-live field in every multicast packet sent.
84 
85  // Sets the maximum transport data unit size in every multicast
86  // packet sent.
88 
89  // SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets.
90  int sndbuf;
91  int rcvbuf;
92 
93  // Type of service (containing DSCP and ECN socket options)
94  int tos;
95 
96  // Socket type.
97  int type;
98 
99  // Linger time, in milliseconds.
100  int linger;
101 
102  // Maximum interval in milliseconds beyond which userspace will
103  // timeout connect().
104  // Default 0 (unused)
106 
107  // Maximum interval in milliseconds beyond which TCP will timeout
108  // retransmitted packets.
109  // Default 0 (unused)
111 
112  // Minimum interval between attempts to reconnect, in milliseconds.
113  // Default 100ms
115 
116  // Maximum interval between attempts to reconnect, in milliseconds.
117  // Default 0 (unused)
119 
120  // Maximum backlog for pending connections.
121  int backlog;
122 
123  // Maximal size of message to handle.
124  int64_t maxmsgsize;
125 
126  // The timeout for send/recv operations for this socket.
127  int rcvtimeo;
128  int sndtimeo;
129 
130  // If true, IPv6 is enabled (as well as IPv4)
131  bool ipv6;
132 
133  // If 1, connecting pipes are not attached immediately, meaning a send()
134  // on a socket with only connecting pipes would block
136 
137  // If 1, (X)SUB socket should filter the messages. If 0, it should not.
138  bool filter;
139 
140  // If true, the subscription matching on (X)PUB and (X)SUB sockets
141  // is reversed. Messages are sent to and received by non-matching
142  // sockets.
144 
145  // If true, the identity message is forwarded to the socket.
147 
148  // if true, router socket accepts non-zmq tcp connections
150  bool raw_notify; // Provide connect notifications
151 
152  // Address of SOCKS proxy
153  std::string socks_proxy_address;
154 
155  // TCP keep-alive settings.
156  // Defaults to -1 = do not change socket options
161 
162  // TCP accept() filters
163  typedef std::vector <tcp_address_mask_t> tcp_accept_filters_t;
164  tcp_accept_filters_t tcp_accept_filters;
165 
166  // IPC accept() filters
167 # if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
168  bool zap_ipc_creds;
169  typedef std::set <uid_t> ipc_uid_accept_filters_t;
170  ipc_uid_accept_filters_t ipc_uid_accept_filters;
171  typedef std::set <gid_t> ipc_gid_accept_filters_t;
172  ipc_gid_accept_filters_t ipc_gid_accept_filters;
173 # endif
174 # if defined ZMQ_HAVE_SO_PEERCRED
175  typedef std::set <pid_t> ipc_pid_accept_filters_t;
176  ipc_pid_accept_filters_t ipc_pid_accept_filters;
177 # endif
178 
179  // Security mechanism for all connections on this socket
181 
182  // If peer is acting as server for PLAIN or CURVE mechanisms
184 
185  // ZAP authentication domain
186  std::string zap_domain;
187 
188  // Security credentials for PLAIN mechanism
189  std::string plain_username;
190  std::string plain_password;
191 
192  // Security credentials for CURVE mechanism
196 
197  // Principals for GSSAPI mechanism
198  std::string gss_principal;
200 
201  // If true, gss encryption will be disabled
203 
204  // ID of the socket.
206 
207  // If true, socket conflates outgoing/incoming messages.
208  // Applicable to dealer, push/pull, pub/sub socket types.
209  // Cannot receive multi-part messages.
210  // Ignores hwm
211  bool conflate;
212 
213  // If connection handshake is not done after this many milliseconds,
214  // close socket. Default is 30 secs. 0 means no handshake timeout.
216 
217  bool connected;
218  // If remote peer receives a PING message and doesn't receive another
219  // message within the ttl value, it should close the connection
220  // (measured in tenths of a second)
221  uint16_t heartbeat_ttl;
222  // Time in milliseconds between sending heartbeat PING messages.
224  // Time in milliseconds to wait for a PING response before disconnecting
226 
227 # if defined ZMQ_HAVE_VMCI
228  uint64_t vmci_buffer_size;
229  uint64_t vmci_buffer_min_size;
230  uint64_t vmci_buffer_max_size;
231  int vmci_connect_timeout;
232 # endif
233 
234  // When creating a new ZMQ socket, if this option is set the value
235  // will be used as the File Descriptor instead of allocating a new
236  // one via the socket () system call.
237  int use_fd;
238  };
239 }
240 
241 #endif
std::string plain_username
Definition: options.hpp:189
bool invert_matching
Definition: options.hpp:143
bool gss_plaintext
Definition: options.hpp:202
int heartbeat_timeout
Definition: options.hpp:225
int multicast_hops
Definition: options.hpp:83
std::string socks_proxy_address
Definition: options.hpp:153
std::string gss_principal
Definition: options.hpp:198
bool recv_identity
Definition: options.hpp:146
int64_t maxmsgsize
Definition: options.hpp:124
int getsockopt(int option_, void *optval_, size_t *optvallen_) const
Definition: options.cpp:642
int connect_timeout
Definition: options.hpp:105
uint64_t affinity
Definition: options.hpp:70
int reconnect_ivl_max
Definition: options.hpp:118
uint8_t curve_server_key[CURVE_KEYSIZE]
Definition: options.hpp:195
uint8_t curve_secret_key[CURVE_KEYSIZE]
Definition: options.hpp:194
std::string gss_service_principal
Definition: options.hpp:199
std::vector< tcp_address_mask_t > tcp_accept_filters_t
Definition: options.hpp:163
int recovery_ivl
Definition: options.hpp:80
int tcp_keepalive_idle
Definition: options.hpp:159
unsigned char identity[256]
Definition: options.hpp:74
int multicast_maxtpdu
Definition: options.hpp:87
std::string plain_password
Definition: options.hpp:190
tcp_accept_filters_t tcp_accept_filters
Definition: options.hpp:164
#define CURVE_KEYSIZE
Definition: options.hpp:50
uint8_t curve_public_key[CURVE_KEYSIZE]
Definition: options.hpp:193
int tcp_keepalive_cnt
Definition: options.hpp:158
bool is_valid(int option_) const
Definition: options.cpp:1038
int setsockopt(int option_, const void *optval_, size_t optvallen_)
Definition: options.cpp:93
std::string zap_domain
Definition: options.hpp:186
uint16_t heartbeat_ttl
Definition: options.hpp:221
int heartbeat_interval
Definition: options.hpp:223
Definition: address.hpp:35
unsigned char identity_size
Definition: options.hpp:73
int tcp_keepalive_intvl
Definition: options.hpp:160