quickfix_ruby_ud 2.0.7-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +257 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +137 -0
- data/ext/quickfix/DOMDocument.h +70 -0
- data/ext/quickfix/DataDictionary.cpp +679 -0
- data/ext/quickfix/DataDictionary.h +607 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
- data/ext/quickfix/DataDictionaryProvider.h +67 -0
- data/ext/quickfix/DatabaseConnectionID.h +98 -0
- data/ext/quickfix/DatabaseConnectionPool.h +84 -0
- data/ext/quickfix/Dictionary.cpp +157 -0
- data/ext/quickfix/Dictionary.h +89 -0
- data/ext/quickfix/Event.h +89 -0
- data/ext/quickfix/Except.h +39 -0
- data/ext/quickfix/Exceptions.h +257 -0
- data/ext/quickfix/Field.h +654 -0
- data/ext/quickfix/FieldConvertors.cpp +86 -0
- data/ext/quickfix/FieldConvertors.h +800 -0
- data/ext/quickfix/FieldMap.cpp +254 -0
- data/ext/quickfix/FieldMap.h +327 -0
- data/ext/quickfix/FieldNumbers.h +44 -0
- data/ext/quickfix/FieldTypes.cpp +62 -0
- data/ext/quickfix/FieldTypes.h +817 -0
- data/ext/quickfix/Fields.h +30 -0
- data/ext/quickfix/FileLog.cpp +176 -0
- data/ext/quickfix/FileLog.h +110 -0
- data/ext/quickfix/FileStore.cpp +369 -0
- data/ext/quickfix/FileStore.h +131 -0
- data/ext/quickfix/FixCommonFields.h +13 -0
- data/ext/quickfix/FixFieldNumbers.h +6132 -0
- data/ext/quickfix/FixFields.h +6133 -0
- data/ext/quickfix/FixValues.h +5790 -0
- data/ext/quickfix/Group.cpp +44 -0
- data/ext/quickfix/Group.h +78 -0
- data/ext/quickfix/HostDetailsProvider.cpp +79 -0
- data/ext/quickfix/HostDetailsProvider.h +44 -0
- data/ext/quickfix/HtmlBuilder.h +178 -0
- data/ext/quickfix/HttpConnection.cpp +914 -0
- data/ext/quickfix/HttpConnection.h +74 -0
- data/ext/quickfix/HttpMessage.cpp +229 -0
- data/ext/quickfix/HttpMessage.h +112 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +49 -0
- data/ext/quickfix/HttpServer.cpp +152 -0
- data/ext/quickfix/HttpServer.h +76 -0
- data/ext/quickfix/Initiator.cpp +310 -0
- data/ext/quickfix/Initiator.h +151 -0
- data/ext/quickfix/Log.cpp +71 -0
- data/ext/quickfix/Log.h +254 -0
- data/ext/quickfix/Message.cpp +617 -0
- data/ext/quickfix/Message.h +419 -0
- data/ext/quickfix/MessageCracker.h +171 -0
- data/ext/quickfix/MessageSorters.cpp +101 -0
- data/ext/quickfix/MessageSorters.h +185 -0
- data/ext/quickfix/MessageStore.cpp +182 -0
- data/ext/quickfix/MessageStore.h +164 -0
- data/ext/quickfix/Mutex.h +120 -0
- data/ext/quickfix/MySQLConnection.h +187 -0
- data/ext/quickfix/MySQLLog.cpp +262 -0
- data/ext/quickfix/MySQLLog.h +158 -0
- data/ext/quickfix/MySQLStore.cpp +323 -0
- data/ext/quickfix/MySQLStore.h +161 -0
- data/ext/quickfix/MySQLStubs.h +203 -0
- data/ext/quickfix/NullStore.cpp +40 -0
- data/ext/quickfix/NullStore.h +89 -0
- data/ext/quickfix/OdbcConnection.h +241 -0
- data/ext/quickfix/OdbcLog.cpp +230 -0
- data/ext/quickfix/OdbcLog.h +109 -0
- data/ext/quickfix/OdbcStore.cpp +313 -0
- data/ext/quickfix/OdbcStore.h +124 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +111 -0
- data/ext/quickfix/Parser.h +50 -0
- data/ext/quickfix/PostgreSQLConnection.h +163 -0
- data/ext/quickfix/PostgreSQLLog.cpp +263 -0
- data/ext/quickfix/PostgreSQLLog.h +157 -0
- data/ext/quickfix/PostgreSQLStore.cpp +327 -0
- data/ext/quickfix/PostgreSQLStore.h +160 -0
- data/ext/quickfix/PostgreSQLStubs.h +203 -0
- data/ext/quickfix/Queue.h +66 -0
- data/ext/quickfix/QuickfixRuby.cpp +131900 -0
- data/ext/quickfix/QuickfixRuby.h +56 -0
- data/ext/quickfix/Responder.h +41 -0
- data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
- data/ext/quickfix/SSLSocketAcceptor.h +186 -0
- data/ext/quickfix/SSLSocketConnection.cpp +434 -0
- data/ext/quickfix/SSLSocketConnection.h +221 -0
- data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
- data/ext/quickfix/SSLSocketInitiator.h +203 -0
- data/ext/quickfix/SSLStubs.h +129 -0
- data/ext/quickfix/Session.cpp +1437 -0
- data/ext/quickfix/Session.h +343 -0
- data/ext/quickfix/SessionFactory.cpp +314 -0
- data/ext/quickfix/SessionFactory.h +84 -0
- data/ext/quickfix/SessionID.h +136 -0
- data/ext/quickfix/SessionSettings.cpp +165 -0
- data/ext/quickfix/SessionSettings.h +283 -0
- data/ext/quickfix/SessionState.h +260 -0
- data/ext/quickfix/Settings.cpp +160 -0
- data/ext/quickfix/Settings.h +56 -0
- data/ext/quickfix/SharedArray.h +274 -0
- data/ext/quickfix/SocketAcceptor.cpp +216 -0
- data/ext/quickfix/SocketAcceptor.h +77 -0
- data/ext/quickfix/SocketConnection.cpp +256 -0
- data/ext/quickfix/SocketConnection.h +102 -0
- data/ext/quickfix/SocketConnector.cpp +112 -0
- data/ext/quickfix/SocketConnector.h +76 -0
- data/ext/quickfix/SocketInitiator.cpp +241 -0
- data/ext/quickfix/SocketInitiator.h +76 -0
- data/ext/quickfix/SocketMonitor.h +26 -0
- data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
- data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
- data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
- data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
- data/ext/quickfix/SocketServer.cpp +163 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
- data/ext/quickfix/ThreadedSocketConnection.h +89 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
- data/ext/quickfix/TimeRange.cpp +227 -0
- data/ext/quickfix/TimeRange.h +215 -0
- data/ext/quickfix/Utility.cpp +639 -0
- data/ext/quickfix/Utility.h +255 -0
- data/ext/quickfix/UtilitySSL.cpp +1612 -0
- data/ext/quickfix/UtilitySSL.h +274 -0
- data/ext/quickfix/Values.h +63 -0
- data/ext/quickfix/config-all.h +10 -0
- data/ext/quickfix/config.h +10 -0
- data/ext/quickfix/config_unix.h +178 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/dirent_windows.h +838 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
- data/ext/quickfix/double-conversion/bignum.cc +766 -0
- data/ext/quickfix/double-conversion/bignum.h +144 -0
- data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
- data/ext/quickfix/double-conversion/cached-powers.h +64 -0
- data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
- data/ext/quickfix/double-conversion/diy-fp.h +118 -0
- data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
- data/ext/quickfix/double-conversion/double-conversion.h +543 -0
- data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
- data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
- data/ext/quickfix/double-conversion/ieee.h +402 -0
- data/ext/quickfix/double-conversion/strtod.cc +557 -0
- data/ext/quickfix/double-conversion/strtod.h +45 -0
- data/ext/quickfix/double-conversion/utils.h +374 -0
- data/ext/quickfix/extconf.rb +76 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +77 -0
- data/ext/quickfix/pugixml.cpp +13237 -0
- data/ext/quickfix/pugixml.hpp +1516 -0
- data/ext/quickfix/scope_guard.hpp +215 -0
- data/ext/quickfix/stdint_msvc.h +254 -0
- data/ext/quickfix/strptime.h +7 -0
- data/lib/2.4/quickfix.so +0 -0
- data/lib/2.5/quickfix.so +0 -0
- data/lib/2.6/quickfix.so +0 -0
- data/lib/2.7/quickfix.so +0 -0
- data/lib/3.0/quickfix.so +0 -0
- data/lib/3.1/quickfix.so +0 -0
- data/lib/3.2/quickfix.so +0 -0
- data/lib/3.3/quickfix.so +0 -0
- data/lib/3.4/quickfix.so +0 -0
- data/lib/quickfix40.rb +274 -0
- data/lib/quickfix41.rb +351 -0
- data/lib/quickfix42.rb +1184 -0
- data/lib/quickfix43.rb +3504 -0
- data/lib/quickfix44.rb +14040 -0
- data/lib/quickfix50.rb +20051 -0
- data/lib/quickfix50sp1.rb +23596 -0
- data/lib/quickfix50sp2.rb +412444 -0
- data/lib/quickfix_fields.rb +79393 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +65 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1282 -0
- data/spec/FIX42.xml +2743 -0
- data/spec/FIX43.xml +4230 -0
- data/spec/FIX44.xml +6600 -0
- data/spec/FIX50.xml +8142 -0
- data/spec/FIX50SP1.xml +9506 -0
- data/spec/FIX50SP2.xml +26069 -0
- data/spec/FIXT11.xml +252 -0
- data/test/DataDictionaryTestCase.rb +268 -0
- data/test/DictionaryTestCase.rb +112 -0
- data/test/FieldBaseTestCase.rb +24 -0
- data/test/MessageStoreTestCase.rb +19 -0
- data/test/MessageTestCase.rb +368 -0
- data/test/SessionSettingsTestCase.rb +41 -0
- metadata +247 -0
@@ -0,0 +1,434 @@
|
|
1
|
+
/* ====================================================================
|
2
|
+
* Copyright (c) 1998-2006 Ralf S. Engelschall. All rights reserved.
|
3
|
+
*
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
5
|
+
* modification, are permitted provided that the following conditions
|
6
|
+
* are met:
|
7
|
+
*
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
*
|
11
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
12
|
+
* notice, this list of conditions and the following
|
13
|
+
* disclaimer in the documentation and/or other materials
|
14
|
+
* provided with the distribution.
|
15
|
+
*
|
16
|
+
* 3. All advertising materials mentioning features or use of this
|
17
|
+
* software must display the following acknowledgment:
|
18
|
+
* "This product includes software developed by
|
19
|
+
* Ralf S. Engelschall <rse@engelschall.com> for use in the
|
20
|
+
* mod_ssl project (http://www.modssl.org/)."
|
21
|
+
*
|
22
|
+
* 4. The names "mod_ssl" must not be used to endorse or promote
|
23
|
+
* products derived from this software without prior written
|
24
|
+
* permission. For written permission, please contact
|
25
|
+
* rse@engelschall.com.
|
26
|
+
*
|
27
|
+
* 5. Products derived from this software may not be called "mod_ssl"
|
28
|
+
* nor may "mod_ssl" appear in their names without prior
|
29
|
+
* written permission of Ralf S. Engelschall.
|
30
|
+
*
|
31
|
+
* 6. Redistributions of any form whatsoever must retain the following
|
32
|
+
* acknowledgment:
|
33
|
+
* "This product includes software developed by
|
34
|
+
* Ralf S. Engelschall <rse@engelschall.com> for use in the
|
35
|
+
* mod_ssl project (http://www.modssl.org/)."
|
36
|
+
*
|
37
|
+
* THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY
|
38
|
+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
39
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
40
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR
|
41
|
+
* HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
42
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
43
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
44
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
45
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
46
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
47
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
48
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
49
|
+
* ====================================================================
|
50
|
+
*/
|
51
|
+
|
52
|
+
/* ====================================================================
|
53
|
+
* Copyright (c) 1995-1999 Ben Laurie. All rights reserved.
|
54
|
+
*
|
55
|
+
* Redistribution and use in source and binary forms, with or without
|
56
|
+
* modification, are permitted provided that the following conditions
|
57
|
+
* are met:
|
58
|
+
*
|
59
|
+
* 1. Redistributions of source code must retain the above copyright
|
60
|
+
* notice, this list of conditions and the following disclaimer.
|
61
|
+
*
|
62
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
63
|
+
* notice, this list of conditions and the following disclaimer in
|
64
|
+
* the documentation and/or other materials provided with the
|
65
|
+
* distribution.
|
66
|
+
*
|
67
|
+
* 3. All advertising materials mentioning features or use of this
|
68
|
+
* software must display the following acknowledgment:
|
69
|
+
* "This product includes software developed by Ben Laurie
|
70
|
+
* for use in the Apache-SSL HTTP server project."
|
71
|
+
*
|
72
|
+
* 4. The name "Apache-SSL Server" must not be used to
|
73
|
+
* endorse or promote products derived from this software without
|
74
|
+
* prior written permission.
|
75
|
+
*
|
76
|
+
* 5. Redistributions of any form whatsoever must retain the following
|
77
|
+
* acknowledgment:
|
78
|
+
* "This product includes software developed by Ben Laurie
|
79
|
+
* for use in the Apache-SSL HTTP server project."
|
80
|
+
*
|
81
|
+
* THIS SOFTWARE IS PROVIDED BY BEN LAURIE ``AS IS'' AND ANY
|
82
|
+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
83
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
84
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BEN LAURIE OR
|
85
|
+
* HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
86
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
87
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
88
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
89
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
90
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
91
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
92
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
93
|
+
* ====================================================================
|
94
|
+
*/
|
95
|
+
|
96
|
+
/****************************************************************************
|
97
|
+
** Copyright (c) 2001-2014
|
98
|
+
**
|
99
|
+
** This file is part of the QuickFIX FIX Engine
|
100
|
+
**
|
101
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
102
|
+
** license as defined by quickfixengine.org and appearing in the file
|
103
|
+
** LICENSE included in the packaging of this file.
|
104
|
+
**
|
105
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
106
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
107
|
+
**
|
108
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
109
|
+
**
|
110
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
111
|
+
** not clear to you.
|
112
|
+
**
|
113
|
+
****************************************************************************/
|
114
|
+
|
115
|
+
#ifdef _MSC_VER
|
116
|
+
#include "stdafx.h"
|
117
|
+
#else
|
118
|
+
#include "config.h"
|
119
|
+
#endif
|
120
|
+
|
121
|
+
#if (HAVE_SSL > 0)
|
122
|
+
|
123
|
+
#include "SSLSocketAcceptor.h"
|
124
|
+
#include "SSLSocketConnection.h"
|
125
|
+
#include "SSLSocketInitiator.h"
|
126
|
+
#include "Session.h"
|
127
|
+
#include "SocketConnector.h"
|
128
|
+
#include "Utility.h"
|
129
|
+
|
130
|
+
namespace FIX {
|
131
|
+
SSLSocketConnection::SSLSocketConnection(socket_handle socket, SSL *ssl, Sessions sessions, SocketMonitor *pMonitor)
|
132
|
+
: m_socket(socket),
|
133
|
+
m_ssl(ssl),
|
134
|
+
m_sendLength(0),
|
135
|
+
m_sessions(sessions),
|
136
|
+
m_pSession(0),
|
137
|
+
m_pMonitor(pMonitor) {
|
138
|
+
#ifdef _MSC_VER
|
139
|
+
FD_ZERO(&m_fds);
|
140
|
+
FD_SET(m_socket, &m_fds);
|
141
|
+
#endif
|
142
|
+
}
|
143
|
+
|
144
|
+
SSLSocketConnection::SSLSocketConnection(
|
145
|
+
SSLSocketInitiator &initiator,
|
146
|
+
const SessionID &sessionID,
|
147
|
+
socket_handle socket,
|
148
|
+
SSL *ssl,
|
149
|
+
SocketMonitor *pMonitor)
|
150
|
+
: m_socket(socket),
|
151
|
+
m_ssl(ssl),
|
152
|
+
m_sendLength(0),
|
153
|
+
m_pSession(initiator.getSession(sessionID, *this)),
|
154
|
+
m_pMonitor(pMonitor) {
|
155
|
+
#ifdef _MSC_VER
|
156
|
+
FD_ZERO(&m_fds);
|
157
|
+
FD_SET(m_socket, &m_fds);
|
158
|
+
#endif
|
159
|
+
m_sessions.insert(sessionID);
|
160
|
+
}
|
161
|
+
|
162
|
+
SSLSocketConnection::~SSLSocketConnection() {
|
163
|
+
if (m_pSession) {
|
164
|
+
Session::unregisterSession(m_pSession->getSessionID());
|
165
|
+
}
|
166
|
+
|
167
|
+
ssl_socket_close(m_socket, m_ssl);
|
168
|
+
|
169
|
+
SSL_free(m_ssl);
|
170
|
+
}
|
171
|
+
|
172
|
+
bool SSLSocketConnection::send(const std::string &message) {
|
173
|
+
Locker l(m_mutex);
|
174
|
+
|
175
|
+
m_sendQueue.push_back(message);
|
176
|
+
processQueue();
|
177
|
+
signal();
|
178
|
+
return true;
|
179
|
+
}
|
180
|
+
|
181
|
+
bool SSLSocketConnection::processQueue() {
|
182
|
+
Locker l(m_mutex);
|
183
|
+
|
184
|
+
m_processQueueNeedsToReadData = false;
|
185
|
+
|
186
|
+
if (m_sendQueue.empty()) {
|
187
|
+
return true;
|
188
|
+
}
|
189
|
+
|
190
|
+
#ifdef _MSC_VER
|
191
|
+
struct timeval timeout = {0, 0};
|
192
|
+
fd_set writeset = m_fds;
|
193
|
+
if (select(1 + m_socket, 0, &writeset, 0, &timeout) <= 0) {
|
194
|
+
return false;
|
195
|
+
}
|
196
|
+
#else
|
197
|
+
struct pollfd pfd = {m_socket, POLLOUT, 0};
|
198
|
+
if (poll(&pfd, 1, 0) <= 0) {
|
199
|
+
return false;
|
200
|
+
}
|
201
|
+
#endif
|
202
|
+
|
203
|
+
const std::string &message = m_sendQueue.front();
|
204
|
+
|
205
|
+
errno = 0;
|
206
|
+
int errCodeSSL = 0;
|
207
|
+
int sent = 0;
|
208
|
+
ERR_clear_error();
|
209
|
+
|
210
|
+
sent = SSL_write(m_ssl, message.c_str() + m_sendLength, message.length() - m_sendLength);
|
211
|
+
|
212
|
+
if (sent > 0) {
|
213
|
+
m_sendLength += sent;
|
214
|
+
|
215
|
+
if (m_sendLength == message.length()) {
|
216
|
+
m_sendLength = 0;
|
217
|
+
m_sendQueue.pop_front();
|
218
|
+
}
|
219
|
+
return m_sendQueue.empty();
|
220
|
+
}
|
221
|
+
|
222
|
+
errCodeSSL = SSL_get_error(m_ssl, sent);
|
223
|
+
|
224
|
+
if ((errCodeSSL == SSL_ERROR_WANT_READ) || (errCodeSSL == SSL_ERROR_WANT_WRITE)) {
|
225
|
+
errno = EINTR;
|
226
|
+
sent = 0;
|
227
|
+
|
228
|
+
if (errCodeSSL == SSL_ERROR_WANT_WRITE) {
|
229
|
+
return false;
|
230
|
+
} else {
|
231
|
+
m_processQueueNeedsToReadData = true;
|
232
|
+
return true; // we may have more to write but we want to read first, so unsignal for now
|
233
|
+
}
|
234
|
+
} else {
|
235
|
+
std::string error = socket_error();
|
236
|
+
m_pSession->getLog()->onEvent("SSL send error <" + IntConvertor::convert(errCodeSSL) + "> " + error);
|
237
|
+
|
238
|
+
return false;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
bool SSLSocketConnection::didProcessQueueRequestToRead() const {
|
243
|
+
Locker l(m_mutex);
|
244
|
+
return m_processQueueNeedsToReadData;
|
245
|
+
}
|
246
|
+
|
247
|
+
void SSLSocketConnection::disconnect() {
|
248
|
+
if (m_pMonitor) {
|
249
|
+
m_pMonitor->drop(m_socket);
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
bool SSLSocketConnection::read(SocketConnector &connector) {
|
254
|
+
if (!m_pSession) {
|
255
|
+
return false;
|
256
|
+
}
|
257
|
+
|
258
|
+
try {
|
259
|
+
readFromSocket();
|
260
|
+
readMessages(connector.getMonitor());
|
261
|
+
} catch (SocketRecvFailed &e) {
|
262
|
+
m_pSession->getLog()->onEvent(e.what());
|
263
|
+
return false;
|
264
|
+
}
|
265
|
+
return true;
|
266
|
+
}
|
267
|
+
|
268
|
+
bool SSLSocketConnection::read(SSLSocketAcceptor &acceptor, SocketServer &server) {
|
269
|
+
std::string message;
|
270
|
+
try {
|
271
|
+
if (!m_pSession) {
|
272
|
+
#if _MSC_VER
|
273
|
+
struct timeval timeout = {1, 0};
|
274
|
+
fd_set readset = m_fds;
|
275
|
+
#else
|
276
|
+
int timeout = 1000; // 1000ms = 1 second
|
277
|
+
struct pollfd pfd = {m_socket, POLLIN | POLLPRI, 0};
|
278
|
+
#endif
|
279
|
+
|
280
|
+
while (!readMessage(message)) {
|
281
|
+
#if _MSC_VER
|
282
|
+
int result = select(1 + m_socket, &readset, 0, 0, &timeout);
|
283
|
+
#else
|
284
|
+
int result = poll(&pfd, 1, timeout);
|
285
|
+
#endif
|
286
|
+
if (result > 0) {
|
287
|
+
readFromSocket();
|
288
|
+
} else if (result == 0) {
|
289
|
+
return false;
|
290
|
+
} else if (result < 0) {
|
291
|
+
return false;
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
m_pSession = Session::lookupSession(message, true);
|
296
|
+
if (!isValidSession()) {
|
297
|
+
m_pSession = 0;
|
298
|
+
if (acceptor.getLog()) {
|
299
|
+
acceptor.getLog()->onEvent("Session not found for incoming message: " + message);
|
300
|
+
acceptor.getLog()->onIncoming(message);
|
301
|
+
}
|
302
|
+
}
|
303
|
+
if (m_pSession) {
|
304
|
+
m_pSession = acceptor.getSession(message, *this);
|
305
|
+
}
|
306
|
+
if (m_pSession) {
|
307
|
+
m_pSession->next(message, UtcTimeStamp::now());
|
308
|
+
}
|
309
|
+
if (!m_pSession) {
|
310
|
+
server.getMonitor().drop(m_socket);
|
311
|
+
return false;
|
312
|
+
}
|
313
|
+
|
314
|
+
Session::registerSession(m_pSession->getSessionID());
|
315
|
+
return true;
|
316
|
+
} else {
|
317
|
+
readFromSocket();
|
318
|
+
readMessages(server.getMonitor());
|
319
|
+
return true;
|
320
|
+
}
|
321
|
+
} catch (SocketRecvFailed &e) {
|
322
|
+
if (m_pSession) {
|
323
|
+
m_pSession->getLog()->onEvent(e.what());
|
324
|
+
}
|
325
|
+
server.getMonitor().drop(m_socket);
|
326
|
+
} catch (InvalidMessage &) {
|
327
|
+
server.getMonitor().drop(m_socket);
|
328
|
+
}
|
329
|
+
return false;
|
330
|
+
}
|
331
|
+
|
332
|
+
bool SSLSocketConnection::isValidSession() {
|
333
|
+
if (m_pSession == 0) {
|
334
|
+
return false;
|
335
|
+
}
|
336
|
+
SessionID sessionID = m_pSession->getSessionID();
|
337
|
+
if (Session::isSessionRegistered(sessionID)) {
|
338
|
+
return false;
|
339
|
+
}
|
340
|
+
return !(m_sessions.find(sessionID) == m_sessions.end());
|
341
|
+
}
|
342
|
+
|
343
|
+
void SSLSocketConnection::readFromSocket() EXCEPT(SocketRecvFailed) {
|
344
|
+
bool pending = false;
|
345
|
+
|
346
|
+
m_readFromSocketNeedsToWriteData = false;
|
347
|
+
do {
|
348
|
+
pending = false;
|
349
|
+
errno = 0;
|
350
|
+
ssize_t size = 0;
|
351
|
+
int errCodeSSL = 0;
|
352
|
+
ERR_clear_error();
|
353
|
+
|
354
|
+
// Cannot do concurrent SSL write and read as ssl context has to be
|
355
|
+
// protected.
|
356
|
+
{
|
357
|
+
Locker locker(m_mutex);
|
358
|
+
|
359
|
+
size = SSL_read(m_ssl, m_buffer, sizeof(m_buffer));
|
360
|
+
if (size <= 0) {
|
361
|
+
errCodeSSL = SSL_get_error(m_ssl, size);
|
362
|
+
} else if (SSL_pending(m_ssl) > 0) {
|
363
|
+
pending = true;
|
364
|
+
}
|
365
|
+
}
|
366
|
+
|
367
|
+
if (size <= 0) {
|
368
|
+
if ((errCodeSSL == SSL_ERROR_WANT_READ) || (errCodeSSL == SSL_ERROR_WANT_WRITE)) {
|
369
|
+
errno = EINTR;
|
370
|
+
size = 0;
|
371
|
+
|
372
|
+
if (errCodeSSL == SSL_ERROR_WANT_WRITE) {
|
373
|
+
Locker locker(m_mutex);
|
374
|
+
m_readFromSocketNeedsToWriteData = true;
|
375
|
+
subscribeToSocketWriteAvailableEvents();
|
376
|
+
}
|
377
|
+
|
378
|
+
return;
|
379
|
+
} else {
|
380
|
+
std::string error = socket_error();
|
381
|
+
|
382
|
+
if (m_pSession) {
|
383
|
+
m_pSession->getLog()->onEvent("SSL read error <" + IntConvertor::convert(errCodeSSL) + "> " + error);
|
384
|
+
} else {
|
385
|
+
std::cerr << UtcTimeStampConvertor::convert(UtcTimeStamp::now()) << "SSL read error <"
|
386
|
+
<< IntConvertor::convert(errCodeSSL) << "> " << error << std::endl;
|
387
|
+
}
|
388
|
+
|
389
|
+
throw SocketRecvFailed(size);
|
390
|
+
}
|
391
|
+
}
|
392
|
+
|
393
|
+
m_parser.addToStream(m_buffer, size);
|
394
|
+
} while (pending);
|
395
|
+
}
|
396
|
+
|
397
|
+
bool SSLSocketConnection::didReadFromSocketRequestToWrite() const {
|
398
|
+
Locker locker(m_mutex);
|
399
|
+
return m_readFromSocketNeedsToWriteData;
|
400
|
+
}
|
401
|
+
|
402
|
+
bool SSLSocketConnection::readMessage(std::string &message) {
|
403
|
+
try {
|
404
|
+
return m_parser.readFixMessage(message);
|
405
|
+
} catch (MessageParseError &) {}
|
406
|
+
return true;
|
407
|
+
}
|
408
|
+
|
409
|
+
void SSLSocketConnection::readMessages(SocketMonitor &socketMonitor) {
|
410
|
+
if (!m_pSession) {
|
411
|
+
return;
|
412
|
+
}
|
413
|
+
|
414
|
+
std::string message;
|
415
|
+
while (readMessage(message)) {
|
416
|
+
try {
|
417
|
+
m_pSession->next(message, UtcTimeStamp::now());
|
418
|
+
} catch (InvalidMessage &) {
|
419
|
+
if (!m_pSession->isLoggedOn()) {
|
420
|
+
socketMonitor.drop(m_socket);
|
421
|
+
}
|
422
|
+
}
|
423
|
+
}
|
424
|
+
}
|
425
|
+
|
426
|
+
void SSLSocketConnection::onTimeout() {
|
427
|
+
if (m_pSession) {
|
428
|
+
m_pSession->next(UtcTimeStamp::now());
|
429
|
+
}
|
430
|
+
}
|
431
|
+
|
432
|
+
} // namespace FIX
|
433
|
+
|
434
|
+
#endif
|
@@ -0,0 +1,221 @@
|
|
1
|
+
/* ====================================================================
|
2
|
+
* Copyright (c) 1998-2006 Ralf S. Engelschall. All rights reserved.
|
3
|
+
*
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
5
|
+
* modification, are permitted provided that the following conditions
|
6
|
+
* are met:
|
7
|
+
*
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
*
|
11
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
12
|
+
* notice, this list of conditions and the following
|
13
|
+
* disclaimer in the documentation and/or other materials
|
14
|
+
* provided with the distribution.
|
15
|
+
*
|
16
|
+
* 3. All advertising materials mentioning features or use of this
|
17
|
+
* software must display the following acknowledgment:
|
18
|
+
* "This product includes software developed by
|
19
|
+
* Ralf S. Engelschall <rse@engelschall.com> for use in the
|
20
|
+
* mod_ssl project (http://www.modssl.org/)."
|
21
|
+
*
|
22
|
+
* 4. The names "mod_ssl" must not be used to endorse or promote
|
23
|
+
* products derived from this software without prior written
|
24
|
+
* permission. For written permission, please contact
|
25
|
+
* rse@engelschall.com.
|
26
|
+
*
|
27
|
+
* 5. Products derived from this software may not be called "mod_ssl"
|
28
|
+
* nor may "mod_ssl" appear in their names without prior
|
29
|
+
* written permission of Ralf S. Engelschall.
|
30
|
+
*
|
31
|
+
* 6. Redistributions of any form whatsoever must retain the following
|
32
|
+
* acknowledgment:
|
33
|
+
* "This product includes software developed by
|
34
|
+
* Ralf S. Engelschall <rse@engelschall.com> for use in the
|
35
|
+
* mod_ssl project (http://www.modssl.org/)."
|
36
|
+
*
|
37
|
+
* THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY
|
38
|
+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
39
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
40
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR
|
41
|
+
* HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
42
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
43
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
44
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
45
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
46
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
47
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
48
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
49
|
+
* ====================================================================
|
50
|
+
*/
|
51
|
+
|
52
|
+
/* ====================================================================
|
53
|
+
* Copyright (c) 1995-1999 Ben Laurie. All rights reserved.
|
54
|
+
*
|
55
|
+
* Redistribution and use in source and binary forms, with or without
|
56
|
+
* modification, are permitted provided that the following conditions
|
57
|
+
* are met:
|
58
|
+
*
|
59
|
+
* 1. Redistributions of source code must retain the above copyright
|
60
|
+
* notice, this list of conditions and the following disclaimer.
|
61
|
+
*
|
62
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
63
|
+
* notice, this list of conditions and the following disclaimer in
|
64
|
+
* the documentation and/or other materials provided with the
|
65
|
+
* distribution.
|
66
|
+
*
|
67
|
+
* 3. All advertising materials mentioning features or use of this
|
68
|
+
* software must display the following acknowledgment:
|
69
|
+
* "This product includes software developed by Ben Laurie
|
70
|
+
* for use in the Apache-SSL HTTP server project."
|
71
|
+
*
|
72
|
+
* 4. The name "Apache-SSL Server" must not be used to
|
73
|
+
* endorse or promote products derived from this software without
|
74
|
+
* prior written permission.
|
75
|
+
*
|
76
|
+
* 5. Redistributions of any form whatsoever must retain the following
|
77
|
+
* acknowledgment:
|
78
|
+
* "This product includes software developed by Ben Laurie
|
79
|
+
* for use in the Apache-SSL HTTP server project."
|
80
|
+
*
|
81
|
+
* THIS SOFTWARE IS PROVIDED BY BEN LAURIE ``AS IS'' AND ANY
|
82
|
+
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
83
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
84
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BEN LAURIE OR
|
85
|
+
* HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
86
|
+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
87
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
88
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
89
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
90
|
+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
91
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
92
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
93
|
+
* ====================================================================
|
94
|
+
*/
|
95
|
+
|
96
|
+
/* -*- C++ -*- */
|
97
|
+
|
98
|
+
/****************************************************************************
|
99
|
+
** Copyright (c) 2001-2014
|
100
|
+
**
|
101
|
+
** This file is part of the QuickFIX FIX Engine
|
102
|
+
**
|
103
|
+
** This file may be distributed under the terms of the quickfixengine.org
|
104
|
+
** license as defined by quickfixengine.org and appearing in the file
|
105
|
+
** LICENSE included in the packaging of this file.
|
106
|
+
**
|
107
|
+
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
108
|
+
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
109
|
+
**
|
110
|
+
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
111
|
+
**
|
112
|
+
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
113
|
+
** not clear to you.
|
114
|
+
**
|
115
|
+
****************************************************************************/
|
116
|
+
|
117
|
+
#ifndef FIX_SSLSOCKETCONNECTION_H
|
118
|
+
#define FIX_SSLSOCKETCONNECTION_H
|
119
|
+
|
120
|
+
#ifndef HAVE_SSL
|
121
|
+
#error SSLSocketConnection.h included, but HAVE_SSL not defined
|
122
|
+
#endif
|
123
|
+
|
124
|
+
#ifdef HAVE_SSL
|
125
|
+
|
126
|
+
#ifdef _MSC_VER
|
127
|
+
#pragma warning(disable : 4503 4355 4786 4290)
|
128
|
+
#endif
|
129
|
+
|
130
|
+
#include "Mutex.h"
|
131
|
+
#include "Parser.h"
|
132
|
+
#include "Responder.h"
|
133
|
+
#include "SessionID.h"
|
134
|
+
#include "SocketMonitor.h"
|
135
|
+
#include "Utility.h"
|
136
|
+
#include "UtilitySSL.h"
|
137
|
+
#include <set>
|
138
|
+
|
139
|
+
namespace FIX {
|
140
|
+
class SSLSocketAcceptor;
|
141
|
+
class SocketServer;
|
142
|
+
class SocketConnector;
|
143
|
+
class SSLSocketInitiator;
|
144
|
+
class Session;
|
145
|
+
|
146
|
+
/// Encapsulates a socket file descriptor (single-threaded).
|
147
|
+
class SSLSocketConnection : Responder {
|
148
|
+
public:
|
149
|
+
typedef std::set<SessionID> Sessions;
|
150
|
+
|
151
|
+
SSLSocketConnection(socket_handle s, SSL *ssl, Sessions sessions, SocketMonitor *pMonitor);
|
152
|
+
SSLSocketConnection(SSLSocketInitiator &, const SessionID &, socket_handle, SSL *, SocketMonitor *);
|
153
|
+
virtual ~SSLSocketConnection();
|
154
|
+
|
155
|
+
socket_handle getSocket() const { return m_socket; }
|
156
|
+
Session *getSession() const { return m_pSession; }
|
157
|
+
|
158
|
+
bool read(SocketConnector &s);
|
159
|
+
bool read(SSLSocketAcceptor &, SocketServer &);
|
160
|
+
bool processQueue();
|
161
|
+
|
162
|
+
void signal() {
|
163
|
+
Locker l(m_mutex);
|
164
|
+
if (m_sendQueue.size() == 1) {
|
165
|
+
m_pMonitor->signal(m_socket);
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
void subscribeToSocketWriteAvailableEvents() { m_pMonitor->signal(m_socket); }
|
170
|
+
|
171
|
+
void unsignal() {
|
172
|
+
Locker l(m_mutex);
|
173
|
+
if (m_sendQueue.size() == 0) {
|
174
|
+
m_pMonitor->unsignal(m_socket);
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
void setHandshakeStartTime(time_t time) { m_handshakeStartTime = time; }
|
179
|
+
|
180
|
+
int getSecondsFromHandshakeStart(time_t now) { return static_cast<int>(now - m_handshakeStartTime); }
|
181
|
+
|
182
|
+
void onTimeout();
|
183
|
+
|
184
|
+
SSL *sslObject() { return m_ssl; }
|
185
|
+
|
186
|
+
bool didProcessQueueRequestToRead() const;
|
187
|
+
bool didReadFromSocketRequestToWrite() const;
|
188
|
+
|
189
|
+
private:
|
190
|
+
typedef std::deque<std::string, ALLOCATOR<std::string>> Queue;
|
191
|
+
|
192
|
+
bool isValidSession();
|
193
|
+
void readFromSocket() EXCEPT(SocketRecvFailed);
|
194
|
+
bool readMessage(std::string &msg);
|
195
|
+
void readMessages(SocketMonitor &s);
|
196
|
+
bool send(const std::string &);
|
197
|
+
void disconnect();
|
198
|
+
|
199
|
+
socket_handle m_socket;
|
200
|
+
SSL *m_ssl;
|
201
|
+
char m_buffer[BUFSIZ];
|
202
|
+
|
203
|
+
Parser m_parser;
|
204
|
+
Queue m_sendQueue;
|
205
|
+
unsigned m_sendLength;
|
206
|
+
Sessions m_sessions;
|
207
|
+
Session *m_pSession;
|
208
|
+
SocketMonitor *m_pMonitor;
|
209
|
+
mutable Mutex m_mutex;
|
210
|
+
#ifdef _MSC_VER
|
211
|
+
fd_set m_fds;
|
212
|
+
#endif
|
213
|
+
bool m_processQueueNeedsToReadData = false;
|
214
|
+
bool m_readFromSocketNeedsToWriteData = false;
|
215
|
+
time_t m_handshakeStartTime = 0;
|
216
|
+
};
|
217
|
+
} // namespace FIX
|
218
|
+
|
219
|
+
#endif
|
220
|
+
|
221
|
+
#endif // FIX_SSLSOCKETCONNECTION_H
|