diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-08-25 16:19:59 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-08-25 16:19:59 +0200 |
commit | 5a03e038dbd5f319abcb5ea43cf77b72bb21fa86 (patch) | |
tree | 6cf9d383b64bcab43fd7e1f51c4c26426a52aaec /cpp/src/IceSSL | |
parent | Removed test/Slice/Forward.ice (diff) | |
download | ice-5a03e038dbd5f319abcb5ea43cf77b72bb21fa86.tar.bz2 ice-5a03e038dbd5f319abcb5ea43cf77b72bb21fa86.tar.xz ice-5a03e038dbd5f319abcb5ea43cf77b72bb21fa86.zip |
Removed unused files
Diffstat (limited to 'cpp/src/IceSSL')
-rw-r--r-- | cpp/src/IceSSL/uwp/AcceptorI.cpp | 221 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/AcceptorI.h | 66 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/ConnectorI.cpp | 120 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/ConnectorI.h | 46 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/EndpointI.cpp | 442 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/EndpointI.h | 99 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/PluginI.cpp | 36 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/TransceiverF.h | 31 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/TransceiverI.cpp | 417 | ||||
-rw-r--r-- | cpp/src/IceSSL/uwp/TransceiverI.h | 93 |
10 files changed, 0 insertions, 1571 deletions
diff --git a/cpp/src/IceSSL/uwp/AcceptorI.cpp b/cpp/src/IceSSL/uwp/AcceptorI.cpp deleted file mode 100644 index c7732d5b1c5..00000000000 --- a/cpp/src/IceSSL/uwp/AcceptorI.cpp +++ /dev/null @@ -1,221 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <IceSSL/uwp/AcceptorI.h> -#include <IceSSL/uwp/TransceiverI.h> -#include <IceSSL/uwp/EndpointI.h> - -#include <Ice/ProtocolInstance.h> -#include <Ice/LocalException.h> -#include <Ice/LoggerUtil.h> -#include <Ice/Exception.h> -#include <Ice/Properties.h> -#include <IceUtil/StringUtil.h> - -using namespace std; -using namespace Ice; -using namespace IceSSL; - -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Storage::Streams; -using namespace Windows::Networking; -using namespace Windows::Networking::Sockets; - -IceUtil::Shared* IceSSL::upCast(AcceptorI* p) { return p; } - -IceInternal::NativeInfoPtr -IceSSL::AcceptorI::getNativeInfo() -{ - return this; -} - -void -IceSSL::AcceptorI::setCompletedHandler(IceInternal::SocketOperationCompletedHandler^ handler) -{ - _completedHandler = handler; -} - -void -IceSSL::AcceptorI::close() -{ - IceUtil::Mutex::Lock lock(_mutex); - if(_acceptPending) - { - assert(_accepted.empty()); - _completedHandler(IceInternal::SocketOperationRead); - _acceptPending = false; - } - else if(!_accepted.empty()) - { - for(deque<StreamSocket^>::const_iterator p = _accepted.begin(); p != _accepted.end(); ++p) - { - IceInternal::closeSocket(*p); - } - _accepted.clear(); - } - - if(_fd != INVALID_SOCKET) - { - IceInternal::closeSocketNoThrow(_fd); - _fd = INVALID_SOCKET; - } -} - -IceInternal::EndpointIPtr -IceSSL::AcceptorI::listen() -{ - try - { - const_cast<IceInternal::Address&>(_addr) = IceInternal::doBind(_fd, _addr); - } - catch(...) - { - _fd = INVALID_SOCKET; - throw; - } - _endpoint = _endpoint->endpoint(this); - return _endpoint; -} - -void -IceSSL::AcceptorI::startAccept() -{ - assert(_fd != INVALID_SOCKET); - - // - // If there are already sockets waiting to be accepted, we just - // notify the selector that the acceptor is ready for acceting the - // new socket. Otherwise, we set the _acceptPending flag, when a - // new socket connection event is received, the message handler - // will notify the selector. - // - IceUtil::Mutex::Lock lock(_mutex); - assert(!_acceptPending); - if(!_accepted.empty()) - { - _completedHandler(IceInternal::SocketOperationRead); - } - else - { - _acceptPending = true; - } -} - -void -IceSSL::AcceptorI::finishAccept() -{ - // - // Nothing to do, we just check there's at least one accepted - // socket or the acceptor was closed. - // - IceUtil::Mutex::Lock lock(_mutex); - assert(!_acceptPending && (!_accepted.empty() || _fd == INVALID_SOCKET)); -} - -IceInternal::TransceiverPtr -IceSSL::AcceptorI::accept() -{ - if(_fd == INVALID_SOCKET) // Acceptor closed. - { - assert(_accepted.empty()); - throw SocketException(__FILE__, __LINE__); - } - - StreamSocket^ fd; - { - IceUtil::Mutex::Lock lock(_mutex); - assert(!_accepted.empty()); - fd = _accepted.front(); - _accepted.pop_front(); - } - - return new TransceiverI(_instance, fd, true); -} - -string -IceSSL::AcceptorI::protocol() const -{ - return _instance->protocol(); -} - -string -IceSSL::AcceptorI::toString() const -{ - return IceInternal::addrToString(_addr); -} - -string -IceSSL::AcceptorI::toDetailedString() const -{ - ostringstream os; - os << "local address = " << toString(); - vector<string> intfs = IceInternal::getHostsForEndpointExpand(IceInternal::inetAddrToString(_addr), _instance->protocolSupport(), true); - if(!intfs.empty()) - { - os << "\nlocal interfaces = "; - os << IceUtilInternal::joinString(intfs, ", "); - } - return os.str(); -} - -int -IceSSL::AcceptorI::effectivePort() const -{ - return IceInternal::getPort(_addr); -} - -IceSSL::AcceptorI::AcceptorI(const EndpointIPtr& endpoint, - const IceInternal::ProtocolInstancePtr& instance, - const string& host, - int port) : - _endpoint(endpoint), - _instance(instance), - _addr(getAddressForServer(host, port, _instance->protocolSupport(), instance->preferIPv6())), - _acceptPending(false) -{ - _fd = ref new StreamSocketListener(); - - safe_cast<StreamSocketListener^>(_fd)->ConnectionReceived += - ref new TypedEventHandler<StreamSocketListener^, StreamSocketListenerConnectionReceivedEventArgs^>( - [=](StreamSocketListener^, StreamSocketListenerConnectionReceivedEventArgs^ args) - { - queueAcceptedSocket(args->Socket); - }); -} - -IceSSL::AcceptorI::~AcceptorI() -{ - assert(_fd == INVALID_SOCKET); -} - -void -IceSSL::AcceptorI::queueAcceptedSocket(StreamSocket^ socket) -{ - IceUtil::Mutex::Lock lock(_mutex); - if(_fd == INVALID_SOCKET) // Acceptor was closed. - { - IceInternal::closeSocket(socket); - return; - } - _accepted.push_back(socket); - - // - // If the acceptor is waiting for a socket to be accepted, notify - // the selector that the acceptor is ready for "read". This will - // in turn caused finishAccept() and accept() to be called by the - // thread pool. If the acceptor isn't ready to accept the socket, - // it is just queued, when startAccept is called it will be dequed. - // - if(_acceptPending) - { - _completedHandler(IceInternal::SocketOperationRead); - _acceptPending = false; - } -} diff --git a/cpp/src/IceSSL/uwp/AcceptorI.h b/cpp/src/IceSSL/uwp/AcceptorI.h deleted file mode 100644 index b64b2bde924..00000000000 --- a/cpp/src/IceSSL/uwp/AcceptorI.h +++ /dev/null @@ -1,66 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef ICE_SSL_UWP_ACCEPTOR_I_H -#define ICE_SSL_UWP_ACCEPTOR_I_H - -#include <Ice/TransceiverF.h> -#include <Ice/ProtocolInstanceF.h> -#include <Ice/Acceptor.h> -#include <Ice/Network.h> -#include <IceSSL/uwp/TransceiverF.h> - -#include <IceUtil/Mutex.h> - -#include <deque> - -namespace IceSSL -{ - -class AcceptorI : public IceInternal::Acceptor, - public IceInternal::NativeInfo -{ -public: - - virtual IceInternal::NativeInfoPtr getNativeInfo(); - virtual void setCompletedHandler(IceInternal::SocketOperationCompletedHandler^); - - virtual void close(); - virtual IceInternal::EndpointIPtr listen(); - - virtual void startAccept(); - virtual void finishAccept(); - - virtual IceInternal::TransceiverPtr accept(); - virtual std::string protocol() const; - virtual std::string toString() const; - virtual std::string toDetailedString() const; - - int effectivePort() const; - -private: - - AcceptorI(const EndpointIPtr&, const IceInternal::ProtocolInstancePtr&, const std::string&, int); - virtual ~AcceptorI(); - friend class EndpointI; - - virtual void queueAcceptedSocket(Windows::Networking::Sockets::StreamSocket^); - - EndpointIPtr _endpoint; - const IceInternal::ProtocolInstancePtr _instance; - const IceInternal::Address _addr; - - IceUtil::Mutex _mutex; - bool _acceptPending; - IceInternal::SocketOperationCompletedHandler^ _completedHandler; - std::deque<Windows::Networking::Sockets::StreamSocket^> _accepted; -}; - -} -#endif diff --git a/cpp/src/IceSSL/uwp/ConnectorI.cpp b/cpp/src/IceSSL/uwp/ConnectorI.cpp deleted file mode 100644 index 0d185e5823f..00000000000 --- a/cpp/src/IceSSL/uwp/ConnectorI.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <IceSSL/uwp/ConnectorI.h> -#include <IceSSL/uwp/TransceiverI.h> -#include <IceSSL/uwp/EndpointI.h> - -#include <Ice/ProtocolInstance.h> -#include <Ice/LoggerUtil.h> -#include <Ice/Network.h> -#include <Ice/Exception.h> - -using namespace std; -using namespace Ice; -using namespace IceSSL; - -IceInternal::TransceiverPtr -IceSSL::ConnectorI::connect() -{ - IceInternal::TransceiverPtr transceiver = new TransceiverI(_instance, createSocket(false, _addr), false); - dynamic_cast<TransceiverI*>(transceiver.get())->connect(_addr); - return transceiver; -} - -Short -IceSSL::ConnectorI::type() const -{ - return _instance->type(); -} - -string -IceSSL::ConnectorI::toString() const -{ - return addrToString(_addr); -} - -bool -IceSSL::ConnectorI::operator==(const Connector& r) const -{ - const ConnectorI* p = dynamic_cast<const ConnectorI*>(&r); - if(!p) - { - return false; - } - - if(type() != p->type()) - { - return false; - } - - if(compareAddress(_addr, p->_addr) != 0) - { - return false; - } - - if(_timeout != p->_timeout) - { - return false; - } - - if(_connectionId != p->_connectionId) - { - return false; - } - - return true; -} - -bool -IceSSL::ConnectorI::operator<(const Connector& r) const -{ - const ConnectorI* p = dynamic_cast<const ConnectorI*>(&r); - if(!p) - { - return type() < r.type(); - } - - if(type() < p->type()) - { - return true; - } - else if(p->type() < type()) - { - return false; - } - - if(_timeout < p->_timeout) - { - return true; - } - else if(p->_timeout < _timeout) - { - return false; - } - - if(_connectionId < p->_connectionId) - { - return true; - } - else if(p->_connectionId < _connectionId) - { - return false; - } - return compareAddress(_addr, p->_addr) < 0; -} - -IceSSL::ConnectorI::ConnectorI(const IceInternal::ProtocolInstancePtr& instance, const IceInternal::Address& addr, - Ice::Int timeout, const string& connectionId) : - _instance(instance), - _addr(addr), - _timeout(timeout), - _connectionId(connectionId) -{ -} diff --git a/cpp/src/IceSSL/uwp/ConnectorI.h b/cpp/src/IceSSL/uwp/ConnectorI.h deleted file mode 100644 index 33dca004ea9..00000000000 --- a/cpp/src/IceSSL/uwp/ConnectorI.h +++ /dev/null @@ -1,46 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef ICE_SSL_UWP_CONNECTOR_I_H -#define ICE_SSL_UWP_CONNECTOR_I_H - -#include <Ice/TransceiverF.h> -#include <Ice/ProtocolInstanceF.h> -#include <Ice/Connector.h> -#include <Ice/Network.h> - -namespace IceSSL -{ - -class ConnectorI : public IceInternal::Connector -{ -public: - - virtual IceInternal::TransceiverPtr connect(); - - virtual Ice::Short type() const; - virtual std::string toString() const; - - virtual bool operator==(const IceInternal::Connector&) const; - virtual bool operator<(const IceInternal::Connector&) const; - -private: - - ConnectorI(const IceInternal::ProtocolInstancePtr&, const IceInternal::Address&, Ice::Int, const std::string&); - friend class EndpointI; - - const IceInternal::ProtocolInstancePtr _instance; - const IceInternal::Address _addr; - const Ice::Int _timeout; - const std::string _connectionId; -}; - -} - -#endif diff --git a/cpp/src/IceSSL/uwp/EndpointI.cpp b/cpp/src/IceSSL/uwp/EndpointI.cpp deleted file mode 100644 index 9e1af78995f..00000000000 --- a/cpp/src/IceSSL/uwp/EndpointI.cpp +++ /dev/null @@ -1,442 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <IceSSL/uwp/EndpointI.h> -#include <IceSSL/uwp/AcceptorI.h> -#include <IceSSL/uwp/ConnectorI.h> -#include <IceSSL/uwp/TransceiverI.h> - -#include <Ice/Network.h> -#include <Ice/OutputStream.h> -#include <Ice/InputStream.h> -#include <Ice/LocalException.h> -#include <Ice/ProtocolInstance.h> -#include <Ice/DefaultsAndOverrides.h> -#include <Ice/HashUtil.h> - -#include <IceSSL/EndpointInfo.h> - -using namespace std; -using namespace Ice; -using namespace IceSSL; - -extern "C" -{ - -Plugin* -createIceSSL(const CommunicatorPtr& com, const string&, const StringSeq&) -{ - IceInternal::ProtocolInstancePtr instance = new IceInternal::ProtocolInstance(com, SSLEndpointType, "ssl", true); - return new IceInternal::EndpointFactoryPlugin(com, new EndpointFactoryI(instance)); -} - -} - -namespace Ice -{ - -void -registerIceSSL(bool loadOnInitialize) -{ - Ice::registerPluginFactory("IceSSL", createIceSSL, true); -} - -} - -#ifndef ICE_CPP11_MAPPING -IceUtil::Shared* IceInternal::upCast(EndpointI* p) { return p; } -#endif - -IceSSL::EndpointI::EndpointI(const IceInternal::ProtocolInstancePtr& instance, const string& ho, Int po, Int ti, - const string& conId, bool co) : - IPEndpointI(instance, ho, po, IceInternal::Address(), conId), - _timeout(ti), - _compress(co) -{ -} - -IceSSL::EndpointI::EndpointI(const IceInternal::ProtocolInstancePtr& instance) : - IPEndpointI(instance), - _timeout(-2), - _compress(false) -{ -} - -IceSSL::EndpointI::EndpointI(const IceInternal::ProtocolInstancePtr& instance, InputStream* s) : - IPEndpointI(instance, s), - _timeout(-1), - _compress(false) -{ - s->read(const_cast<Int&>(_timeout)); - s->read(const_cast<bool&>(_compress)); -} - -Ice::EndpointInfoPtr -IceSSL::EndpointI::getInfo() const -{ - IPEndpointInfoPtr info; - if(_instance->secure()) - { - info = ICE_MAKE_SHARED(IceInternal::InfoI<IceSSL::EndpointInfo>, ICE_SHARED_FROM_CONST_THIS(EndpointI)); - } - else - { - info = ICE_MAKE_SHARED(IceInternal::InfoI<Ice::TCPEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(EndpointI)); - } - fillEndpointInfo(info.get()); - return info; -} - -Ice::EndpointInfoPtr -IceSSL::EndpointI::getWSInfo(const string& resource) const -{ - IPEndpointInfoPtr info; - IceSSL::WSSEndpointInfoPtr i = ICE_MAKE_SHARED(IceInternal::InfoI<IceSSL::WSSEndpointInfo>, ICE_SHARED_FROM_CONST_THIS(EndpointI)); - i->resource = resource; - info = i; - fillEndpointInfo(info.get()); - return info; -} - -Int -IceSSL::EndpointI::timeout() const -{ - return _timeout; -} - -IceInternal::EndpointIPtr -IceSSL::EndpointI::timeout(Int timeout) const -{ - if(timeout == _timeout) - { - return ICE_SHARED_FROM_CONST_THIS(EndpointI); - } - else - { - return ICE_MAKE_SHARED(EndpointI, _instance, _host, _port, timeout, _connectionId, _compress); - } -} - -IceInternal::EndpointIPtr -IceSSL::EndpointI::connectionId(const string& connectionId) const -{ - if(connectionId == _connectionId) - { - return ICE_SHARED_FROM_CONST_THIS(EndpointI); - } - else - { - return ICE_MAKE_SHARED(EndpointI, _instance, _host, _port, _timeout, connectionId, _compress); - } -} - -bool -IceSSL::EndpointI::compress() const -{ - return _compress; -} - -IceInternal::EndpointIPtr -IceSSL::EndpointI::compress(bool compress) const -{ - if(compress == _compress) - { - return ICE_SHARED_FROM_CONST_THIS(EndpointI); - } - else - { - return ICE_MAKE_SHARED(EndpointI, _instance, _host, _port, _timeout, _connectionId, compress); - } -} - -bool -IceSSL::EndpointI::datagram() const -{ - return false; -} - -bool -IceSSL::EndpointI::secure() const -{ - return true; -} - -IceInternal::TransceiverPtr -IceSSL::EndpointI::transceiver() const -{ - return 0; -} - -IceInternal::AcceptorPtr -IceSSL::EndpointI::acceptor(const string&) const -{ - return new AcceptorI(ICE_DYNAMIC_CAST(EndpointI, ICE_SHARED_FROM_CONST_THIS(EndpointI)), _instance, _host, _port); -} - -EndpointIPtr -IceSSL::EndpointI::endpoint(const AcceptorIPtr& acceptor) const -{ - return ICE_MAKE_SHARED(EndpointI, _instance, _host, acceptor->effectivePort(), _timeout, _connectionId, _compress); -} - -string -IceSSL::EndpointI::options() const -{ - // - // WARNING: Certain features, such as proxy validation in Glacier2, - // depend on the format of proxy strings. Changes to toString() and - // methods called to generate parts of the reference string could break - // these features. Please review for all features that depend on the - // format of proxyToString() before changing this and related code. - // - ostringstream s; - - s << IPEndpointI::options(); - - if(_timeout == -1) - { - s << " -t infinite"; - } - else - { - s << " -t " << _timeout; - } - - if(_compress) - { - s << " -z"; - } - - return s.str(); -} - -bool -#ifdef ICE_CPP11_MAPPING -IceSSL::EndpointI::operator==(const Endpoint& r) const -#else -IceSSL::EndpointI::operator==(const LocalObject& r) const -#endif -{ - if(!IPEndpointI::operator==(r)) - { - return false; - } - - const EndpointI* p = dynamic_cast<const EndpointI*>(&r); - if(!p) - { - return false; - } - - if(this == p) - { - return true; - } - - if(_timeout != p->_timeout) - { - return false; - } - - if(_compress != p->_compress) - { - return false; - } - - return true; -} - -bool -#ifdef ICE_CPP11_MAPPING -IceSSL::EndpointI::operator<(const Endpoint& r) const -#else -IceSSL::EndpointI::operator<(const LocalObject& r) const -#endif -{ - const EndpointI* p = dynamic_cast<const EndpointI*>(&r); - if(!p) - { - const EndpointI* e = dynamic_cast<const EndpointI*>(&r); - if(!e) - { - return false; - } - return type() < e->type(); - } - - if(this == p) - { - return false; - } - - if(_timeout < p->_timeout) - { - return true; - } - else if(p->_timeout < _timeout) - { - return false; - } - - if(!_compress && p->_compress) - { - return true; - } - else if(p->_compress < _compress) - { - return false; - } - - return IPEndpointI::operator<(r); -} - -void -IceSSL::EndpointI::streamWriteImpl(OutputStream* s) const -{ - IPEndpointI::streamWriteImpl(s); - s->write(_timeout); - s->write(_compress); -} - -void -IceSSL::EndpointI::hashInit(Ice::Int& h) const -{ - IPEndpointI::hashInit(h); - IceInternal::hashAdd(h, _timeout); - IceInternal::hashAdd(h, _compress); -} - -void -IceSSL::EndpointI::fillEndpointInfo(IPEndpointInfo* info) const -{ - IPEndpointI::fillEndpointInfo(info); - info->timeout = _timeout; - info->compress = _compress; -} - -void -IceSSL::EndpointI::initWithOptions(vector<string>& args, bool oaEndpoint) -{ - IPEndpointI::initWithOptions(args, oaEndpoint); - - if(_timeout == -2) - { - const_cast<Int&>(_timeout) = _instance->defaultTimeout(); - } -} - -bool -IceSSL::EndpointI::checkOption(const string& option, const string& argument, const string& endpoint) -{ - if(IPEndpointI::checkOption(option, argument, endpoint)) - { - return true; - } - - switch(option[1]) - { - case 't': - { - if(argument.empty()) - { - EndpointParseException ex(__FILE__, __LINE__); - ex.str = "no argument provided for -t option in endpoint " + endpoint; - throw ex; - } - - if(argument == "infinite") - { - const_cast<Int&>(_timeout) = -1; - } - else - { - istringstream t(argument); - if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1) - { - EndpointParseException ex(__FILE__, __LINE__); - ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw ex; - } - } - return true; - } - - case 'z': - { - if(!argument.empty()) - { - EndpointParseException ex(__FILE__, __LINE__); - ex.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint; - throw ex; - } - const_cast<bool&>(_compress) = true; - return true; - } - - default: - { - return false; - } - } -} - -IceInternal::ConnectorPtr -IceSSL::EndpointI::createConnector(const IceInternal::Address& address, const IceInternal::NetworkProxyPtr& proxy) const -{ - // TODO: Add support for network proxies? - return new ConnectorI(_instance, address, _timeout, _connectionId); -} - -IceInternal::IPEndpointIPtr -IceSSL::EndpointI::createEndpoint(const string& host, int port, const string& connectionId) const -{ - return ICE_MAKE_SHARED(EndpointI, _instance, host, port, _timeout, connectionId, _compress); -} - -IceSSL::EndpointFactoryI::EndpointFactoryI(const IceInternal::ProtocolInstancePtr& instance) : _instance(instance) -{ -} - -Short -IceSSL::EndpointFactoryI::type() const -{ - return _instance->type(); -} - -string -IceSSL::EndpointFactoryI::protocol() const -{ - return _instance->protocol(); -} - -IceInternal::EndpointIPtr -IceSSL::EndpointFactoryI::create(vector<string>& args, bool oaEndpoint) const -{ - IceInternal::IPEndpointIPtr endpt = ICE_MAKE_SHARED(EndpointI, _instance); - endpt->initWithOptions(args, oaEndpoint); - return endpt; -} - -IceInternal::EndpointIPtr -IceSSL::EndpointFactoryI::read(InputStream* s) const -{ - return ICE_MAKE_SHARED(EndpointI, _instance, s); -} - -void -IceSSL::EndpointFactoryI::destroy() -{ - _instance = 0; -} - -IceInternal::EndpointFactoryPtr -IceSSL::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& instance) const -{ - return new EndpointFactoryI(instance); -} diff --git a/cpp/src/IceSSL/uwp/EndpointI.h b/cpp/src/IceSSL/uwp/EndpointI.h deleted file mode 100644 index 02b2ecab644..00000000000 --- a/cpp/src/IceSSL/uwp/EndpointI.h +++ /dev/null @@ -1,99 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef ICE_SSL_UWP_ENDPOINT_I_H -#define ICE_SSL_UWP_ENDPOINT_I_H - -#include <IceUtil/Config.h> -#include <Ice/IPEndpointI.h> -#include <Ice/EndpointFactory.h> -#include <Ice/WSEndpoint.h> -#include <Ice/Network.h> // for IceIternal::Address -#include <IceSSL/uwp/TransceiverF.h> - -namespace IceSSL -{ - -class EndpointI : public IceInternal::IPEndpointI, public IceInternal::WSEndpointDelegate -{ -public: - - EndpointI(const IceInternal::ProtocolInstancePtr&, const std::string&, Ice::Int, Ice::Int, const std::string&, bool); - EndpointI(const IceInternal::ProtocolInstancePtr&); - EndpointI(const IceInternal::ProtocolInstancePtr&, Ice::InputStream*); - - virtual Ice::EndpointInfoPtr getInfo() const; - virtual Ice::EndpointInfoPtr getWSInfo(const std::string&) const; - - virtual Ice::Int timeout() const; - virtual IceInternal::EndpointIPtr timeout(Ice::Int) const; - virtual IceInternal::EndpointIPtr connectionId(const ::std::string&) const; - virtual bool compress() const; - virtual IceInternal::EndpointIPtr compress(bool) const; - virtual bool datagram() const; - virtual bool secure() const; - - virtual IceInternal::TransceiverPtr transceiver() const; - virtual IceInternal::AcceptorPtr acceptor(const std::string&) const; - virtual std::string options() const; - -#ifdef ICE_CPP11_MAPPING - virtual bool operator==(const Ice::Endpoint&) const; - virtual bool operator<(const Ice::Endpoint&) const; -#else - virtual bool operator==(const Ice::LocalObject&) const; - virtual bool operator<(const Ice::LocalObject&) const; -#endif - - EndpointIPtr endpoint(const AcceptorIPtr&) const; - - using IceInternal::IPEndpointI::connectionId; - -protected: - - virtual void streamWriteImpl(Ice::OutputStream*) const; - virtual void hashInit(Ice::Int&) const; - virtual void initWithOptions(std::vector<std::string>&, bool); - virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const; - virtual bool checkOption(const std::string&, const std::string&, const std::string&); - - virtual IceInternal::ConnectorPtr createConnector(const IceInternal::Address&, const IceInternal::NetworkProxyPtr&) const; - virtual IceInternal::IPEndpointIPtr createEndpoint(const std::string&, int, const std::string&) const; - -private: - - // - // All members are const, because endpoints are immutable. - // - const Ice::Int _timeout; - const bool _compress; -}; - -class EndpointFactoryI : public IceInternal::EndpointFactory -{ -public: - - EndpointFactoryI(const IceInternal::ProtocolInstancePtr&); - - virtual Ice::Short type() const; - virtual std::string protocol() const; - virtual IceInternal::EndpointIPtr create(std::vector<std::string>&, bool) const; - virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const; - virtual void destroy(); - - virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const; - -private: - - IceInternal::ProtocolInstancePtr _instance; -}; - -} - -#endif diff --git a/cpp/src/IceSSL/uwp/PluginI.cpp b/cpp/src/IceSSL/uwp/PluginI.cpp deleted file mode 100644 index 6ee5ba21755..00000000000 --- a/cpp/src/IceSSL/uwp/PluginI.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <IceSSL/PluginI.h> -#include <IceSSL/Instance.h> -#include <IceSSL/SSLEngine.h> -#include <IceSSL/EndpointI.h> - -#include <Ice/ProtocolPluginFacade.h> -#include <Ice/ProtocolInstance.h> -#include <Ice/LocalException.h> - -using namespace std; -using namespace Ice; -using namespace IceSSL; - -// -// Plug-in factory function. -// - -namespace Ice -{ - -ICE_SSL_API void -registerIceSSL(bool loadOnInitialize) -{ - Ice::registerPluginFactory("IceSSL", createIceSSL, true); -} - -} diff --git a/cpp/src/IceSSL/uwp/TransceiverF.h b/cpp/src/IceSSL/uwp/TransceiverF.h deleted file mode 100644 index 5384607f1a9..00000000000 --- a/cpp/src/IceSSL/uwp/TransceiverF.h +++ /dev/null @@ -1,31 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef ICE_UWP_TRANSCEIVER_F_H -#define ICE_UWP_TRANSCEIVER_F_H - -#include <IceUtil/Shared.h> -#include <Ice/Handle.h> - -namespace IceSSL -{ - -class EndpointI; -#ifndef ICE_CPP11_MAPPING -ICE_API IceUtil::Shared* upCast(EndpointI*); -#endif -ICE_DEFINE_PTR(EndpointIPtr, EndpointI); - -class AcceptorI; -ICE_API IceUtil::Shared* upCast(AcceptorI*); -typedef IceInternal::Handle<AcceptorI> AcceptorIPtr; - -} - -#endif diff --git a/cpp/src/IceSSL/uwp/TransceiverI.cpp b/cpp/src/IceSSL/uwp/TransceiverI.cpp deleted file mode 100644 index 0ec28120a7f..00000000000 --- a/cpp/src/IceSSL/uwp/TransceiverI.cpp +++ /dev/null @@ -1,417 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include <IceSSL/uwp/TransceiverI.h> -#include <Ice/Connection.h> -#include <Ice/ProtocolInstance.h> -#include <Ice/LoggerUtil.h> -#include <Ice/Buffer.h> -#include <Ice/LocalException.h> -#include <Ice/Properties.h> - -#include <IceSSL/EndpointInfo.h> -#include <IceSSL/ConnectionInfo.h> - -using namespace std; -using namespace Ice; -using namespace IceSSL; - -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Storage::Streams; -using namespace Windows::Networking; -using namespace Windows::Networking::Sockets; - -namespace -{ - -AsyncOperationCompletedHandler<unsigned int>^ -createAsyncOperationCompletedHandler(IceInternal::SocketOperationCompletedHandler^ cb, IceInternal::SocketOperation op, IceInternal::AsyncInfo& info) -{ - return ref new AsyncOperationCompletedHandler<unsigned int>( - [=,&info] (IAsyncOperation<unsigned int>^ operation, Windows::Foundation::AsyncStatus status) - { - if(status != Windows::Foundation::AsyncStatus::Completed) - { - info.count = SOCKET_ERROR; - info.error = operation->ErrorCode.Value; - } - else - { - info.count = static_cast<int>(operation->GetResults()); - } - cb(op); - }); -} - -} - -IceInternal::NativeInfoPtr -IceSSL::TransceiverI::getNativeInfo() -{ - return this; -} - -void -IceSSL::TransceiverI::setCompletedHandler(IceInternal::SocketOperationCompletedHandler^ handler) -{ - _completedHandler = handler; - _readOperationCompletedHandler = createAsyncOperationCompletedHandler(handler, IceInternal::SocketOperationRead, _read); - _writeOperationCompletedHandler = createAsyncOperationCompletedHandler(handler, IceInternal::SocketOperationWrite, _write); -} - -IceInternal::SocketOperation -IceSSL::TransceiverI::initialize(IceInternal::Buffer&, IceInternal::Buffer&) -{ - if(_state == StateNeedConnect) - { - _state = StateConnectPending; - return IceInternal::SocketOperationConnect; - } - else if(_state <= StateConnectPending) - { - if(_write.count == SOCKET_ERROR) - { - IceInternal::checkConnectErrorCode(__FILE__, __LINE__, _write.error, _connectAddr.host); - } - _state = StateConnected; - _desc = IceInternal::fdToString(_fd); - } - assert(_state == StateConnected); - return IceInternal::SocketOperationNone; -} - -IceInternal::SocketOperation -IceSSL::TransceiverI::closing(bool initiator, const Ice::LocalException&) -{ - // If we are initiating the connection closure, wait for the peer - // to close the TCP/IP connection. Otherwise, close immediately. - return initiator ? IceInternal::SocketOperationRead : IceInternal::SocketOperationNone; -} - -void -IceSSL::TransceiverI::close() -{ - assert(_fd != INVALID_SOCKET); - - _completedHandler = nullptr; - _readOperationCompletedHandler = nullptr; - _writeOperationCompletedHandler = nullptr; - - try - { - IceInternal::closeSocket(_fd); - _fd = INVALID_SOCKET; - } - catch(const SocketException&) - { - _fd = INVALID_SOCKET; - throw; - } -} - -IceInternal::SocketOperation -IceSSL::TransceiverI::write(IceInternal::Buffer& buf) -{ - return buf.i == buf.b.end() ? IceInternal::SocketOperationNone : IceInternal::SocketOperationWrite; -} - -IceInternal::SocketOperation -IceSSL::TransceiverI::read(IceInternal::Buffer& buf) -{ - return buf.i == buf.b.end() ? IceInternal::SocketOperationNone : IceInternal::SocketOperationRead; -} - -bool -IceSSL::TransceiverI::startWrite(IceInternal::Buffer& buf) -{ - if(_state < StateConnected) - { - try - { - IAsyncAction^ action = safe_cast<StreamSocket^>(_fd)->ConnectAsync(_connectAddr.host, - _connectAddr.port, - SocketProtectionLevel::Tls12); - - if(!checkIfErrorOrCompleted(IceInternal::SocketOperationConnect, action)) - { - IceInternal::SocketOperationCompletedHandler^ completed = _completedHandler; - action->Completed = ref new AsyncActionCompletedHandler( - [=] (IAsyncAction^ info, Windows::Foundation::AsyncStatus status) - { - if(status != Windows::Foundation::AsyncStatus::Completed) - { - _write.count = SOCKET_ERROR; - _write.error = info->ErrorCode.Value; - } - else - { - _write.count = 0; - } - completed(IceInternal::SocketOperationConnect); - }); - } - } - catch(Platform::Exception^ ex) - { - IceInternal::checkConnectErrorCode(__FILE__, __LINE__, ex->HResult, _connectAddr.host); - } - return false; - } - - assert(!buf.b.empty()); - assert(buf.i != buf.b.end()); - - int packetSize = static_cast<int>(buf.b.end() - buf.i); - if(_maxSendPacketSize > 0 && packetSize > _maxSendPacketSize) - { - packetSize = _maxSendPacketSize; - } - assert(packetSize > 0); - _writer->WriteBytes(ref new Array<unsigned char>(&*buf.i, packetSize)); - try - { - DataWriterStoreOperation^ operation = _writer->StoreAsync(); - if(checkIfErrorOrCompleted(IceInternal::SocketOperationWrite, operation)) - { - _write.count = operation->GetResults(); - } - else - { - operation->Completed = _writeOperationCompletedHandler; - } - } - catch(Platform::Exception^ ex) - { - IceInternal::checkErrorCode(__FILE__, __LINE__, ex->HResult); - } - return packetSize == static_cast<int>(buf.b.end() - buf.i); -} - -void -IceSSL::TransceiverI::finishWrite(IceInternal::Buffer& buf) -{ - if(_state < StateConnected) - { - if(_write.count == SOCKET_ERROR) - { - IceInternal::checkConnectErrorCode(__FILE__, __LINE__, _write.error, _connectAddr.host); - } - _verified = true; - return; - } - - if(_write.count == SOCKET_ERROR) - { - IceInternal::checkErrorCode(__FILE__, __LINE__, _write.error); - } - - buf.i += _write.count; -} - -void -IceSSL::TransceiverI::startRead(IceInternal::Buffer& buf) -{ - int packetSize = static_cast<int>(buf.b.end() - buf.i); - if(_maxReceivePacketSize > 0 && packetSize > _maxReceivePacketSize) - { - packetSize = _maxReceivePacketSize; - } - assert(!buf.b.empty() && buf.i != buf.b.end()); - - try - { - DataReaderLoadOperation^ operation = _reader->LoadAsync(packetSize); - if(checkIfErrorOrCompleted(IceInternal::SocketOperationRead, operation)) - { - _read.count = operation->GetResults(); - } - else - { - operation->Completed = _readOperationCompletedHandler; - } - } - catch(Platform::Exception^ ex) - { - IceInternal::checkErrorCode(__FILE__, __LINE__, ex->HResult); - } -} - -void -IceSSL::TransceiverI::finishRead(IceInternal::Buffer& buf) -{ - if(_read.count == SOCKET_ERROR) - { - IceInternal::checkErrorCode(__FILE__, __LINE__, _read.error); - } - else if(_read.count == 0) - { - ConnectionLostException ex(__FILE__, __LINE__); - ex.error = 0; - throw ex; - } - - try - { - auto data = ref new Platform::Array<unsigned char>(_read.count); - _reader->ReadBytes(data); - memcpy(&*buf.i, data->Data, _read.count); - } - catch(Platform::Exception^ ex) - { - IceInternal::checkErrorCode(__FILE__, __LINE__, ex->HResult); - } - - buf.i += _read.count; -} - -string -IceSSL::TransceiverI::protocol() const -{ - return _instance->protocol(); -} - -string -IceSSL::TransceiverI::toString() const -{ - return _desc; -} - -string -IceSSL::TransceiverI::toDetailedString() const -{ - return toString(); -} - -Ice::ConnectionInfoPtr -IceSSL::TransceiverI::getInfo() const -{ - Ice::IPConnectionInfoPtr info; - if(_instance->secure()) - { - IceSSL::ConnectionInfoPtr sslInfo = ICE_MAKE_SHARED(IceSSL::ConnectionInfo); - sslInfo->verified = _verified; - info = sslInfo; - } - else - { - info = ICE_MAKE_SHARED(Ice::TCPConnectionInfo); - } - fillConnectionInfo(info); - return info; -} - -Ice::ConnectionInfoPtr -IceSSL::TransceiverI::getWSInfo(const Ice::HeaderDict& headers) const -{ - if(_instance->secure()) - { - IceSSL::WSSConnectionInfoPtr info = ICE_MAKE_SHARED(IceSSL::WSSConnectionInfo); - info->verified = _verified; - fillConnectionInfo(info); - info->headers = headers; - return info; - } - else - { - Ice::WSConnectionInfoPtr info = ICE_MAKE_SHARED(Ice::WSConnectionInfo); - fillConnectionInfo(info); - info->headers = headers; - return info; - } -} - -void -IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&) -{ -} - - void - IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize) - { - setTcpBufSize(_fd, rcvSize, sndSize, _instance); - } - -IceSSL::TransceiverI::TransceiverI(const IceInternal::ProtocolInstancePtr& instance, SOCKET fd, bool connected) : - NativeInfo(fd), - _instance(instance), - _state(connected ? StateConnected : StateNeedConnect), - _desc(connected ? IceInternal::fdToString(_fd) : string()), - _verified(false) -{ - StreamSocket^ streamSocket = safe_cast<StreamSocket^>(_fd); - _writer = ref new DataWriter(streamSocket->OutputStream); - _reader = ref new DataReader(streamSocket->InputStream); - _reader->InputStreamOptions = InputStreamOptions::Partial; - - setTcpBufSize(_fd, _instance); - - _maxSendPacketSize = streamSocket->Control->OutboundBufferSizeInBytes / 2; - if(_maxSendPacketSize < 512) - { - _maxSendPacketSize = 0; - } - - _maxReceivePacketSize = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.RcvSize", 128 * 1024); -} - -IceSSL::TransceiverI::~TransceiverI() -{ - assert(_fd == INVALID_SOCKET); -} - -void -IceSSL::TransceiverI::connect(const IceInternal::Address& addr) -{ - _connectAddr = addr; -} - -bool -IceSSL::TransceiverI::checkIfErrorOrCompleted(IceInternal::SocketOperation op, IAsyncInfo^ info, int count) -{ - // - // NOTE: It's important to only check for info->Status once as it - // might change during the checks below (the Status can be changed - // by the Windows thread pool concurrently). - // - // We consider that a canceled async status is the same as an - // error. A canceled async status can occur if there's a timeout - // and the socket is closed. - // - Windows::Foundation::AsyncStatus status = info->Status; - if(status == Windows::Foundation::AsyncStatus::Completed) - { - _completedHandler(op); - return true; - } - else if (status == Windows::Foundation::AsyncStatus::Started) - { - return false; - } - else - { - if(_state < StateConnected) - { - IceInternal::checkConnectErrorCode(__FILE__, __LINE__, info->ErrorCode.Value, _connectAddr.host); - } - else - { - IceInternal::checkErrorCode(__FILE__, __LINE__, info->ErrorCode.Value); - } - return true; // Prevent compiler warning. - } -} - -void -IceSSL::TransceiverI::fillConnectionInfo(const Ice::IPConnectionInfoPtr& info) const -{ - IceInternal::fdToAddressAndPort(_fd, info->localAddress, info->localPort, info->remoteAddress, info->remotePort); - info->rcvSize = IceInternal::getRecvBufferSize(_fd); - info->sndSize = IceInternal::getSendBufferSize(_fd); -} diff --git a/cpp/src/IceSSL/uwp/TransceiverI.h b/cpp/src/IceSSL/uwp/TransceiverI.h deleted file mode 100644 index 4e8b7e6c620..00000000000 --- a/cpp/src/IceSSL/uwp/TransceiverI.h +++ /dev/null @@ -1,93 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef ICE_SSL_UWP_TRANSCEIVER_I_H -#define ICE_SSL_UWP_TRANSCEIVER_I_H - -#include <Ice/ProtocolInstanceF.h> -#include <Ice/Transceiver.h> -#include <Ice/Network.h> -#include <Ice/WSTransceiver.h> - -namespace IceSSL -{ - -class ConnectorI; -class AcceptorI; - -class TransceiverI : public IceInternal::Transceiver, - public IceInternal::NativeInfo, - public IceInternal::WSTransceiverDelegate -{ - enum State - { - StateNeedConnect, - StateConnectPending, - StateConnected - }; - -public: - - virtual IceInternal::NativeInfoPtr getNativeInfo(); - virtual void setCompletedHandler(IceInternal::SocketOperationCompletedHandler^); - - virtual IceInternal::SocketOperation initialize(IceInternal::Buffer&, IceInternal::Buffer&); - - virtual IceInternal::SocketOperation closing(bool, const Ice::LocalException&); - virtual void close(); - virtual IceInternal::SocketOperation write(IceInternal::Buffer&); - virtual IceInternal::SocketOperation read(IceInternal::Buffer&); - - virtual bool startWrite(IceInternal::Buffer&); - virtual void finishWrite(IceInternal::Buffer&); - virtual void startRead(IceInternal::Buffer&); - virtual void finishRead(IceInternal::Buffer&); - - virtual std::string protocol() const; - virtual std::string toString() const; - virtual std::string toDetailedString() const; - virtual Ice::ConnectionInfoPtr getInfo() const; - virtual Ice::ConnectionInfoPtr getWSInfo(const Ice::HeaderDict&) const; - virtual void checkSendSize(const IceInternal::Buffer&); - virtual void setBufferSize(int rcvSize, int sndSize); - -private: - - TransceiverI(const IceInternal::ProtocolInstancePtr&, SOCKET, bool); - virtual ~TransceiverI(); - - void connect(const IceInternal::Address&); - bool checkIfErrorOrCompleted(IceInternal::SocketOperation, Windows::Foundation::IAsyncInfo^, int = 0); - void fillConnectionInfo(const Ice::IPConnectionInfoPtr&) const; - - friend class ConnectorI; - friend class AcceptorI; - - const IceInternal::ProtocolInstancePtr _instance; - - State _state; - std::string _desc; - bool _verified; - IceInternal::Address _connectAddr; - - IceInternal::AsyncInfo _read; - IceInternal::AsyncInfo _write; - int _maxSendPacketSize; - int _maxReceivePacketSize; - - Windows::Storage::Streams::DataReader^ _reader; - Windows::Storage::Streams::DataWriter^ _writer; - - Windows::Foundation::AsyncOperationCompletedHandler<unsigned int>^ _readOperationCompletedHandler; - Windows::Foundation::AsyncOperationCompletedHandler<unsigned int>^ _writeOperationCompletedHandler; -}; - -} - -#endif |