diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/.depend | 4 | ||||
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 91 | ||||
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 181 | ||||
-rw-r--r-- | cpp/src/Ice/Exception.cpp | 28 | ||||
-rw-r--r-- | cpp/src/Ice/Protocol.h | 20 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 40 | ||||
-rw-r--r-- | cpp/src/Ice/TraceUtil.cpp | 26 | ||||
-rw-r--r-- | cpp/src/Ice/UdpEndpoint.cpp | 213 | ||||
-rw-r--r-- | cpp/src/Ice/UdpEndpoint.h | 4 |
9 files changed, 521 insertions, 86 deletions
diff --git a/cpp/src/Ice/.depend b/cpp/src/Ice/.depend index 15acf553132..7bf4cdcc7d2 100644 --- a/cpp/src/Ice/.depend +++ b/cpp/src/Ice/.depend @@ -11,7 +11,7 @@ Stats.o: Stats.cpp ../../include/Ice/Stats.h ../../include/Ice/LocalObjectF.h .. SysLoggerI.o: SysLoggerI.cpp ../Ice/SysLoggerI.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Config.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/Exception.h ../../include/Ice/Logger.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h Stream.o: Stream.cpp ../../include/Ice/Stream.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactory.h BuiltinSequences.o: BuiltinSequences.cpp ../../include/Ice/BuiltinSequences.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/LocalException.h ../../include/Ice/ObjectFactory.h ../../include/Ice/Stream.h -BasicStream.o: BasicStream.cpp ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../Ice/TraceLevelsF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Proxy.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../Ice/ProxyFactory.h ../../include/Ice/ObjectFactory.h ../Ice/ObjectFactoryManager.h ../../include/Ice/UserExceptionFactory.h ../Ice/UserExceptionFactoryManager.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/LocalException.h +BasicStream.o: BasicStream.cpp ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../Ice/TraceLevelsF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Proxy.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../Ice/ProxyFactory.h ../../include/Ice/ObjectFactory.h ../Ice/ObjectFactoryManager.h ../../include/Ice/UserExceptionFactory.h ../Ice/UserExceptionFactoryManager.h ../../include/Ice/UserExceptionFactoryF.h ../../include/Ice/LocalException.h ../Ice/Protocol.h DefaultsAndOverrides.o: DefaultsAndOverrides.cpp ../Ice/DefaultsAndOverrides.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../Ice/DefaultsAndOverridesF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/PropertiesF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../../include/Ice/Properties.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h ../Ice/Network.h TraceLevels.o: TraceLevels.cpp ../Ice/TraceLevels.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../Ice/TraceLevelsF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/PropertiesF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../../include/Ice/Properties.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/BuiltinSequences.h TraceUtil.o: TraceUtil.cpp ../Ice/TraceUtil.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/StreamF.h ../Ice/TraceLevelsF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/InstanceF.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/StatsF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Proxy.h ../../include/Ice/ConnectionF.h ../../include/Ice/EndpointF.h ../../include/Ice/ReferenceF.h ../../include/Ice/OutgoingAsyncF.h ../Ice/TraceLevels.h ../../include/Ice/Logger.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../Ice/Protocol.h ../../include/Ice/IdentityUtil.h @@ -31,7 +31,7 @@ Endpoint.o: Endpoint.cpp ../Ice/Endpoint.h ../../include/IceUtil/Shared.h ../../ EndpointFactory.o: EndpointFactory.cpp ../../include/Ice/EndpointFactory.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/EndpointF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/EndpointFactoryF.h EndpointFactoryManager.o: EndpointFactoryManager.cpp ../Ice/EndpointFactoryManager.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/Exception.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../../include/Ice/EndpointF.h ../../include/Ice/EndpointFactoryF.h ../Ice/EndpointFactoryManagerF.h ../Ice/Endpoint.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../Ice/UnknownEndpoint.h ../../include/Ice/EndpointFactory.h ../../include/Ice/BasicStream.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../../include/Ice/LocalException.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../Ice/Instance.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../Ice/TraceLevelsF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/DefaultsAndOverrides.h TcpEndpoint.o: TcpEndpoint.cpp ../Ice/TcpEndpoint.h ../Ice/Endpoint.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/EndpointF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../../include/Ice/EndpointFactory.h ../../include/Ice/EndpointFactoryF.h ../Ice/Network.h ../Ice/TcpAcceptor.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../Ice/Acceptor.h ../Ice/TcpConnector.h ../Ice/Connector.h ../Ice/TcpTransceiver.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalException.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/DefaultsAndOverrides.h -UdpEndpoint.o: UdpEndpoint.cpp ../Ice/UdpEndpoint.h ../Ice/Endpoint.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/EndpointF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../../include/Ice/EndpointFactory.h ../../include/Ice/EndpointFactoryF.h ../Ice/Network.h ../Ice/UdpTransceiver.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalException.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/DefaultsAndOverrides.h +UdpEndpoint.o: UdpEndpoint.cpp ../Ice/UdpEndpoint.h ../Ice/Endpoint.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/EndpointF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../../include/Ice/EndpointFactory.h ../../include/Ice/EndpointFactoryF.h ../Ice/Network.h ../Ice/UdpTransceiver.h ../Ice/TraceLevelsF.h ../../include/Ice/LoggerF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../../include/Ice/StatsF.h ../Ice/Transceiver.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalException.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../Ice/DefaultsAndOverrides.h ../Ice/Protocol.h UnknownEndpoint.o: UnknownEndpoint.cpp ../Ice/UnknownEndpoint.h ../Ice/Endpoint.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/EndpointF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../../include/Ice/InstanceF.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../../include/Ice/EndpointFactory.h ../../include/Ice/EndpointFactoryF.h ../../include/Ice/BasicStream.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../Ice/Instance.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../Ice/TraceLevelsF.h ../Ice/DefaultsAndOverridesF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactoryF.h ../../include/Ice/ProxyFactoryF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h Reference.o: Reference.cpp ../Ice/Reference.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/ReferenceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Exception.h ../../include/Ice/Config.h ../Ice/ReferenceFactoryF.h ../../include/Ice/EndpointF.h ../../include/Ice/InstanceF.h ../../include/Ice/RouterF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../../include/Ice/Proxy.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/LocatorF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ReferenceFactory.h ../../include/Ice/LocalException.h ../Ice/Instance.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../Ice/TraceLevelsF.h ../Ice/DefaultsAndOverridesF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../../include/Ice/IdentityUtil.h ../Ice/Endpoint.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../Ice/RouterInfo.h ../../include/Ice/RoutingTableF.h ../../include/Ice/Router.h ../Ice/LocatorInfo.h ../../include/Ice/Locator.h ../../include/Ice/IncomingAsync.h ../Ice/StringUtil.h ReferenceFactory.o: ReferenceFactory.cpp ../Ice/ReferenceFactory.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/IceUtil/Mutex.h ../../include/IceUtil/Lock.h ../../include/IceUtil/ThreadException.h ../../include/IceUtil/Exception.h ../Ice/ReferenceFactoryF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../Ice/Reference.h ../../include/Ice/ReferenceF.h ../../include/Ice/EndpointF.h ../../include/Ice/InstanceF.h ../../include/Ice/RouterF.h ../../include/Ice/LocalObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ObjectF.h ../../include/Ice/Exception.h ../../include/Ice/LocalObject.h ../../include/Ice/StreamF.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/ConnectionF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/OutgoingAsyncF.h ../../include/Ice/Current.h ../../include/Ice/Identity.h ../../include/Ice/Facet.h ../../include/Ice/Object.h ../../include/Ice/IncomingAsyncF.h ../../include/Ice/Outgoing.h ../../include/IceUtil/Monitor.h ../../include/IceUtil/Cond.h ../../include/IceUtil/Time.h ../../include/Ice/BasicStream.h ../../include/Ice/Buffer.h ../../include/Ice/ObjectFactoryF.h ../../include/Ice/Incoming.h ../../include/Ice/ServantLocatorF.h ../../include/Ice/ServantManagerF.h ../../include/Ice/Direct.h ../../include/Ice/LocatorF.h ../Ice/RouterInfoF.h ../Ice/LocatorInfoF.h ../Ice/ProxyFactory.h ../../include/Ice/LocalException.h ../Ice/Instance.h ../../include/IceUtil/RecMutex.h ../../include/Ice/CommunicatorF.h ../../include/Ice/PropertiesF.h ../../include/Ice/LoggerF.h ../../include/Ice/StatsF.h ../Ice/TraceLevelsF.h ../Ice/DefaultsAndOverridesF.h ../Ice/ThreadPoolF.h ../../include/Ice/ConnectionFactoryF.h ../../include/Ice/ConnectionMonitorF.h ../Ice/ObjectFactoryManagerF.h ../Ice/UserExceptionFactoryManagerF.h ../../include/Ice/ObjectAdapterFactoryF.h ../Ice/EndpointFactoryManagerF.h ../../include/Ice/DynamicLibraryF.h ../../include/Ice/PluginF.h ../../include/Ice/IdentityUtil.h ../Ice/Endpoint.h ../Ice/TransceiverF.h ../Ice/ConnectorF.h ../Ice/AcceptorF.h ../Ice/EndpointFactoryManager.h ../../include/Ice/EndpointFactoryF.h ../Ice/RouterInfo.h ../../include/Ice/RoutingTableF.h ../Ice/LocatorInfo.h ../Ice/StringUtil.h diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index d564ab96994..e4b22071ccd 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -22,6 +22,7 @@ #include <Ice/UserExceptionFactory.h> #include <Ice/UserExceptionFactoryManager.h> #include <Ice/LocalException.h> +#include <Ice/Protocol.h> using namespace std; using namespace Ice; @@ -80,8 +81,9 @@ IceInternal::BasicStream::reserve(int total) void IceInternal::BasicStream::startWriteEncaps() { - write(Byte(0)); // Encoding write(Int(0)); // Placeholder for the encapsulation length + write(encodingMajor); + write(encodingMinor); _writeEncapsStack.resize(_writeEncapsStack.size() + 1); _currentWriteEncaps = &_writeEncapsStack.back(); _currentWriteEncaps->start = b.size(); @@ -101,24 +103,18 @@ IceInternal::BasicStream::endWriteEncaps() { _currentWriteEncaps = &_writeEncapsStack.back(); } - Int sz = b.size() - start; + Int sz = b.size() - start + sizeof(Int) + 2; // Size includes size and version const Byte* p = reinterpret_cast<const Byte*>(&sz); #ifdef ICE_UTIL_BIGENDIAN - reverse_copy(p, p + sizeof(Int), b.begin() + start - sizeof(Int)); + reverse_copy(p, p + sizeof(Int), b.begin() + start - sizeof(Int) - 2); // - 2 for major and minor version byte #else - copy(p, p + sizeof(Int), b.begin() + start - sizeof(Int)); + copy(p, p + sizeof(Int), b.begin() + start - sizeof(Int) - 2); // - 2 for major and minor version byte #endif } void IceInternal::BasicStream::startReadEncaps() { - Byte encoding; - read(encoding); - if(encoding != 0) - { - throw UnsupportedEncodingException(__FILE__, __LINE__); - } Int sz; // // I don't use readSize() and writeSize() for encapsulations, @@ -132,9 +128,26 @@ IceInternal::BasicStream::startReadEncaps() { throw NegativeSizeException(__FILE__, __LINE__); } + + Byte eMajor; + Byte eMinor; + read(eMajor); + read(eMinor); + if(eMajor != encodingMajor + || static_cast<unsigned char>(eMinor) > static_cast<unsigned char>(encodingMinor)) + { + UnsupportedEncodingException ex(__FILE__, __LINE__); + ex.badMajor = static_cast<unsigned char>(eMajor); + ex.badMinor = static_cast<unsigned char>(eMinor); + ex.major = static_cast<unsigned char>(encodingMajor); + ex.minor = static_cast<unsigned char>(encodingMinor); + throw ex; + } + _readEncapsStack.resize(_readEncapsStack.size() + 1); _currentReadEncaps = &_readEncapsStack.back(); - _currentReadEncaps->encoding = encoding; + _currentReadEncaps->encodingMajor = eMajor; + _currentReadEncaps->encodingMinor = eMinor; _currentReadEncaps->start = i - b.begin(); } @@ -167,14 +180,14 @@ IceInternal::BasicStream::skipReadEncaps() { _currentReadEncaps = &_readEncapsStack.back(); } - i = b.begin() + start - sizeof(Int); + i = b.begin() + start - sizeof(Int) - 2; // - 2 for major and minor version byte Int sz; read(sz); if(sz < 0) { throw NegativeSizeException(__FILE__, __LINE__); } - i += sz; + i += sz - sizeof(Int); if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); @@ -187,7 +200,7 @@ IceInternal::BasicStream::checkReadEncaps() assert(_currentReadEncaps); int start = _currentReadEncaps->start; Container::iterator save = i; - i = b.begin() + start - sizeof(Int); + i = b.begin() + start - sizeof(Int) - 2; // - 2 for major and minor version byte Int sz; read(sz); if(sz < 0) @@ -195,7 +208,7 @@ IceInternal::BasicStream::checkReadEncaps() throw NegativeSizeException(__FILE__, __LINE__); } i = save; - if(sz != i - (b.begin() + start)) + if(static_cast<unsigned>(sz) != i - (b.begin() + start) + sizeof(Int) + 2) { throw EncapsulationException(__FILE__, __LINE__); } @@ -207,33 +220,43 @@ IceInternal::BasicStream::getReadEncapsSize() assert(_currentReadEncaps); int start = _currentReadEncaps->start; Container::iterator save = i; - i = b.begin() + start - sizeof(Int); + i = b.begin() + start - sizeof(Int) - 2; // - 2 for major and minor version byte Int sz; read(sz); if(sz < 0) { throw NegativeSizeException(__FILE__, __LINE__); } + + Byte eMajor; + Byte eMinor; + read(eMajor); + read(eMinor); + if(eMajor != encodingMajor + || static_cast<unsigned char>(eMinor) > static_cast<unsigned char>(encodingMinor)) + { + UnsupportedEncodingException ex(__FILE__, __LINE__); + ex.badMajor = static_cast<unsigned char>(eMajor); + ex.badMinor = static_cast<unsigned char>(eMinor); + ex.major = static_cast<unsigned char>(encodingMajor); + ex.minor = static_cast<unsigned char>(encodingMinor); + throw ex; + } + i = save; - return sz; + return sz - sizeof(Int) - 2; } void IceInternal::BasicStream::skipEncaps() { - Byte encoding; - read(encoding); - if(encoding != 0) - { - throw UnsupportedEncodingException(__FILE__, __LINE__); - } Int sz; read(sz); if(sz < 0) { throw NegativeSizeException(__FILE__, __LINE__); } - i += sz; + i += sz - sizeof(Int); if(i > b.end()) { throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); @@ -295,6 +318,26 @@ IceInternal::BasicStream::readBlob(vector<Byte>& v, Int sz) } void +IceInternal::BasicStream::writeBlob(const Ice::Byte* v, size_t len) +{ + int pos = b.size(); + resize(pos + len); + copy(&v[0], &v[0 + len], b.begin() + pos); +} + +void +IceInternal::BasicStream::readBlob(Ice::Byte* v, size_t len) +{ + if(static_cast<size_t>(b.end() - i) < len) + { + throw UnmarshalOutOfBoundsException(__FILE__, __LINE__); + } + Container::iterator begin = i; + i += len; + copy(begin, i, &v[0]); +} + +void IceInternal::BasicStream::write(const vector<Byte>& v) { Int sz = v.size(); diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 3fc002bd188..042253209b2 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -182,8 +182,11 @@ IceInternal::Connection::validate() // connection validation. // BasicStream os(_instance.get()); - os.write(protocolVersion); - os.write(encodingVersion); + os.writeBlob(magic, sizeof(magic)); + os.write(protocolMajor); + os.write(protocolMinor); + os.write(encodingMajor); + os.write(encodingMinor); os.write(validateConnectionMsg); os.write(headerSize); // Message size. os.i = os.b.begin(); @@ -203,24 +206,69 @@ IceInternal::Connection::validate() assert(is.i == is.b.end()); assert(is.i - is.b.begin() >= headerSize); is.i = is.b.begin(); - Byte protVer; - is.read(protVer); - if(protVer != protocolVersion) + MagicBytes m(sizeof(magic), 0); + is.readBlob(m, sizeof(magic)); + if(!equal(m.begin(), m.end(), magic)) { - throw UnsupportedProtocolException(__FILE__, __LINE__); + BadMagicException ex(__FILE__, __LINE__); + ex.badMagic = m; + throw ex; } - Byte encVer; - is.read(encVer); - if(encVer != encodingVersion) + + Byte pMajor; + Byte pMinor; + is.read(pMajor); + is.read(pMinor); + + // + // We only check the major version number here. The minor version + // number is irrelevant -- no matter what minor version number is offered + // by the server, we can be certain that the server supports at least minor version 0. + // As the client, we are obliged to never produce a message with a minor + // version number that is larger than what the server can understand, but we don't + // care if the server understands more than we do. + // + // Note: Once we add minor versions, we need to modify the client side to never produce + // a message with a minor number that is greater than what the server can handle. Similarly, + // the server side will have to be modified so it never replies with a minor version that is + // greater than what the client can handle. + // + if(pMajor != protocolMajor) + { + UnsupportedProtocolException ex(__FILE__, __LINE__); + ex.badMajor = static_cast<unsigned char>(pMajor); + ex.badMinor = static_cast<unsigned char>(pMinor); + ex.major = static_cast<unsigned char>(protocolMajor); + ex.minor = static_cast<unsigned char>(protocolMinor); + throw ex; + } + + Byte eMajor; + Byte eMinor; + is.read(eMajor); + is.read(eMinor); + + // + // The same applies here as above -- only the major version number + // of the encoding is relevant. + // + if(eMajor != encodingMajor) { - throw UnsupportedEncodingException(__FILE__, __LINE__); + UnsupportedEncodingException ex(__FILE__, __LINE__); + ex.badMajor = static_cast<unsigned char>(eMajor); + ex.badMinor = static_cast<unsigned char>(eMinor); + ex.major = static_cast<unsigned char>(encodingMajor); + ex.minor = static_cast<unsigned char>(encodingMinor); + throw ex; } + Byte messageType; is.read(messageType); if(messageType != validateConnectionMsg) { throw ConnectionNotValidatedException(__FILE__, __LINE__); } + Int size; is.read(size); if(size != headerSize) @@ -346,7 +394,7 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway) // // Change message type. // - os->b[2] = compressedRequestMsg; + os->b[8] = compressedRequestMsg; // // Do compression. @@ -370,7 +418,7 @@ IceInternal::Connection::sendRequest(Outgoing* out, bool oneway) const Byte* p; Int sz = os->b.size(); p = reinterpret_cast<const Byte*>(&sz); - copy(p, p + sizeof(Int), os->b.begin() + 3); + copy(p, p + sizeof(Int), os->b.begin() + 9); // // Send the request. @@ -447,7 +495,7 @@ IceInternal::Connection::sendAsyncRequest(const OutgoingAsyncPtr& out) // // Change message type. // - os->b[2] = compressedRequestMsg; + os->b[8] = compressedRequestMsg; // // Do compression. @@ -471,7 +519,7 @@ IceInternal::Connection::sendAsyncRequest(const OutgoingAsyncPtr& out) const Byte* p; Int sz = os->b.size(); p = reinterpret_cast<const Byte*>(&sz); - copy(p, p + sizeof(Int), os->b.begin() + 3); + copy(p, p + sizeof(Int), os->b.begin() + 9); // // Send the request. @@ -597,7 +645,7 @@ IceInternal::Connection::flushBatchRequest() // // Change message type. // - _batchStream.b[2] = compressedRequestBatchMsg; + _batchStream.b[8] = compressedRequestBatchMsg; // // Do compression. @@ -621,7 +669,7 @@ IceInternal::Connection::flushBatchRequest() const Byte* p; Int sz = _batchStream.b.size(); p = reinterpret_cast<const Byte*>(&sz); - copy(p, p + sizeof(Int), _batchStream.b.begin() + 3); + copy(p, p + sizeof(Int), _batchStream.b.begin() + 9); // // Send the batch request. @@ -685,7 +733,7 @@ IceInternal::Connection::sendResponse(BasicStream* os) // // Change message type. // - os->b[2] = compressedReplyMsg; + os->b[8] = compressedReplyMsg; // // Do compression. @@ -709,7 +757,7 @@ IceInternal::Connection::sendResponse(BasicStream* os) const Byte* p; Int sz = os->b.size(); p = reinterpret_cast<const Byte*>(&sz); - copy(p, p + sizeof(Int), os->b.begin() + 3); + copy(p, p + sizeof(Int), os->b.begin() + 9); // // Send the reply. @@ -864,12 +912,50 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout); } - Byte messageType; - try { assert(stream.i == stream.b.end()); - stream.i = stream.b.begin() + 2; + stream.i = stream.b.begin(); + + MagicBytes m(sizeof(magic), 0); + stream.readBlob(m, sizeof(magic)); + if(!equal(m.begin(), m.end(), magic)) + { + BadMagicException ex(__FILE__, __LINE__); + ex.badMagic = m; + throw ex; + } + + Byte pMajor; + Byte pMinor; + stream.read(pMajor); + stream.read(pMinor); + if(pMajor != protocolMajor + || static_cast<unsigned char>(pMinor) > static_cast<unsigned char>(protocolMinor)) + { + UnsupportedProtocolException ex(__FILE__, __LINE__); + ex.badMajor = static_cast<unsigned char>(pMajor); + ex.badMinor = static_cast<unsigned char>(pMinor); + ex.major = static_cast<unsigned char>(protocolMajor); + ex.minor = static_cast<unsigned char>(protocolMinor); + throw ex; + } + Byte eMajor; + Byte eMinor; + stream.read(eMajor); + stream.read(eMinor); + if(eMajor != encodingMajor + || static_cast<unsigned char>(eMinor) > static_cast<unsigned char>(encodingMinor)) + { + UnsupportedEncodingException ex(__FILE__, __LINE__); + ex.badMajor = static_cast<unsigned char>(eMajor); + ex.badMinor = static_cast<unsigned char>(eMinor); + ex.major = static_cast<unsigned char>(encodingMajor); + ex.minor = static_cast<unsigned char>(encodingMinor); + throw ex; + } + + Byte messageType; stream.read(messageType); // @@ -1228,13 +1314,13 @@ IceInternal::Connection::Connection(const InstancePtr& instance, _transceiver(transceiver), _endpoint(endpoint), _adapter(adapter), - _logger(_instance->logger()), // Chached for better performance. - _traceLevels(_instance->traceLevels()), // Chached for better performance. + _logger(_instance->logger()), // Cached for better performance. + _traceLevels(_instance->traceLevels()), // Cached for better performance. _registeredWithPool(false), _warn(false), _acmTimeout(0), - _requestHdr(headerSize + 4, 0), - _requestBatchHdr(headerSize + 4, 0), + _requestHdr(headerSize + sizeof(Int), 0), + _requestBatchHdr(headerSize + sizeof(Int), 0), _replyHdr(headerSize, 0), _nextRequestId(1), _requestsHint(_requests.end()), @@ -1255,19 +1341,37 @@ IceInternal::Connection::Connection(const InstancePtr& instance, } vector<Byte>& requestHdr = const_cast<vector<Byte>&>(_requestHdr); - requestHdr[0] = protocolVersion; - requestHdr[1] = encodingVersion; - requestHdr[2] = requestMsg; + requestHdr[0] = magic[0]; + requestHdr[1] = magic[1]; + requestHdr[2] = magic[2]; + requestHdr[3] = magic[3]; + requestHdr[4] = protocolMajor; + requestHdr[5] = protocolMinor; + requestHdr[6] = encodingMajor; + requestHdr[7] = encodingMinor; + requestHdr[8] = requestMsg; vector<Byte>& requestBatchHdr = const_cast<vector<Byte>&>(_requestBatchHdr); - requestBatchHdr[0] = protocolVersion; - requestBatchHdr[1] = encodingVersion; - requestBatchHdr[2] = requestBatchMsg; + requestBatchHdr[0] = magic[0]; + requestBatchHdr[1] = magic[1]; + requestBatchHdr[2] = magic[2]; + requestBatchHdr[3] = magic[3]; + requestBatchHdr[4] = protocolMajor; + requestBatchHdr[5] = protocolMinor; + requestBatchHdr[6] = encodingMajor; + requestBatchHdr[7] = encodingMinor; + requestBatchHdr[8] = requestBatchMsg; vector<Byte>& replyHdr = const_cast<vector<Byte>&>(_replyHdr); - replyHdr[0] = protocolVersion; - replyHdr[1] = encodingVersion; - replyHdr[2] = replyMsg; + replyHdr[0] = magic[0]; + replyHdr[1] = magic[1]; + replyHdr[2] = magic[2]; + replyHdr[3] = magic[3]; + replyHdr[4] = protocolMajor; + replyHdr[5] = protocolMinor; + replyHdr[6] = encodingMajor; + replyHdr[7] = encodingMinor; + replyHdr[8] = replyMsg; } IceInternal::Connection::~Connection() @@ -1441,8 +1545,11 @@ IceInternal::Connection::initiateShutdown() const // Before we shut down, we send a close connection message. // BasicStream os(_instance.get()); - os.write(protocolVersion); - os.write(encodingVersion); + os.writeBlob(magic, sizeof(magic)); + os.write(protocolMajor); + os.write(protocolMinor); + os.write(encodingMajor); + os.write(encodingMinor); os.write(closeConnectionMsg); os.write(headerSize); // Message size. os.i = os.b.begin(); @@ -1590,7 +1697,7 @@ IceInternal::Connection::doCompress(BasicStream& uncompressed, BasicStream& comp // Int compressedSize = compressed.b.size(); p = reinterpret_cast<const Byte*>(&compressedSize); - copy(p, p + sizeof(Int), uncompressed.b.begin() + 3); + copy(p, p + sizeof(Int), uncompressed.b.begin() + 9); // // Add the size of the uncompressed stream before the message body diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp index 0a5c1ca19be..2495a24137e 100644 --- a/cpp/src/Ice/Exception.cpp +++ b/cpp/src/Ice/Exception.cpp @@ -19,6 +19,7 @@ #include <Ice/IdentityUtil.h> #include <Ice/StringUtil.h> #include <Ice/Plugin.h> +#include <iomanip> using namespace std; using namespace Ice; @@ -257,17 +258,40 @@ Ice::ProtocolException::ice_print(ostream& out) const } void +Ice::BadMagicException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ":\nunknown magic number: "; + + ios_base::fmtflags originalFlags = out.flags(); // Save stream state + ostream::char_type originalFill = out.fill(); + + out.flags(ios_base::hex); // Change to hex + out.fill('0'); // Fill with leading zeros + + out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[0])) << ", "; + out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[1])) << ", "; + out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[2])) << ", "; + out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[3])); + + out.fill(originalFill); // Restore stream state + out.flags(originalFlags); +} + +void Ice::UnsupportedProtocolException::ice_print(ostream& out) const { Exception::ice_print(out); - out << ":\nprotocol error: unsupported protocol version"; + out << ":\nprotocol error: unsupported protocol version: " << badMajor << "." << badMinor; + out << "\n(can only support protocols compatible with version " << major << "." << minor << ")"; } void Ice::UnsupportedEncodingException::ice_print(ostream& out) const { Exception::ice_print(out); - out << ":\nprotocol error: unsupported encoding version"; + out << ":\nprotocol error: unsupported encoding version: " << badMajor << "." << badMinor; + out << "\n(can only support encodings compatible with version " << major << "." << major << ")"; } void diff --git a/cpp/src/Ice/Protocol.h b/cpp/src/Ice/Protocol.h index a82628fd19b..ae0e232bafe 100644 --- a/cpp/src/Ice/Protocol.h +++ b/cpp/src/Ice/Protocol.h @@ -23,18 +23,28 @@ namespace IceInternal // // Size of the Ice protocol header // -// Protocol version (Byte) -// Encoding version (Byte) +// Magic number (4 Bytes) +// Protocol version major (Byte) +// Protocol version minor (Byte) +// Encoding version major (Byte) +// Encoding version minor (Byte) // Message type (Byte) // Message size (Int) // -const ::Ice::Int headerSize = 7; +const ::Ice::Int headerSize = 13; + +// +// The magic number at the front of each message +// +const ::Ice::Byte magic[] = { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P' // // The current Ice protocol and encoding version // -const ::Ice::Byte protocolVersion = 0; -const ::Ice::Byte encodingVersion = 0; +const ::Ice::Byte protocolMajor = 1; +const ::Ice::Byte protocolMinor = 0; +const ::Ice::Byte encodingMajor = 1; +const ::Ice::Byte encodingMinor = 0; // // The Ice protocol message types diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 3210f7413ff..584c08f209e 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -522,17 +522,41 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler) int pos = stream.i - stream.b.begin(); assert(pos >= headerSize); stream.i = stream.b.begin(); - Byte protVer; - stream.read(protVer); - if(protVer != protocolVersion) + MagicBytes m(sizeof(magic), 0); + stream.readBlob(m, sizeof(magic)); + if(!equal(m.begin(), m.end(), magic)) { - throw UnsupportedProtocolException(__FILE__, __LINE__); + BadMagicException ex(__FILE__, __LINE__); + ex.badMagic = m; + throw ex; } - Byte encVer; - stream.read(encVer); - if(encVer != encodingVersion) + Byte pMajor; + Byte pMinor; + stream.read(pMajor); + stream.read(pMinor); + if(pMajor != protocolMajor + || static_cast<unsigned char>(pMinor) > static_cast<unsigned char>(protocolMinor)) { - throw UnsupportedEncodingException(__FILE__, __LINE__); + UnsupportedProtocolException ex(__FILE__, __LINE__); + ex.badMajor = static_cast<unsigned char>(pMajor); + ex.badMinor = static_cast<unsigned char>(pMinor); + ex.major = static_cast<unsigned char>(protocolMajor); + ex.minor = static_cast<unsigned char>(protocolMinor); + throw ex; + } + Byte eMajor; + Byte eMinor; + stream.read(eMajor); + stream.read(eMinor); + if(eMajor != encodingMajor + || static_cast<unsigned char>(eMinor) > static_cast<unsigned char>(encodingMinor)) + { + UnsupportedEncodingException ex(__FILE__, __LINE__); + ex.badMajor = static_cast<unsigned char>(eMajor); + ex.badMinor = static_cast<unsigned char>(eMinor); + ex.major = static_cast<unsigned char>(encodingMajor); + ex.minor = static_cast<unsigned char>(encodingMinor); + throw ex; } Byte messageType; stream.read(messageType); diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp index e87d2fcdfd8..1015ea834f6 100644 --- a/cpp/src/Ice/TraceUtil.cpp +++ b/cpp/src/Ice/TraceUtil.cpp @@ -82,13 +82,25 @@ printRequestHeader(ostream& s, BasicStream& stream) static void printHeader(ostream& s, BasicStream& stream) { - Byte protVer; - stream.read(protVer); -// s << "\nprotocol version = " << static_cast<int>(protVer); - - Byte encVer; - stream.read(encVer); -// s << "\nencoding version = " << static_cast<int>(encVer); + Byte magic; + stream.read(magic); // Don't bother printing the magic number + stream.read(magic); + stream.read(magic); + stream.read(magic); + + Byte pMajor; + Byte pMinor; + stream.read(pMajor); + stream.read(pMinor); +// s << "\nprotocol version = " << static_cast<unsigned>(pMajor) +// << "." << static_cast<unsigned>(pMinor); + + Byte eMajor; + Byte eMinor; + stream.read(eMajor); + stream.read(eMinor); +// s << "\nencoding version = " << static_cast<unsigned>(eMajor) +// << "." << static_cast<unsigned>(eMinor); Byte type; stream.read(type); diff --git a/cpp/src/Ice/UdpEndpoint.cpp b/cpp/src/Ice/UdpEndpoint.cpp index ce2879ed995..fcd37a1cda7 100644 --- a/cpp/src/Ice/UdpEndpoint.cpp +++ b/cpp/src/Ice/UdpEndpoint.cpp @@ -19,6 +19,7 @@ #include <Ice/LocalException.h> #include <Ice/Instance.h> #include <Ice/DefaultsAndOverrides.h> +#include <Ice/Protocol.h> using namespace std; using namespace Ice; @@ -28,6 +29,10 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& _instance(instance), _host(ho), _port(po), + _protocolMajor(protocolMajor), + _protocolMinor(protocolMinor), + _encodingMajor(encodingMajor), + _encodingMinor(encodingMinor), _connect(false), _compress(co) { @@ -36,6 +41,10 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& str) : _instance(instance), _port(0), + _protocolMajor(protocolMajor), + _protocolMinor(protocolMinor), + _encodingMajor(encodingMajor), + _encodingMinor(encodingMinor), _connect(false), _compress(false) { @@ -81,6 +90,119 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string& switch(option[1]) { + case 'v': + { + if(argument.empty()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + + string::size_type pos = argument.find('.'); + if(pos == string::npos) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + string majorStr = argument.substr(0, pos); + string minorStr = argument.substr(pos + 1, string::npos); + + istringstream majStr(majorStr); + Int majVersion; + if(!(majStr >> majVersion) || !majStr.eof()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + + istringstream minStr(minorStr); + Int minVersion; + if(!(minStr >> minVersion) || !minStr.eof()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + + if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + + if(majVersion != protocolMajor) + { + UnsupportedProtocolException ex(__FILE__, __LINE__); + ex.badMajor = majVersion; + ex.badMinor = minVersion; + ex.major = static_cast<unsigned char>(protocolMajor); + ex.minor = static_cast<unsigned char>(protocolMinor); + throw ex; + } + + const_cast<Byte&>(_protocolMajor) = majVersion; + const_cast<Byte&>(_protocolMinor) = minVersion; + + break; + } + + case 'e': + { + if(argument.empty()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + string::size_type pos = argument.find('.'); + string majorStr = argument.substr(0, pos); + string minorStr = argument.substr(pos + 1, string::npos); + + istringstream majStr(majorStr); + Int majVersion; + if(!(majStr >> majVersion) || !majStr.eof()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + + istringstream minStr(minorStr); + Int minVersion; + if(!(minStr >> minVersion) || !minStr.eof()) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + + if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = "udp " + str; + throw ex; + } + + if(majVersion != static_cast<unsigned char>(encodingMajor)) + { + UnsupportedEncodingException ex(__FILE__, __LINE__); + ex.badMajor = majVersion; + ex.badMinor = minVersion; + ex.major = static_cast<unsigned char>(encodingMajor); + ex.minor = static_cast<unsigned char>(encodingMinor); + throw ex; + } + + const_cast<Byte&>(_encodingMajor) = majVersion; + const_cast<Byte&>(_encodingMinor) = minVersion; + + break; + } + case 'h': { if(argument.empty()) @@ -153,6 +275,28 @@ IceInternal::UdpEndpoint::UdpEndpoint(BasicStream* s) : s->startReadEncaps(); s->read(const_cast<string&>(_host)); s->read(const_cast<Int&>(_port)); + s->read(const_cast<Byte&>(_protocolMajor)); + s->read(const_cast<Byte&>(_protocolMinor)); + s->read(const_cast<Byte&>(_encodingMajor)); + s->read(const_cast<Byte&>(_encodingMinor)); + if(_protocolMajor != protocolMajor) + { + UnsupportedProtocolException ex(__FILE__, __LINE__); + ex.badMajor = _protocolMajor; + ex.badMinor = _protocolMinor; + ex.major = static_cast<unsigned char>(protocolMajor); + ex.minor = static_cast<unsigned char>(protocolMinor); + throw ex; + } + if(_encodingMajor != encodingMajor) + { + UnsupportedEncodingException ex(__FILE__, __LINE__); + ex.badMajor = _encodingMajor; + ex.badMinor = _encodingMinor; + ex.major = static_cast<unsigned char>(encodingMajor); + ex.minor = static_cast<unsigned char>(encodingMinor); + throw ex; + } // Not transmitted. //s->read(const_cast<bool&>(_connect)); s->read(const_cast<bool&>(_compress)); @@ -166,6 +310,10 @@ IceInternal::UdpEndpoint::streamWrite(BasicStream* s) const s->startWriteEncaps(); s->write(_host); s->write(_port); + s->write(_protocolMajor); + s->write(_protocolMinor); + s->write(_encodingMajor); + s->write(_encodingMinor); // Not transmitted. //s->write(_connect); s->write(_compress); @@ -176,7 +324,14 @@ string IceInternal::UdpEndpoint::toString() const { ostringstream s; - s << "udp -h " << _host << " -p " << _port; + s << "udp"; + s << " -v " + << static_cast<unsigned>(static_cast<unsigned char>(_protocolMajor)) << "." + << static_cast<unsigned>(static_cast<unsigned char>(_protocolMinor)); + s << " -e " + << static_cast<unsigned>(static_cast<unsigned char>(_encodingMajor)) << "." + << static_cast<unsigned>(static_cast<unsigned char>(_encodingMinor)); + s << " -h " << _host << " -p " << _port; if(_connect) { s << " -c"; @@ -316,6 +471,26 @@ IceInternal::UdpEndpoint::operator==(const Endpoint& r) const return false; } + if(_protocolMajor != p->_protocolMajor) + { + return false; + } + + if(_protocolMinor != p->_protocolMinor) + { + return false; + } + + if(_encodingMajor != p->_encodingMajor) + { + return false; + } + + if(_encodingMinor != p->_encodingMinor) + { + return false; + } + if(_host != p->_host) { // @@ -378,6 +553,42 @@ IceInternal::UdpEndpoint::operator<(const Endpoint& r) const return false; } + if(_protocolMajor < p->_protocolMajor) + { + return true; + } + else if(p->_protocolMajor < _protocolMajor) + { + return false; + } + + if(_protocolMinor < p->_protocolMinor) + { + return true; + } + else if(p->_protocolMinor < _protocolMinor) + { + return false; + } + + if(_encodingMajor < p->_encodingMajor) + { + return true; + } + else if(p->_encodingMajor < _encodingMajor) + { + return false; + } + + if(_encodingMinor < p->_encodingMinor) + { + return true; + } + else if(p->_encodingMinor < _encodingMinor) + { + return false; + } + if(_host != p->_host) { // diff --git a/cpp/src/Ice/UdpEndpoint.h b/cpp/src/Ice/UdpEndpoint.h index ac47daddcb9..46538d8e3be 100644 --- a/cpp/src/Ice/UdpEndpoint.h +++ b/cpp/src/Ice/UdpEndpoint.h @@ -60,6 +60,10 @@ private: const InstancePtr _instance; const std::string _host; const Ice::Int _port; + const Ice::Byte _protocolMajor; + const Ice::Byte _protocolMinor; + const Ice::Byte _encodingMajor; + const Ice::Byte _encodingMinor; const bool _connect; const bool _compress; }; |