ThreadedSSLSocketConnection.h
Go to the documentation of this file.
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_THREADEDSSLSOCKETCONNECTION_H
118 #define FIX_THREADEDSSLSOCKETCONNECTION_H
119 
120 #if (HAVE_SSL > 0)
121 
122 #ifdef _MSC_VER
123 #pragma warning(disable : 4503 4355 4786 4290)
124 #endif
125 
126 #include "Parser.h"
127 #include "Responder.h"
128 #include "SessionID.h"
129 #include "Mutex.h"
130 #include "UtilitySSL.h"
131 #include <set>
132 #include <map>
133 
134 namespace FIX
135 {
136 class ThreadedSSLSocketAcceptor;
137 class ThreadedSSLSocketInitiator;
138 class Session;
139 class Application;
140 class Log;
141 
143 class ThreadedSSLSocketConnection : Responder
144 {
145 public:
146  typedef std::set< SessionID > Sessions;
147 
148  ThreadedSSLSocketConnection(int s, SSL *ssl, Sessions sessions, Log *pLog);
149  ThreadedSSLSocketConnection(const SessionID &, int s, SSL *ssl,
150  const std::string &address, short port,
151  Log *pLog);
152  virtual ~ThreadedSSLSocketConnection();
153 
154  Session *getSession() const { return m_pSession; }
155  int getSocket() const { return m_socket; }
156  bool connect();
157  void disconnect();
158  bool read();
159  SSL *sslObject() { return m_ssl; }
160 
161 private:
162  typedef std::pair< int, SSL * > SocketKey;
163 
164  bool readMessage(std::string &msg) throw(SocketRecvFailed);
165  void processStream();
166  bool send(const std::string &);
167  bool setSession(const std::string &msg);
168 
169  int m_socket;
170  SSL *m_ssl;
171  char m_buffer[BUFSIZ];
172 
173  std::string m_address;
174  int m_port;
175 
176  Log *m_pLog;
177  Parser m_parser;
178  Sessions m_sessions;
179  Session *m_pSession;
180  bool m_disconnect;
181  fd_set m_fds;
182 
183  Mutex m_mutex;
184 };
185 }
186 
187 #endif // FIX_THREADEDSOCKETCONNECTION_H
188 
189 #endif
SessionID.h
UtilitySSL.h
Mutex.h
Parser.h
FIX
Definition: Acceptor.cpp:34
Responder.h

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001