options.hpp 5.49 KB
Newer Older
1
/*
2
    Copyright (c) 2007-2014 Contributors as noted in the AUTHORS file
3 4 5 6

    This file is part of 0MQ.

    0MQ is free software; you can redistribute it and/or modify it under
7
    the terms of the GNU Lesser General Public License as published by
8 9 10 11 12 13
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    0MQ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU Lesser General Public License for more details.
15

16
    You should have received a copy of the GNU Lesser General Public License
17 18 19 20 21 22
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __ZMQ_OPTIONS_HPP_INCLUDED__
#define __ZMQ_OPTIONS_HPP_INCLUDED__

23
#include <string>
24
#include <vector>
25
#include <set>
26

27
#include "stddef.h"
unknown's avatar
unknown committed
28
#include "stdint.hpp"
29
#include "tcp_address.hpp"
30
#include "../include/zmq.h"
unknown's avatar
unknown committed
31

32 33 34 35
#if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
#include <sys/types.h>
#endif

Pieter Hintjens's avatar
Pieter Hintjens committed
36 37 38 39
//  Normal base 256 key is 32 bytes
#define CURVE_KEYSIZE       32
//  Key encoded using Z85 is 40 bytes
#define CURVE_KEYSIZE_Z85   40
40

41 42 43 44 45 46
namespace zmq
{
    struct options_t
    {
        options_t ();

47
        int setsockopt (int option_, const void *optval_, size_t optvallen_);
48
        int getsockopt (int option_, void *optval_, size_t *optvallen_);
49

50 51 52
        //  High-water marks for message pipes.
        int sndhwm;
        int rcvhwm;
53

54
        //  I/O thread affinity.
55
        uint64_t affinity;
malosek's avatar
malosek committed
56

57 58 59
        //  Socket identity
        unsigned char identity_size;
        unsigned char identity [256];
60

61
        //  Maximum transfer rate [kb/s]. Default 100kb/s.
62
        int rate;
malosek's avatar
malosek committed
63

64
        //  Reliability time interval [ms]. Default 10 seconds.
65
        int recovery_ivl;
66

67 68 69
        // Sets the time-to-live field in every multicast packet sent.
        int multicast_hops;

70 71 72
        // SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets.
        int sndbuf;
        int rcvbuf;
73

74 75 76
        // Type of service (containing DSCP and ECN socket options)
        int tos;

77 78 79
        //  Socket type.
        int type;

80 81 82
        //  Linger time, in milliseconds.
        int linger;

83 84
        //  Minimum interval between attempts to reconnect, in milliseconds.
        //  Default 100ms
85
        int reconnect_ivl;
86

87 88 89
        //  Maximum interval between attempts to reconnect, in milliseconds.
        //  Default 0 (unused)
        int reconnect_ivl_max;
90

91 92 93
        //  Maximum backlog for pending connections.
        int backlog;

94 95 96
        //  Maximal size of message to handle.
        int64_t maxmsgsize;

97 98 99 100
        // The timeout for send/recv operations for this socket.
        int rcvtimeo;
        int sndtimeo;

Pieter Hintjens's avatar
Pieter Hintjens committed
101 102
        //  If true, IPv6 is enabled (as well as IPv4)
        bool ipv6;
103

104 105
        //  If 1, connecting pipes are not attached immediately, meaning a send()
        //  on a socket with only connecting pipes would block
106
        int immediate;
Steven McCoy's avatar
Steven McCoy committed
107

108 109
        //  If 1, (X)SUB socket should filter the messages. If 0, it should not.
        bool filter;
110

111
        //  If true, the identity message is forwarded to the socket.
112
        bool recv_identity;
Martin Hurton's avatar
Martin Hurton committed
113

114 115
        // if true, router socket accepts non-zmq tcp connections
        bool raw_sock;
116

117 118 119
        //  Addres of SOCKS proxy
        std::string socks_proxy_address;

120 121 122 123 124 125 126
        //  TCP keep-alive settings.
        //  Defaults to -1 = do not change socket options
        int tcp_keepalive;
        int tcp_keepalive_cnt;
        int tcp_keepalive_idle;
        int tcp_keepalive_intvl;

127 128 129 130
        // TCP accept() filters
        typedef std::vector <tcp_address_mask_t> tcp_accept_filters_t;
        tcp_accept_filters_t tcp_accept_filters;

131 132
        // IPC accept() filters
#       if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
133
        bool zap_ipc_creds;
134 135 136 137 138 139 140 141 142 143
        typedef std::set <uid_t> ipc_uid_accept_filters_t;
        ipc_uid_accept_filters_t ipc_uid_accept_filters;
        typedef std::set <gid_t> ipc_gid_accept_filters_t;
        ipc_gid_accept_filters_t ipc_gid_accept_filters;
#       endif
#       if defined ZMQ_HAVE_SO_PEERCRED
        typedef std::set <pid_t> ipc_pid_accept_filters_t;
        ipc_pid_accept_filters_t ipc_pid_accept_filters;
#       endif

144 145
        //  Security mechanism for all connections on this socket
        int mechanism;
146

147
        //  If peer is acting as server for PLAIN or CURVE mechanisms
148 149 150 151 152
        int as_server;

        //  ZAP authentication domain
        std::string zap_domain;

153 154 155 156
        //  Security credentials for PLAIN mechanism
        std::string plain_username;
        std::string plain_password;

157
        //  Security credentials for CURVE mechanism
158 159 160
        uint8_t curve_public_key [CURVE_KEYSIZE];
        uint8_t curve_secret_key [CURVE_KEYSIZE];
        uint8_t curve_server_key [CURVE_KEYSIZE];
161

Chris Busbey's avatar
Chris Busbey committed
162 163 164
        //  Principals for GSSAPI mechanism
        std::string gss_principal;
        std::string gss_service_principal;
165

166 167 168
        //  If true, gss encryption will be disabled
        bool gss_plaintext;

169 170
        //  ID of the socket.
        int socket_id;
danielkr's avatar
danielkr committed
171 172 173 174 175 176

        //  If true, socket conflates outgoing/incoming messages.
        //  Applicable to dealer, push/pull, pub/sub socket types.
        //  Cannot receive multi-part messages.
        //  Ignores hwm
        bool conflate;
177 178 179 180 181

        //  If connection handshake is not done after this many milliseconds,
        //  close socket.  Default is 30 secs.  0 means no handshake timeout.
        int handshake_ivl;

182 183 184 185
    };
}

#endif