diff options
author | Anthony Neal <aneal@zeroc.com> | 2001-11-13 15:42:30 +0000 |
---|---|---|
committer | Anthony Neal <aneal@zeroc.com> | 2001-11-13 15:42:30 +0000 |
commit | fcd722bf5050ea9f3b96288bc30fe539744b3e00 (patch) | |
tree | aaee49bc6dc47c3abd88b3b0c2abe91dd3f2a824 /cpp/src/Ice/SslTransceiver.cpp | |
parent | minor fixes (diff) | |
download | ice-fcd722bf5050ea9f3b96288bc30fe539744b3e00.tar.bz2 ice-fcd722bf5050ea9f3b96288bc30fe539744b3e00.tar.xz ice-fcd722bf5050ea9f3b96288bc30fe539744b3e00.zip |
Incorporates SSL, with all Ice tests running under SSL.
Diffstat (limited to 'cpp/src/Ice/SslTransceiver.cpp')
-rw-r--r-- | cpp/src/Ice/SslTransceiver.cpp | 106 |
1 files changed, 97 insertions, 9 deletions
diff --git a/cpp/src/Ice/SslTransceiver.cpp b/cpp/src/Ice/SslTransceiver.cpp index 60e931084c0..76af7b5daf7 100644 --- a/cpp/src/Ice/SslTransceiver.cpp +++ b/cpp/src/Ice/SslTransceiver.cpp @@ -7,19 +7,36 @@ // All Rights Reserved // // ********************************************************************** - -#include <Ice/SslTransceiver.h> +
+#ifdef SSL_EXTENSION
+#include <Ice/SslConnection.h>
+#endif +
+#include <Ice/SslTransceiver.h>
#include <Ice/Instance.h> #include <Ice/TraceLevels.h> #include <Ice/Logger.h> #include <Ice/Buffer.h> #include <Ice/Network.h> #include <Ice/Exception.h> +
+#ifdef SSL_EXTENSION
+#include <Ice/Security.h>
+#include <Ice/SslException.h>
+#include <sstream>
+#endif
using namespace std; using namespace Ice; using namespace IceInternal; +#ifdef SSL_EXTENSION
+using IceSecurity::SecurityException;
+using IceSecurity::Ssl::InitException;
+using IceSecurity::Ssl::ReInitException;
+using IceSecurity::Ssl::ShutdownException;
+#endif
+
int IceInternal::SslTransceiver::fd() { @@ -29,6 +46,10 @@ IceInternal::SslTransceiver::fd() void IceInternal::SslTransceiver::close() { +#ifndef SSL_EXTENSION
+ METHOD_INV("SslTransceiver::close()");
+#endif
+
if (_traceLevels->network >= 1) { ostringstream s; @@ -37,14 +58,23 @@ IceInternal::SslTransceiver::close() } int fd = _fd; + cleanUpSSL();
_fd = INVALID_SOCKET; ::shutdown(fd, SHUT_RDWR); // helps to unblock threads in recv() closeSocket(fd); +
+#ifndef SSL_EXTENSION
+ METHOD_RET("SslTransceiver::close()");
+#endif
} void IceInternal::SslTransceiver::shutdown() { +#ifndef SSL_EXTENSION
+ METHOD_INV("SslTransceiver::shutdown()");
+#endif
+
if (_traceLevels->network >= 2) { ostringstream s; @@ -53,11 +83,17 @@ IceInternal::SslTransceiver::shutdown() } ::shutdown(_fd, SHUT_WR); // Shutdown socket for writing +
+#ifndef SSL_EXTENSION
+ METHOD_RET("SslTransceiver::shutdown()");
+#endif
} void IceInternal::SslTransceiver::write(Buffer& buf, int timeout) -{ +{
+#ifndef SSL_EXTENSION
+ METHOD_INV("SslTransceiver::write()")
int packetSize = buf.b.end() - buf.i; #ifdef WIN32 @@ -162,12 +198,22 @@ IceInternal::SslTransceiver::write(Buffer& buf, int timeout) { packetSize = buf.b.end() - buf.i; } - } + }
+
+ METHOD_INV("SslTransceiver::write()");
+#else
+
+ _sslConnection->write(buf, timeout);
+
+#endif
} void IceInternal::SslTransceiver::read(Buffer& buf, int timeout) { +#ifndef SSL_EXTENSION
+ METHOD_INV("SslTransceiver::read()");
+
int packetSize = buf.b.end() - buf.i; while (buf.i != buf.b.end()) @@ -263,6 +309,18 @@ IceInternal::SslTransceiver::read(Buffer& buf, int timeout) packetSize = buf.b.end() - buf.i; } } +
+ METHOD_INV("SslTransceiver::read()");
+#else
+
+ if (!_sslConnection->read(buf, timeout))
+ {
+ ConnectionLostException clEx(__FILE__, __LINE__);
+ clEx.error = 0;
+ throw clEx;
+ }
+
+#endif
} string @@ -271,12 +329,25 @@ IceInternal::SslTransceiver::toString() const return fdToString(_fd); } -IceInternal::SslTransceiver::SslTransceiver(const InstancePtr& instance, int fd) : - _instance(instance), - _fd(fd), - _traceLevels(instance->traceLevels()), - _logger(instance->logger()) +#ifndef SSL_EXTENSION
+IceInternal::SslTransceiver::SslTransceiver(const InstancePtr& instance, int fd) :
+ _instance(instance),
+ _fd(fd),
+ _traceLevels(instance->traceLevels()),
+ _logger(instance->logger())
+#else
+IceInternal::SslTransceiver::SslTransceiver(const InstancePtr& instance, int fd, Connection* sslConnection) :
+ _instance(instance),
+ _fd(fd),
+ _traceLevels(instance->traceLevels()),
+ _logger(instance->logger()),
+ _sslConnection(sslConnection)
+#endif { +#ifdef SSL_EXTENSION
+ assert(sslConnection != 0);
+#endif
+
FD_ZERO(&_rFdSet); FD_ZERO(&_wFdSet); } @@ -284,4 +355,21 @@ IceInternal::SslTransceiver::SslTransceiver(const InstancePtr& instance, int fd) IceInternal::SslTransceiver::~SslTransceiver() { assert(_fd == INVALID_SOCKET); +
+#ifdef SSL_EXTENSION
+ cleanUpSSL();
+#endif
} +
+void
+IceInternal::SslTransceiver::cleanUpSSL()
+{
+#ifdef SSL_EXTENSION
+ if (_sslConnection != 0)
+ {
+ _sslConnection->shutdown();
+ delete _sslConnection;
+ _sslConnection = 0;
+ }
+#endif
+}
|