diff options
Diffstat (limited to 'cpp')
42 files changed, 593 insertions, 415 deletions
diff --git a/cpp/include/Ice/StreamHelpers.h b/cpp/include/Ice/StreamHelpers.h index d1862d9a9cd..91c5d43e63f 100644 --- a/cpp/include/Ice/StreamHelpers.h +++ b/cpp/include/Ice/StreamHelpers.h @@ -632,7 +632,7 @@ struct StreamOptionalHelper<T, StreamHelperCategoryStruct, false> template<class S> static inline void write(S* stream, const T& v) { - size_t pos = stream->startSize(); + typename S::size_type pos = stream->startSize(); stream->write(v); stream->endSize(pos); } diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index 57a04cc9435..fd7947d5dd2 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -36,12 +36,15 @@ using namespace IceInternal; void Ice::CommunicatorI::destroy() { - _instance->destroy(); + if(_instance) + { + _instance->destroy(); + } } void Ice::CommunicatorI::shutdown() -{ +{ _instance->objectAdapterFactory()->shutdown(); } @@ -223,7 +226,7 @@ Ice::CommunicatorI::begin_flushBatchRequests(const Callback_Communicator_flushBa } #ifdef ICE_CPP11 -AsyncResultPtr +AsyncResultPtr Ice::CommunicatorI::begin_flushBatchRequests( const IceInternal::Function<void (const Exception&)>& exception, const IceInternal::Function<void (bool)>& sent) @@ -232,14 +235,14 @@ Ice::CommunicatorI::begin_flushBatchRequests( { public: - + Cpp11CB(const IceInternal::Function<void (const Exception&)>& excb, const IceInternal::Function<void (bool)>& sentcb) : IceInternal::Cpp11FnCallbackNC(excb, sentcb) { CallbackBase::checkCallback(true, excb != nullptr); } - + virtual void completed(const AsyncResultPtr& __result) const { diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp index 2690f4d13b3..8df552d9d20 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.cpp +++ b/cpp/src/Ice/DefaultsAndOverrides.cpp @@ -10,7 +10,6 @@ #include <IceUtil/DisableWarnings.h> #include <Ice/DefaultsAndOverrides.h> #include <Ice/Properties.h> -#include <Ice/Network.h> #include <Ice/LocalException.h> using namespace std; @@ -36,7 +35,27 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro const_cast<string&>(defaultHost) = properties->getProperty("Ice.Default.Host"); string value; - + +#ifdef ICE_OS_WINRT + const_cast<Address&>(defaultSourceAddress) = getInvalidAddress(); +#else + value = properties->getProperty("Ice.Default.SourceAddress"); + if(!value.empty()) + { + const_cast<Address&>(defaultSourceAddress) = getNumericAddress(value); + if(!isAddressValid(defaultSourceAddress)) + { + InitializationException ex(__FILE__, __LINE__); + ex.reason = "invalid IP address set for Ice.Default.SourceAddress: `" + value + "'"; + throw ex; + } + } + else + { + const_cast<Address&>(defaultSourceAddress) = getInvalidAddress(); + } +#endif + value = properties->getProperty("Ice.Override.Timeout"); if(!value.empty()) { @@ -79,7 +98,7 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro if(value == "Random") { defaultEndpointSelection = Random; - } + } else if(value == "Ordered") { defaultEndpointSelection = Ordered; @@ -91,10 +110,10 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro throw ex; } - const_cast<int&>(defaultInvocationTimeout) = + const_cast<int&>(defaultInvocationTimeout) = properties->getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1); - const_cast<int&>(defaultLocatorCacheTimeout) = + const_cast<int&>(defaultLocatorCacheTimeout) = properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1); const_cast<bool&>(defaultPreferSecure) = diff --git a/cpp/src/Ice/DefaultsAndOverrides.h b/cpp/src/Ice/DefaultsAndOverrides.h index cc5f6f04f48..5ce55469c31 100644 --- a/cpp/src/Ice/DefaultsAndOverrides.h +++ b/cpp/src/Ice/DefaultsAndOverrides.h @@ -17,6 +17,7 @@ #include <Ice/Endpoint.h> #include <Ice/EndpointTypes.h> #include <Ice/Format.h> +#include <Ice/Network.h> namespace IceInternal { @@ -28,6 +29,7 @@ public: DefaultsAndOverrides(const ::Ice::PropertiesPtr&); std::string defaultHost; + Address defaultSourceAddress; std::string defaultProtocol; bool defaultCollocationOptimization; Ice::EndpointSelectionType defaultEndpointSelection; diff --git a/cpp/src/Ice/IPEndpointI.cpp b/cpp/src/Ice/IPEndpointI.cpp index a94f05ce429..832b5403573 100644 --- a/cpp/src/Ice/IPEndpointI.cpp +++ b/cpp/src/Ice/IPEndpointI.cpp @@ -74,7 +74,7 @@ IceInternal::IPEndpointInfoI::secure() const return _endpoint->secure(); } -Ice::EndpointInfoPtr +Ice::EndpointInfoPtr IceInternal::IPEndpointI::getInfo() const { Ice::IPEndpointInfoPtr info = new IPEndpointInfoI(const_cast<IPEndpointI*>(this)); @@ -128,7 +128,7 @@ IceInternal::IPEndpointI::connectors(Ice::EndpointSelectionType selType) const return _instance->resolve(_host, _port, selType, const_cast<IPEndpointI*>(this)); } -const std::string& +const std::string& IceInternal::IPEndpointI::host() const { return _host; @@ -219,6 +219,11 @@ IceInternal::IPEndpointI::options() const s << " -p " << _port; + if(isAddressValid(_sourceAddr)) + { + s << " --sourceAddress " << inetAddrToString(_sourceAddr); + } + return s.str(); } @@ -251,6 +256,11 @@ IceInternal::IPEndpointI::operator==(const LocalObject& r) const return false; } + if(compareAddress(_sourceAddr, p->_sourceAddr) != 0) + { + return false; + } + return true; } @@ -309,6 +319,16 @@ IceInternal::IPEndpointI::operator<(const LocalObject& r) const return false; } + int rc = compareAddress(_sourceAddr, p->_sourceAddr); + if(rc < 0) + { + return true; + } + else if(rc > 0) + { + return false; + } + return false; } @@ -336,6 +356,10 @@ IceInternal::IPEndpointI::hashInit(Ice::Int& h) const hashAdd(h, _host); hashAdd(h, _port); hashAdd(h, _connectionId); + if(isAddressValid(_sourceAddr)) + { + hashAdd(h, inetAddrToString(_sourceAddr)); + } } void @@ -343,6 +367,7 @@ IceInternal::IPEndpointI::fillEndpointInfo(Ice::IPEndpointInfo* info) const { info->host = _host; info->port = _port; + info->sourceAddress = inetAddrToString(_sourceAddr); } void @@ -367,14 +392,26 @@ IceInternal::IPEndpointI::initWithOptions(vector<string>& args, bool oaEndpoint) throw ex; } } + + if(isAddressValid(_sourceAddr)) + { + if(oaEndpoint) + { + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "`--sourceAddress' not valid for object adapter endpoint `" + toString() + "'"; + throw ex; + } + } + else if(!oaEndpoint) + { + const_cast<Address&>(_sourceAddr) = _instance->defaultSourceAddress(); + } } bool IceInternal::IPEndpointI::checkOption(const string& option, const string& argument, const string& endpoint) { - switch(option[1]) - { - case 'h': + if(option == "-h") { if(argument.empty()) { @@ -383,10 +420,8 @@ IceInternal::IPEndpointI::checkOption(const string& option, const string& argume throw ex; } const_cast<string&>(_host) = argument; - return true; } - - case 'p': + else if(option == "-p") { if(argument.empty()) { @@ -407,21 +442,38 @@ IceInternal::IPEndpointI::checkOption(const string& option, const string& argume ex.str = "port value `" + argument + "' out of range in endpoint " + endpoint; throw ex; } - return true; } - - default: + else if(option == "--sourceAddress") { - return false; + if(argument.empty()) + { + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "no argument provided for --sourceAddress option in endpoint " + endpoint; + throw ex; + } +#ifndef ICE_OS_WINRT + const_cast<Address&>(_sourceAddr) = getNumericAddress(argument); + if(!isAddressValid(_sourceAddr)) + { + Ice::EndpointParseException ex(__FILE__, __LINE__); + ex.str = "invalid IP address provided for --sourceAddress option in endpoint " + endpoint; + throw ex; + } +#endif } + else + { + return false; } + return true; } -IceInternal::IPEndpointI::IPEndpointI(const ProtocolInstancePtr& instance, const string& host, int port, - const string& connectionId) : +IceInternal::IPEndpointI::IPEndpointI(const ProtocolInstancePtr& instance, const string& host, int port, + const Address& sourceAddr, const string& connectionId) : _instance(instance), _host(host), _port(port), + _sourceAddr(sourceAddr), _connectionId(connectionId), _hashInitialized(false) { @@ -430,6 +482,7 @@ IceInternal::IPEndpointI::IPEndpointI(const ProtocolInstancePtr& instance, const IceInternal::IPEndpointI::IPEndpointI(const ProtocolInstancePtr& instance) : _instance(instance), _port(0), + _sourceAddr(getInvalidAddress()), _hashInitialized(false) { } @@ -437,6 +490,7 @@ IceInternal::IPEndpointI::IPEndpointI(const ProtocolInstancePtr& instance) : IceInternal::IPEndpointI::IPEndpointI(const ProtocolInstancePtr& instance, BasicStream* s) : _instance(instance), _port(0), + _sourceAddr(getInvalidAddress()), _hashInitialized(false) { s->read(const_cast<string&>(_host), false); diff --git a/cpp/src/Ice/IPEndpointI.h b/cpp/src/Ice/IPEndpointI.h index 3aeda2d5a0c..06cb405e5da 100644 --- a/cpp/src/Ice/IPEndpointI.h +++ b/cpp/src/Ice/IPEndpointI.h @@ -87,15 +87,16 @@ protected: virtual ConnectorPtr createConnector(const Address& address, const NetworkProxyPtr&) const = 0; virtual IPEndpointIPtr createEndpoint(const std::string&, int, const std::string&) const = 0; - IPEndpointI(const ProtocolInstancePtr&, const std::string&, int, const std::string&); + IPEndpointI(const ProtocolInstancePtr&, const std::string&, int, const Address&, const std::string&); IPEndpointI(const ProtocolInstancePtr&); IPEndpointI(const ProtocolInstancePtr&, BasicStream*); const ProtocolInstancePtr _instance; const std::string _host; const int _port; + const Address _sourceAddr; const std::string _connectionId; - + private: mutable bool _hashInitialized; diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 6bea9242dd1..6d1076e950b 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -39,7 +39,7 @@ #include <Ice/MetricsAdminI.h> #include <Ice/InstrumentationI.h> #include <Ice/ProtocolInstance.h> - + #include <IceUtil/UUID.h> #include <IceUtil/Mutex.h> #include <IceUtil/MutexPtrLock.h> @@ -116,7 +116,7 @@ public: Init() { staticMutex = new IceUtil::Mutex; - + // // Although probably not necessary here, we consistently lock // staticMutex before accessing instanceList @@ -130,7 +130,7 @@ public: { IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(staticMutex); int notDestroyedCount = 0; - + for(std::list<IceInternal::Instance*>::const_iterator p = instanceList->begin(); p != instanceList->end(); ++p) { @@ -139,7 +139,7 @@ public: notDestroyedCount++; } } - + if(notDestroyedCount > 0) { cerr << "!! " << IceUtil::Time::now().toDateTime() << " error: "; @@ -365,7 +365,7 @@ IceInternal::Instance::serverThreadPool(bool create) { throw CommunicatorDestroyedException(__FILE__, __LINE__); } - + if(!_serverThreadPool && create) // Lazy initialization. { int timeout = _initData.properties->getPropertyAsInt("Ice.ServerIdleTime"); @@ -384,7 +384,7 @@ IceInternal::Instance::endpointHostResolver() { throw CommunicatorDestroyedException(__FILE__, __LINE__); } - + assert(_endpointHostResolver); return _endpointHostResolver; } @@ -476,8 +476,8 @@ Identity IceInternal::Instance::stringToIdentity(const string& s) const { // - // This method only accepts printable ascii. Since printable ascii is a subset - // of all narrow string encodings, it is not necessary to convert the string + // This method only accepts printable ascii. Since printable ascii is a subset + // of all narrow string encodings, it is not necessary to convert the string // from the native string encoding. Any characters other than printable-ASCII // will cause an IllegalArgumentException. Note that it can contain Unicode // encoded in the escaped form which is the reason why we call fromUTF8 after @@ -638,7 +638,7 @@ IceInternal::Instance::getAdmin() // Add all facets to OA // FacetMap filteredFacets; - + for(FacetMap::iterator p = _adminFacets.begin(); p != _adminFacets.end(); ++p) { if(_adminFacetFilter.empty() || _adminFacetFilter.find(p->first) != _adminFacetFilter.end()) @@ -648,7 +648,7 @@ IceInternal::Instance::getAdmin() else { filteredFacets[p->first] = p->second; - } + } } _adminFacets.swap(filteredFacets); @@ -674,15 +674,15 @@ IceInternal::Instance::getAdmin() _adminAdapter = 0; throw; } - + Ice::ObjectPrx admin = adapter->createProxy(_adminIdentity); if(defaultLocator != 0 && serverId != "") - { + { ProcessPrx process = ProcessPrx::uncheckedCast(admin->ice_facet("Process")); try { // - // Note that as soon as the process proxy is registered, the communicator might be + // Note that as soon as the process proxy is registered, the communicator might be // shutdown by a remote client and admin facets might start receiving calls. // defaultLocator->getRegistry()->setServerProcessProxy(serverId, process); @@ -696,7 +696,7 @@ IceInternal::Instance::getAdmin() out << "the server is not known to the locator registry"; } - throw InitializationException(__FILE__, __LINE__, "Locator knows nothing about server '" + + throw InitializationException(__FILE__, __LINE__, "Locator knows nothing about server '" + serverId + "'"); } catch(const LocalException& ex) @@ -709,13 +709,13 @@ IceInternal::Instance::getAdmin() throw; } } - + if(_traceLevels->location >= 1) { Trace out(_initData.logger, _traceLevels->locationCat); out << "registered server `" + serverId + "' with the locator registry"; } - + return admin; } else @@ -744,15 +744,15 @@ IceInternal::Instance::addAdminFacet(const Ice::ObjectPtr& servant, const string } else { - _adminAdapter->addFacet(servant, _adminIdentity, facet); + _adminAdapter->addFacet(servant, _adminIdentity, facet); } -} +} Ice::ObjectPtr IceInternal::Instance::removeAdminFacet(const string& facet) { IceUtil::RecMutex::Lock sync(*this); - + if(_state == StateDestroyed) { throw CommunicatorDestroyedException(__FILE__, __LINE__); @@ -775,7 +775,7 @@ IceInternal::Instance::removeAdminFacet(const string& facet) } else { - result = _adminAdapter->removeFacet(_adminIdentity, facet); + result = _adminAdapter->removeFacet(_adminIdentity, facet); } return result; @@ -807,7 +807,7 @@ IceInternal::Instance::findAdminFacet(const string& facet) } return result; -} +} void IceInternal::Instance::setDefaultLocator(const Ice::LocatorPrx& defaultLocator) @@ -822,7 +822,7 @@ IceInternal::Instance::setDefaultLocator(const Ice::LocatorPrx& defaultLocator) _referenceFactory = _referenceFactory->setDefaultLocator(defaultLocator); } -void +void IceInternal::Instance::setDefaultRouter(const Ice::RouterPrx& defaultRouter) { IceUtil::RecMutex::Lock sync(*this); @@ -905,7 +905,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi { _initData.properties = createProperties(); } - + if(!oneOffDone) { // @@ -913,7 +913,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi // string stdOutFilename = _initData.properties->getProperty("Ice.StdOut"); string stdErrFilename = _initData.properties->getProperty("Ice.StdErr"); - + if(stdOutFilename != "") { FILE* file = IceUtilInternal::freopen(stdOutFilename, "a", stdout); @@ -925,7 +925,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi throw ex; } } - + if(stdErrFilename != "") { FILE* file = IceUtilInternal::freopen(stdErrFilename, "a", stderr); @@ -937,7 +937,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi throw ex; } } - + if(_initData.properties->getPropertyAsInt("Ice.NullHandleAbort") > 0) { IceUtilInternal::nullHandleAbort = true; @@ -951,7 +951,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi { IceUtilInternal::printStackTraces = true; } - + #ifndef _WIN32 string newUser = _initData.properties->getProperty("Ice.ChangeUser"); if(!newUser.empty()) @@ -972,7 +972,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi throw ex; } } - + if(setgid(pw->pw_gid) == -1) { SyscallException ex(__FILE__, __LINE__); @@ -986,7 +986,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi ex.error = getSystemErrno(); throw ex; } - + if(setuid(pw->pw_uid) == -1) { SyscallException ex(__FILE__, __LINE__); @@ -996,10 +996,10 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi } #endif oneOffDone = true; - } - + } + if(instanceCount() == 1) - { + { #if defined(_WIN32) && !defined(ICE_OS_WINRT) WORD version = MAKEWORD(1, 1); WSADATA data; @@ -1010,7 +1010,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi throw ex; } #endif - + #ifndef _WIN32 struct sigaction action; action.sa_handler = SIG_IGN; @@ -1033,7 +1033,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi #endif } } - + if(!_initData.logger) { @@ -1046,8 +1046,8 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi throw InitializationException(__FILE__, __LINE__, "Both syslog and file logger cannot be enabled."); } - _initData.logger = - new SysLoggerI(_initData.properties->getProperty("Ice.ProgramName"), + _initData.logger = + new SysLoggerI(_initData.properties->getProperty("Ice.ProgramName"), _initData.properties->getPropertyWithDefault("Ice.SyslogFacility", "LOG_USER")); } else @@ -1061,7 +1061,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _initData.logger = getProcessLogger(); if(LoggerIPtr::dynamicCast(_initData.logger)) { - _initData.logger = new LoggerI(_initData.properties->getProperty("Ice.ProgramName"), "", + _initData.logger = new LoggerI(_initData.properties->getProperty("Ice.ProgramName"), "", logStdErrConvert, _stringConverter); } } @@ -1073,12 +1073,12 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi const ACMConfig defaultClientACM(_initData.properties, _initData.logger, "Ice.ACM", ACMConfig(false)); const ACMConfig defaultServerACM(_initData.properties, _initData.logger, "Ice.ACM", ACMConfig(true)); - + const_cast<ACMConfig&>(_clientACM) = ACMConfig(_initData.properties, _initData.logger, "Ice.ACM.Client", defaultClientACM); - + const_cast<ACMConfig&>(_serverACM) = ACMConfig(_initData.properties, _initData.logger, "Ice.ACM.Server", @@ -1108,7 +1108,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi // Client ACM enabled by default. Server ACM disabled by default. // #ifndef ICE_OS_WINRT - const_cast<ImplicitContextIPtr&>(_implicitContext) = + const_cast<ImplicitContextIPtr&>(_implicitContext) = ImplicitContextI::create(_initData.properties->getProperty("Ice.ImplicitContext")); #endif _routerManager = new RouterManager; @@ -1168,7 +1168,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi ProtocolInstancePtr tcpInstance = new ProtocolInstance(this, TCPEndpointType, "tcp"); EndpointFactoryPtr tcpFactory = new StreamEndpointFactory(tcpInstance); _endpointFactoryManager->add(tcpFactory); - + ProtocolInstancePtr sslInstance = new ProtocolInstance(this, IceSSL::EndpointType, "ssl"); EndpointFactoryPtr sslFactory = new StreamEndpointFactory(sslInstance); _endpointFactoryManager->add(sslFactory); @@ -1186,7 +1186,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _servantFactoryManager = new ObjectFactoryManager(); _objectAdapterFactory = new ObjectAdapterFactory(this, communicator); - + _retryQueue = new RetryQueue(this); if(_wstringConverter == 0) @@ -1199,7 +1199,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi // StringSeq facetSeq = _initData.properties->getPropertyAsList("Ice.Admin.Facets"); - + if(!facetSeq.empty()) { _adminFacetFilter.insert(facetSeq.begin(), facetSeq.end()); @@ -1276,7 +1276,7 @@ IceInternal::Instance::~Instance() #if defined(_WIN32) && !defined(ICE_OS_WINRT) WSACleanup(); #endif - + #ifndef _WIN32 sigaction(SIGPIPE, &oldAction, 0); @@ -1341,7 +1341,7 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) out << "cannot create thread for endpoint host resolver:\n" << ex; throw; } - + _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0); // @@ -1360,7 +1360,7 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) { _referenceFactory = _referenceFactory->setDefaultLocator(locator); } - + // // Show process id if requested (but only once). // @@ -1372,7 +1372,7 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) // IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(staticMutex); printProcessId = !printProcessIdDone; - + // // We anticipate: we want to print it once, and we don't care when. // @@ -1404,7 +1404,7 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) // // This must be done last as this call creates the Ice.Admin object adapter - // and eventually register a process proxy with the Ice locator (allowing + // and eventually register a process proxy with the Ice locator (allowing // remote clients to invoke on Ice.Admin facets as soon as it's registered). // if(_initData.properties->getPropertyAsIntWithDefault("Ice.Admin.DelayCreation", 0) <= 0) @@ -1418,7 +1418,7 @@ IceInternal::Instance::destroy() { { IceUtil::RecMutex::Lock sync(*this); - + // // If the _state is not StateActive then the instance is // either being destroyed, or has already been destroyed. @@ -1439,7 +1439,7 @@ IceInternal::Instance::destroy() if(_objectAdapterFactory) { - _objectAdapterFactory->shutdown(); + _objectAdapterFactory->shutdown(); } if(_outgoingConnectionFactory) @@ -1473,7 +1473,7 @@ IceInternal::Instance::destroy() CommunicatorObserverIPtr observer = CommunicatorObserverIPtr::dynamicCast(_observer); if(observer) { - observer->destroy(); + observer->destroy(); } _observer->setObserverUpdater(0); // Break cyclic reference count. } @@ -1494,7 +1494,7 @@ IceInternal::Instance::destroy() _serverThreadPool->destroy(); std::swap(_serverThreadPool, serverThreadPool); } - + if(_clientThreadPool) { _clientThreadPool->destroy(); @@ -1517,13 +1517,13 @@ IceInternal::Instance::destroy() _servantFactoryManager->destroy(); _servantFactoryManager = 0; } - + //_referenceFactory->destroy(); // No destroy function defined. _referenceFactory = 0; - + // _proxyFactory->destroy(); // No destroy function defined. _proxyFactory = 0; - + if(_routerManager) { _routerManager->destroy(); @@ -1575,7 +1575,7 @@ IceInternal::Instance::destroy() endpointHostResolver->getThreadControl().join(); } #endif - + if(_initData.properties->getPropertyAsInt("Ice.Warn.UnusedProperties") > 0) { set<string> unusedProperties = static_cast<PropertiesI*>(_initData.properties.get())->getUnusedProperties(); diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index f60a27e298e..9373b960fda 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -98,7 +98,7 @@ public: { return _observer; } - + const Ice::ImplicitContextIPtr& getImplicitContext() const { return _implicitContext; @@ -109,10 +109,10 @@ public: IceUtil::StringConverterPtr getStringConverter() const { return _stringConverter; } void setStringConverter(const IceUtil::StringConverterPtr&); - + IceUtil::WstringConverterPtr getWstringConverter() const { return _wstringConverter; } void setWstringConverter(const IceUtil::WstringConverterPtr&); - + void setLogger(const Ice::LoggerPtr&); void setThreadHook(const Ice::ThreadNotificationPtr&); @@ -174,14 +174,14 @@ private: class ProcessI : public Ice::Process { public: - + ProcessI(const Ice::CommunicatorPtr&); - + virtual void shutdown(const Ice::Current&); virtual void writeMessage(const std::string&, Ice::Int, const Ice::Current&); - + private: - + const Ice::CommunicatorPtr _communicator; }; diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index a9d480b2eda..d329368612e 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -30,7 +30,7 @@ #if defined(ICE_OS_WINRT) # include <IceUtil/InputUtil.h> # include <ppltasks.h> // For Concurrency::task -#elif defined(_WIN32) +#elif defined(_WIN32) # include <winsock2.h> # include <ws2tcpip.h> # include <iphlpapi.h> @@ -374,7 +374,7 @@ getLocalAddresses(ProtocolSupport protocol) if(!(ifr[i].ifr_flags & IFF_LOOPBACK)) // Don't include loopback interface addresses { // - // On Solaris the above Loopback check does not always work so we double + // On Solaris the above Loopback check does not always work so we double // check the address below. Solaris also returns duplicate entries that need // to be filtered out. // @@ -461,7 +461,7 @@ getInterfaceIndex(const string& name) { return 0; } - + int index = 0; // @@ -479,7 +479,7 @@ getInterfaceIndex(const string& name) // in6_addr addr; bool isAddr = inet_pton(AF_INET6, name.c_str(), &addr) > 0; - + #ifdef _WIN32 IP_ADAPTER_ADDRESSES addrs; ULONG buflen = 0; @@ -499,7 +499,7 @@ getInterfaceIndex(const string& name) { if(ipAddr->Address.lpSockaddr->sa_family == AF_INET6) { - struct sockaddr_in6* ipv6Addr = + struct sockaddr_in6* ipv6Addr = reinterpret_cast<struct sockaddr_in6*>(ipAddr->Address.lpSockaddr); if(memcmp(&addr, &ipv6Addr->sin6_addr, sizeof(in6_addr)) == 0) { @@ -535,7 +535,7 @@ getInterfaceIndex(const string& name) // // Look for an interface with a matching IP address - // + // if(isAddr) { # if defined(__linux) || defined(__APPLE__) || defined(__FreeBSD__) @@ -553,7 +553,7 @@ getInterfaceIndex(const string& name) index = if_nametoindex(curr->ifa_name); break; } - } + } curr = curr->ifa_next; } ::freeifaddrs(ifap); @@ -694,6 +694,21 @@ getInterfaceAddress(const string& name) return addr; } +int +getAddressStorageSize(const Address& addr) +{ + int size = 0; + if(addr.saStorage.ss_family == AF_INET) + { + size = sizeof(sockaddr_in); + } + else if(addr.saStorage.ss_family == AF_INET6) + { + size = sizeof(sockaddr_in6); + } + return size; +} + #endif // #ifndef ICE_OS_WINRT } @@ -849,7 +864,7 @@ bool IceInternal::noMoreFds(int error) { #if defined(ICE_OS_WINRT) - return error == (int)SocketErrorStatus::TooManyOpenFiles; + return error == (int)SocketErrorStatus::TooManyOpenFiles; #elif defined(_WIN32) return error == WSAEMFILE; #else @@ -1471,6 +1486,19 @@ IceInternal::isAddressValid(const Address& addr) #endif } +Address +IceInternal::getInvalidAddress() +{ +#ifndef ICE_OS_WINRT + Address addr; + memset(&addr.saStorage, 0, sizeof(sockaddr_storage)); + addr.saStorage.ss_family = AF_UNSPEC; + return addr; +#else + return Address(); +#endif +} + #ifdef ICE_OS_WINRT vector<string> IceInternal::getHostsForEndpointExpand(const string&, ProtocolSupport, bool) @@ -1521,16 +1549,8 @@ string IceInternal::inetAddrToString(const Address& ss) { #ifndef ICE_OS_WINRT - int size = 0; - if(ss.saStorage.ss_family == AF_INET) - { - size = static_cast<int>(sizeof(sockaddr_in)); - } - else if(ss.saStorage.ss_family == AF_INET6) - { - size = static_cast<int>(sizeof(sockaddr_in6)); - } - else + int size = getAddressStorageSize(ss); + if(size == 0) { return ""; } @@ -1684,7 +1704,7 @@ IceInternal::setTcpBufSize(SOCKET fd, const Ice::PropertiesPtr& properties, cons out << "TCP receive buffer size: requested size of " << sizeRequested << " adjusted to " << size; } } - + sizeRequested = properties->getPropertyAsIntWithDefault("Ice.TCP.SndSize", dfltBufSize); if(sizeRequested > 0) { @@ -1790,7 +1810,7 @@ IceInternal::getSendBufferSize(SOCKET fd) #ifndef ICE_OS_WINRT int sz; socklen_t len = sizeof(sz); - if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, &len) == SOCKET_ERROR || + if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, &len) == SOCKET_ERROR || static_cast<unsigned int>(len) != sizeof(sz)) { closeSocketNoThrow(fd); @@ -1834,7 +1854,7 @@ IceInternal::getRecvBufferSize(SOCKET fd) #ifndef ICE_OS_WINRT int sz; socklen_t len = sizeof(sz); - if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, &len) == SOCKET_ERROR || + if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, &len) == SOCKET_ERROR || static_cast<unsigned int>(len) != sizeof(sz)) { closeSocketNoThrow(fd); @@ -1882,7 +1902,7 @@ IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string&) try { // - // NOTE: WinRT doesn't allow specyfing the interface. + // NOTE: WinRT doesn't allow specyfing the interface. // safe_cast<DatagramSocket^>(fd)->JoinMulticastGroup(group.host); } @@ -1992,7 +2012,7 @@ IceInternal::doBind(SOCKET fd, const Address& addr) local.host = addr.host; local.port = listener->Information->LocalPort; } - + DatagramSocket^ datagram = dynamic_cast<DatagramSocket^>(fd); if(datagram != nullptr) { @@ -2015,20 +2035,8 @@ IceInternal::doBind(SOCKET fd, const Address& addr) } return local; #else - int size; - if(addr.saStorage.ss_family == AF_INET) - { - size = static_cast<int>(sizeof(sockaddr_in)); - } - else if(addr.saStorage.ss_family == AF_INET6) - { - size = static_cast<int>(sizeof(sockaddr_in6)); - } - else - { - assert(false); - size = 0; // Keep the compiler happy. - } + int size = getAddressStorageSize(addr); + assert(size != 0); if(::bind(fd, &addr.sa, size) == SOCKET_ERROR) { @@ -2052,6 +2060,20 @@ IceInternal::doBind(SOCKET fd, const Address& addr) #ifndef ICE_OS_WINRT +Address +IceInternal::getNumericAddress(const std::string& address) +{ + vector<Address> addrs = getAddresses(address, 0, EnableBoth, Ice::Ordered, false, false); + if(addrs.empty()) + { + return getInvalidAddress(); + } + else + { + return addrs[0]; + } +} + int IceInternal::getSocketErrno() { @@ -2123,7 +2145,7 @@ bool IceInternal::connectFailed() { #if defined(_WIN32) - int error = WSAGetLastError(); + int error = WSAGetLastError(); return error == WSAECONNREFUSED || error == WSAETIMEDOUT || error == WSAENETUNREACH || @@ -2131,7 +2153,7 @@ IceInternal::connectFailed() error == WSAECONNRESET || error == WSAESHUTDOWN || error == WSAECONNABORTED || - error == ERROR_SEM_TIMEOUT || + error == ERROR_SEM_TIMEOUT || error == ERROR_NETNAME_DELETED; #else return errno == ECONNREFUSED || @@ -2230,24 +2252,17 @@ repeatListen: } bool -IceInternal::doConnect(SOCKET fd, const Address& addr) +IceInternal::doConnect(SOCKET fd, const Address& addr, const Address& sourceAddr) { -repeatConnect: - int size; - if(addr.saStorage.ss_family == AF_INET) + if(isAddressValid(sourceAddr)) { - size = static_cast<int>(sizeof(sockaddr_in)); - } - else if(addr.saStorage.ss_family == AF_INET6) - { - size = static_cast<int>(sizeof(sockaddr_in6)); - } - else - { - assert(false); - size = 0; // Keep the compiler happy. + doBind(fd, sourceAddr); } +repeatConnect: + int size = getAddressStorageSize(addr); + assert(size != 0); + if(::connect(fd, &addr.sa, size) == SOCKET_ERROR) { if(interrupted()) @@ -2324,7 +2339,7 @@ IceInternal::doFinishConnect(SOCKET fd) ex.error = getSocketErrno(); throw ex; } - + if(val > 0) { #if defined(_WIN32) @@ -2430,10 +2445,10 @@ IceInternal::createPipe(SOCKET fds[2]) { setBlock(fds[0], true); # ifndef NDEBUG - bool connected = doConnect(fds[0], addr); + bool connected = doConnect(fds[0], addr, getInvalidAddress()); assert(connected); # else - doConnect(fds[0], addr); + doConnect(fds[0], addr, getInvalidAddress()); # endif } catch(...) @@ -2535,7 +2550,7 @@ IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr, Hos DNSException ex(file, line); ex.error = static_cast<int>(error); // - // Don't need to pass a wide string converter as the wide string come from + // Don't need to pass a wide string converter as the wide string come from // Windows API. // ex.host = IceUtil::wstringToString(host->RawName->Data(), IceUtil::getProcessStringConverter()); @@ -2586,38 +2601,37 @@ IceInternal::checkErrorCode(const char* file, int line, HRESULT herr) #if defined(ICE_USE_IOCP) void -IceInternal::doConnectAsync(SOCKET fd, const Address& addr, AsyncInfo& info) +IceInternal::doConnectAsync(SOCKET fd, const Address& addr, const Address& sourceAddr, AsyncInfo& info) { // // NOTE: It's the caller's responsability to close the socket upon // failure to connect. The socket isn't closed by this method. // - Address bindAddr; - memset(&bindAddr.saStorage, 0, sizeof(sockaddr_storage)); - - int size; - if(addr.saStorage.ss_family == AF_INET) - { - size = sizeof(sockaddr_in); - bindAddr.saIn.sin_family = AF_INET; - bindAddr.saIn.sin_port = htons(0); - bindAddr.saIn.sin_addr.s_addr = htonl(INADDR_ANY); - } - else if(addr.saStorage.ss_family == AF_INET6) + if(isAddressValid(sourceAddr)) { - size = sizeof(sockaddr_in6); - - bindAddr.saIn6.sin6_family = AF_INET6; - bindAddr.saIn6.sin6_port = htons(0); - bindAddr.saIn6.sin6_addr = in6addr_any; + bindAddr = sourceAddr; } else { - assert(false); - size = 0; // Keep the compiler happy. + memset(&bindAddr.saStorage, 0, sizeof(sockaddr_storage)); + if(addr.saStorage.ss_family == AF_INET) + { + bindAddr.saIn.sin_family = AF_INET; + bindAddr.saIn.sin_port = htons(0); + bindAddr.saIn.sin_addr.s_addr = htonl(INADDR_ANY); + } + else if(addr.saStorage.ss_family == AF_INET6) + { + bindAddr.saIn6.sin6_family = AF_INET6; + bindAddr.saIn6.sin6_port = htons(0); + bindAddr.saIn6.sin6_addr = in6addr_any; + } } + int size = getAddressStorageSize(bindAddr); + assert(size != 0); + if(::bind(fd, &bindAddr.sa, size) == SOCKET_ERROR) { SocketException ex(__FILE__, __LINE__); @@ -2628,20 +2642,20 @@ IceInternal::doConnectAsync(SOCKET fd, const Address& addr, AsyncInfo& info) LPFN_CONNECTEX ConnectEx = NULL; // a pointer to the 'ConnectEx()' function GUID GuidConnectEx = WSAID_CONNECTEX; // The Guid DWORD dwBytes; - if(WSAIoctl(fd, + if(WSAIoctl(fd, SIO_GET_EXTENSION_FUNCTION_POINTER, &GuidConnectEx, sizeof(GuidConnectEx), &ConnectEx, sizeof(ConnectEx), &dwBytes, - NULL, + NULL, NULL) == SOCKET_ERROR) { SocketException ex(__FILE__, __LINE__); ex.error = getSocketErrno(); throw ex; - } + } if(!ConnectEx(fd, &addr.sa, size, 0, 0, 0, &info)) { diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h index 3bc5856aea6..a9dd19ded04 100644 --- a/cpp/src/Ice/Network.h +++ b/cpp/src/Ice/Network.h @@ -19,7 +19,8 @@ #include <Ice/NetworkF.h> #include <Ice/PropertiesF.h> // For setTcpBufSize #include <Ice/LoggerF.h> // For setTcpBufSize -#include <Ice/Protocol.h> +#include <Ice/Protocol.h> +#include <Ice/ProtocolInstanceF.h> #include <Ice/EndpointTypes.h> #ifdef ICE_OS_WINRT @@ -56,7 +57,7 @@ typedef int ssize_t; # define ICE_USE_POLL 1 #endif -#if defined(_WIN32) || defined(__osf__) +#if defined(_WIN32) || defined(__osf__) typedef int socklen_t; #endif @@ -99,12 +100,12 @@ typedef int socklen_t; IN PVOID lpSendBuffer OPTIONAL, IN DWORD dwSendDataLength, OUT LPDWORD lpdwBytesSent, IN LPOVERLAPPED lpOverlapped); - typedef BOOL (PASCAL FAR * LPFN_ACCEPTEX)(IN SOCKET sListenSocket, IN SOCKET sAcceptSocket, + typedef BOOL (PASCAL FAR * LPFN_ACCEPTEX)(IN SOCKET sListenSocket, IN SOCKET sAcceptSocket, IN PVOID lpOutputBuffer, IN DWORD dwReceiveDataLength, IN DWORD dwLocalAddressLength, IN DWORD dwRemoteAddressLength, OUT LPDWORD lpdwBytesReceived, IN LPOVERLAPPED lpOverlapped); #endif - + namespace IceInternal { @@ -156,14 +157,14 @@ struct ICE_API AsyncInfo int count; int error; }; - + public delegate void SocketOperationCompletedHandler(int); #endif class ICE_API NativeInfo : virtual public IceUtil::Shared { public: - + NativeInfo(SOCKET socketFd = INVALID_SOCKET) : _fd(socketFd) { } @@ -267,7 +268,7 @@ typedef IceUtil::Handle<SOCKSNetworkProxy> SOCKSNetworkProxyPtr; ICE_API bool noMoreFds(int); ICE_API std::string errorToStringDNS(int); -ICE_API std::vector<Address> getAddresses(const std::string&, int, ProtocolSupport, Ice::EndpointSelectionType, bool, +ICE_API std::vector<Address> getAddresses(const std::string&, int, ProtocolSupport, Ice::EndpointSelectionType, bool, bool); ICE_API ProtocolSupport getProtocolSupport(const Address&); ICE_API Address getAddressForServer(const std::string&, int, ProtocolSupport, bool); @@ -287,6 +288,7 @@ ICE_API void fdToAddressAndPort(SOCKET, std::string&, int&, std::string&, int&); ICE_API void addrToAddressAndPort(const Address&, std::string&, int&); ICE_API std::string addressesToString(const Address&, const Address&, bool); ICE_API bool isAddressValid(const Address&); +ICE_API Address getInvalidAddress(); ICE_API std::vector<std::string> getHostsForEndpointExpand(const std::string&, ProtocolSupport, bool); @@ -324,20 +326,22 @@ ICE_API bool connectInProgress(); ICE_API bool connectionLost(); ICE_API void doListen(SOCKET, int); -ICE_API bool doConnect(SOCKET, const Address&); +ICE_API bool doConnect(SOCKET, const Address&, const Address&); ICE_API void doFinishConnect(SOCKET); ICE_API SOCKET doAccept(SOCKET); ICE_API void createPipe(SOCKET fds[2]); ICE_API int getSocketErrno(); + +ICE_API Address getNumericAddress(const std::string&); #else ICE_API void checkConnectErrorCode(const char*, int, HRESULT, Windows::Networking::HostName^); ICE_API void checkErrorCode(const char*, int, HRESULT); #endif #if defined(ICE_USE_IOCP) -ICE_API void doConnectAsync(SOCKET, const Address&, AsyncInfo&); +ICE_API void doConnectAsync(SOCKET, const Address&, const Address&, AsyncInfo&); ICE_API void doFinishConnectAsync(SOCKET, AsyncInfo&); #endif } diff --git a/cpp/src/Ice/NetworkF.h b/cpp/src/Ice/NetworkF.h index 26cd50739b5..143ef4b0b82 100644 --- a/cpp/src/Ice/NetworkF.h +++ b/cpp/src/Ice/NetworkF.h @@ -17,6 +17,12 @@ namespace IceInternal { +#ifdef ICE_OS_WINRT +struct ICE_API Address; +#else +union Address; +#endif + class NetworkProxy; ICE_API IceUtil::Shared* upCast(NetworkProxy*); typedef Handle<NetworkProxy> NetworkProxyPtr; diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index bbd8bf78e33..44c32e9e96b 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -12,7 +12,7 @@ #include <Ice/PropertyNames.h> -const IceInternal::Property IcePropsData[] = +const IceInternal::Property IcePropsData[] = { IceInternal::Property("Ice.ACM.Client", true, 0), IceInternal::Property("Ice.ACM.Server", true, 0), @@ -105,6 +105,7 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.Default.Router.Context.*", false, 0), IceInternal::Property("Ice.Default.Router", false, 0), IceInternal::Property("Ice.Default.SlicedFormat", false, 0), + IceInternal::Property("Ice.Default.SourceAddress", false, 0), IceInternal::Property("Ice.IPv4", false, 0), IceInternal::Property("Ice.IPv6", false, 0), IceInternal::Property("Ice.EventLog.Source", false, 0), @@ -181,7 +182,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceProps(IcePropsData, sizeof(IcePropsData)/sizeof(IcePropsData[0])); -const IceInternal::Property IceMXPropsData[] = +const IceInternal::Property IceMXPropsData[] = { IceInternal::Property("IceMX.Metrics.*.GroupBy", false, 0), IceInternal::Property("IceMX.Metrics.*.Map", false, 0), @@ -195,7 +196,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceMXProps(IceMXPropsData, sizeof(IceMXPropsData)/sizeof(IceMXPropsData[0])); -const IceInternal::Property IceDiscoveryPropsData[] = +const IceInternal::Property IceDiscoveryPropsData[] = { IceInternal::Property("IceDiscovery.Multicast.ACM.Timeout", false, 0), IceInternal::Property("IceDiscovery.Multicast.ACM.Heartbeat", false, 0), @@ -319,7 +320,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceDiscoveryProps(IceDiscoveryPropsData, sizeof(IceDiscoveryPropsData)/sizeof(IceDiscoveryPropsData[0])); -const IceInternal::Property IceGridDiscoveryPropsData[] = +const IceInternal::Property IceGridDiscoveryPropsData[] = { IceInternal::Property("IceGridDiscovery.Reply.ACM.Timeout", false, 0), IceInternal::Property("IceGridDiscovery.Reply.ACM.Heartbeat", false, 0), @@ -407,7 +408,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceGridDiscoveryProps(IceGridDiscoveryPropsData, sizeof(IceGridDiscoveryPropsData)/sizeof(IceGridDiscoveryPropsData[0])); -const IceInternal::Property IceBoxPropsData[] = +const IceInternal::Property IceBoxPropsData[] = { IceInternal::Property("IceBox.InheritProperties", false, 0), IceInternal::Property("IceBox.InstanceName", false, 0), @@ -458,7 +459,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceBoxProps(IceBoxPropsData, sizeof(IceBoxPropsData)/sizeof(IceBoxPropsData[0])); -const IceInternal::Property IceBoxAdminPropsData[] = +const IceInternal::Property IceBoxAdminPropsData[] = { IceInternal::Property("IceBoxAdmin.ServiceManager.Proxy.EndpointSelection", false, 0), IceInternal::Property("IceBoxAdmin.ServiceManager.Proxy.ConnectionCached", false, 0), @@ -476,7 +477,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceBoxAdminProps(IceBoxAdminPropsData, sizeof(IceBoxAdminPropsData)/sizeof(IceBoxAdminPropsData[0])); -const IceInternal::Property IceGridAdminPropsData[] = +const IceInternal::Property IceGridAdminPropsData[] = { IceInternal::Property("IceGridAdmin.AuthenticateUsingSSL", false, 0), IceInternal::Property("IceGridAdmin.MetricsConfig", false, 0), @@ -533,7 +534,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceGridAdminProps(IceGridAdminPropsData, sizeof(IceGridAdminPropsData)/sizeof(IceGridAdminPropsData[0])); -const IceInternal::Property IceGridPropsData[] = +const IceInternal::Property IceGridPropsData[] = { IceInternal::Property("IceGrid.AdminRouter.ACM.Timeout", false, 0), IceInternal::Property("IceGrid.AdminRouter.ACM.Heartbeat", false, 0), @@ -935,7 +936,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceGridProps(IceGridPropsData, sizeof(IceGridPropsData)/sizeof(IceGridPropsData[0])); -const IceInternal::Property IcePatch2PropsData[] = +const IceInternal::Property IcePatch2PropsData[] = { IceInternal::Property("IcePatch2.ACM.Timeout", false, 0), IceInternal::Property("IcePatch2.ACM.Heartbeat", false, 0), @@ -984,7 +985,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IcePatch2Props(IcePatch2PropsData, sizeof(IcePatch2PropsData)/sizeof(IcePatch2PropsData[0])); -const IceInternal::Property IcePatch2ClientPropsData[] = +const IceInternal::Property IcePatch2ClientPropsData[] = { IceInternal::Property("IcePatch2Client.ChunkSize", false, 0), IceInternal::Property("IcePatch2Client.Directory", false, 0), @@ -997,7 +998,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IcePatch2ClientProps(IcePatch2ClientPropsData, sizeof(IcePatch2ClientPropsData)/sizeof(IcePatch2ClientPropsData[0])); -const IceInternal::Property IceSSLPropsData[] = +const IceInternal::Property IceSSLPropsData[] = { IceInternal::Property("IceSSL.Alias", false, 0), IceInternal::Property("IceSSL.CertAuthDir", false, 0), @@ -1046,7 +1047,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceSSLProps(IceSSLPropsData, sizeof(IceSSLPropsData)/sizeof(IceSSLPropsData[0])); -const IceInternal::Property IceStormAdminPropsData[] = +const IceInternal::Property IceStormAdminPropsData[] = { IceInternal::Property("IceStormAdmin.TopicManager.*", false, 0), IceInternal::Property("IceStormAdmin.Host", false, 0), @@ -1057,7 +1058,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::IceStormAdminProps(IceStormAdminPropsData, sizeof(IceStormAdminPropsData)/sizeof(IceStormAdminPropsData[0])); -const IceInternal::Property Glacier2PropsData[] = +const IceInternal::Property Glacier2PropsData[] = { IceInternal::Property("Glacier2.AddSSLContext", true, 0), IceInternal::Property("Glacier2.AddConnectionContext", false, 0), @@ -1206,7 +1207,7 @@ const IceInternal::PropertyArray IceInternal::PropertyNames::Glacier2Props(Glacier2PropsData, sizeof(Glacier2PropsData)/sizeof(Glacier2PropsData[0])); -const IceInternal::Property FreezePropsData[] = +const IceInternal::Property FreezePropsData[] = { IceInternal::Property("Freeze.DbEnv.*.CheckpointPeriod", false, 0), IceInternal::Property("Freeze.DbEnv.*.DbHome", false, 0), diff --git a/cpp/src/Ice/ProtocolInstance.cpp b/cpp/src/Ice/ProtocolInstance.cpp index 483544d4c81..b643a0c7020 100644 --- a/cpp/src/Ice/ProtocolInstance.cpp +++ b/cpp/src/Ice/ProtocolInstance.cpp @@ -53,13 +53,19 @@ IceInternal::ProtocolInstance::protocolSupport() const { return _instance->protocolSupport(); } - -const string& + +const string& IceInternal::ProtocolInstance::defaultHost() const { return _instance->defaultsAndOverrides()->defaultHost; } - + +const Address& +IceInternal::ProtocolInstance::defaultSourceAddress() const +{ + return _instance->defaultsAndOverrides()->defaultSourceAddress; +} + const EncodingVersion& IceInternal::ProtocolInstance::defaultEncoding() const { @@ -78,15 +84,15 @@ IceInternal::ProtocolInstance::messageSizeMax() const return _instance->messageSizeMax(); } -vector<ConnectorPtr> +vector<ConnectorPtr> IceInternal::ProtocolInstance::resolve(const string& host, int port, EndpointSelectionType type, const IPEndpointIPtr& endpt) const { return _instance->endpointHostResolver()->resolve(host, port, type, endpt); } -void -IceInternal::ProtocolInstance::resolve(const string& host, int port, EndpointSelectionType type, +void +IceInternal::ProtocolInstance::resolve(const string& host, int port, EndpointSelectionType type, const IPEndpointIPtr& endpt, const EndpointI_connectorsPtr& cb) const { _instance->endpointHostResolver()->resolve(host, port, type, endpt, cb); diff --git a/cpp/src/Ice/ProtocolInstance.h b/cpp/src/Ice/ProtocolInstance.h index 88d3048b8f1..6a356af9a87 100644 --- a/cpp/src/Ice/ProtocolInstance.h +++ b/cpp/src/Ice/ProtocolInstance.h @@ -25,9 +25,9 @@ namespace IceInternal class ICE_API ProtocolInstance : public IceUtil::Shared { public: - + ProtocolInstance(const Ice::CommunicatorPtr&, Ice::Short, const std::string&); - + int traceLevel() const { return _traceLevel; @@ -61,12 +61,13 @@ public: bool preferIPv6() const; ProtocolSupport protocolSupport() const; const std::string& defaultHost() const; + const Address& defaultSourceAddress() const; const Ice::EncodingVersion& defaultEncoding() const; NetworkProxyPtr networkProxy() const; size_t messageSizeMax() const; - + std::vector<ConnectorPtr> resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&) const; - void resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&, + void resolve(const std::string&, int, Ice::EndpointSelectionType, const IPEndpointIPtr&, const EndpointI_connectorsPtr&) const; private: diff --git a/cpp/src/Ice/TcpConnector.cpp b/cpp/src/Ice/TcpConnector.cpp index 934315bc129..41579d374df 100644 --- a/cpp/src/Ice/TcpConnector.cpp +++ b/cpp/src/Ice/TcpConnector.cpp @@ -30,7 +30,8 @@ IceInternal::TcpConnector::connect() try { - TransceiverPtr transceiver = new TcpTransceiver(_instance, createSocket(false, _addr), _proxy, _addr); + TransceiverPtr transceiver = + new TcpTransceiver(_instance, createSocket(false, _addr), _proxy, _addr, _sourceAddr); dynamic_cast<TcpTransceiver*>(transceiver.get())->connect(); return transceiver; } @@ -70,12 +71,17 @@ IceInternal::TcpConnector::operator==(const Connector& r) const { return false; } - + if(_timeout != p->_timeout) { return false; } + if(compareAddress(_sourceAddr, p->_sourceAddr) != 0) + { + return false; + } + if(_connectionId != p->_connectionId) { return false; @@ -108,6 +114,16 @@ IceInternal::TcpConnector::operator<(const Connector& r) const return false; } + int rc = compareAddress(_sourceAddr, p->_sourceAddr); + if(rc < 0) + { + return true; + } + else if(rc > 0) + { + return false; + } + if(_connectionId < p->_connectionId) { return true; @@ -119,11 +135,13 @@ IceInternal::TcpConnector::operator<(const Connector& r) const return compareAddress(_addr, p->_addr) < 0; } -IceInternal::TcpConnector::TcpConnector(const ProtocolInstancePtr& instance, const Address& addr, - const NetworkProxyPtr& proxy, Ice::Int timeout, const string& connectionId) : +IceInternal::TcpConnector::TcpConnector(const ProtocolInstancePtr& instance, const Address& addr, + const NetworkProxyPtr& proxy, const Address& sourceAddr, + Ice::Int timeout, const string& connectionId) : _instance(instance), _addr(addr), _proxy(proxy), + _sourceAddr(sourceAddr), _timeout(timeout), _connectionId(connectionId) { diff --git a/cpp/src/Ice/TcpConnector.h b/cpp/src/Ice/TcpConnector.h index 1acb6efc1c9..1b3f6c7e92a 100644 --- a/cpp/src/Ice/TcpConnector.h +++ b/cpp/src/Ice/TcpConnector.h @@ -21,7 +21,7 @@ namespace IceInternal class TcpConnector : public Connector { public: - + virtual TransceiverPtr connect(); virtual Ice::Short type() const; @@ -32,14 +32,16 @@ public: virtual bool operator<(const Connector&) const; private: - - TcpConnector(const ProtocolInstancePtr&, const Address&, const NetworkProxyPtr&, Ice::Int, const std::string&); + + TcpConnector(const ProtocolInstancePtr&, const Address&, const NetworkProxyPtr&, const Address&, Ice::Int, + const std::string&); virtual ~TcpConnector(); friend class TcpEndpointI; const ProtocolInstancePtr _instance; const Address _addr; const NetworkProxyPtr _proxy; + const Address _sourceAddr; const Ice::Int _timeout; const std::string _connectionId; }; diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index 40fcbfed98b..7d593d6203a 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -21,11 +21,12 @@ using namespace std; using namespace Ice; using namespace IceInternal; -IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, const string& ho, Int po, Int ti, - const string& conId, bool co) : - IPEndpointI(instance, ho, po, conId), - _timeout(ti), - _compress(co) +IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, const string& host, Int port, + const Address& sourceAddr, Int timeout, const string& connectionId, + bool compress) : + IPEndpointI(instance, host, port, sourceAddr, connectionId), + _timeout(timeout), + _compress(compress) { } @@ -51,7 +52,7 @@ IceInternal::TcpEndpointI::getInfo() const class InfoI : public Ice::TCPEndpointInfo { public: - + InfoI(const EndpointIPtr& endpoint) : _endpoint(endpoint) { } @@ -61,13 +62,13 @@ IceInternal::TcpEndpointI::getInfo() const { return _endpoint->type(); } - + virtual bool datagram() const { return _endpoint->datagram(); } - + virtual bool secure() const { @@ -75,7 +76,7 @@ IceInternal::TcpEndpointI::getInfo() const } private: - + const EndpointIPtr _endpoint; }; @@ -99,7 +100,7 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const } else { - return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress); + return new TcpEndpointI(_instance, _host, _port, _sourceAddr, timeout, _connectionId, _compress); } } @@ -118,7 +119,7 @@ IceInternal::TcpEndpointI::compress(bool compress) const } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress); + return new TcpEndpointI(_instance, _host, _port, _sourceAddr, _timeout, _connectionId, compress); } } @@ -323,16 +324,16 @@ IceInternal::TcpEndpointI::checkOption(const string& option, const string& argum } } -ConnectorPtr +ConnectorPtr IceInternal::TcpEndpointI::createConnector(const Address& address, const NetworkProxyPtr& proxy) const { - return new TcpConnector(_instance, address, proxy, _timeout, _connectionId); + return new TcpConnector(_instance, address, proxy, _sourceAddr, _timeout, _connectionId); } -IPEndpointIPtr +IPEndpointIPtr IceInternal::TcpEndpointI::createEndpoint(const string& host, int port, const string& connectionId) const { - return new TcpEndpointI(_instance, host, port, _timeout, connectionId, _compress); + return new TcpEndpointI(_instance, host, port, _sourceAddr, _timeout, connectionId, _compress); } IceInternal::TcpEndpointFactory::TcpEndpointFactory(const ProtocolInstancePtr& instance) : _instance(instance) @@ -375,7 +376,7 @@ IceInternal::TcpEndpointFactory::destroy() _instance = 0; } -EndpointFactoryPtr +EndpointFactoryPtr IceInternal::TcpEndpointFactory::clone(const ProtocolInstancePtr& instance) const { return new TcpEndpointFactory(instance); diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h index 93f9a37445e..3dba15da6f4 100644 --- a/cpp/src/Ice/TcpEndpointI.h +++ b/cpp/src/Ice/TcpEndpointI.h @@ -22,7 +22,8 @@ class TcpEndpointI : public IPEndpointI { public: - TcpEndpointI(const ProtocolInstancePtr&, const std::string&, Ice::Int, Ice::Int, const std::string&, bool); + TcpEndpointI(const ProtocolInstancePtr&, const std::string&, Ice::Int, const Address&, Ice::Int, const std::string&, + bool); TcpEndpointI(const ProtocolInstancePtr&); TcpEndpointI(const ProtocolInstancePtr&, BasicStream*); @@ -84,7 +85,7 @@ private: ProtocolInstancePtr _instance; }; - + } #endif diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp index f5c30d11457..4c8be1b2f28 100644 --- a/cpp/src/Ice/TcpTransceiver.cpp +++ b/cpp/src/Ice/TcpTransceiver.cpp @@ -334,7 +334,7 @@ IceInternal::TcpTransceiver::read(Buffer& buf, bool&) if(_instance->traceLevel() >= 3) { Trace out(_instance->logger(), _instance->traceCategory()); - out << "received " << ret << " of " << packetSize << " bytes via " << _instance->protocol() << '\n' + out << "received " << ret << " of " << packetSize << " bytes via " << _instance->protocol() << '\n' << toString(); } @@ -352,7 +352,7 @@ IceInternal::TcpTransceiver::startWrite(Buffer& buf) if(_state == StateConnectPending) { Address addr = _proxy ? _proxy->getAddress() : _addr; - doConnectAsync(_fd, addr, _write); + doConnectAsync(_fd, addr, _sourceAddr, _write); return false; } @@ -423,7 +423,7 @@ IceInternal::TcpTransceiver::finishWrite(Buffer& buf) } Trace out(_instance->logger(), _instance->traceCategory()); - out << "sent " << _write.count << " of " << packetSize << " bytes via " << _instance->protocol() << '\n' + out << "sent " << _write.count << " of " << packetSize << " bytes via " << _instance->protocol() << '\n' << toString(); } @@ -497,7 +497,7 @@ IceInternal::TcpTransceiver::finishRead(Buffer& buf, bool&) packetSize = _maxReceivePacketSize; } Trace out(_instance->logger(), _instance->traceCategory()); - out << "received " << _read.count << " of " << packetSize << " bytes via " << _instance->protocol() << '\n' + out << "received " << _read.count << " of " << packetSize << " bytes via " << _instance->protocol() << '\n' << toString(); } @@ -534,12 +534,14 @@ IceInternal::TcpTransceiver::checkSendSize(const Buffer& buf, size_t messageSize } } -IceInternal::TcpTransceiver::TcpTransceiver(const ProtocolInstancePtr& instance, SOCKET fd, - const NetworkProxyPtr& proxy, const Address& addr) : +IceInternal::TcpTransceiver::TcpTransceiver(const ProtocolInstancePtr& instance, SOCKET fd, + const NetworkProxyPtr& proxy, const Address& addr, + const Address& sourceAddr) : NativeInfo(fd), _instance(instance), _proxy(proxy), _addr(addr), + _sourceAddr(sourceAddr), _state(StateNeedConnect) #ifdef ICE_USE_IOCP , _read(SocketOperationRead), @@ -574,6 +576,7 @@ IceInternal::TcpTransceiver::TcpTransceiver(const ProtocolInstancePtr& instance, NativeInfo(fd), _instance(instance), _addr(Address()), + _sourceAddr(getInvalidAddress()), _state(StateConnected), _desc(fdToString(_fd)) #ifdef ICE_USE_IOCP @@ -617,7 +620,7 @@ IceInternal::TcpTransceiver::connect() try { Address addr = _proxy ? _proxy->getAddress() : _addr; - if(doConnect(_fd, addr)) + if(doConnect(_fd, addr, _sourceAddr)) { _state = StateConnected; _desc = fdToString(_fd, _proxy, _addr, true); diff --git a/cpp/src/Ice/TcpTransceiver.h b/cpp/src/Ice/TcpTransceiver.h index 691e9aafce7..4e0f36b0056 100644 --- a/cpp/src/Ice/TcpTransceiver.h +++ b/cpp/src/Ice/TcpTransceiver.h @@ -37,7 +37,7 @@ public: #ifdef ICE_USE_IOCP virtual AsyncInfo* getAsyncInfo(SocketOperation); #endif - + virtual SocketOperation initialize(Buffer&, Buffer&, bool&); virtual SocketOperation closing(bool, const Ice::LocalException&); virtual void close(); @@ -56,7 +56,7 @@ public: private: - TcpTransceiver(const ProtocolInstancePtr&, SOCKET, const NetworkProxyPtr&, const Address&); + TcpTransceiver(const ProtocolInstancePtr&, SOCKET, const NetworkProxyPtr&, const Address&, const Address&); TcpTransceiver(const ProtocolInstancePtr&, SOCKET); virtual ~TcpTransceiver(); @@ -68,7 +68,8 @@ private: const ProtocolInstancePtr _instance; const NetworkProxyPtr _proxy; const Address _addr; - + const Address _sourceAddr; + State _state; std::string _desc; diff --git a/cpp/src/Ice/UdpConnector.cpp b/cpp/src/Ice/UdpConnector.cpp index de3c38175bf..d35b0904190 100644 --- a/cpp/src/Ice/UdpConnector.cpp +++ b/cpp/src/Ice/UdpConnector.cpp @@ -20,7 +20,7 @@ using namespace IceInternal; TransceiverPtr IceInternal::UdpConnector::connect() { - return new UdpTransceiver(_instance, _addr, _mcastInterface, _mcastTtl); + return new UdpTransceiver(_instance, _addr, _sourceAddr, _mcastInterface, _mcastTtl); } Short @@ -63,6 +63,11 @@ IceInternal::UdpConnector::operator==(const Connector& r) const return false; } + if(compareAddress(_sourceAddr, p->_sourceAddr) != 0) + { + return false; + } + return true; } @@ -107,13 +112,27 @@ IceInternal::UdpConnector::operator<(const Connector& r) const { return false; } + + int rc = compareAddress(_sourceAddr, p->_sourceAddr); + if(rc < 0) + { + return true; + } + else if(rc > 0) + { + return false; + } return compareAddress(_addr, p->_addr) == -1; } -IceInternal::UdpConnector::UdpConnector(const ProtocolInstancePtr& instance, const Address& addr, - const string& mcastInterface, int mcastTtl, const std::string& connectionId) : +IceInternal::UdpConnector::UdpConnector(const ProtocolInstancePtr& instance, const Address& addr, + const Address& sourceAddr, const string& mcastInterface, int mcastTtl, + const std::string& connectionId) : _instance(instance), _addr(addr), +#ifndef ICE_OS_WINRT + _sourceAddr(sourceAddr), +#endif _mcastInterface(mcastInterface), _mcastTtl(mcastTtl), _connectionId(connectionId) diff --git a/cpp/src/Ice/UdpConnector.h b/cpp/src/Ice/UdpConnector.h index 26cedca2e62..9f1d7ebe0b6 100644 --- a/cpp/src/Ice/UdpConnector.h +++ b/cpp/src/Ice/UdpConnector.h @@ -21,7 +21,7 @@ namespace IceInternal class UdpConnector : public Connector { public: - + virtual TransceiverPtr connect(); virtual Ice::Short type() const; @@ -32,14 +32,16 @@ public: virtual bool operator<(const Connector&) const; private: - - UdpConnector(const ProtocolInstancePtr&, const Address&, const std::string&, int, const std::string&); + + UdpConnector(const ProtocolInstancePtr&, const Address&, const Address&, const std::string&, int, + const std::string&); virtual ~UdpConnector(); friend class UdpEndpointI; const ProtocolInstancePtr _instance; const Address _addr; + const Address _sourceAddr; const std::string _mcastInterface; const int _mcastTtl; const std::string _connectionId; diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index a1a4b4fdfe9..22d87e20174 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -22,11 +22,12 @@ using namespace std; using namespace Ice; using namespace IceInternal; -IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance, const string& ho, Int po, - const string& mif, Int mttl, bool conn, const string& conId, bool co) : - IPEndpointI(instance, ho, po, conId), - _mcastInterface(mif), +IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance, const string& host, Int port, + const Address& sourceAddr, const string& mcastInterface, Int mttl, bool conn, + const string& conId, bool co) : + IPEndpointI(instance, host, port, sourceAddr, conId), _mcastTtl(mttl), + _mcastInterface(mcastInterface), _connect(conn), _compress(co) { @@ -65,7 +66,7 @@ IceInternal::UdpEndpointI::getInfo() const class InfoI : public Ice::UDPEndpointInfo { public: - + InfoI(const EndpointIPtr& endpoint) : _endpoint(endpoint) { } @@ -75,13 +76,13 @@ IceInternal::UdpEndpointI::getInfo() const { return _endpoint->type(); } - + virtual bool datagram() const { return _endpoint->datagram(); } - + virtual bool secure() const { @@ -89,7 +90,7 @@ IceInternal::UdpEndpointI::getInfo() const } private: - + const EndpointIPtr _endpoint; }; @@ -125,7 +126,8 @@ IceInternal::UdpEndpointI::compress(bool compress) const } else { - return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, _connectionId, compress); + return new UdpEndpointI(_instance, _host, _port, _sourceAddr, _mcastInterface, _mcastTtl, _connect, + _connectionId, compress); } } @@ -325,8 +327,8 @@ IceInternal::UdpEndpointI::fillEndpointInfo(IPEndpointInfo* info) const { udpInfo->timeout = -1; udpInfo->compress = _compress; - udpInfo->mcastInterface = _mcastInterface; udpInfo->mcastTtl = _mcastTtl; + udpInfo->mcastInterface = _mcastInterface; } } @@ -415,16 +417,17 @@ IceInternal::UdpEndpointI::checkOption(const string& option, const string& argum return true; } -ConnectorPtr +ConnectorPtr IceInternal::UdpEndpointI::createConnector(const Address& address, const NetworkProxyPtr&) const { - return new UdpConnector(_instance, address, _mcastInterface, _mcastTtl, _connectionId); + return new UdpConnector(_instance, address, _sourceAddr, _mcastInterface, _mcastTtl, _connectionId); } -IPEndpointIPtr +IPEndpointIPtr IceInternal::UdpEndpointI::createEndpoint(const string& host, int port, const string& connectionId) const { - return new UdpEndpointI(_instance, host, port, _mcastInterface, _mcastTtl, _connect, connectionId, _compress); + return new UdpEndpointI(_instance, host, port, _sourceAddr, _mcastInterface, _mcastTtl, _connect, connectionId, + _compress); } IceInternal::UdpEndpointFactory::UdpEndpointFactory(const ProtocolInstancePtr& instance) : _instance(instance) @@ -467,7 +470,7 @@ IceInternal::UdpEndpointFactory::destroy() _instance = 0; } -EndpointFactoryPtr +EndpointFactoryPtr IceInternal::UdpEndpointFactory::clone(const ProtocolInstancePtr& instance) const { return new UdpEndpointFactory(instance); diff --git a/cpp/src/Ice/UdpEndpointI.h b/cpp/src/Ice/UdpEndpointI.h index f7f734bc7d4..ae43d412a32 100644 --- a/cpp/src/Ice/UdpEndpointI.h +++ b/cpp/src/Ice/UdpEndpointI.h @@ -22,8 +22,8 @@ class UdpEndpointI : public IPEndpointI { public: - UdpEndpointI(const ProtocolInstancePtr&, const std::string&, Ice::Int, const std::string&, Ice::Int, bool, - const std::string&, bool); + UdpEndpointI(const ProtocolInstancePtr&, const std::string&, Ice::Int, const Address&, const std::string&, + Ice::Int, bool, const std::string&, bool); UdpEndpointI(const ProtocolInstancePtr&); UdpEndpointI(const ProtocolInstancePtr&, BasicStream*); @@ -60,8 +60,8 @@ private: // // All members are const, because endpoints are immutable. // - const std::string _mcastInterface; const Ice::Int _mcastTtl; + const std::string _mcastInterface; const bool _connect; const bool _compress; }; diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index a82f0e0f4ae..18ea62ffe47 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -56,7 +56,7 @@ IceInternal::UdpTransceiver::getAsyncInfo(SocketOperation status) } } #elif defined(ICE_OS_WINRT) -void +void IceInternal::UdpTransceiver::setCompletedHandler(SocketOperationCompletedHandler^ handler) { _completedHandler = handler; @@ -204,7 +204,7 @@ repeat: } # ifdef _WIN32 - ret = ::sendto(_fd, reinterpret_cast<const char*>(&buf.b[0]), static_cast<int>(buf.b.size()), 0, + ret = ::sendto(_fd, reinterpret_cast<const char*>(&buf.b[0]), static_cast<int>(buf.b.size()), 0, &_peerAddr.sa, len); # else ret = ::sendto(_fd, reinterpret_cast<const char*>(&buf.b[0]), buf.b.size(), 0, @@ -274,7 +274,7 @@ repeat: memset(&peerAddr.saStorage, 0, sizeof(sockaddr_storage)); socklen_t len = static_cast<socklen_t>(sizeof(sockaddr_storage)); - ret = recvfrom(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, 0, + ret = recvfrom(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, 0, &peerAddr.sa, &len); if(ret != SOCKET_ERROR) @@ -287,7 +287,7 @@ repeat: { if(recvTruncated()) { - // The message was truncated and the whole buffer is filled. We ignore + // The message was truncated and the whole buffer is filled. We ignore // this error here, it will be detected at the connection level when // the Ice message size is checked against the buffer size. ret = static_cast<ssize_t>(buf.b.size()); @@ -298,12 +298,12 @@ repeat: { goto repeat; } - + if(wouldBlock()) { return SocketOperationRead; } - + if(connectionLost()) { ConnectionLostException ex(__FILE__, __LINE__); @@ -318,7 +318,7 @@ repeat: } } } - + if(_state == StateNeedConnect) { // @@ -327,10 +327,10 @@ repeat: assert(_incoming); // Client connections should always be connected at this point. # ifndef NDEBUG - bool connected = doConnect(_fd, _peerAddr); + bool connected = doConnect(_fd, _peerAddr, getInvalidAddress()); assert(connected); # else - doConnect(_fd, _peerAddr); + doConnect(_fd, _peerAddr, getInvalidAddress()); # endif _state = StateConnected; @@ -459,7 +459,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf) // NOTE: unlike other methods, it's important to modify _write.count // _before_ calling checkIfErrorOrCompleted since this isn't called // with the connection mutex but from a Windows thread pool thread. - // So we can't modify the _write structure after calling the + // So we can't modify the _write structure after calling the // completed callback. // _write.count = operation->GetResults(); @@ -475,7 +475,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf) { checkConnectErrorCode(__FILE__, __LINE__, operation->ErrorCode.Value, _addr.host); } - else + else { checkErrorCode(__FILE__, __LINE__, operation->ErrorCode.Value); } @@ -542,7 +542,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf) ex.error = 0; throw ex; } - err = WSASendTo(_fd, &_write.buf, 1, &_write.count, 0, &_peerAddr.sa, + err = WSASendTo(_fd, &_write.buf, 1, &_write.count, 0, &_peerAddr.sa, len, &_write, NULL); } @@ -626,8 +626,8 @@ IceInternal::UdpTransceiver::startRead(Buffer& buf) { memset(&_readAddr.saStorage, 0, sizeof(struct sockaddr_storage)); _readAddrLen = static_cast<socklen_t>(sizeof(sockaddr_storage)); - - err = WSARecvFrom(_fd, &_read.buf, 1, &_read.count, &_read.flags, + + err = WSARecvFrom(_fd, &_read.buf, 1, &_read.count, &_read.flags, &_readAddr.sa, &_readAddrLen, &_read, NULL); } @@ -685,8 +685,9 @@ IceInternal::UdpTransceiver::finishRead(Buffer& buf, bool&) try { DataReader^ reader = args->GetDataReader(); - ret = min(static_cast<int>(reader->UnconsumedBufferLength), static_cast<int>(buf.b.size())); // Truncate received data if too large. - + // Truncate received data if too large. + ret = min(static_cast<int>(reader->UnconsumedBufferLength), static_cast<int>(buf.b.size())); + Array<unsigned char>^ data = ref new Array<unsigned char>(ret); reader->ReadBytes(data); memcpy(&*buf.i, data->Data, ret); @@ -707,7 +708,7 @@ IceInternal::UdpTransceiver::finishRead(Buffer& buf, bool&) if(recvTruncated()) { - // The message was truncated and the whole buffer is filled. We ignore + // The message was truncated and the whole buffer is filled. We ignore // this error here, it will be detected at the connection level when // the Ice message size is checked against the buffer size. _read.count = static_cast<int>(buf.b.size()); @@ -728,7 +729,7 @@ IceInternal::UdpTransceiver::finishRead(Buffer& buf, bool&) } } } - + if(_state == StateNotConnected) { _peerAddr = _readAddr; @@ -826,7 +827,7 @@ IceInternal::UdpTransceiver::getInfo() const } else { - fdToAddressAndPort(_fd, info->localAddress, info->localPort, info->remoteAddress, info->remotePort); + fdToAddressAndPort(_fd, info->localAddress, info->localPort, info->remoteAddress, info->remotePort); } if(isAddressValid(_mcastAddr)) @@ -849,7 +850,7 @@ IceInternal::UdpTransceiver::checkSendSize(const Buffer& buf, size_t messageSize } // - // The maximum packetSize is either the maximum allowable UDP packet size, or + // The maximum packetSize is either the maximum allowable UDP packet size, or // the UDP send buffer size (which ever is smaller). // const int packetSize = min(_maxPacketSize, _sndSize - _udpOverhead); @@ -866,12 +867,14 @@ IceInternal::UdpTransceiver::effectivePort() const } -IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, +IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, const Address& addr, #ifdef ICE_OS_WINRT + const Address&, const string&, int #else + const Address& sourceAddr, const string& mcastInterface, int mcastTtl #endif @@ -881,7 +884,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, _addr(addr), _state(StateNeedConnect) #if defined(ICE_USE_IOCP) - , _read(SocketOperationRead), + , _read(SocketOperationRead), _write(SocketOperationWrite) #elif defined(ICE_OS_WINRT) , _readPending(false) @@ -912,13 +915,13 @@ IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, } // - // In general, connecting a datagram socket should be non-blocking as this just setups + // In general, connecting a datagram socket should be non-blocking as this just setups // the default destination address for the socket. However, on some OS, connect sometime // returns EWOULDBLOCK. If that's the case, we keep the state as StateNeedConnect. This // will make sure the transceiver is notified when the socket is ready for sending (see // the initialize() implementation). // - if(doConnect(_fd, _addr)) + if(doConnect(_fd, _addr, sourceAddr)) { _state = StateConnected; } @@ -934,7 +937,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, #ifdef ICE_USE_IOCP // - // On Windows when using IOCP, we must make sure that the socket is connected without + // On Windows when using IOCP, we must make sure that the socket is connected without // blocking as there's no way to do a non-blocking datagram socket conection (ConnectEx // only supports connection oriented sockets). According to Microsoft documentation of // the connect() call, this should always be the case. @@ -952,7 +955,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, #ifdef ICE_OS_WINRT , _readPending(false) #elif defined(ICE_USE_IOCP) - , _read(SocketOperationRead), + , _read(SocketOperationRead), _write(SocketOperationWrite) #endif { @@ -989,7 +992,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, // // Windows does not allow binding to the mcast address itself // so we bind to INADDR_ANY (0.0.0.0) instead. As a result, - // bi-directional connection won't work because the source + // bi-directional connection won't work because the source // address won't be the multicast address and the client will // therefore reject the datagram. // @@ -1028,7 +1031,7 @@ IceInternal::UdpTransceiver::UdpTransceiver(const ProtocolInstancePtr& instance, Trace out(_instance->logger(), _instance->traceCategory()); out << "starting to receive " << _instance->protocol() << " packets\n" << toString(); - vector<string> interfaces = + vector<string> interfaces = getHostsForEndpointExpand(inetAddrToString(_addr), _instance->protocolSupport(), true); if(!interfaces.empty()) { @@ -1153,7 +1156,7 @@ IceInternal::UdpTransceiver::checkIfErrorOrCompleted(SocketOperation op, IAsyncI { checkConnectErrorCode(__FILE__, __LINE__, info->ErrorCode.Value, _addr.host); } - else + else { checkErrorCode(__FILE__, __LINE__, info->ErrorCode.Value); } diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h index 02b8c3267f5..618d788480c 100644 --- a/cpp/src/Ice/UdpTransceiver.h +++ b/cpp/src/Ice/UdpTransceiver.h @@ -43,7 +43,7 @@ public: #elif defined(ICE_OS_WINRT) virtual void setCompletedHandler(SocketOperationCompletedHandler^); #endif - + virtual SocketOperation initialize(Buffer&, Buffer&, bool&); virtual SocketOperation closing(bool, const Ice::LocalException&); virtual void close(); @@ -64,7 +64,7 @@ public: private: - UdpTransceiver(const ProtocolInstancePtr&, const Address&, const std::string&, int); + UdpTransceiver(const ProtocolInstancePtr&, const Address&, const Address&, const std::string&, int); UdpTransceiver(const ProtocolInstancePtr&, const std::string&, int, const std::string&, bool); virtual ~UdpTransceiver(); diff --git a/cpp/src/Ice/winrt/StreamAcceptor.cpp b/cpp/src/Ice/winrt/StreamAcceptor.cpp index 4031fecf790..f7bf238c159 100644 --- a/cpp/src/Ice/winrt/StreamAcceptor.cpp +++ b/cpp/src/Ice/winrt/StreamAcceptor.cpp @@ -55,7 +55,7 @@ IceInternal::StreamAcceptor::close() assert(_accepted.empty()); _completedHandler(SocketOperationRead); _acceptPending = false; - } + } else if(!_accepted.empty()) { for(deque<StreamSocket^>::const_iterator p = _accepted.begin(); p != _accepted.end(); ++p) @@ -78,7 +78,7 @@ IceInternal::StreamAcceptor::listen() Trace out(_instance->logger(), _instance->traceCategory()); out << "accepting " << _instance->protocol() << " connections at " << toString(); - vector<string> interfaces = + vector<string> interfaces = getHostsForEndpointExpand(inetAddrToString(_addr), _instance->protocolSupport(), true); if(!interfaces.empty()) { @@ -131,7 +131,7 @@ IceInternal::StreamAcceptor::accept() assert(_accepted.empty()); throw SocketException(__FILE__, __LINE__); } - + StreamSocket^ fd; { IceUtil::Mutex::Lock lock(_mutex); @@ -173,13 +173,13 @@ IceInternal::StreamAcceptor::StreamAcceptor(const ProtocolInstancePtr& instance, { _fd = ref new StreamSocketListener(); - safe_cast<StreamSocketListener^>(_fd)->ConnectionReceived += + safe_cast<StreamSocketListener^>(_fd)->ConnectionReceived += ref new TypedEventHandler<StreamSocketListener^, StreamSocketListenerConnectionReceivedEventArgs^>( [=](StreamSocketListener^, StreamSocketListenerConnectionReceivedEventArgs^ args) { queueAcceptedSocket(args->Socket); }); - + if(_instance->traceLevel() >= 2) { Trace out(_instance->logger(), _instance->traceCategory()); @@ -210,7 +210,7 @@ IceInternal::StreamAcceptor::queueAcceptedSocket(StreamSocket^ socket) // 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(SocketOperationRead); diff --git a/cpp/src/Ice/winrt/StreamEndpointI.cpp b/cpp/src/Ice/winrt/StreamEndpointI.cpp index 778a9329aa4..b58f9e826ce 100644 --- a/cpp/src/Ice/winrt/StreamEndpointI.cpp +++ b/cpp/src/Ice/winrt/StreamEndpointI.cpp @@ -31,24 +31,24 @@ namespace template<class T> class InfoI : public T { public: - + InfoI(Ice::Short type, Ice::Int to, bool comp, const string& host, Ice::Int port) : - T(to, comp, host, port), _type(type) + T(to, comp, host, port, ""), _type(type) { } - + virtual Ice::Short type() const { return _type; } - + virtual bool datagram() const { return false; } - + virtual bool secure() const { @@ -56,7 +56,7 @@ public: } private: - + Ice::Short _type; }; @@ -64,7 +64,7 @@ private: IceInternal::StreamEndpointI::StreamEndpointI(const ProtocolInstancePtr& instance, const string& ho, Int po, Int ti, const string& conId, bool co) : - IPEndpointI(instance, ho, po, conId), + IPEndpointI(instance, ho, po, getInvalidAddress(), conId), _timeout(ti), _compress(co) { @@ -341,14 +341,14 @@ IceInternal::StreamEndpointI::checkOption(const string& option, const string& ar } } -ConnectorPtr +ConnectorPtr IceInternal::StreamEndpointI::createConnector(const Address& address, const NetworkProxyPtr& proxy) const { // TODO: Add support for network proxies? return new StreamConnector(_instance, address, _timeout, _connectionId); } -IPEndpointIPtr +IPEndpointIPtr IceInternal::StreamEndpointI::createEndpoint(const string& host, int port, const string& connectionId) const { return new StreamEndpointI(_instance, host, port, _timeout, connectionId, _compress); @@ -394,7 +394,7 @@ IceInternal::StreamEndpointFactory::destroy() _instance = 0; } -EndpointFactoryPtr +EndpointFactoryPtr IceInternal::StreamEndpointFactory::clone(const ProtocolInstancePtr& instance) const { return new StreamEndpointFactory(instance); diff --git a/cpp/src/Ice/winrt/StreamTransceiver.cpp b/cpp/src/Ice/winrt/StreamTransceiver.cpp index 234fe3f122f..f921425cc9a 100644 --- a/cpp/src/Ice/winrt/StreamTransceiver.cpp +++ b/cpp/src/Ice/winrt/StreamTransceiver.cpp @@ -285,7 +285,7 @@ IceInternal::StreamTransceiver::startRead(Buffer& buf) } void -IceInternal::StreamTransceiver::finishRead(Buffer& buf) +IceInternal::StreamTransceiver::finishRead(Buffer& buf, bool& hasMoreData) { if(_read.count == SOCKET_ERROR) { diff --git a/cpp/src/Ice/winrt/StreamTransceiver.h b/cpp/src/Ice/winrt/StreamTransceiver.h index 160f7c0122e..c37c6eb8f54 100644 --- a/cpp/src/Ice/winrt/StreamTransceiver.h +++ b/cpp/src/Ice/winrt/StreamTransceiver.h @@ -43,7 +43,7 @@ public: virtual bool startWrite(Buffer&); virtual void finishWrite(Buffer&); virtual void startRead(Buffer&); - virtual void finishRead(Buffer&); + virtual void finishRead(Buffer&, bool&); virtual std::string protocol() const; virtual std::string toString() const; diff --git a/cpp/src/IceSSL/ConnectorI.cpp b/cpp/src/IceSSL/ConnectorI.cpp index f1640673ba7..b8cb1144b5b 100644 --- a/cpp/src/IceSSL/ConnectorI.cpp +++ b/cpp/src/IceSSL/ConnectorI.cpp @@ -45,7 +45,7 @@ IceSSL::ConnectorI::connect() try { - return new TransceiverI(_instance, IceInternal::createSocket(false, _addr), _proxy, _host, _addr); + return new TransceiverI(_instance, IceInternal::createSocket(false, _addr), _proxy, _host, _addr, _sourceAddr); } catch(const Ice::LocalException& ex) { @@ -89,6 +89,11 @@ IceSSL::ConnectorI::operator==(const IceInternal::Connector& r) const return false; } + if(IceInternal::compareAddress(_sourceAddr, p->_sourceAddr) != 0) + { + return false; + } + if(_connectionId != p->_connectionId) { return false; @@ -121,6 +126,16 @@ IceSSL::ConnectorI::operator<(const IceInternal::Connector& r) const return false; } + int rc = compareAddress(_sourceAddr, p->_sourceAddr); + if(rc < 0) + { + return true; + } + else if(rc > 0) + { + return false; + } + if(_connectionId < p->_connectionId) { return true; @@ -134,12 +149,13 @@ IceSSL::ConnectorI::operator<(const IceInternal::Connector& r) const } IceSSL::ConnectorI::ConnectorI(const InstancePtr& instance, const string& host, const IceInternal::Address& addr, - const IceInternal::NetworkProxyPtr& proxy, Ice::Int timeout, - const string& connectionId) : + const IceInternal::NetworkProxyPtr& proxy, const IceInternal::Address& sourceAddr, + Ice::Int timeout, const string& connectionId) : _instance(instance), _host(host), _addr(addr), _proxy(proxy), + _sourceAddr(sourceAddr), _timeout(timeout), _connectionId(connectionId) { diff --git a/cpp/src/IceSSL/ConnectorI.h b/cpp/src/IceSSL/ConnectorI.h index 2cb2a295222..fb73ddd743c 100644 --- a/cpp/src/IceSSL/ConnectorI.h +++ b/cpp/src/IceSSL/ConnectorI.h @@ -24,7 +24,7 @@ class EndpointI; class ConnectorI : public IceInternal::Connector { public: - + virtual IceInternal::TransceiverPtr connect(); virtual Ice::Short type() const; @@ -35,9 +35,10 @@ public: virtual bool operator<(const IceInternal::Connector&) const; private: - + ConnectorI(const InstancePtr&, const std::string&, const IceInternal::Address&, - const IceInternal::NetworkProxyPtr&, Ice::Int, const std::string&); + const IceInternal::NetworkProxyPtr&, const IceInternal::Address&, + Ice::Int, const std::string&); virtual ~ConnectorI(); friend class EndpointI; @@ -45,6 +46,7 @@ private: const std::string _host; const IceInternal::Address _addr; const IceInternal::NetworkProxyPtr _proxy; + const IceInternal::Address _sourceAddr; const Ice::Int _timeout; const std::string _connectionId; }; diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index d17b7e16cc8..7782e11f517 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -21,9 +21,9 @@ using namespace std; using namespace Ice; using namespace IceSSL; -IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti, const string& conId, - bool co) : - IceInternal::IPEndpointI(instance, ho, po, conId), +IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int po, + const IceInternal::Address& sourceAddr, Int ti, const string& conId, bool co) : + IceInternal::IPEndpointI(instance, ho, po, sourceAddr, conId), _instance(instance), _timeout(ti), _compress(co) @@ -54,7 +54,7 @@ IceSSL::EndpointI::getInfo() const class InfoI : public EndpointInfo { public: - + InfoI(const IceInternal::EndpointIPtr& endpoint) : _endpoint(endpoint) { } @@ -64,13 +64,13 @@ IceSSL::EndpointI::getInfo() const { return _endpoint->type(); } - + virtual bool datagram() const { return _endpoint->datagram(); } - + virtual bool secure() const { @@ -78,13 +78,13 @@ IceSSL::EndpointI::getInfo() const } private: - + const IceInternal::EndpointIPtr _endpoint; }; IPEndpointInfoPtr info = new InfoI(const_cast<EndpointI*>(this)); fillEndpointInfo(info.get()); - return info; + return info; } Int @@ -102,7 +102,7 @@ IceSSL::EndpointI::timeout(Int timeout) const } else { - return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress); + return new EndpointI(_instance, _host, _port, _sourceAddr, timeout, _connectionId, _compress); } } @@ -121,7 +121,7 @@ IceSSL::EndpointI::compress(bool compress) const } else { - return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress); + return new EndpointI(_instance, _host, _port, _sourceAddr, _timeout, _connectionId, compress); } } @@ -148,7 +148,7 @@ IceInternal::AcceptorPtr IceSSL::EndpointI::acceptor(IceInternal::EndpointIPtr& endp, const string& adapterName) const { AcceptorI* p = new AcceptorI(_instance, adapterName, _host, _port); - endp = new EndpointI(_instance, _host, p->effectivePort(), _timeout, _connectionId, _compress); + endp = new EndpointI(_instance, _host, p->effectivePort(), _sourceAddr, _timeout, _connectionId, _compress); return p; } @@ -228,7 +228,7 @@ IceSSL::EndpointI::operator<(const Ice::LocalObject& r) const { return false; } - + if(_timeout < p->_timeout) { return true; @@ -325,16 +325,16 @@ IceSSL::EndpointI::checkOption(const string& option, const string& argument, con } } -IceInternal::ConnectorPtr +IceInternal::ConnectorPtr IceSSL::EndpointI::createConnector(const IceInternal::Address& address, const IceInternal::NetworkProxyPtr& proxy) const { - return new ConnectorI(_instance, _host, address, proxy, _timeout, _connectionId); + return new ConnectorI(_instance, _host, address, proxy, _sourceAddr, _timeout, _connectionId); } -IceInternal::IPEndpointIPtr +IceInternal::IPEndpointIPtr IceSSL::EndpointI::createEndpoint(const string& host, int port, const string& connectionId) const { - return new EndpointI(_instance, host, port, _timeout, connectionId, _compress); + return new EndpointI(_instance, host, port, _sourceAddr, _timeout, connectionId, _compress); } IceSSL::EndpointFactoryI::EndpointFactoryI(const InstancePtr& instance) : _instance(instance) @@ -377,7 +377,7 @@ IceSSL::EndpointFactoryI::destroy() _instance = 0; } -IceInternal::EndpointFactoryPtr +IceInternal::EndpointFactoryPtr IceSSL::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& instance) const { return new EndpointFactoryI(new Instance(_instance->engine(), instance->type(), instance->protocol())); diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h index 68d14fa9d5b..5d797d2dfe7 100644 --- a/cpp/src/IceSSL/EndpointI.h +++ b/cpp/src/IceSSL/EndpointI.h @@ -23,7 +23,8 @@ class EndpointI : public IceInternal::IPEndpointI { public: - EndpointI(const InstancePtr&, const std::string&, Ice::Int, Ice::Int, const std::string&, bool); + EndpointI(const InstancePtr&, const std::string&, Ice::Int, const IceInternal::Address&, Ice::Int, + const std::string&, bool); EndpointI(const InstancePtr&); EndpointI(const InstancePtr&, IceInternal::BasicStream*); @@ -52,7 +53,7 @@ protected: 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&, + virtual IceInternal::ConnectorPtr createConnector(const IceInternal::Address&, const IceInternal::NetworkProxyPtr&) const; virtual IceInternal::IPEndpointIPtr createEndpoint(const std::string&, int, const std::string&) const; diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp index 14aad8b9163..39ae9e822e4 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp @@ -291,7 +291,7 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B if(_engine->securityTraceLevel() >= 1) { ostringstream ostr; - ostr << "IceSSL: ignoring certificate verification failure:\n" + ostr << "IceSSL: ignoring certificate verification failure:\n" << X509_verify_cert_error_string(result); _instance->logger()->trace(_instance->traceCategory(), ostr.str()); } @@ -440,6 +440,7 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf) { ERR_clear_error(); // Clear any spurious errors. assert(_fd != INVALID_SOCKET); + int ret = SSL_write(_ssl, reinterpret_cast<const void*>(&*buf.i), packetSize); if(ret <= 0) { @@ -536,7 +537,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) // We assume that OpenSSL doesn't read more SSL records than // necessary to fill the requested data and that the sender sends // Ice messages in individual SSL records. - // + // if(_state == StateProxyConnectRequestPending) { @@ -721,13 +722,15 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer& buf, size_t messa } IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const IceInternal::NetworkProxyPtr& proxy, - const string& host, const IceInternal::Address& addr) : + const string& host, const IceInternal::Address& addr, + const IceInternal::Address& sourceAddr) : IceInternal::NativeInfo(fd), _instance(instance), _engine(OpenSSLEnginePtr::dynamicCast(instance->engine())), _proxy(proxy), _host(host), _addr(addr), + _sourceAddr(sourceAddr), _incoming(false), _ssl(0), _state(StateNeedConnect) @@ -736,7 +739,7 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const IceInternal::setTcpBufSize(fd, _instance->properties(), _instance->logger()); IceInternal::Address connectAddr = proxy ? proxy->getAddress() : addr; - if(IceInternal::doConnect(_fd, connectAddr)) + if(IceInternal::doConnect(_fd, connectAddr, _sourceAddr)) { _state = StateConnected; _desc = IceInternal::fdToString(_fd, _proxy, _addr, true); @@ -757,6 +760,7 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const _instance(instance), _engine(OpenSSLEnginePtr::dynamicCast(instance->engine())), _addr(IceInternal::Address()), + _sourceAddr(IceInternal::getInvalidAddress()), _adapterName(adapterName), _incoming(true), _ssl(0), diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.h b/cpp/src/IceSSL/OpenSSLTransceiverI.h index 8833dcb58b8..1b5db51a2f4 100644 --- a/cpp/src/IceSSL/OpenSSLTransceiverI.h +++ b/cpp/src/IceSSL/OpenSSLTransceiverI.h @@ -67,7 +67,7 @@ public: private: TransceiverI(const InstancePtr&, SOCKET, const IceInternal::NetworkProxyPtr&, const std::string&, - const IceInternal::Address&); + const IceInternal::Address&, const IceInternal::Address&); TransceiverI(const InstancePtr&, SOCKET, const std::string&); virtual ~TransceiverI(); @@ -88,10 +88,11 @@ private: const InstancePtr _instance; const OpenSSLEnginePtr _engine; - + const IceInternal::NetworkProxyPtr _proxy; const std::string _host; const IceInternal::Address _addr; + const IceInternal::Address _sourceAddr; const std::string _adapterName; const bool _incoming; diff --git a/cpp/src/IceSSL/SChannelTransceiverI.cpp b/cpp/src/IceSSL/SChannelTransceiverI.cpp index ae36570991a..cf1ebb836db 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.cpp +++ b/cpp/src/IceSSL/SChannelTransceiverI.cpp @@ -967,7 +967,7 @@ IceSSL::TransceiverI::startWrite(IceInternal::Buffer& buffer) if(_state == StateConnectPending) { IceInternal::Address addr = _proxy ? _proxy->getAddress() : _addr; - doConnectAsync(_fd, addr, _write); + doConnectAsync(_fd, addr, _sourceAddr, _write); return false; } @@ -1176,13 +1176,15 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer& buf, size_t messa } IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const IceInternal::NetworkProxyPtr& proxy, - const string& host, const IceInternal::Address& addr) : + const string& host, const IceInternal::Address& addr, + const IceInternal::Address& sourceAddr) : IceInternal::NativeInfo(fd), _instance(instance), _engine(SChannelEnginePtr::dynamicCast(instance->engine())), _proxy(proxy), _host(host), _addr(addr), + _sourceAddr(sourceAddr), _incoming(false), _state(StateNeedConnect), _writeBuffer(0), @@ -1218,7 +1220,7 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const #ifndef ICE_USE_IOCP IceInternal::Address connectAddr = proxy ? proxy->getAddress() : addr; - if(IceInternal::doConnect(_fd, connectAddr)) + if(IceInternal::doConnect(_fd, connectAddr, _sourceAddr)) { _state = StateConnected; _desc = IceInternal::fdToString(_fd, _proxy, _addr, true); diff --git a/cpp/src/IceSSL/SChannelTransceiverI.h b/cpp/src/IceSSL/SChannelTransceiverI.h index 7bf2fcb2137..85752b929a3 100644 --- a/cpp/src/IceSSL/SChannelTransceiverI.h +++ b/cpp/src/IceSSL/SChannelTransceiverI.h @@ -77,7 +77,7 @@ public: private: TransceiverI(const InstancePtr&, SOCKET, const IceInternal::NetworkProxyPtr&, const std::string&, - const IceInternal::Address&); + const IceInternal::Address&, const IceInternal::Address&); TransceiverI(const InstancePtr&, SOCKET, const std::string&); virtual ~TransceiverI(); @@ -100,6 +100,7 @@ private: const IceInternal::NetworkProxyPtr _proxy; const std::string _host; const IceInternal::Address _addr; + const IceInternal::Address _sourceAddr; const std::string _adapterName; const bool _incoming; diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp index a64b4d8ee65..b43218cc8f2 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp @@ -98,15 +98,15 @@ socketRead(SSLConnectionRef connection, void* data, size_t* length) void checkTrustResult(SecTrustRef trust, const SecureTransportEnginePtr& engine, const InstancePtr& instance) { - OSStatus err = noErr; + OSStatus err = noErr; SecTrustResultType trustResult = kSecTrustResultOtherError; if(trust) - { + { if((err = SecTrustSetAnchorCertificates(trust, engine->getCertificateAuthorities()))) { throw SecurityException(__FILE__, __LINE__, "IceSSL: handshake failure:\n" + errorToString(err)); } - + // // Disable network fetch, we don't want this to block. // @@ -114,7 +114,7 @@ checkTrustResult(SecTrustRef trust, const SecureTransportEnginePtr& engine, cons { throw ProtocolException(__FILE__, __LINE__, "IceSSL: handshake failure:\n" + errorToString(err)); } - + // // Evaluate the trust // @@ -257,7 +257,7 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B assert(_state == StateConnected); - OSStatus err = 0; + OSStatus err = 0; if(!_ssl) { // @@ -269,17 +269,17 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B throw SecurityException(__FILE__, __LINE__, "IceSSL: setting IO functions failed\n" + errorToString(err)); } - + if((err = SSLSetConnection(_ssl, reinterpret_cast<SSLConnectionRef>(this)))) { - throw SecurityException(__FILE__, __LINE__, "IceSSL: setting SSL connection failed\n" + + throw SecurityException(__FILE__, __LINE__, "IceSSL: setting SSL connection failed\n" + errorToString(err)); } } - + SSLSessionState state; SSLGetSessionState(_ssl, &state); - + // // SSL Handshake // @@ -365,11 +365,11 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B SSLProtocol protocol; SSLGetNegotiatedProtocolVersion(_ssl, &protocol); const string sslProtocolName = protocolName(protocol); - + SSLCipherSuite cipher; SSLGetNegotiatedCipher(_ssl, &cipher); const string sslCipherName = _engine->getCipherName(cipher); - + if(sslCipherName.empty()) { out << "unknown cipher\n"; @@ -438,7 +438,7 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf) // return writeRaw(buf) ? IceInternal::SocketOperationNone : IceInternal::SocketOperationWrite; } - + if(buf.i == buf.b.end()) { return IceInternal::SocketOperationNone; @@ -455,7 +455,7 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf) size_t processed = 0; OSStatus err = _buffered ? SSLWrite(_ssl, 0, 0, &processed) : SSLWrite(_ssl, reinterpret_cast<const void*>(buf.i), packetSize, &processed); - + if(err) { if(err == errSSLWouldBlock) @@ -467,12 +467,12 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf) assert(_flags & SSLWantWrite); return IceInternal::SocketOperationWrite; } - + if(err == errSSLClosedGraceful) { throw ConnectionLostException(__FILE__, __LINE__, 0); } - + // // SSL protocol errors are defined in SecureTransport.h are in the range // -9800 to -9849 @@ -481,7 +481,7 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf) { throw ProtocolException(__FILE__, __LINE__, "IceSSL: error during read:\n" + errorToString(err)); } - + errno = err; if(IceInternal::connectionLost()) { @@ -535,7 +535,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) // We assume that SecureTransport doesn't read more SSL records // than necessary to fill the requested data and that the sender // sends Ice messages in individual SSL records. - // + // if(_state == StateProxyConnectRequestPending) { @@ -558,17 +558,17 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) assert(_fd != INVALID_SOCKET); size_t processed = 0; OSStatus err = SSLRead(_ssl, reinterpret_cast<void*>(buf.i), packetSize, &processed); - + if(processed) { if(_instance->traceLevel() >= 3) { Trace out(_instance->logger(), _instance->traceCategory()); - out << "received " << processed << " of " << packetSize << " bytes via " << protocol() << "\n" + out << "received " << processed << " of " << packetSize << " bytes via " << protocol() << "\n" << toString(); } } - + if(err) { if(err == errSSLWouldBlock) @@ -577,7 +577,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) assert(_flags & SSLWantRead); return IceInternal::SocketOperationRead; } - + if(err == errSSLClosedGraceful || err == errSSLPeerBadRecordMac || err == errSSLPeerDecryptionFail) { // @@ -587,7 +587,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) // throw ConnectionLostException(__FILE__, __LINE__, 0); } - + // // SSL protocol errors are defined in SecureTransport.h are in the range // -9800 to -9849 @@ -596,7 +596,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf, bool&) { throw ProtocolException(__FILE__, __LINE__, "IceSSL: error during read:\n" + errorToString(err)); } - + errno = err; if(IceInternal::connectionLost()) { @@ -646,13 +646,15 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer& buf, size_t messa } IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const IceInternal::NetworkProxyPtr& proxy, - const string& host, const IceInternal::Address& addr) : + const string& host, const IceInternal::Address& addr, + const IceInternal::Address& sourceAddr) : IceInternal::NativeInfo(fd), _instance(instance), _engine(SecureTransportEnginePtr::dynamicCast(instance->engine())), _proxy(proxy), _host(host), _addr(addr), + _sourceAddr(sourceAddr), _incoming(false), _ssl(0), _trust(0), @@ -662,9 +664,9 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const assert(_engine); IceInternal::setBlock(fd, false); IceInternal::setTcpBufSize(fd, _instance->properties(), _instance->logger()); - + IceInternal::Address connectAddr = proxy ? proxy->getAddress() : addr; - if(IceInternal::doConnect(_fd, connectAddr)) + if(IceInternal::doConnect(_fd, connectAddr, _sourceAddr)) { _state = StateConnected; _desc = IceInternal::fdToString(_fd, _proxy, _addr, true); @@ -678,7 +680,7 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const { _desc = IceInternal::fdToString(_fd, _proxy, _addr, true); } - + // // Limit the size of packets passed to SSLWrite/SSLRead to avoid // blocking and holding too much memory. @@ -692,6 +694,7 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const _instance(instance), _engine(SecureTransportEnginePtr::dynamicCast(instance->engine())), _addr(IceInternal::Address()), + _sourceAddr(IceInternal::getInvalidAddress()), _adapterName(adapterName), _incoming(true), _ssl(0), @@ -703,7 +706,7 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, SOCKET fd, const assert(_engine); IceInternal::setBlock(fd, false); IceInternal::setTcpBufSize(fd, _instance->properties(), _instance->logger()); - + // // Limit the size of packets passed to SSLWrite/SSLRead to avoid // blocking and holding too much memory. @@ -729,12 +732,12 @@ IceSSL::TransceiverI::getNativeConnectionInfo() const { SecCertificateRef cert = SecTrustGetCertificateAtIndex(_trust, i); CFRetain(cert); - + CertificatePtr certificate = new Certificate(cert); info->nativeCerts.push_back(certificate); info->certs.push_back(certificate->encode()); } - + SSLCipherSuite cipher; SSLGetNegotiatedCipher(_ssl, &cipher); info->cipher = _engine->getCipherName(cipher); @@ -868,13 +871,13 @@ OSStatus IceSSL::TransceiverI::writeRaw(const char* data, size_t* length) const { _flags &= ~SSLWantWrite; - + assert(_fd != INVALID_SOCKET); - + char* i = const_cast<char*>(data); int packetSize = *length; char* end = i + packetSize; - + while(i != end) { ssize_t ret = ::send(_fd, const_cast<const char*>(i), packetSize, 0); @@ -882,7 +885,7 @@ IceSSL::TransceiverI::writeRaw(const char* data, size_t* length) const { return errSSLClosedGraceful; } - + if(ret == SOCKET_ERROR) { if(IceInternal::interrupted()) @@ -895,7 +898,7 @@ IceSSL::TransceiverI::writeRaw(const char* data, size_t* length) const packetSize /= 2; continue; } - + if(IceInternal::wouldBlock()) { *length = i - data; @@ -904,7 +907,7 @@ IceSSL::TransceiverI::writeRaw(const char* data, size_t* length) const } return errno; } - + i += ret; if(packetSize > end - i) @@ -933,7 +936,7 @@ IceSSL::TransceiverI::readRaw(char* data, size_t* length) const { return errSSLClosedGraceful; } - + if(ret == SOCKET_ERROR) { if(IceInternal::interrupted()) @@ -946,7 +949,7 @@ IceSSL::TransceiverI::readRaw(char* data, size_t* length) const packetSize /= 2; continue; } - + if(IceInternal::wouldBlock()) { *length = i - data; @@ -955,14 +958,14 @@ IceSSL::TransceiverI::readRaw(char* data, size_t* length) const } return errno; } - + i += ret; if(packetSize > end - i) { packetSize = end - i; } } - + *length = i - data; return noErr; } diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.h b/cpp/src/IceSSL/SecureTransportTransceiverI.h index ea5051814df..17ff0bb4c7c 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.h +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.h @@ -58,16 +58,16 @@ public: OSStatus writeRaw(const char*, size_t*) const; OSStatus readRaw(char*, size_t*) const; - + private: TransceiverI(const InstancePtr&, SOCKET, const IceInternal::NetworkProxyPtr&, const std::string&, - const IceInternal::Address&); + const IceInternal::Address&, const IceInternal::Address&); TransceiverI(const InstancePtr&, SOCKET, const std::string&); virtual ~TransceiverI(); virtual NativeConnectionInfoPtr getNativeConnectionInfo() const; - + bool writeRaw(IceInternal::Buffer&); bool readRaw(IceInternal::Buffer&); @@ -80,20 +80,21 @@ private: const IceInternal::NetworkProxyPtr _proxy; const std::string _host; const IceInternal::Address _addr; + const IceInternal::Address _sourceAddr; const std::string _adapterName; const bool _incoming; SSLContextRef _ssl; SecTrustRef _trust; - + size_t _buffered; enum SSLWantFlags { SSLWantRead = 0x1, SSLWantWrite = 0x2 }; - + mutable Ice::Byte _flags; State _state; diff --git a/cpp/src/IceUtil/winrt/.depend.mak b/cpp/src/IceUtil/winrt/.depend.mak index 9bc46f6eaf2..81240f1b661 100755 --- a/cpp/src/IceUtil/winrt/.depend.mak +++ b/cpp/src/IceUtil/winrt/.depend.mak @@ -1,21 +1 @@ -$(ARCH)\$(CONFIG)\ArgVector$(OBJEXT): ..\ArgVector.cpp "$(includedir)\IceUtil\ArgVector.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\DisableWarnings.h" -$(ARCH)\$(CONFIG)\Cond$(OBJEXT): ..\Cond.cpp "$(includedir)\IceUtil\Cond.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Time.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Exception.h" -$(ARCH)\$(CONFIG)\ConvertUTF$(OBJEXT): ..\ConvertUTF.cpp "..\ConvertUTF.h" "..\Unicode.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\StringConverter.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Handle.h" -$(ARCH)\$(CONFIG)\CountDownLatch$(OBJEXT): ..\CountDownLatch.cpp "$(includedir)\IceUtil\CountDownLatch.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Time.h" -$(ARCH)\$(CONFIG)\Exception$(OBJEXT): ..\Exception.cpp "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\MutexPtrLock.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Time.h" "$(includedir)\IceUtil\Mutex.h" "$(includedir)\IceUtil\Lock.h" "$(includedir)\IceUtil\MutexProtocol.h" "$(includedir)\IceUtil\StringUtil.h" -$(ARCH)\$(CONFIG)\FileUtil$(OBJEXT): ..\FileUtil.cpp "$(includedir)\IceUtil\DisableWarnings.h" "$(includedir)\IceUtil\FileUtil.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Handle.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\StringConverter.h" -$(ARCH)\$(CONFIG)\InputUtil$(OBJEXT): ..\InputUtil.cpp "$(includedir)\IceUtil\InputUtil.h" "$(includedir)\IceUtil\Config.h" -$(ARCH)\$(CONFIG)\Options$(OBJEXT): ..\Options.cpp "$(includedir)\IceUtil\Options.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\RecMutex.h" "$(includedir)\IceUtil\Lock.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Time.h" "$(includedir)\IceUtil\MutexProtocol.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Handle.h" "$(includedir)\IceUtil\StringUtil.h" -$(ARCH)\$(CONFIG)\OutputUtil$(OBJEXT): ..\OutputUtil.cpp "$(includedir)\IceUtil\OutputUtil.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\FileUtil.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Handle.h" "$(includedir)\IceUtil\Exception.h" -$(ARCH)\$(CONFIG)\Random$(OBJEXT): ..\Random.cpp "$(includedir)\IceUtil\Random.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Mutex.h" "$(includedir)\IceUtil\Lock.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Time.h" "$(includedir)\IceUtil\MutexProtocol.h" "$(includedir)\IceUtil\MutexPtrLock.h" -$(ARCH)\$(CONFIG)\RecMutex$(OBJEXT): ..\RecMutex.cpp "$(includedir)\IceUtil\RecMutex.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Lock.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Time.h" "$(includedir)\IceUtil\MutexProtocol.h" -$(ARCH)\$(CONFIG)\Shared$(OBJEXT): ..\Shared.cpp "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Config.h" -$(ARCH)\$(CONFIG)\StringUtil$(OBJEXT): ..\StringUtil.cpp "$(includedir)\IceUtil\StringUtil.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\StringConverter.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Handle.h" "$(includedir)\IceUtil\ScopedArray.h" -$(ARCH)\$(CONFIG)\Thread$(OBJEXT): ..\Thread.cpp "$(includedir)\IceUtil\Thread.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Handle.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Mutex.h" "$(includedir)\IceUtil\Lock.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Time.h" "$(includedir)\IceUtil\MutexProtocol.h" -$(ARCH)\$(CONFIG)\ThreadException$(OBJEXT): ..\ThreadException.cpp "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Time.h" -$(ARCH)\$(CONFIG)\Time$(OBJEXT): ..\Time.cpp "$(includedir)\IceUtil\DisableWarnings.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Time.h" -$(ARCH)\$(CONFIG)\Timer$(OBJEXT): ..\Timer.cpp "$(includedir)\IceUtil\Timer.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Thread.h" "$(includedir)\IceUtil\Handle.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Mutex.h" "$(includedir)\IceUtil\Lock.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Time.h" "$(includedir)\IceUtil\MutexProtocol.h" "$(includedir)\IceUtil\Monitor.h" "$(includedir)\IceUtil\Cond.h" -$(ARCH)\$(CONFIG)\UUID$(OBJEXT): ..\UUID.cpp "$(includedir)\IceUtil\UUID.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Random.h" "$(includedir)\IceUtil\Exception.h" -$(ARCH)\$(CONFIG)\Unicode$(OBJEXT): ..\Unicode.cpp "..\Unicode.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\StringConverter.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Handle.h" "..\ConvertUTF.h" -$(ARCH)\$(CONFIG)\MutexProtocol$(OBJEXT): ..\MutexProtocol.cpp "$(includedir)\IceUtil\MutexProtocol.h" "$(includedir)\IceUtil\Config.h" -$(ARCH)\$(CONFIG)\StringConverter$(OBJEXT): ..\StringConverter.cpp "$(includedir)\IceUtil\StringConverter.h" "$(includedir)\IceUtil\Config.h" "$(includedir)\IceUtil\Exception.h" "$(includedir)\IceUtil\Shared.h" "$(includedir)\IceUtil\Handle.h" "$(includedir)\IceUtil\MutexPtrLock.h" "$(includedir)\IceUtil\ThreadException.h" "$(includedir)\IceUtil\Time.h" "$(includedir)\IceUtil\Mutex.h" "$(includedir)\IceUtil\Lock.h" "$(includedir)\IceUtil\MutexProtocol.h" "$(includedir)\IceUtil\ScopedArray.h" "$(includedir)\IceUtil\StringUtil.h" "..\Unicode.h" +$(ARCH)\$(CONFIG)\ArgVector$(OBJEXT): ..\ArgVector.cpp "$(includedir)\IceUtil\ArgVector.h" "$(includedir)\IceUtil\Config.h"
\ No newline at end of file diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp index 68279a1f664..5f8096a5b1a 100644 --- a/cpp/test/Ice/info/AllTests.cpp +++ b/cpp/test/Ice/info/AllTests.cpp @@ -21,9 +21,10 @@ allTests(const Ice::CommunicatorPtr& communicator) { cout << "testing proxy endpoint information... " << flush; { - Ice::ObjectPrx p1 = communicator->stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z:" - "udp -h udphost -p 10001 --interface eth0 --ttl 5:" - "opaque -e 1.8 -t 100 -v ABCD"); + Ice::ObjectPrx p1 = + communicator->stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" + "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:" + "opaque -e 1.8 -t 100 -v ABCD"); Ice::EndpointSeq endps = p1->ice_getEndpoints(); @@ -32,6 +33,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(ipEndpoint->host == "tcphost"); test(ipEndpoint->port == 10000); test(ipEndpoint->timeout == 1200); + test(ipEndpoint->sourceAddress == "10.10.10.10"); test(ipEndpoint->compress); test(!ipEndpoint->datagram()); test((ipEndpoint->type() == Ice::TCPEndpointType && !ipEndpoint->secure()) || @@ -47,6 +49,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(udpEndpoint); test(udpEndpoint->host == "udphost"); test(udpEndpoint->port == 10001); + test(udpEndpoint->sourceAddress == "10.10.10.10"); test(udpEndpoint->mcastInterface == "eth0"); test(udpEndpoint->mcastTtl == 5); test(udpEndpoint->timeout == -1); |